equal
deleted
inserted
replaced
39 #ifdef XINERAMA |
39 #ifdef XINERAMA |
40 #include <X11/extensions/Xinerama.h> |
40 #include <X11/extensions/Xinerama.h> |
41 #endif |
41 #endif |
42 |
42 |
43 /* macros */ |
43 /* macros */ |
|
44 #define ADJUSTBORDER(C, BW) if((C)->bw != (BW)) XSetWindowBorder(dpy, (C)->win, (BW)); |
44 #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
45 #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) |
45 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
46 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
46 #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) |
47 #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH)) |
47 #define ISVISIBLE(x) (x->tags & tagset[seltags]) |
48 #define ISVISIBLE(x) (x->tags & tagset[seltags]) |
48 #define LENGTH(x) (sizeof x / sizeof x[0]) |
49 #define LENGTH(x) (sizeof x / sizeof x[0]) |
126 unsigned int tags; |
127 unsigned int tags; |
127 Bool isfloating; |
128 Bool isfloating; |
128 } Rule; |
129 } Rule; |
129 |
130 |
130 /* function declarations */ |
131 /* function declarations */ |
131 static void adjustborder(Client *c, Bool issingle); |
|
132 static void applyrules(Client *c); |
132 static void applyrules(Client *c); |
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); |
136 static void buttonpress(XEvent *e); |
136 static void buttonpress(XEvent *e); |
244 /* compile-time check if all tags fit into an unsigned int bit array. */ |
244 /* compile-time check if all tags fit into an unsigned int bit array. */ |
245 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; }; |
245 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; }; |
246 |
246 |
247 /* function implementations */ |
247 /* function implementations */ |
248 void |
248 void |
249 adjustborder(Client *c, Bool issingle) { |
|
250 XWindowChanges wc; |
|
251 |
|
252 wc.border_width = issingle ? 0 : borderpx; |
|
253 if(c->bw != wc.border_width) { |
|
254 c->bw = wc.border_width; |
|
255 XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); |
|
256 } |
|
257 } |
|
258 |
|
259 void |
|
260 applyrules(Client *c) { |
249 applyrules(Client *c) { |
261 unsigned int i; |
250 unsigned int i; |
262 Rule *r; |
251 Rule *r; |
263 XClassHint ch = { 0 }; |
252 XClassHint ch = { 0 }; |
264 |
253 |
939 unsigned int n; |
928 unsigned int n; |
940 Client *c; |
929 Client *c; |
941 |
930 |
942 for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++); |
931 for(n = 0, c = nexttiled(clients); c && n < 2; c = nexttiled(c->next), n++); |
943 for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
932 for(c = nexttiled(clients); c; c = nexttiled(c->next)) { |
944 adjustborder(c, n == 1); |
933 ADJUSTBORDER(c, (n == 1 ? 0 : borderpx)) |
945 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); |
934 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); |
946 } |
935 } |
947 } |
936 } |
948 |
937 |
949 void |
938 void |
1146 case Expose: |
1135 case Expose: |
1147 case MapRequest: |
1136 case MapRequest: |
1148 handler[ev.type](&ev); |
1137 handler[ev.type](&ev); |
1149 break; |
1138 break; |
1150 case MotionNotify: |
1139 case MotionNotify: |
1151 nw = MAX(ev.xmotion.x - ocx - 2*c->bw + 1, 1); |
1140 nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); |
1152 nh = MAX(ev.xmotion.y - ocy - 2*c->bw + 1, 1); |
1141 nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); |
1153 |
|
1154 if(snap && nw >= wx && nw <= wx + ww |
1142 if(snap && nw >= wx && nw <= wx + ww |
1155 && nh >= wy && nh <= wy + wh) { |
1143 && nh >= wy && nh <= wy + wh) { |
1156 if(!c->isfloating && lt[sellt]->arrange |
1144 if(!c->isfloating && lt[sellt]->arrange |
1157 && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) |
1145 && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) |
1158 togglefloating(NULL); |
1146 togglefloating(NULL); |
1344 void |
1332 void |
1345 showhide(Client *c) { |
1333 showhide(Client *c) { |
1346 if(!c) |
1334 if(!c) |
1347 return; |
1335 return; |
1348 if(ISVISIBLE(c)) { /* show clients top down */ |
1336 if(ISVISIBLE(c)) { /* show clients top down */ |
1349 adjustborder(c, False); |
1337 ADJUSTBORDER(c, borderpx) |
1350 XMoveWindow(dpy, c->win, c->x, c->y); |
1338 XMoveWindow(dpy, c->win, c->x, c->y); |
1351 if(!lt[sellt]->arrange || c->isfloating) |
1339 if(!lt[sellt]->arrange || c->isfloating) |
1352 resize(c, c->x, c->y, c->w, c->h, True); |
1340 resize(c, c->x, c->y, c->w, c->h, True); |
1353 showhide(c->snext); |
1341 showhide(c->snext); |
1354 } |
1342 } |
1408 return; |
1396 return; |
1409 |
1397 |
1410 /* master */ |
1398 /* master */ |
1411 c = nexttiled(clients); |
1399 c = nexttiled(clients); |
1412 mw = mfact * ww; |
1400 mw = mfact * ww; |
1413 adjustborder(c, n == 1); |
1401 ADJUSTBORDER(c, (n == 1 ? 0 : borderpx)) |
1414 resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); |
1402 resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); |
1415 |
1403 |
1416 if(--n == 0) |
1404 if(--n == 0) |
1417 return; |
1405 return; |
1418 |
1406 |
1423 h = wh / n; |
1411 h = wh / n; |
1424 if(h < bh) |
1412 if(h < bh) |
1425 h = wh; |
1413 h = wh; |
1426 |
1414 |
1427 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
1415 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
1428 adjustborder(c, False); |
1416 ADJUSTBORDER(c, borderpx) |
1429 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
1417 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
1430 ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); |
1418 ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); |
1431 if(h != wh) |
1419 if(h != wh) |
1432 y = c->y + HEIGHT(c); |
1420 y = c->y + HEIGHT(c); |
1433 } |
1421 } |