150 void manage(Window w, XWindowAttributes *wa); |
151 void manage(Window w, XWindowAttributes *wa); |
151 void mappingnotify(XEvent *e); |
152 void mappingnotify(XEvent *e); |
152 void maprequest(XEvent *e); |
153 void maprequest(XEvent *e); |
153 void monocle(void); |
154 void monocle(void); |
154 void movemouse(Client *c); |
155 void movemouse(Client *c); |
155 Client *nexttiled(Client *c); |
156 Client *nextunfloating(Client *c); |
156 void propertynotify(XEvent *e); |
157 void propertynotify(XEvent *e); |
157 void quit(const char *arg); |
158 void quit(const char *arg); |
158 void resize(Client *c, int x, int y, int w, int h, Bool sizehints); |
159 void resize(Client *c, int x, int y, int w, int h, Bool sizehints); |
159 void resizemouse(Client *c); |
160 void resizemouse(Client *c); |
160 void restack(void); |
161 void restack(void); |
161 void run(void); |
162 void run(void); |
162 void scan(void); |
163 void scan(void); |
163 void setclientstate(Client *c, long state); |
164 void setclientstate(Client *c, long state); |
164 void setmfact(const char *arg); |
|
165 void setup(void); |
165 void setup(void); |
166 void spawn(const char *arg); |
166 void spawn(const char *arg); |
167 void tag(const char *arg); |
167 void tag(const char *arg); |
168 unsigned int textnw(const char *text, unsigned int len); |
168 unsigned int textnw(const char *text, unsigned int len); |
169 unsigned int textw(const char *text); |
169 unsigned int textw(const char *text); |
170 void tileresize(Client *c, int x, int y, int w, int h); |
|
171 void tile(void); |
|
172 void togglefloating(const char *arg); |
170 void togglefloating(const char *arg); |
173 void togglelayout(const char *arg); |
171 void togglelayout(const char *arg); |
174 void toggletag(const char *arg); |
172 void toggletag(const char *arg); |
175 void toggleview(const char *arg); |
173 void toggleview(const char *arg); |
176 void unban(Client *c); |
174 void unban(Client *c); |
190 |
188 |
191 /* variables */ |
189 /* variables */ |
192 char stext[256]; |
190 char stext[256]; |
193 int screen, sx, sy, sw, sh; |
191 int screen, sx, sy, sw, sh; |
194 int (*xerrorxlib)(Display *, XErrorEvent *); |
192 int (*xerrorxlib)(Display *, XErrorEvent *); |
195 int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh; |
193 int bx, by, bw, bh, blw, wx, wy, ww, wh; |
196 int seltags = 0; |
194 int seltags = 0; |
197 double mfact; |
|
198 unsigned int numlockmask = 0; |
195 unsigned int numlockmask = 0; |
199 void (*handler[LASTEvent]) (XEvent *) = { |
196 void (*handler[LASTEvent]) (XEvent *) = { |
200 [ButtonPress] = buttonpress, |
197 [ButtonPress] = buttonpress, |
201 [ConfigureRequest] = configurerequest, |
198 [ConfigureRequest] = configurerequest, |
202 [ConfigureNotify] = configurenotify, |
199 [ConfigureNotify] = configurenotify, |
1335 |
1332 |
1336 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1333 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1337 PropModeReplace, (unsigned char *)data, 2); |
1334 PropModeReplace, (unsigned char *)data, 2); |
1338 } |
1335 } |
1339 |
1336 |
1340 /* TODO: move this into tile.c */ |
|
1341 void |
|
1342 setmfact(const char *arg) { |
|
1343 double d; |
|
1344 |
|
1345 if(!lt->arrange) /* TODO: check this against the actual tile() function */ |
|
1346 return; |
|
1347 if(!arg) |
|
1348 mfact = MFACT; |
|
1349 else { |
|
1350 d = strtod(arg, NULL); |
|
1351 if(arg[0] == '-' || arg[0] == '+') |
|
1352 d += mfact; |
|
1353 if(d < 0.1 || d > 0.9) |
|
1354 return; |
|
1355 mfact = d; |
|
1356 } |
|
1357 updategeom(); |
|
1358 arrange(); |
|
1359 } |
|
1360 |
|
1361 void |
1337 void |
1362 setup(void) { |
1338 setup(void) { |
1363 unsigned int i, w; |
1339 unsigned int i, w; |
1364 XSetWindowAttributes wa; |
1340 XSetWindowAttributes wa; |
1365 |
1341 |
1370 sx = 0; |
1346 sx = 0; |
1371 sy = 0; |
1347 sy = 0; |
1372 sw = DisplayWidth(dpy, screen); |
1348 sw = DisplayWidth(dpy, screen); |
1373 sh = DisplayHeight(dpy, screen); |
1349 sh = DisplayHeight(dpy, screen); |
1374 bh = dc.font.height + 2; |
1350 bh = dc.font.height + 2; |
1375 mfact = MFACT; |
|
1376 updategeom(); |
1351 updategeom(); |
1377 |
1352 |
1378 /* init atoms */ |
1353 /* init atoms */ |
1379 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
1354 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
1380 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
1355 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
1489 } |
1464 } |
1490 |
1465 |
1491 unsigned int |
1466 unsigned int |
1492 textw(const char *text) { |
1467 textw(const char *text) { |
1493 return textnw(text, strlen(text)) + dc.font.height; |
1468 return textnw(text, strlen(text)) + dc.font.height; |
1494 } |
|
1495 |
|
1496 void |
|
1497 tileresize(Client *c, int x, int y, int w, int h) { |
|
1498 resize(c, x, y, w, h, RESIZEHINTS); |
|
1499 if((RESIZEHINTS) && ((c->h < bh) || (c->h > h) || (c->w < bh) || (c->w > w))) |
|
1500 /* client doesn't accept size constraints */ |
|
1501 resize(c, x, y, w, h, False); |
|
1502 } |
|
1503 |
|
1504 void |
|
1505 tile(void) { |
|
1506 int y, h; |
|
1507 unsigned int i, n; |
|
1508 Client *c; |
|
1509 |
|
1510 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++); |
|
1511 if(n == 0) |
|
1512 return; |
|
1513 |
|
1514 /* master */ |
|
1515 c = nexttiled(clients); |
|
1516 |
|
1517 if(n == 1) |
|
1518 tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); |
|
1519 else |
|
1520 tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw); |
|
1521 |
|
1522 if(--n == 0) |
|
1523 return; |
|
1524 |
|
1525 /* tile stack */ |
|
1526 y = ty; |
|
1527 h = th / n; |
|
1528 if(h < bh) |
|
1529 h = th; |
|
1530 |
|
1531 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
|
1532 if(i + 1 == n) /* remainder */ |
|
1533 tileresize(c, tx, y, tw - 2 * c->bw, (ty + th) - y - 2 * c->bw); |
|
1534 else |
|
1535 tileresize(c, tx, y, tw - 2 * c->bw, h - 2 * c->bw); |
|
1536 if(h != th) |
|
1537 y = c->y + c->h + 2 * c->bw; |
|
1538 } |
|
1539 } |
1469 } |
1540 |
1470 |
1541 void |
1471 void |
1542 togglefloating(const char *arg) { |
1472 togglefloating(const char *arg) { |
1543 if(!sel) |
1473 if(!sel) |
1787 xerrorstart(Display *dpy, XErrorEvent *ee) { |
1711 xerrorstart(Display *dpy, XErrorEvent *ee) { |
1788 otherwm = True; |
1712 otherwm = True; |
1789 return -1; |
1713 return -1; |
1790 } |
1714 } |
1791 |
1715 |
1792 /* TODO: move this into tile.c */ |
|
1793 void |
|
1794 zoom(const char *arg) { |
|
1795 Client *c = sel; |
|
1796 |
|
1797 if(c == nexttiled(clients)) |
|
1798 if(!c || !(c = nexttiled(c->next))) |
|
1799 return; |
|
1800 if(lt->arrange && !sel->isfloating) { /* TODO: check this against tile() */ |
|
1801 detach(c); |
|
1802 attach(c); |
|
1803 focus(c); |
|
1804 } |
|
1805 arrange(); |
|
1806 } |
|
1807 |
|
1808 int |
1716 int |
1809 main(int argc, char *argv[]) { |
1717 main(int argc, char *argv[]) { |
1810 if(argc == 2 && !strcmp("-v", argv[1])) |
1718 if(argc == 2 && !strcmp("-v", argv[1])) |
1811 eprint("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n"); |
1719 eprint("dwm-"VERSION", © 2006-2008 dwm engineers, see LICENSE for details\n"); |
1812 else if(argc != 1) |
1720 else if(argc != 1) |