Refactor window initial state setting in separate function
authorHugo Villeneuve <hugo@hugovil.com>
Fri, 31 May 2013 23:58:33 +0000 (19:58 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Fri, 31 May 2013 23:58:33 +0000 (19:58 -0400)
src/dockapp.c

index 59984c3..6558ab6 100644 (file)
 /* Specifies the border width */
 #define BWIDTH 2
 
+static void
+dockapp_set_withdrawn_state(Display *d, Window w)
+{
+       XWMHints *hints;
+
+       hints = XGetWMHints(d, w);
+       hints->flags |= StateHint;
+       hints->initial_state = WithdrawnState;
+       XSetWMHints(d, w, hints);
+       XFree(hints);
+}
+
 /*******************************************************************************
  * New window creation and initialization for a Dockable Application
  ******************************************************************************/
@@ -53,7 +65,6 @@ dockapp_init(int argc, char *argv[], char *display_arg, char *geometry_arg)
 {
        GtkWidget *dockwin;
        GtkWidget *iconwin;
-       XWMHints wm_hints;
 
        gtk_init(&argc, &argv);
 
@@ -75,13 +86,8 @@ dockapp_init(int argc, char *argv[], char *display_arg, char *geometry_arg)
        gtk_widget_show_all(dockwin);
 
        if (hvclock_infos.dockapp_mode == true) {
-               /* Dockapp specific initialization */
-               wm_hints.flags = StateHint | IconWindowHint | WindowGroupHint;
-               wm_hints.initial_state = WithdrawnState;
-               wm_hints.icon_window = GDK_WINDOW_XWINDOW(iconwin->window);
-               wm_hints.window_group = GDK_WINDOW_XWINDOW(dockwin->window);
-
-               XSetWMHints(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
-                           GDK_WINDOW_XWINDOW(dockwin->window), &wm_hints);
+               dockapp_set_withdrawn_state(
+                       GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
+                       GDK_WINDOW_XWINDOW(dockwin->window));
        }
 }