diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2009-03-17 19:53:00 +0000 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2009-03-17 19:53:00 +0000 |
| commit | 565697087b92db6eb09e896f60f68503ce0a4ac1 (patch) | |
| tree | a562959d806b30a065444df9b73bca8971519d7e /dwm.c | |
| parent | applied the patch I missed from Gottox, thanks mate! (diff) | |
| download | dwm-565697087b92db6eb09e896f60f68503ce0a4ac1.tar.gz dwm-565697087b92db6eb09e896f60f68503ce0a4ac1.zip | |
applied Gottox' patches, and also removed usegrab
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 120 |
1 files changed, 55 insertions, 65 deletions
| @@ -129,7 +129,7 @@ typedef struct { | |||
| 129 | 129 | ||
| 130 | /* function declarations */ | 130 | /* function declarations */ |
| 131 | static void applyrules(Client *c); | 131 | static void applyrules(Client *c); |
| 132 | static void applysizehints(Client *c, int *w, int *h); | 132 | static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h); |
| 133 | static void arrange(void); | 133 | static void arrange(void); |
| 134 | static void attach(Client *c); | 134 | static void attach(Client *c); |
| 135 | static void attachstack(Client *c); | 135 | static void attachstack(Client *c); |
| @@ -252,6 +252,7 @@ applyrules(Client *c) { | |||
| 252 | XClassHint ch = { 0 }; | 252 | XClassHint ch = { 0 }; |
| 253 | 253 | ||
| 254 | /* rule matching */ | 254 | /* rule matching */ |
| 255 | c->isfloating = c->tags = 0; | ||
| 255 | if(XGetClassHint(dpy, c->win, &ch)) { | 256 | if(XGetClassHint(dpy, c->win, &ch)) { |
| 256 | for(i = 0; i < LENGTH(rules); i++) { | 257 | for(i = 0; i < LENGTH(rules); i++) { |
| 257 | r = &rules[i]; | 258 | r = &rules[i]; |
| @@ -259,7 +260,7 @@ applyrules(Client *c) { | |||
| 259 | && (!r->class || (ch.res_class && strstr(ch.res_class, r->class))) | 260 | && (!r->class || (ch.res_class && strstr(ch.res_class, r->class))) |
| 260 | && (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) { | 261 | && (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) { |
| 261 | c->isfloating = r->isfloating; | 262 | c->isfloating = r->isfloating; |
| 262 | c->tags |= r->tags & TAGMASK ? r->tags & TAGMASK : tagset[seltags]; | 263 | c->tags |= r->tags; |
| 263 | } | 264 | } |
| 264 | } | 265 | } |
| 265 | if(ch.res_class) | 266 | if(ch.res_class) |
| @@ -267,60 +268,72 @@ applyrules(Client *c) { | |||
| 267 | if(ch.res_name) | 268 | if(ch.res_name) |
| 268 | XFree(ch.res_name); | 269 | XFree(ch.res_name); |
| 269 | } | 270 | } |
| 270 | if(!c->tags) | 271 | c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : tagset[seltags]; |
| 271 | c->tags = tagset[seltags]; | ||
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | void | 274 | Bool |
| 275 | applysizehints(Client *c, int *w, int *h) { | 275 | applysizehints(Client *c, int *x, int *y, int *w, int *h) { |
| 276 | Bool baseismin; | 276 | Bool baseismin; |
| 277 | 277 | ||
| 278 | if(!resizehints && !c->isfloating) | ||
| 279 | return; | ||
| 280 | |||
| 281 | /* see last two sentences in ICCCM 4.1.2.3 */ | ||
| 282 | baseismin = c->basew == c->minw && c->baseh == c->minh; | ||
| 283 | |||
| 284 | /* set minimum possible */ | 278 | /* set minimum possible */ |
| 285 | *w = MAX(1, *w); | 279 | *w = MAX(1, *w); |
| 286 | *h = MAX(1, *h); | 280 | *h = MAX(1, *h); |
| 287 | 281 | ||
| 288 | if(!baseismin) { /* temporarily remove base dimensions */ | 282 | if(*x > sx + sw) |
| 289 | *w -= c->basew; | 283 | *x = sw - WIDTH(c); |
| 290 | *h -= c->baseh; | 284 | if(*y > sy + sh) |
| 291 | } | 285 | *y = sh - HEIGHT(c); |
| 286 | if(*x + *w + 2 * c->bw < sx) | ||
| 287 | *x = sx; | ||
| 288 | if(*y + *h + 2 * c->bw < sy) | ||
| 289 | *y = sy; | ||
| 290 | if(*h < bh) | ||
| 291 | *h = bh; | ||
| 292 | if(*w < bh) | ||
| 293 | *w = bh; | ||
| 294 | |||
| 295 | if(resizehints || c->isfloating) { | ||
| 296 | /* see last two sentences in ICCCM 4.1.2.3 */ | ||
| 297 | baseismin = c->basew == c->minw && c->baseh == c->minh; | ||
| 298 | |||
| 299 | if(!baseismin) { /* temporarily remove base dimensions */ | ||
| 300 | *w -= c->basew; | ||
| 301 | *h -= c->baseh; | ||
| 302 | } | ||
| 292 | 303 | ||
| 293 | /* adjust for aspect limits */ | 304 | /* adjust for aspect limits */ |
| 294 | if(c->mina > 0 && c->maxa > 0) { | 305 | if(c->mina > 0 && c->maxa > 0) { |
| 295 | if(c->maxa < (float)*w / *h) | 306 | if(c->maxa < (float)*w / *h) |
| 296 | *w = *h * c->maxa; | 307 | *w = *h * c->maxa; |
| 297 | else if(c->mina < (float)*h / *w) | 308 | else if(c->mina < (float)*h / *w) |
| 298 | *h = *w * c->mina; | 309 | *h = *w * c->mina; |
| 299 | } | 310 | } |
| 300 | 311 | ||
| 301 | if(baseismin) { /* increment calculation requires this */ | 312 | if(baseismin) { /* increment calculation requires this */ |
| 302 | *w -= c->basew; | 313 | *w -= c->basew; |
| 303 | *h -= c->baseh; | 314 | *h -= c->baseh; |
| 304 | } | 315 | } |
| 305 | 316 | ||
| 306 | /* adjust for increment value */ | 317 | /* adjust for increment value */ |
| 307 | if(c->incw) | 318 | if(c->incw) |
| 308 | *w -= *w % c->incw; | 319 | *w -= *w % c->incw; |
| 309 | if(c->inch) | 320 | if(c->inch) |
| 310 | *h -= *h % c->inch; | 321 | *h -= *h % c->inch; |
| 311 | 322 | ||
| 312 | /* restore base dimensions */ | 323 | /* restore base dimensions */ |
| 313 | *w += c->basew; | 324 | *w += c->basew; |
| 314 | *h += c->baseh; | 325 | *h += c->baseh; |
| 315 | 326 | ||
| 316 | *w = MAX(*w, c->minw); | 327 | *w = MAX(*w, c->minw); |
| 317 | *h = MAX(*h, c->minh); | 328 | *h = MAX(*h, c->minh); |
| 318 | 329 | ||
| 319 | if(c->maxw) | 330 | if(c->maxw) |
| 320 | *w = MIN(*w, c->maxw); | 331 | *w = MIN(*w, c->maxw); |
| 321 | 332 | ||
| 322 | if(c->maxh) | 333 | if(c->maxh) |
| 323 | *h = MIN(*h, c->maxh); | 334 | *h = MIN(*h, c->maxh); |
| 335 | } | ||
| 336 | return *x != c->x || *y != c->y || *w != c->w || *h != c->h; | ||
| 324 | } | 337 | } |
| 325 | 338 | ||
| 326 | void | 339 | void |
| @@ -1005,8 +1018,6 @@ movemouse(const Arg *arg) { | |||
| 1005 | None, cursor[CurMove], CurrentTime) != GrabSuccess) | 1018 | None, cursor[CurMove], CurrentTime) != GrabSuccess) |
| 1006 | return; | 1019 | return; |
| 1007 | XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); | 1020 | XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui); |
| 1008 | if(usegrab) | ||
| 1009 | XGrabServer(dpy); | ||
| 1010 | do { | 1021 | do { |
| 1011 | XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); | 1022 | XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); |
| 1012 | switch (ev.type) { | 1023 | switch (ev.type) { |
| @@ -1037,8 +1048,6 @@ movemouse(const Arg *arg) { | |||
| 1037 | } | 1048 | } |
| 1038 | } | 1049 | } |
| 1039 | while(ev.type != ButtonRelease); | 1050 | while(ev.type != ButtonRelease); |
| 1040 | if(usegrab) | ||
| 1041 | XUngrabServer(dpy); | ||
| 1042 | XUngrabPointer(dpy, CurrentTime); | 1051 | XUngrabPointer(dpy, CurrentTime); |
| 1043 | } | 1052 | } |
| 1044 | 1053 | ||
| @@ -1091,22 +1100,7 @@ void | |||
| 1091 | resize(Client *c, int x, int y, int w, int h) { | 1100 | resize(Client *c, int x, int y, int w, int h) { |
| 1092 | XWindowChanges wc; | 1101 | XWindowChanges wc; |
| 1093 | 1102 | ||
| 1094 | applysizehints(c, &w, &h); | 1103 | if(applysizehints(c, &x, &y, &w, &h)) { |
| 1095 | if(w <= 0 || h <= 0) | ||
| 1096 | return; | ||
| 1097 | if(x > sx + sw) | ||
| 1098 | x = sw - WIDTH(c); | ||
| 1099 | if(y > sy + sh) | ||
| 1100 | y = sh - HEIGHT(c); | ||
| 1101 | if(x + w + 2 * c->bw < sx) | ||
| 1102 | x = sx; | ||
| 1103 | if(y + h + 2 * c->bw < sy) | ||
| 1104 | y = sy; | ||
| 1105 | if(h < bh) | ||
| 1106 | h = bh; | ||
| 1107 | if(w < bh) | ||
| 1108 | w = bh; | ||
| 1109 | if(c->x != x || c->y != y || c->w != w || c->h != h) { | ||
| 1110 | c->x = wc.x = x; | 1104 | c->x = wc.x = x; |
| 1111 | c->y = wc.y = y; | 1105 | c->y = wc.y = y; |
| 1112 | c->w = wc.width = w; | 1106 | c->w = wc.width = w; |
| @@ -1135,8 +1129,6 @@ resizemouse(const Arg *arg) { | |||
| 1135 | None, cursor[CurResize], CurrentTime) != GrabSuccess) | 1129 | None, cursor[CurResize], CurrentTime) != GrabSuccess) |
| 1136 | return; | 1130 | return; |
| 1137 | XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); | 1131 | XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); |
| 1138 | if(usegrab) | ||
| 1139 | XGrabServer(dpy); | ||
| 1140 | do { | 1132 | do { |
| 1141 | XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); | 1133 | XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev); |
| 1142 | switch(ev.type) { | 1134 | switch(ev.type) { |
| @@ -1161,8 +1153,6 @@ resizemouse(const Arg *arg) { | |||
| 1161 | } | 1153 | } |
| 1162 | } | 1154 | } |
| 1163 | while(ev.type != ButtonRelease); | 1155 | while(ev.type != ButtonRelease); |
| 1164 | if(usegrab) | ||
| 1165 | XUngrabServer(dpy); | ||
| 1166 | XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); | 1156 | XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1); |
| 1167 | XUngrabPointer(dpy, CurrentTime); | 1157 | XUngrabPointer(dpy, CurrentTime); |
| 1168 | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); | 1158 | while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); |
