158 void resizemouse(Client *c); |
158 void resizemouse(Client *c); |
159 void restack(void); |
159 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); |
166 void tag(const char *arg); |
167 void tag(const char *arg); |
167 unsigned int textnw(const char *text, unsigned int len); |
168 unsigned int textnw(const char *text, unsigned int len); |
218 Cursor cursor[CurLast]; |
219 Cursor cursor[CurLast]; |
219 Display *dpy; |
220 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" |
226 #define TAGSZ (LENGTH(tags) * sizeof(Bool)) |
228 #define TAGSZ (LENGTH(tags) * sizeof(Bool)) |
227 static Bool tmp[LENGTH(tags)]; |
229 static Bool tmp[LENGTH(tags)]; |
402 void |
404 void |
403 configurenotify(XEvent *e) { |
405 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 } |
415 |
413 |
416 void |
414 void |
1377 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1375 XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32, |
1378 PropModeReplace, (unsigned char *)data, 2); |
1376 PropModeReplace, (unsigned char *)data, 2); |
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; |
1385 |
1428 |
1386 if(!arg) |
1429 if(!arg) |
1408 XSetWindowAttributes wa; |
1451 XSetWindowAttributes wa; |
1409 |
1452 |
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); |
1420 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
1463 wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False); |
1421 wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False); |
1464 wmatom[WMName] = XInternAtom(dpy, "WM_NAME", False); |
1434 dc.norm[ColFG] = getcolor(NORMFGCOLOR); |
1477 dc.norm[ColFG] = getcolor(NORMFGCOLOR); |
1435 dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); |
1478 dc.sel[ColBorder] = getcolor(SELBORDERCOLOR); |
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); |
1443 if(!dc.font.set) |
1486 if(!dc.font.set) |
1444 XSetFont(dpy, dc.gc, dc.font.xfont->fid); |
1487 XSetFont(dpy, dc.gc, dc.font.xfont->fid); |
1448 prevtags = emallocz(TAGSZ); |
1491 prevtags = emallocz(TAGSZ); |
1449 seltags[0] = prevtags[0] = True; |
1492 seltags[0] = prevtags[0] = True; |
1450 |
1493 |
1451 /* init layouts */ |
1494 /* init layouts */ |
1452 lt = &layouts[0]; |
1495 lt = &layouts[0]; |
1453 |
|
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 |
1496 |
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); |
1472 if(i > blw) |
1500 if(i > blw) |