diff options
author | raveit65 <[email protected]> | 2020-12-27 11:46:13 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-27 11:46:13 +0100 |
commit | 181184aba23ac392a7a6ce92751ab5561721f3c2 (patch) | |
tree | f8d06ef68f64428f2b4cba8d273c0744b2ac751f /stickynotes/util.c | |
parent | eddd0898e16124081e226b07fd0901ff0eae2871 (diff) | |
download | mate-applets-181184aba23ac392a7a6ce92751ab5561721f3c2.tar.bz2 mate-applets-181184aba23ac392a7a6ce92751ab5561721f3c2.tar.xz |
stickynotes: improve code-style
- tabs to spaces
- shortened lines
- unnecessary casts on functions which accept a gpointer like g_signal_connect
Diffstat (limited to 'stickynotes/util.c')
-rw-r--r-- | stickynotes/util.c | 153 |
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); } |