summaryrefslogtreecommitdiff
path: root/stickynotes/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'stickynotes/util.c')
-rw-r--r--stickynotes/util.c153
1 files changed, 77 insertions, 76 deletions
diff --git a/stickynotes/util.c b/stickynotes/util.c
index d8e370c4..b5faf292 100644
--- a/stickynotes/util.c
+++ b/stickynotes/util.c
@@ -29,97 +29,98 @@
static Atom
xstuff_atom_get (const char *atom_name)
{
- static GHashTable *atom_hash;
- Display *xdisplay;
- Atom retval;
+ static GHashTable *atom_hash;
+ Display *xdisplay;
+ Atom retval;
- g_return_val_if_fail (atom_name != NULL, None);
+ g_return_val_if_fail (atom_name != NULL, None);
- xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- if (!atom_hash)
- atom_hash = g_hash_table_new_full (
- g_str_hash, g_str_equal, g_free, NULL);
+ if (!atom_hash)
+ atom_hash = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free, NULL);
- retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
- if (!retval) {
- retval = XInternAtom (xdisplay, atom_name, FALSE);
+ retval = GPOINTER_TO_UINT (g_hash_table_lookup (atom_hash, atom_name));
+ if (!retval) {
+ retval = XInternAtom (xdisplay, atom_name, FALSE);
- if (retval != None)
- g_hash_table_insert (atom_hash, g_strdup (atom_name),
- GUINT_TO_POINTER (retval));
- }
+ if (retval != None)
+ g_hash_table_insert (atom_hash, g_strdup (atom_name),
+ GUINT_TO_POINTER (retval));
+ }
- return retval;
+ return retval;
}
int
xstuff_get_current_workspace (GtkWindow *window)
{
- Window root_window;
- Atom type = None;
- gulong nitems;
- gulong bytes_after;
- gulong *num;
- int format;
- int result;
- int retval;
- GdkDisplay *gdk_display;
- Display *xdisplay;
-
- root_window = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)));
+ Window root_window;
+ Atom type = None;
+ gulong nitems;
+ gulong bytes_after;
+ gulong *num;
+ int format;
+ int result;
+ int retval;
+ GdkDisplay *gdk_display;
+ Display *xdisplay;
+
+ root_window = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)));
gdk_display = gdk_display_get_default ();
- xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display);
-
- gdk_x11_display_error_trap_push (gdk_display);
- result = XGetWindowProperty (xdisplay,
- root_window,
- xstuff_atom_get ("_NET_CURRENT_DESKTOP"),
- 0, G_MAXLONG,
- False, XA_CARDINAL,
- &type, &format, &nitems,
- &bytes_after, (gpointer) &num);
- if (gdk_x11_display_error_trap_pop (gdk_display) || result != Success)
- return -1;
-
- if (type != XA_CARDINAL) {
- XFree (num);
- return -1;
- }
-
- retval = *num;
-
- XFree (num);
-
- return retval;
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display);
+
+ gdk_x11_display_error_trap_push (gdk_display);
+ result = XGetWindowProperty (xdisplay,
+ root_window,
+ xstuff_atom_get ("_NET_CURRENT_DESKTOP"),
+ 0, G_MAXLONG,
+ False, XA_CARDINAL,
+ &type, &format, &nitems,
+ &bytes_after, (gpointer) &num);
+ if (gdk_x11_display_error_trap_pop (gdk_display) || result != Success)
+ return -1;
+
+ if (type != XA_CARDINAL) {
+ XFree (num);
+ return -1;
+ }
+
+ retval = *num;
+
+ XFree (num);
+
+ return retval;
}
void
xstuff_change_workspace (GtkWindow *window,
int new_space)
{
- XEvent xev;
- Window xwindow;
- Display *gdk_display;
- Screen *screen;
-
- gdk_display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- xwindow = GDK_WINDOW_XID (GDK_WINDOW (gtk_widget_get_window (GTK_WIDGET (window))));
- screen = GDK_SCREEN_XSCREEN (gtk_widget_get_screen (GTK_WIDGET (window)));
-
- xev.xclient.type = ClientMessage;
- xev.xclient.serial = 0;
- xev.xclient.send_event = True;
- xev.xclient.display = gdk_display;
- xev.xclient.window = xwindow;
- xev.xclient.message_type = xstuff_atom_get ("_NET_WM_DESKTOP");
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = new_space;
- xev.xclient.data.l[1] = 0;
- xev.xclient.data.l[2] = 0;
-
- XSendEvent (gdk_display,
- RootWindowOfScreen (screen),
- False,
- SubstructureRedirectMask | SubstructureNotifyMask,
- &xev);
+ XEvent xev;
+ Window xwindow;
+ Display *gdk_display;
+ Screen *screen;
+
+ gdk_display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ xwindow = GDK_WINDOW_XID (GDK_WINDOW (gtk_widget_get_window (GTK_WIDGET (window))));
+ screen = GDK_SCREEN_XSCREEN (gtk_widget_get_screen (GTK_WIDGET (window)));
+
+ xev.xclient.type = ClientMessage;
+ xev.xclient.serial = 0;
+ xev.xclient.send_event = True;
+ xev.xclient.display = gdk_display;
+ xev.xclient.window = xwindow;
+ xev.xclient.message_type = xstuff_atom_get ("_NET_WM_DESKTOP");
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = new_space;
+ xev.xclient.data.l[1] = 0;
+ xev.xclient.data.l[2] = 0;
+
+ XSendEvent (gdk_display,
+ RootWindowOfScreen (screen),
+ False,
+ SubstructureRedirectMask | SubstructureNotifyMask,
+ &xev);
}