summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-05-11 20:20:53 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-05-11 20:20:53 +0100
commit7eb26288fc6aa4c8850f41d475230b1619df622b (patch)
treea76bedee5c65feb8528f9412a1da92cbabe85a21 /dwm.c
parentcleaned up config.def.h (diff)
downloaddwm-7eb26288fc6aa4c8850f41d475230b1619df622b.tar.gz
dwm-7eb26288fc6aa4c8850f41d475230b1619df622b.zip
removed Geom stuff, introduced updategeom() again, still view is somewhat broken?
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c122
1 files changed, 51 insertions, 71 deletions
diff --git a/dwm.c b/dwm.c
index 56ca615..6ef2ab2 100644
--- a/dwm.c
+++ b/dwm.c
@@ -41,21 +41,13 @@
41#include <X11/Xutil.h> 41#include <X11/Xutil.h>
42 42
43/* macros */ 43/* macros */
44#define MAX(a, b) ((a)>(b)?(a):(b)) 44#define MAX(a, b) ((a) > (b) ? (a) : (b))
45#define MIN(a, b) ((a)<(b)?(a):(b)) 45#define MIN(a, b) ((a) < (b) ? (a) : (b))
46#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) 46#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
47#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) 47#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
48#define LENGTH(x) (sizeof x / sizeof x[0]) 48#define LENGTH(x) (sizeof x / sizeof x[0])
49#define MAXTAGLEN 16 49#define MAXTAGLEN 16
50#define MOUSEMASK (BUTTONMASK|PointerMotionMask) 50#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
51#define DEFGEOM(GEONAME,BX,BY,BW,WX,WY,WW,WH,MX,MY,MW,MH,TX,TY,TW,TH,MOX,MOY,MOW,MOH) \
52void GEONAME(void) { \
53 bx = (BX); by = (BY); bw = (BW); \
54 wx = (WX); wy = (WY); ww = (WW); wh = (WH); \
55 mx = (MX); my = (MY); mw = (MW); mh = (MH); \
56 tx = (TX); ty = (TY); tw = (TW); th = (TH); \
57 mox = (MOX); moy = (MOY); mow = (MOW); moh = (MOH); \
58}
59 51
60/* enums */ 52/* enums */
61enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ 53enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
@@ -97,11 +89,6 @@ typedef struct {
97} DC; /* draw context */ 89} DC; /* draw context */
98 90
99typedef struct { 91typedef struct {
100 const char *symbol;
101 void (*apply)(void);
102} Geom;
103
104typedef struct {
105 unsigned long mod; 92 unsigned long mod;
106 KeySym keysym; 93 KeySym keysym;
107 void (*func)(const char *arg); 94 void (*func)(const char *arg);
@@ -178,7 +165,6 @@ void restack(void);
178void run(void); 165void run(void);
179void scan(void); 166void scan(void);
180void setclientstate(Client *c, long state); 167void setclientstate(Client *c, long state);
181void setgeom(const char *arg);
182void setlayout(const char *arg); 168void setlayout(const char *arg);
183void setmfact(const char *arg); 169void setmfact(const char *arg);
184void setup(void); 170void setup(void);
@@ -198,7 +184,8 @@ void toggleview(const char *arg);
198void unban(Client *c); 184void unban(Client *c);
199void unmanage(Client *c); 185void unmanage(Client *c);
200void unmapnotify(XEvent *e); 186void unmapnotify(XEvent *e);
201void updatebarpos(void); 187void updatebar(void);
188void updategeom(void);
202void updatesizehints(Client *c); 189void updatesizehints(Client *c);
203void updatetitle(Client *c); 190void updatetitle(Client *c);
204void updatewmhints(Client *c); 191void updatewmhints(Client *c);
@@ -213,7 +200,7 @@ void zoom(const char *arg);
213char stext[256]; 200char stext[256];
214int screen, sx, sy, sw, sh; 201int screen, sx, sy, sw, sh;
215int (*xerrorxlib)(Display *, XErrorEvent *); 202int (*xerrorxlib)(Display *, XErrorEvent *);
216int bx, by, bw, bh, blw, bgw, mx, my, mw, mh, mox, moy, mow, moh, tx, ty, tw, th, wx, wy, ww, wh; 203int bx, by, bw, bh, blw, mx, my, mw, mh, tx, ty, tw, th, wx, wy, ww, wh;
217int seltags = 0; 204int seltags = 0;
218double mfact; 205double mfact;
219unsigned int numlockmask = 0; 206unsigned int numlockmask = 0;
@@ -241,8 +228,6 @@ Client *stack = NULL;
241Cursor cursor[CurLast]; 228Cursor cursor[CurLast];
242Display *dpy; 229Display *dpy;
243DC dc = {0}; 230DC dc = {0};
244Geom geoms[];
245Geom *geom = geoms;
246Layout layouts[]; 231Layout layouts[];
247Layout *lt = layouts; 232Layout *lt = layouts;
248Window root, barwin; 233Window root, barwin;
@@ -330,14 +315,10 @@ buttonpress(XEvent *e) {
330 XButtonPressedEvent *ev = &e->xbutton; 315 XButtonPressedEvent *ev = &e->xbutton;
331 316
332 if(ev->window == barwin) { 317 if(ev->window == barwin) {
333 if((ev->x < bgw) && ev->button == Button1) { 318 x = 0;
334 setgeom(NULL);
335 return;
336 }
337 x = bgw;
338 for(i = 0; i < LENGTH(tags); i++) { 319 for(i = 0; i < LENGTH(tags); i++) {
339 x += textw(tags[i]); 320 x += textw(tags[i]);
340 if(ev->x >= bgw && ev->x < x) { 321 if(ev->x < x) {
341 if(ev->button == Button1) { 322 if(ev->button == Button1) {
342 if(ev->state & MODKEY) 323 if(ev->state & MODKEY)
343 tag(tags[i]); 324 tag(tags[i]);
@@ -440,7 +421,9 @@ configurenotify(XEvent *e) {
440 if(ev->window == root && (ev->width != sw || ev->height != sh)) { 421 if(ev->window == root && (ev->width != sw || ev->height != sh)) {
441 sw = ev->width; 422 sw = ev->width;
442 sh = ev->height; 423 sh = ev->height;
443 setgeom(geom->symbol); 424 updategeom();
425 updatebar();
426 arrange();
444 } 427 }
445} 428}
446 429
@@ -531,11 +514,6 @@ drawbar(void) {
531 Client *c; 514 Client *c;
532 515
533 dc.x = 0; 516 dc.x = 0;
534 if(bgw > 0) {
535 dc.w = bgw;
536 drawtext(geom->symbol, dc.norm, False);
537 dc.x += bgw;
538 }
539 for(c = stack; c && !isvisible(c, NULL); c = c->snext); 517 for(c = stack; c && !isvisible(c, NULL); c = c->snext);
540 for(i = 0; i < LENGTH(tags); i++) { 518 for(i = 0; i < LENGTH(tags); i++) {
541 dc.w = textw(tags[i]); 519 dc.w = textw(tags[i]);
@@ -1064,7 +1042,7 @@ monocle(void) {
1064 1042
1065 for(c = clients; c; c = c->next) 1043 for(c = clients; c; c = c->next)
1066 if((lt->isfloating || !c->isfloating) && isvisible(c, NULL)) 1044 if((lt->isfloating || !c->isfloating) && isvisible(c, NULL))
1067 resize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw, RESIZEHINTS); 1045 resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, RESIZEHINTS);
1068} 1046}
1069 1047
1070void 1048void
@@ -1399,27 +1377,6 @@ setclientstate(Client *c, long state) {
1399} 1377}
1400 1378
1401void 1379void
1402setgeom(const char *arg) {
1403 unsigned int i;
1404
1405 if(!arg) {
1406 if(++geom == &geoms[LENGTH(geoms)])
1407 geom = &geoms[0];
1408 }
1409 else {
1410 for(i = 0; i < LENGTH(geoms); i++)
1411 if(!strcmp(geoms[i].symbol, arg))
1412 break;
1413 if(i == LENGTH(geoms))
1414 return;
1415 geom = &geoms[i];
1416 }
1417 geom->apply();
1418 updatebarpos();
1419 arrange();
1420}
1421
1422void
1423setlayout(const char *arg) { 1380setlayout(const char *arg) {
1424 unsigned int i; 1381 unsigned int i;
1425 1382
@@ -1457,7 +1414,8 @@ setmfact(const char *arg) {
1457 return; 1414 return;
1458 mfact = d; 1415 mfact = d;
1459 } 1416 }
1460 setgeom(geom->symbol); 1417 updategeom();
1418 arrange();
1461} 1419}
1462 1420
1463void 1421void
@@ -1469,15 +1427,14 @@ setup(void) {
1469 screen = DefaultScreen(dpy); 1427 screen = DefaultScreen(dpy);
1470 root = RootWindow(dpy, screen); 1428 root = RootWindow(dpy, screen);
1471 initfont(FONT); 1429 initfont(FONT);
1472
1473 /* apply default geometry */
1474 sx = 0; 1430 sx = 0;
1475 sy = 0; 1431 sy = 0;
1476 sw = DisplayWidth(dpy, screen); 1432 sw = DisplayWidth(dpy, screen);
1477 sh = DisplayHeight(dpy, screen); 1433 sh = DisplayHeight(dpy, screen);
1478 bh = dc.font.height + 2; 1434 bh = dc.font.height + 2;
1479 mfact = MFACT; 1435
1480 geom->apply(); 1436 /* update geometry */
1437 updategeom();
1481 1438
1482 /* init atoms */ 1439 /* init atoms */
1483 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); 1440 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
@@ -1517,10 +1474,6 @@ setup(void) {
1517 w = textw(layouts[i].symbol); 1474 w = textw(layouts[i].symbol);
1518 blw = MAX(blw, w); 1475 blw = MAX(blw, w);
1519 } 1476 }
1520 for(bgw = i = 0; LENGTH(geoms) > 1 && i < LENGTH(geoms); i++) {
1521 w = textw(geoms[i].symbol);
1522 bgw = MAX(bgw, w);
1523 }
1524 1477
1525 wa.override_redirect = 1; 1478 wa.override_redirect = 1;
1526 wa.background_pixmap = ParentRelative; 1479 wa.background_pixmap = ParentRelative;
@@ -1633,7 +1586,7 @@ tilemaster(unsigned int n) {
1633 Client *c = nexttiled(clients); 1586 Client *c = nexttiled(clients);
1634 1587
1635 if(n == 1) 1588 if(n == 1)
1636 tileresize(c, mox, moy, mow - 2 * c->bw, moh - 2 * c->bw); 1589 tileresize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw);
1637 else 1590 else
1638 tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw); 1591 tileresize(c, mx, my, mw - 2 * c->bw, mh - 2 * c->bw);
1639 return c; 1592 return c;
@@ -1751,7 +1704,7 @@ unmapnotify(XEvent *e) {
1751} 1704}
1752 1705
1753void 1706void
1754updatebarpos(void) { 1707updatebar(void) {
1755 1708
1756 if(dc.drawable != 0) 1709 if(dc.drawable != 0)
1757 XFreePixmap(dpy, dc.drawable); 1710 XFreePixmap(dpy, dc.drawable);
@@ -1760,6 +1713,34 @@ updatebarpos(void) {
1760} 1713}
1761 1714
1762void 1715void
1716updategeom(void) {
1717
1718 /* bar geometry */
1719 bx = 0;
1720 by = 0;
1721 bw = sw;
1722
1723 /* window area geometry */
1724 wx = sx;
1725 wy = sy;
1726 ww = sw;
1727 sh = sh - bh;
1728
1729 /* master area geometry */
1730 mfact = MFACT;
1731 mx = wx;
1732 my = wy;
1733 mw = mfact * ww;
1734 mh = wh;
1735
1736 /* tile area geometry */
1737 tx = mx + mw;
1738 ty = wy;
1739 tw = ww - mw;
1740 th = wh;
1741}
1742
1743void
1763updatesizehints(Client *c) { 1744updatesizehints(Client *c) {
1764 long msize; 1745 long msize;
1765 XSizeHints size; 1746 XSizeHints size;
@@ -1912,4 +1893,3 @@ main(int argc, char *argv[]) {
1912 XCloseDisplay(dpy); 1893 XCloseDisplay(dpy);
1913 return 0; 1894 return 0;
1914} 1895}
1915