Use a separate socket per workspace on X (patch by Erik de Castro
Lopo, thanks). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5232 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
a1ae5af38d
commit
4c3ab61c3f
@ -2,6 +2,10 @@
|
||||
|
||||
* src/keyfile.c:
|
||||
Save document indent width with the session.
|
||||
* src/ui_utils.h, src/socket.c, src/ui_utils.c, doc/geany.txt,
|
||||
doc/geany.html, TODO:
|
||||
Use a separate socket per workspace on X (patch by Erik de Castro
|
||||
Lopo, thanks).
|
||||
|
||||
|
||||
2010-09-14 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
||||
|
||||
1
TODO
1
TODO
@ -21,7 +21,6 @@ Note: features included in brackets have lower priority.
|
||||
o (sci macro support - as a plugin?)
|
||||
o (parsing tags from a memory buffer instead of a file on disk)
|
||||
o (tango-like icons for the symbol list)
|
||||
o (per-workspace instances with socket support?)
|
||||
|
||||
|
||||
1.0:
|
||||
|
||||
@ -718,9 +718,9 @@ dragging the dividers.</p>
|
||||
<h2><a class="toc-backref" href="#id28" id="command-line-options" name="command-line-options">Command line options</a></h2>
|
||||
<table border="1" class="docutils">
|
||||
<colgroup>
|
||||
<col width="9%" />
|
||||
<col width="18%" />
|
||||
<col width="72%" />
|
||||
<col width="13%" />
|
||||
<col width="25%" />
|
||||
<col width="62%" />
|
||||
</colgroup>
|
||||
<thead valign="bottom">
|
||||
<tr><th class="head">Short option</th>
|
||||
@ -818,11 +818,11 @@ available if Geany was compiled with support for VTE.</td>
|
||||
<tr><td><em>none</em></td>
|
||||
<td>--socket-file</td>
|
||||
<td><p class="first">Use this socket filename for communication with a
|
||||
running Geany instance. This can be used with the following
|
||||
command to execute Geany on the current workspace:</p>
|
||||
<pre class="last literal-block">
|
||||
geany --socket-file=/tmp/geany-sock-$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}')
|
||||
</pre>
|
||||
running Geany instance. By default Geany uses one
|
||||
socket file per workspace for X Windows, otherwise
|
||||
only one.</p>
|
||||
<p class="last">Example:
|
||||
geany --socket-file=/tmp/geany-sock-2</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td><em>none</em></td>
|
||||
@ -6133,7 +6133,7 @@ USE OR PERFORMANCE OF THIS SOFTWARE.</p>
|
||||
<div class="footer">
|
||||
<hr class="footer" />
|
||||
<a class="reference" href="geany.txt">View document source</a>.
|
||||
Generated on: 2010-09-09 15:36 UTC.
|
||||
Generated on: 2010-09-15 16:58 UTC.
|
||||
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
|
||||
|
||||
</div>
|
||||
|
||||
@ -365,10 +365,12 @@ Short option Long option Function
|
||||
available if Geany was compiled with support for VTE.
|
||||
|
||||
*none* --socket-file Use this socket filename for communication with a
|
||||
running Geany instance. This can be used with the following
|
||||
command to execute Geany on the current workspace::
|
||||
running Geany instance. By default Geany uses one
|
||||
socket file per workspace for X Windows, otherwise
|
||||
only one.
|
||||
|
||||
geany --socket-file=/tmp/geany-sock-$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}')
|
||||
Example:
|
||||
geany --socket-file=/tmp/geany-sock-2
|
||||
|
||||
*none* --vte-lib Specify explicitly the path including filename or only
|
||||
the filename to the VTE library, e.g.
|
||||
|
||||
@ -271,6 +271,7 @@ gint socket_init(gint argc, gchar **argv)
|
||||
return -1;
|
||||
#else
|
||||
gchar *display_name = gdk_get_display();
|
||||
gint workspace = ui_get_current_workspace(display_name);
|
||||
gchar *hostname = utils_get_hostname();
|
||||
gchar *p;
|
||||
|
||||
@ -284,8 +285,8 @@ gint socket_init(gint argc, gchar **argv)
|
||||
*p = '_';
|
||||
|
||||
if (socket_info.file_name == NULL)
|
||||
socket_info.file_name = g_strdup_printf("%s%cgeany_socket_%s_%s",
|
||||
app->configdir, G_DIR_SEPARATOR, hostname, display_name);
|
||||
socket_info.file_name = g_strdup_printf("%s%cgeany_socket_%s_%s_ws%d",
|
||||
app->configdir, G_DIR_SEPARATOR, hostname, display_name, workspace);
|
||||
|
||||
g_free(display_name);
|
||||
g_free(hostname);
|
||||
|
||||
@ -31,6 +31,14 @@
|
||||
#include <ctype.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
/* For ui_get_current_workspace() */
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/Xatom.h>
|
||||
#endif
|
||||
|
||||
#include "ui_utils.h"
|
||||
#include "prefs.h"
|
||||
#include "sciwrappers.h"
|
||||
@ -2434,3 +2442,48 @@ void ui_editable_insert_text_callback(GtkEditable *editable, gchar *new_text,
|
||||
g_signal_stop_emission_by_name(editable, "insert-text");
|
||||
}
|
||||
|
||||
|
||||
/* Get the current visible workspace number for the given display name.
|
||||
*
|
||||
* If the X11 window property isn't found, 0 (the first workspace)
|
||||
* is returned.
|
||||
*
|
||||
* Has been tested and verified to work under GNOME and KDE. Assuming that
|
||||
* most other X11 desktops will work the same. For non-X11 backends it returns
|
||||
* a workspace number of 0.
|
||||
*
|
||||
* This code is a slightly modified version of code that was ripped from Gedit
|
||||
* which ripped it from Galeon. */
|
||||
gint ui_get_current_workspace(const gchar *display_name)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkScreen *screen = gdk_screen_get_default();
|
||||
GdkWindow *root_win = gdk_screen_get_root_window(screen);
|
||||
GdkDisplay *display = gdk_display_open(display_name);
|
||||
Atom type;
|
||||
gint format;
|
||||
gulong nitems;
|
||||
gulong bytes_after;
|
||||
guint *current_desktop;
|
||||
gint err, result;
|
||||
gint ret = 0;
|
||||
|
||||
gdk_error_trap_push();
|
||||
result = XGetWindowProperty(GDK_DISPLAY_XDISPLAY(display), GDK_WINDOW_XID(root_win),
|
||||
gdk_x11_get_xatom_by_name_for_display(display, "_NET_CURRENT_DESKTOP"),
|
||||
0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
|
||||
&bytes_after, (gpointer) ¤t_desktop);
|
||||
err = gdk_error_trap_pop();
|
||||
|
||||
if (err == Success && result == Success)
|
||||
{
|
||||
if (type == XA_CARDINAL && format == 32 && nitems > 0)
|
||||
ret = current_desktop[0];
|
||||
XFree(current_desktop);
|
||||
}
|
||||
gdk_display_close(display);
|
||||
return ret;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -318,4 +318,6 @@ gboolean ui_is_keyval_enter_or_return(guint keyval);
|
||||
|
||||
gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value);
|
||||
|
||||
gint ui_get_current_workspace(const gchar *display_name);
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user