]> Pileus Git - wmpus/blobdiff - wm-wmii.c
Add TYPE_TOOLBAR instead of hiding them in sys
[wmpus] / wm-wmii.c
index 7814d71d4c695a4fe0ecee0547aa42182983f714..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;
@@ -722,10 +726,11 @@ int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr)
        if (EV_MOUSE0 <= ev && ev <= EV_MOUSE7) {
                if (ev == EV_MOUSE1 && !mod.MODKEY && !mod.up)
                        return raise_float(win),         0;
+               if ((ev == EV_MOUSE3 && mod.MODKEY && !mod.up) ||
+                   (ev == EV_MOUSE1 && mod.MODKEY && !mod.up && mod.shift))
+                       return set_move(win,ptr,RESIZE), 1;
                if (ev == EV_MOUSE1 && mod.MODKEY && !mod.up)
                        return set_move(win,ptr,MOVE),   1;
-               if (ev == EV_MOUSE3 && mod.MODKEY && !mod.up)
-                       return set_move(win,ptr,RESIZE), 1;
                if (move_mode != NONE && mod.up)
                        return set_move(win,ptr,NONE),   1;
                if (ev == EV_MOUSE1 && !mod.up && win->state == ST_SHADE)
@@ -884,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());
@@ -904,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);
@@ -928,7 +939,8 @@ void wm_init(win_t *root)
 
        event_t ev_e[] = {EV_ENTER, EV_FOCUS};
        event_t ev_s[] = {'h', 'j', 'k', 'l', 'c', 'q', ' ',
-               '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
+               '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
+               EV_MOUSE1, EV_MOUSE3};
        event_t ev_m[] = {'h', 'j', 'k', 'l', 'd', 's', 'm', 't', 'f', ' ',
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
                EV_F1, EV_F2, EV_F3, EV_F4,  EV_F5,  EV_F6,