]> Pileus Git - wmpus/commitdiff
Add TYPE_TOOLBAR instead of hiding them in sys
authorAndy Spencer <andy753421@gmail.com>
Sat, 11 Aug 2012 07:16:58 +0000 (07:16 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 11 Aug 2012 07:16:58 +0000 (07:16 +0000)
This hopefully makes things a little cleaner because it avoids having a
global wm_update function and gives the wm a little more control.
However, it now needs some special code to handle toolbars.

sys-x11.c
sys.h
wm-wmii.c
wm.h

index 68baaee22cb16540683f1aedbc281e0d773ca140..1a7c7e016f45c12f47d6b8d19b972ed1449a2dd5 100644 (file)
--- a/sys-x11.c
+++ b/sys-x11.c
@@ -404,10 +404,8 @@ static void process_event(int type, XEvent *xe, win_t *root)
        else if (type == UnmapNotify) {
                if ((win = win_find(dpy,xe->xunmap.window,0)) &&
                     win->state != ST_HIDE) {
-                       if (!strut_del(root, win))
-                               wm_remove(win);
-                       else
-                               wm_update();
+                       strut_del(root, win);
+                       wm_remove(win);
                        win->state = ST_HIDE;
                }
        }
@@ -444,10 +442,9 @@ static void process_event(int type, XEvent *xe, win_t *root)
                        if (win_prop(win, NET_STATE) == atoms[NET_FULL])
                                win->state = ST_FULL;
                        XSelectInput(win->sys->dpy, win->sys->xid, PropertyChangeMask);
-                       if (!strut_add(root, win))
-                               wm_insert(win);
-                       else
-                               wm_update();
+                       if (strut_add(root, win))
+                               win->type = TYPE_TOOLBAR;
+                       wm_insert(win);
                }
                sys_show(win, win->state);
        }
@@ -712,12 +709,14 @@ void sys_run(win_t *root)
                                        &par, &xid, &kids, &nkids)) {
                        for(int i = 0; i < nkids; i++) {
                                win_t *win = win_find(root->sys->dpy, kids[i], 1);
-                               if (win && win_viewable(win) && !strut_add(root,win))
+                               if (win && win_viewable(win)) {
+                                       if (strut_add(root,win))
+                                               win->type = TYPE_TOOLBAR;
                                        wm_insert(win);
+                               }
                        }
                        XFree(kids);
                }
-               wm_update(); // For struts
        }
 
        /* Main loop */
diff --git a/sys.h b/sys.h
index 3599c3da13382c89421d542d2ebefbe600b65cbf..adc0247590c6470b74e1769607542d492b1dd748 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -39,6 +39,7 @@ typedef enum {
 typedef enum {
        TYPE_NORMAL,
        TYPE_DIALOG,
+       TYPE_TOOLBAR,
 } type_t;
 
 /* Basic window type */
index 1cc43afc8c5286bec2f4f882454b8d9137d72819..ef54d6b93ab5e39a37a24ae220d786b870887de0 100644 (file)
--- a/wm-wmii.c
+++ b/wm-wmii.c
@@ -124,6 +124,9 @@ static ptr_t   move_prev;
 static layer_t move_layer;
 static struct { int v, h; } move_dir;
 
+/* Prototypes */
+void wm_update(void);
+
 /********************
  * Helper functions *
  ********************/
@@ -679,9 +682,7 @@ static void wm_update_cols(dpy_t *dpy)
        }
 }
 
-/*******************************
- * Window management functions *
- *******************************/
+/* Refresh the window layout */
 void wm_update(void)
 {
        /* Updates window sizes */
@@ -708,6 +709,9 @@ void wm_update(void)
                set_focus(wm_focus);
 }
 
+/*******************************
+ * Window management functions *
+ *******************************/
 int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr)
 {
        if (!win || win == wm_dpy->geom) return 0;
@@ -885,6 +889,10 @@ void wm_insert(win_t *win)
        printf("wm_insert: %p\n", win);
        print_txt();
 
+       /* Check for toolbars */
+       if (win->type == TYPE_TOOLBAR)
+               return wm_update();
+
        /* Initialize window */
        win->wm = new0(win_wm_t);
        sys_watch(win, EV_ENTER, MOD());
@@ -905,6 +913,8 @@ void wm_remove(win_t *win)
 {
        printf("wm_remove: %p\n", win);
        print_txt();
+       if (win->type == TYPE_TOOLBAR)
+               return wm_update();
        for (list_t *tag = wm->tags; tag; tag = tag->next)
                cut_win(win, tag->data);
        free(win->wm);
diff --git a/wm.h b/wm.h
index 57d79a37481ab31d243ee9d08d89bb321eb65342..0f776f93f04e8d557ca8320a7bbc73d6f6d8c6f9 100644 (file)
--- a/wm.h
+++ b/wm.h
@@ -22,9 +22,6 @@
  * The window provided to these function is generally the
  * window with the keyboard or mouse focus. */
 
-/* Refresh the window layout */
-void wm_update(void);
-
 /* Called for each watched event */
 int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr);