equal
deleted
inserted
replaced
58 /* typedefs */ |
58 /* typedefs */ |
59 typedef struct Client Client; |
59 typedef struct Client Client; |
60 struct Client { |
60 struct Client { |
61 char name[256]; |
61 char name[256]; |
62 int x, y, w, h; |
62 int x, y, w, h; |
63 int fx, fy, fw, fh; |
|
64 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
63 int basew, baseh, incw, inch, maxw, maxh, minw, minh; |
65 int minax, maxax, minay, maxay; |
64 int minax, maxax, minay, maxay; |
66 long flags; |
65 long flags; |
67 unsigned int bw, oldbw; |
66 unsigned int bw, oldbw; |
68 Bool isbanned, isfixed, isfloating, isurgent; |
67 Bool isbanned, isfixed, isfloating, isurgent; |
96 } Key; |
95 } Key; |
97 |
96 |
98 typedef struct { |
97 typedef struct { |
99 const char *symbol; |
98 const char *symbol; |
100 void (*arrange)(void); |
99 void (*arrange)(void); |
101 Bool isfloating; |
|
102 } Layout; |
100 } Layout; |
103 |
101 |
104 typedef struct { |
102 typedef struct { |
105 const char *class; |
103 const char *class; |
106 const char *instance; |
104 const char *instance; |
271 Client *c; |
269 Client *c; |
272 |
270 |
273 for(c = clients; c; c = c->next) |
271 for(c = clients; c; c = c->next) |
274 if(isvisible(c, NULL)) { |
272 if(isvisible(c, NULL)) { |
275 unban(c); |
273 unban(c); |
276 if(lt->isfloating || c->isfloating) |
274 if(!lt->arrange || c->isfloating) |
277 resize(c, c->fx, c->fy, c->fw, c->fh, True); |
275 resize(c, c->x, c->y, c->w, c->h, True); |
278 } |
276 } |
279 else |
277 else |
280 ban(c); |
278 ban(c); |
281 |
279 |
282 focus(NULL); |
280 focus(NULL); |
343 if(ev->button == Button1) { |
341 if(ev->button == Button1) { |
344 restack(); |
342 restack(); |
345 movemouse(c); |
343 movemouse(c); |
346 } |
344 } |
347 else if(ev->button == Button2) { |
345 else if(ev->button == Button2) { |
348 if(!lt->isfloating && c->isfloating) |
346 if(lt->arrange && c->isfloating) |
349 togglefloating(NULL); |
347 togglefloating(NULL); |
350 else |
348 else |
351 zoom(NULL); |
349 zoom(NULL); |
352 } |
350 } |
353 else if(ev->button == Button3 && !c->isfixed) { |
351 else if(ev->button == Button3 && !c->isfixed) { |
433 XWindowChanges wc; |
431 XWindowChanges wc; |
434 |
432 |
435 if((c = getclient(ev->window))) { |
433 if((c = getclient(ev->window))) { |
436 if(ev->value_mask & CWBorderWidth) |
434 if(ev->value_mask & CWBorderWidth) |
437 c->bw = ev->border_width; |
435 c->bw = ev->border_width; |
438 if(c->isfixed || c->isfloating || lt->isfloating) { |
436 if(c->isfixed || c->isfloating || !lt->arrange) { |
439 if(ev->value_mask & CWX) |
437 if(ev->value_mask & CWX) |
440 c->x = sx + ev->x; |
438 c->x = sx + ev->x; |
441 if(ev->value_mask & CWY) |
439 if(ev->value_mask & CWY) |
442 c->y = sy + ev->y; |
440 c->y = sy + ev->y; |
443 if(ev->value_mask & CWWidth) |
441 if(ev->value_mask & CWWidth) |
966 c->win = w; |
964 c->win = w; |
967 |
965 |
968 /* geometry */ |
966 /* geometry */ |
969 c->x = wa->x; |
967 c->x = wa->x; |
970 c->y = wa->y; |
968 c->y = wa->y; |
971 c->w = c->fw = wa->width; |
969 c->w = wa->width; |
972 c->h = c->fh = wa->height; |
970 c->h = wa->height; |
973 c->oldbw = wa->border_width; |
971 c->oldbw = wa->border_width; |
974 if(c->w == sw && c->h == sh) { |
972 if(c->w == sw && c->h == sh) { |
975 c->x = sx; |
973 c->x = sx; |
976 c->y = sy; |
974 c->y = sy; |
977 c->bw = wa->border_width; |
975 c->bw = wa->border_width; |
983 c->y = wy + wh - c->h - 2 * c->bw; |
981 c->y = wy + wh - c->h - 2 * c->bw; |
984 c->x = MAX(c->x, wx); |
982 c->x = MAX(c->x, wx); |
985 c->y = MAX(c->y, wy); |
983 c->y = MAX(c->y, wy); |
986 c->bw = BORDERPX; |
984 c->bw = BORDERPX; |
987 } |
985 } |
988 c->fx = c->x; |
|
989 c->fy = c->y; |
|
990 |
986 |
991 wc.border_width = c->bw; |
987 wc.border_width = c->bw; |
992 XConfigureWindow(dpy, w, CWBorderWidth, &wc); |
988 XConfigureWindow(dpy, w, CWBorderWidth, &wc); |
993 XSetWindowBorder(dpy, w, dc.norm[ColBorder]); |
989 XSetWindowBorder(dpy, w, dc.norm[ColBorder]); |
994 configure(c); /* propagates border_width, if size doesn't change */ |
990 configure(c); /* propagates border_width, if size doesn't change */ |
1038 void |
1034 void |
1039 monocle(void) { |
1035 monocle(void) { |
1040 Client *c; |
1036 Client *c; |
1041 |
1037 |
1042 for(c = clients; c; c = c->next) |
1038 for(c = clients; c; c = c->next) |
1043 if((lt->isfloating || !c->isfloating) && isvisible(c, NULL)) |
1039 if(!c->isfloating && isvisible(c, NULL)) |
1044 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, RESIZEHINTS); |
1040 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, RESIZEHINTS); |
1045 } |
1041 } |
1046 |
1042 |
1047 void |
1043 void |
1048 movemouse(Client *c) { |
1044 movemouse(Client *c) { |
1078 nx = wx + ww - c->w - 2 * c->bw; |
1074 nx = wx + ww - c->w - 2 * c->bw; |
1079 if(abs(wy - ny) < SNAP) |
1075 if(abs(wy - ny) < SNAP) |
1080 ny = wy; |
1076 ny = wy; |
1081 else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < SNAP) |
1077 else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < SNAP) |
1082 ny = wy + wh - c->h - 2 * c->bw; |
1078 ny = wy + wh - c->h - 2 * c->bw; |
1083 if(!c->isfloating && !lt->isfloating && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) |
1079 if(!c->isfloating && lt->arrange && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) |
1084 togglefloating(NULL); |
1080 togglefloating(NULL); |
1085 if(lt->isfloating || c->isfloating) { |
1081 if(!lt->arrange || c->isfloating) |
1086 c->fx = nx; |
|
1087 c->fy = ny; |
|
1088 resize(c, nx, ny, c->w, c->h, False); |
1082 resize(c, nx, ny, c->w, c->h, False); |
1089 } |
|
1090 break; |
1083 break; |
1091 } |
1084 } |
1092 } |
1085 } |
1093 } |
1086 } |
1094 |
1087 |
1227 break; |
1220 break; |
1228 case MotionNotify: |
1221 case MotionNotify: |
1229 XSync(dpy, False); |
1222 XSync(dpy, False); |
1230 nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); |
1223 nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1); |
1231 nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); |
1224 nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1); |
1232 if(!c->isfloating && !lt->isfloating && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) { |
1225 if(!c->isfloating && lt->arrange && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) { |
1233 c->fx = c->x; |
|
1234 c->fy = c->y; |
|
1235 togglefloating(NULL); |
1226 togglefloating(NULL); |
1236 } |
1227 } |
1237 if((lt->isfloating) || c->isfloating) { |
1228 if(!lt->arrange || c->isfloating) |
1238 resize(c, c->x, c->y, nw, nh, True); |
1229 resize(c, c->x, c->y, nw, nh, True); |
1239 c->fw = nw; |
|
1240 c->fh = nh; |
|
1241 } |
|
1242 break; |
1230 break; |
1243 } |
1231 } |
1244 } |
1232 } |
1245 } |
1233 } |
1246 |
1234 |
1251 XWindowChanges wc; |
1239 XWindowChanges wc; |
1252 |
1240 |
1253 drawbar(); |
1241 drawbar(); |
1254 if(!sel) |
1242 if(!sel) |
1255 return; |
1243 return; |
1256 if(sel->isfloating || lt->isfloating) |
1244 if(sel->isfloating || !lt->arrange) |
1257 XRaiseWindow(dpy, sel->win); |
1245 XRaiseWindow(dpy, sel->win); |
1258 if(!lt->isfloating) { |
1246 if(lt->arrange) { |
1259 wc.stack_mode = Below; |
1247 wc.stack_mode = Below; |
1260 wc.sibling = barwin; |
1248 wc.sibling = barwin; |
1261 for(c = stack; c; c = c->snext) |
1249 for(c = stack; c; c = c->snext) |
1262 if(!c->isfloating && isvisible(c, NULL)) { |
1250 if(!c->isfloating && isvisible(c, NULL)) { |
1263 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); |
1251 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); |
1361 |
1349 |
1362 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1350 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1363 PropModeReplace, (unsigned char *)data, 2); |
1351 PropModeReplace, (unsigned char *)data, 2); |
1364 } |
1352 } |
1365 |
1353 |
|
1354 /* TODO: move this into tile.c */ |
1366 void |
1355 void |
1367 setmfact(const char *arg) { |
1356 setmfact(const char *arg) { |
1368 double d; |
1357 double d; |
1369 |
1358 |
1370 if(lt->isfloating) |
1359 if(!lt->arrange) /* TODO: check this against the actual tile() function */ |
1371 return; |
1360 return; |
1372 if(!arg) |
1361 if(!arg) |
1373 mfact = MFACT; |
1362 mfact = MFACT; |
1374 else { |
1363 else { |
1375 d = strtod(arg, NULL); |
1364 d = strtod(arg, NULL); |
1840 xerrorstart(Display *dpy, XErrorEvent *ee) { |
1829 xerrorstart(Display *dpy, XErrorEvent *ee) { |
1841 otherwm = True; |
1830 otherwm = True; |
1842 return -1; |
1831 return -1; |
1843 } |
1832 } |
1844 |
1833 |
|
1834 /* TODO: move this into tile.c */ |
1845 void |
1835 void |
1846 zoom(const char *arg) { |
1836 zoom(const char *arg) { |
1847 Client *c = sel; |
1837 Client *c = sel; |
1848 |
1838 |
1849 if(c == nexttiled(clients)) |
1839 if(c == nexttiled(clients)) |
1850 if(!c || !(c = nexttiled(c->next))) |
1840 if(!c || !(c = nexttiled(c->next))) |
1851 return; |
1841 return; |
1852 if(!lt->isfloating && !sel->isfloating) { |
1842 if(lt->arrange && !sel->isfloating) { /* TODO: check this against tile() */ |
1853 detach(c); |
1843 detach(c); |
1854 attach(c); |
1844 attach(c); |
1855 focus(c); |
1845 focus(c); |
1856 } |
1846 } |
1857 arrange(); |
1847 arrange(); |