JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
there might be envs which need Xlib.h
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 9932974..2602ed2 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -41,6 +41,7 @@
 #include <X11/cursorfont.h>
 #include <X11/keysym.h>
 #include <X11/Xatom.h>
+#include <X11/Xlib.h>
 #include <X11/Xproto.h>
 #include <X11/Xutil.h>
 
@@ -335,16 +336,24 @@ buttonpress(XEvent *e) {
                focus(c);
                if(CLEANMASK(ev->state) != MODKEY)
                        return;
-               if(ev->button == Button1 && (isarrange(floating) || c->isfloating)) {
-                       restack();
+               if(ev->button == Button1) {
+                       if(!isarrange(floating) && !c->isfloating)
+                               togglefloating(NULL);
+                       else
+                               restack();
                        movemouse(c);
                }
-               else if(ev->button == Button2)
-                       zoom(NULL);
-               else if(ev->button == Button3
-               && (isarrange(floating) || c->isfloating) && !c->isfixed)
-               {
-                       restack();
+               else if(ev->button == Button2) {
+                       if(isarrange(tile) && !c->isfixed && c->isfloating)
+                               togglefloating(NULL);
+                       else
+                               zoom(NULL);
+               }
+               else if(ev->button == Button3 && !c->isfixed) {
+                       if(!isarrange(floating) && !c->isfloating)
+                               togglefloating(NULL);
+                       else
+                               restack();
                        resizemouse(c);
                }
        }