SF.net SVN: geany:[5232] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Wed Sep 15 17:04:24 UTC 2010
Revision: 5232
http://geany.svn.sourceforge.net/geany/?rev=5232&view=rev
Author: ntrel
Date: 2010-09-15 17:04:23 +0000 (Wed, 15 Sep 2010)
Log Message:
-----------
Use a separate socket per workspace on X (patch by Erik de Castro
Lopo, thanks).
Modified Paths:
--------------
trunk/ChangeLog
trunk/TODO
trunk/doc/geany.html
trunk/doc/geany.txt
trunk/src/socket.c
trunk/src/ui_utils.c
trunk/src/ui_utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-09-15 14:59:41 UTC (rev 5231)
+++ trunk/ChangeLog 2010-09-15 17:04:23 UTC (rev 5232)
@@ -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>
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2010-09-15 14:59:41 UTC (rev 5231)
+++ trunk/TODO 2010-09-15 17:04:23 UTC (rev 5232)
@@ -21,7 +21,6 @@
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:
Modified: trunk/doc/geany.html
===================================================================
--- trunk/doc/geany.html 2010-09-15 14:59:41 UTC (rev 5231)
+++ trunk/doc/geany.html 2010-09-15 17:04:23 UTC (rev 5232)
@@ -718,9 +718,9 @@
<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 @@
<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 @@
<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>
Modified: trunk/doc/geany.txt
===================================================================
--- trunk/doc/geany.txt 2010-09-15 14:59:41 UTC (rev 5231)
+++ trunk/doc/geany.txt 2010-09-15 17:04:23 UTC (rev 5232)
@@ -365,10 +365,12 @@
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.
Modified: trunk/src/socket.c
===================================================================
--- trunk/src/socket.c 2010-09-15 14:59:41 UTC (rev 5231)
+++ trunk/src/socket.c 2010-09-15 17:04:23 UTC (rev 5232)
@@ -271,6 +271,7 @@
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 @@
*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);
Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c 2010-09-15 14:59:41 UTC (rev 5231)
+++ trunk/src/ui_utils.c 2010-09-15 17:04:23 UTC (rev 5232)
@@ -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 @@
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
+}
Modified: trunk/src/ui_utils.h
===================================================================
--- trunk/src/ui_utils.h 2010-09-15 14:59:41 UTC (rev 5231)
+++ trunk/src/ui_utils.h 2010-09-15 17:04:23 UTC (rev 5232)
@@ -318,4 +318,6 @@
gint ui_get_gtk_settings_integer(const gchar *property_name, gint default_value);
+gint ui_get_current_workspace(const gchar *display_name);
+
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list