summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dwm.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/dwm.c b/dwm.c
index edba139..bded0c5 100644
--- a/dwm.c
+++ b/dwm.c
@@ -53,8 +53,8 @@
53#define MIN(a, b) ((a) < (b) ? (a) : (b)) 53#define MIN(a, b) ((a) < (b) ? (a) : (b))
54#define MAXTAGLEN 16 54#define MAXTAGLEN 16
55#define MOUSEMASK (BUTTONMASK|PointerMotionMask) 55#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
56#define WIDTH(x) ((x)->w + 2*(x)->bw) 56#define WIDTH(x) ((x)->w + 2 * (x)->bw)
57#define HEIGHT(x) ((x)->h + 2*(x)->bw) 57#define HEIGHT(x) ((x)->h + 2 * (x)->bw)
58#define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) 58#define TAGMASK ((int)((1LL << LENGTH(tags)) - 1))
59#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) 59#define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height)
60 60
@@ -932,7 +932,7 @@ monocle(void) {
932 Client *c; 932 Client *c;
933 933
934 for(c = nexttiled(clients); c; c = nexttiled(c->next)) 934 for(c = nexttiled(clients); c; c = nexttiled(c->next))
935 resize(c, wx, wy, ww - 2*c->bw, wh - 2*c->bw, resizehints); 935 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints);
936} 936}
937 937
938void 938void
@@ -952,6 +952,8 @@ movemouse(const Arg *arg) {
952 None, cursor[CurMove], CurrentTime) != GrabSuccess) 952 None, cursor[CurMove], CurrentTime) != GrabSuccess)
953 return; 953 return;
954 XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); 954 XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
955 if(usegrab)
956 XGrabServer(dpy);
955 do { 957 do {
956 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); 958 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
957 switch (ev.type) { 959 switch (ev.type) {
@@ -961,7 +963,6 @@ movemouse(const Arg *arg) {
961 handler[ev.type](&ev); 963 handler[ev.type](&ev);
962 break; 964 break;
963 case MotionNotify: 965 case MotionNotify:
964 XSync(dpy, False);
965 nx = ocx + (ev.xmotion.x - x); 966 nx = ocx + (ev.xmotion.x - x);
966 ny = ocy + (ev.xmotion.y - y); 967 ny = ocy + (ev.xmotion.y - y);
967 if(snap && nx >= wx && nx <= wx + ww 968 if(snap && nx >= wx && nx <= wx + ww
@@ -983,6 +984,8 @@ movemouse(const Arg *arg) {
983 } 984 }
984 } 985 }
985 while(ev.type != ButtonRelease); 986 while(ev.type != ButtonRelease);
987 if(usegrab)
988 XUngrabServer(dpy);
986 XUngrabPointer(dpy, CurrentTime); 989 XUngrabPointer(dpy, CurrentTime);
987} 990}
988 991
@@ -1121,6 +1124,8 @@ resizemouse(const Arg *arg) {
1121 None, cursor[CurResize], CurrentTime) != GrabSuccess) 1124 None, cursor[CurResize], CurrentTime) != GrabSuccess)
1122 return; 1125 return;
1123 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); 1126 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
1127 if(usegrab)
1128 XGrabServer(dpy);
1124 do { 1129 do {
1125 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); 1130 XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
1126 switch(ev.type) { 1131 switch(ev.type) {
@@ -1130,7 +1135,6 @@ resizemouse(const Arg *arg) {
1130 handler[ev.type](&ev); 1135 handler[ev.type](&ev);
1131 break; 1136 break;
1132 case MotionNotify: 1137 case MotionNotify:
1133 XSync(dpy, False);
1134 nw = MAX(ev.xmotion.x - ocx - 2*c->bw + 1, 1); 1138 nw = MAX(ev.xmotion.x - ocx - 2*c->bw + 1, 1);
1135 nh = MAX(ev.xmotion.y - ocy - 2*c->bw + 1, 1); 1139 nh = MAX(ev.xmotion.y - ocy - 2*c->bw + 1, 1);
1136 1140
@@ -1146,6 +1150,8 @@ resizemouse(const Arg *arg) {
1146 } 1150 }
1147 } 1151 }
1148 while(ev.type != ButtonRelease); 1152 while(ev.type != ButtonRelease);
1153 if(usegrab)
1154 XUngrabServer(dpy);
1149 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); 1155 XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
1150 XUngrabPointer(dpy, CurrentTime); 1156 XUngrabPointer(dpy, CurrentTime);
1151 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); 1157 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
@@ -1435,7 +1441,7 @@ tile(void) {
1435 /* master */ 1441 /* master */
1436 c = nexttiled(clients); 1442 c = nexttiled(clients);
1437 mw = mfact * ww; 1443 mw = mfact * ww;
1438 resize(c, wx, wy, (n == 1 ? ww : mw) - 2*c->bw, wh - 2*c->bw, resizehints); 1444 resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints);
1439 1445
1440 if(--n == 0) 1446 if(--n == 0)
1441 return; 1447 return;
@@ -1449,8 +1455,14 @@ tile(void) {
1449 h = wh; 1455 h = wh;
1450 1456
1451 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { 1457 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1452 resize(c, x, y, w - 2*c->bw, /* remainder */ ((i + 1 == n) 1458 if(i + 1 == n) { /* remainder */
1453 ? wy + wh - y : h) - 2*c->bw, resizehints); 1459 if(wy + wh - y < bh)
1460 resize(c, x, y, w - 2 * c->bw, wy + wh - y - 2 * c->bw, False);
1461 else
1462 resize(c, x, y, w - 2 * c->bw, wy + wh - y - 2 * c->bw, resizehints);
1463 }
1464 else
1465 resize(c, x, y, w - 2 * c->bw, h - 2 * c->bw, resizehints);
1454 if(h != wh) 1466 if(h != wh)
1455 y = c->y + HEIGHT(c); 1467 y = c->y + HEIGHT(c);
1456 } 1468 }