Xinqi Bao's Git

implemented focusprev on button1 press in the bar, and focusnext on button3 press...
[dwm.git] / event.c
diff --git a/event.c b/event.c
index 36d873f..53a110a 100644 (file)
--- a/event.c
+++ b/event.c
@@ -103,21 +103,25 @@ buttonpress(XEvent *e)
 
        if(barwin == ev->window) {
                switch(ev->button) {
 
        if(barwin == ev->window) {
                switch(ev->button) {
-               default:
+               case Button1:
                        x = 0;
                        for(a.i = 0; a.i < ntags; a.i++) {
                                x += textw(tags[a.i]);
                                if(ev->x < x) {
                                        view(&a);
                        x = 0;
                        for(a.i = 0; a.i < ntags; a.i++) {
                                x += textw(tags[a.i]);
                                if(ev->x < x) {
                                        view(&a);
-                                       break;
+                                       return;
                                }
                        }
                                }
                        }
+                       focusprev(NULL);
+                       break;
+               case Button3:
+                       focusnext(NULL);
                        break;
                case Button4:
                        break;
                case Button4:
-                       viewnext(&a);
+                       viewprev(&a);
                        break;
                case Button5:
                        break;
                case Button5:
-                       viewprev(&a);
+                       viewnext(&a);
                        break;
                }
        }
                        break;
                }
        }
@@ -132,8 +136,7 @@ buttonpress(XEvent *e)
                                movemouse(c);
                        break;
                case Button2:
                                movemouse(c);
                        break;
                case Button2:
-                       if(!c->ismax && arrange != dofloat && !c->isfloat)
-                               zoom(NULL);
+                       zoom(NULL);
                        break;
                case Button3:
                        if(!c->ismax && (arrange == dofloat || c->isfloat))
                        break;
                case Button3:
                        if(!c->ismax && (arrange == dofloat || c->isfloat))
@@ -226,8 +229,11 @@ enternotify(XEvent *e)
 
        if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
                focus(c);
 
        if((c = getclient(ev->window)) || (c = getctitle(ev->window)))
                focus(c);
-       else if(ev->window == root)
+       else if(ev->window == root) {
                issel = True;
                issel = True;
+               XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+               drawall();
+       }
 }
 
 static void
 }
 
 static void
@@ -267,8 +273,10 @@ leavenotify(XEvent *e)
 {
        XCrossingEvent *ev = &e->xcrossing;
 
 {
        XCrossingEvent *ev = &e->xcrossing;
 
-       if((ev->window == root) && !ev->same_screen)
-               issel = True;
+       if((ev->window == root) && !ev->same_screen) {
+               issel = False;
+               drawall();
+       }
 }
 
 static void
 }
 
 static void