JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
changed symbols for float/tiled mode, added mouse-driven mode toggle to buttonpress()
[dwm.git] / event.c
diff --git a/event.c b/event.c
index c8a87c1..35cd4f9 100644 (file)
--- a/event.c
+++ b/event.c
@@ -105,20 +105,26 @@ buttonpress(XEvent *e)
        XButtonPressedEvent *ev = &e->xbutton;
 
        if(barwin == ev->window) {
-               x = 0;
-               for(a.i = 0; a.i < ntags; a.i++) {
-                       x += textw(tags[a.i]);
-                       if(ev->x < x) {
-                               if(ev->button == Button1)
-                                       view(&a);
-                               else if(ev->button == Button3)
-                                       toggleview(&a);
-                               return;
+               if(ev->x < modew)
+                       togglemode(NULL);
+               else {
+                       x = modew;
+                       for(a.i = 0; a.i < ntags; a.i++) {
+                               x += textw(tags[a.i]);
+                               if(ev->x < x) {
+                                       if(ev->button == Button1)
+                                               view(&a);
+                                       else if(ev->button == Button3)
+                                               toggleview(&a);
+                                       return;
+                               }
                        }
                }
        }
        else if((c = getclient(ev->window))) {
                focus(c);
+               if(CLEANMASK(ev->state) == 0)
+                       return;
                switch(ev->button) {
                default:
                        break;
@@ -384,3 +390,16 @@ grabkeys()
                                GrabModeAsync, GrabModeAsync);
        }
 }
+
+void
+procevent()
+{
+       XEvent ev;
+
+       while(XPending(dpy)) {
+               XNextEvent(dpy, &ev);
+               if(handler[ev.type])
+                       (handler[ev.type])(&ev); /* call handler */
+       }
+}
+