diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 78 |
1 files changed, 53 insertions, 25 deletions
| @@ -160,6 +160,7 @@ void restack(void); | |||
| 160 | void run(void); | 160 | void run(void); |
| 161 | void scan(void); | 161 | void scan(void); |
| 162 | void setclientstate(Client *c, long state); | 162 | void setclientstate(Client *c, long state); |
| 163 | void setdefaultgeoms(void); | ||
| 163 | void setlayout(const char *arg); | 164 | void setlayout(const char *arg); |
| 164 | void setup(void); | 165 | void setup(void); |
| 165 | void spawn(const char *arg); | 166 | void spawn(const char *arg); |
| @@ -220,6 +221,7 @@ Display *dpy; | |||
| 220 | DC dc = {0}; | 221 | DC dc = {0}; |
| 221 | Layout *lt = NULL; | 222 | Layout *lt = NULL; |
| 222 | Window root, barwin; | 223 | Window root, barwin; |
| 224 | void (*setgeoms)(void) = setdefaultgeoms; | ||
| 223 | 225 | ||
| 224 | /* configuration, allows nested code to access above variables */ | 226 | /* configuration, allows nested code to access above variables */ |
| 225 | #include "config.h" | 227 | #include "config.h" |
| @@ -404,11 +406,7 @@ configurenotify(XEvent *e) { | |||
| 404 | XConfigureEvent *ev = &e->xconfigure; | 406 | XConfigureEvent *ev = &e->xconfigure; |
| 405 | 407 | ||
| 406 | if(ev->window == root && (ev->width != sw || ev->height != sh)) { | 408 | if(ev->window == root && (ev->width != sw || ev->height != sh)) { |
| 407 | sw = ev->width; | 409 | setgeoms(); |
| 408 | sh = ev->height; | ||
| 409 | XFreePixmap(dpy, dc.drawable); | ||
| 410 | dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen)); | ||
| 411 | XMoveResizeWindow(dpy, barwin, bx, by, bw, bh); | ||
| 412 | arrange(); | 410 | arrange(); |
| 413 | } | 411 | } |
| 414 | } | 412 | } |
| @@ -1379,6 +1377,51 @@ setclientstate(Client *c, long state) { | |||
| 1379 | } | 1377 | } |
| 1380 | 1378 | ||
| 1381 | void | 1379 | void |
| 1380 | setdefaultgeoms(void) { | ||
| 1381 | |||
| 1382 | /* screen dimensions */ | ||
| 1383 | sx = 0; | ||
| 1384 | sy = 0; | ||
| 1385 | sw = DisplayWidth(dpy, screen); | ||
| 1386 | sh = DisplayHeight(dpy, screen); | ||
| 1387 | |||
| 1388 | /* bar position */ | ||
| 1389 | bx = sx; | ||
| 1390 | by = sy; | ||
| 1391 | bw = sw; | ||
| 1392 | bh = dc.font.height + 2; | ||
| 1393 | |||
| 1394 | /* window area */ | ||
| 1395 | wx = sx; | ||
| 1396 | wy = sy + bh; | ||
| 1397 | ww = sw; | ||
| 1398 | wh = sh - bh; | ||
| 1399 | |||
| 1400 | /* master area */ | ||
| 1401 | mx = wx; | ||
| 1402 | my = wy; | ||
| 1403 | mw = ((float)sw) * 0.55; | ||
| 1404 | mh = wh; | ||
| 1405 | |||
| 1406 | /* tile area */ | ||
| 1407 | tx = wx; | ||
| 1408 | ty = wy; | ||
| 1409 | tw = ww - mw; | ||
| 1410 | th = wh; | ||
| 1411 | |||
| 1412 | /* monocle area */ | ||
| 1413 | mox = wx; | ||
| 1414 | moy = wy; | ||
| 1415 | mow = ww; | ||
| 1416 | moh = wh; | ||
| 1417 | |||
| 1418 | if(dc.drawable != 0) | ||
| 1419 | XFreePixmap(dpy, dc.drawable); | ||
| 1420 | dc.drawable = XCreatePixmap(dpy, root, bw, bh, DefaultDepth(dpy, screen)); | ||
| 1421 | XMoveResizeWindow(dpy, barwin, bx, by, bw, bh); | ||
| 1422 | } | ||
| 1423 | |||
| 1424 | void | ||
| 1382 | setlayout(const char *arg) { | 1425 | setlayout(const char *arg) { |
| 1383 | static Layout *revert = 0; | 1426 | static Layout *revert = 0; |
| 1384 | unsigned int i; | 1427 | unsigned int i; |
| @@ -1410,10 +1453,10 @@ setup(void) { | |||
| 1410 | /* init screen */ | 1453 | /* init screen */ |
| 1411 | screen = DefaultScreen(dpy); | 1454 | screen = DefaultScreen(dpy); |
| 1412 | root = RootWindow(dpy, screen); | 1455 | root = RootWindow(dpy, screen); |
| 1413 | sx = 0; | 1456 | initfont(FONT); |
| 1414 | sy = 0; | 1457 | |
| 1415 | sw = DisplayWidth(dpy, screen); | 1458 | /* apply default geometries */ |
| 1416 | sh = DisplayHeight(dpy, screen); | 1459 | setgeoms(); |
| 1417 | 1460 | ||
| 1418 | /* init atoms */ | 1461 | /* init atoms */ |
| 1419 | wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); | 1462 | wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); |
| @@ -1436,7 +1479,7 @@ setup(void) { | |||
| 1436 | dc.sel[ColBG] = getcolor(SELBGCOLOR); | 1479 | dc.sel[ColBG] = getcolor(SELBGCOLOR); |
| 1437 | dc.sel[ColFG] = getcolor(SELFGCOLOR); | 1480 | dc.sel[ColFG] = getcolor(SELFGCOLOR); |
| 1438 | initfont(FONT); | 1481 | initfont(FONT); |
| 1439 | dc.h = bh = dc.font.height + 2; | 1482 | dc.h = bh; |
| 1440 | dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); | 1483 | dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen)); |
| 1441 | dc.gc = XCreateGC(dpy, root, 0, 0); | 1484 | dc.gc = XCreateGC(dpy, root, 0, 0); |
| 1442 | XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); | 1485 | XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); |
| @@ -1451,21 +1494,6 @@ setup(void) { | |||
| 1451 | /* init layouts */ | 1494 | /* init layouts */ |
| 1452 | lt = &layouts[0]; | 1495 | lt = &layouts[0]; |
| 1453 | 1496 | ||
| 1454 | /* bar position */ | ||
| 1455 | bx = BX; by = BY; bw = BW; | ||
| 1456 | |||
| 1457 | /* window area */ | ||
| 1458 | wx = WX; wy = WY; ww = WW; wh = WH; | ||
| 1459 | |||
| 1460 | /* master area */ | ||
| 1461 | mx = MX; my = MY; mw = MW; mh = MH; | ||
| 1462 | |||
| 1463 | /* tile area */ | ||
| 1464 | tx = TX; ty = TY; tw = TW; th = TH; | ||
| 1465 | |||
| 1466 | /* monocle area */ | ||
| 1467 | mox = MOX; moy = MOY; mow = MOW; moh = MOH; | ||
| 1468 | |||
| 1469 | /* init bar */ | 1497 | /* init bar */ |
| 1470 | for(blw = i = 0; i < LENGTH(layouts); i++) { | 1498 | for(blw = i = 0; i < LENGTH(layouts); i++) { |
| 1471 | i = textw(layouts[i].symbol); | 1499 | i = textw(layouts[i].symbol); |
