summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.def.h61
-rw-r--r--config.mk4
-rw-r--r--dwm.115
-rw-r--r--dwm.c269
4 files changed, 124 insertions, 225 deletions
diff --git a/config.def.h b/config.def.h
index 8537d6f..c87553f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -1,7 +1,6 @@
1/* See LICENSE file for copyright and license details. */ 1/* See LICENSE file for copyright and license details. */
2 2
3/* appearance */ 3/* appearance */
4#define BARPOS BarTop /* BarBot, BarOff */
5#define BORDERPX 1 4#define BORDERPX 1
6#define FONT "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*" 5#define FONT "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"
7#define NORMBORDERCOLOR "#cccccc" 6#define NORMBORDERCOLOR "#cccccc"
@@ -11,6 +10,58 @@
11#define SELBGCOLOR "#0066ff" 10#define SELBGCOLOR "#0066ff"
12#define SELFGCOLOR "#ffffff" 11#define SELFGCOLOR "#ffffff"
13 12
13#if WORK
14
15/* bar position */
16#define BX 0
17#define BY 0
18#define BW 1280
19
20/* master area */
21#define MX 0
22#define MY bh
23#define MW 1280
24#define MH 800 - bh
25
26/* tile area, might be on a different screen */
27#define TX 1280
28#define TY 0
29#define TW 1680
30#define TH 1050
31
32/* monocle area, might be restricted to a specific screen */
33#define MOX MX
34#define MOY MY
35#define MOW MW
36#define MOH MH
37
38#else
39
40/* bar position */
41#define BX sx
42#define BY sy
43#define BW sw
44
45/* master area */
46#define MX sx
47#define MY sy + bh
48#define MW ((int)(((float)sw) * 0.6))
49#define MH sh - bh
50
51/* tile area, might be on a different screen */
52#define TX sx + MW
53#define TY MY
54#define TW sw - MW
55#define TH MH
56
57/* monocle area, might be restricted to a specific screen */
58#define MOX sx
59#define MOY MY
60#define MOW sw
61#define MOH MH
62
63#endif
64
14/* tagging */ 65/* tagging */
15const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; 66const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
16 67
@@ -23,7 +74,6 @@ Rule rules[] = {
23}; 74};
24 75
25/* layout(s) */ 76/* layout(s) */
26#define MWFACT 0.6 /* master width factor [0.1 .. 0.9] */
27#define RESIZEHINTS True /* False - respect size hints in tiled resizals */ 77#define RESIZEHINTS True /* False - respect size hints in tiled resizals */
28#define SNAP 32 /* snap pixel */ 78#define SNAP 32 /* snap pixel */
29 79
@@ -41,15 +91,14 @@ Key keys[] = {
41 { MODKEY, XK_p, spawn, 91 { MODKEY, XK_p, spawn,
42 "exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" }, 92 "exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
43 { MODKEY|ShiftMask, XK_Return, spawn, "exec uxterm" }, 93 { MODKEY|ShiftMask, XK_Return, spawn, "exec uxterm" },
44 { MODKEY, XK_b, togglebar, NULL },
45 { MODKEY, XK_j, focusnext, NULL }, 94 { MODKEY, XK_j, focusnext, NULL },
46 { MODKEY, XK_k, focusprev, NULL }, 95 { MODKEY, XK_k, focusprev, NULL },
47 { MODKEY, XK_h, setmwfact, "-0.05" },
48 { MODKEY, XK_l, setmwfact, "+0.05" },
49 { MODKEY, XK_r, reapply, NULL }, 96 { MODKEY, XK_r, reapply, NULL },
50 { MODKEY, XK_Return, zoom, NULL }, 97 { MODKEY, XK_Return, zoom, NULL },
51 { MODKEY, XK_Tab, viewprevtag, NULL }, 98 { MODKEY, XK_Tab, viewprevtag, NULL },
52 { MODKEY, XK_space, setlayout, NULL }, 99 { MODKEY, XK_m, setlayout, "[M]" },
100 { MODKEY, XK_f, setlayout, "><>" },
101 { MODKEY, XK_t, setlayout, "[]=" },
53 { MODKEY|ShiftMask, XK_space, togglefloating, NULL }, 102 { MODKEY|ShiftMask, XK_space, togglefloating, NULL },
54 { MODKEY|ShiftMask, XK_c, killclient, NULL }, 103 { MODKEY|ShiftMask, XK_c, killclient, NULL },
55 { MODKEY, XK_0, view, NULL }, 104 { MODKEY, XK_0, view, NULL },
diff --git a/config.mk b/config.mk
index f2335ac..96811e0 100644
--- a/config.mk
+++ b/config.mk
@@ -12,12 +12,12 @@ X11LIB = /usr/X11R6/lib
12 12
13# includes and libs 13# includes and libs
14INCS = -I. -I/usr/include -I${X11INC} 14INCS = -I. -I/usr/include -I${X11INC}
15LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXinerama 15LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
16 16
17# flags 17# flags
18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" 18CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
19LDFLAGS = -s ${LIBS} 19LDFLAGS = -s ${LIBS}
20CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" 20CFLAGS = -g -std=c99 -pedantic -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\" -DWORK
21LDFLAGS = -g ${LIBS} 21LDFLAGS = -g ${LIBS}
22 22
23# Solaris 23# Solaris
diff --git a/dwm.1 b/dwm.1
index 586d080..672f0d7 100644
--- a/dwm.1
+++ b/dwm.1
@@ -63,14 +63,14 @@ Zooms/cycles current window to/from master area (tiled layout only).
63.B Mod1\-Tab 63.B Mod1\-Tab
64Toggles to the previously selected tags. 64Toggles to the previously selected tags.
65.TP 65.TP
66.B Mod1\-space 66.B Mod1\-f
67Toggles between layouts. 67Apply floating layout.
68.TP 68.TP
69.B Mod1\-b 69.B Mod1\-m
70Shows/hides the status bar. 70Apply monocle layout.
71.TP 71.TP
72.B Mod1\-h 72.B Mod1\-t
73Decreases the master area width about 5% (tiled layout only). 73Apply tiled layout.
74.TP 74.TP
75.B Mod1\-j 75.B Mod1\-j
76Focus next window. 76Focus next window.
@@ -78,9 +78,6 @@ Focus next window.
78.B Mod1\-k 78.B Mod1\-k
79Focus previous window. 79Focus previous window.
80.TP 80.TP
81.B Mod1\-l
82Increases the master area width about 5% (tiled layout only).
83.TP
84.B Mod1\-r 81.B Mod1\-r
85Re-applies tagging rules to all windows. 82Re-applies tagging rules to all windows.
86.TP 83.TP
diff --git a/dwm.c b/dwm.c
index a1a34e2..a122180 100644
--- a/dwm.c
+++ b/dwm.c
@@ -40,24 +40,6 @@
40#include <X11/Xlib.h> 40#include <X11/Xlib.h>
41#include <X11/Xproto.h> 41#include <X11/Xproto.h>
42#include <X11/Xutil.h> 42#include <X11/Xutil.h>
43/*
44 * TODO: Idea:
45 * I intend to not provide real Xinerama support, but instead having a Column
46 * tilecols[] array which is used by tile(), and a Column maxcols[] arrays which is used by
47 * monocle(). Those arrays should be initialized in config.h. For simplicity
48 * reasons mwfact should be replaced with a more advanced method which
49 * implements the same, but using the boundary between tilecols[0] and
50 * tilecols[1] instead. Besides this, get rid of BARPOS and use instead the
51 * following mechanism:
52 *
53 * #define BX 0
54 * #define BY 0
55 * #define BW sw
56 * bh is calculated automatically and should be used for the
57 */
58//#ifdef XINERAMA
59#include <X11/extensions/Xinerama.h>
60//#endif
61 43
62/* macros */ 44/* macros */
63#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) 45#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
@@ -66,9 +48,7 @@
66#define MAXTAGLEN 16 48#define MAXTAGLEN 16
67#define MOUSEMASK (BUTTONMASK|PointerMotionMask) 49#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
68 50
69
70/* enums */ 51/* enums */
71enum { BarTop, BarBot, BarOff }; /* bar position */
72enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ 52enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
73enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ 53enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
74enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ 54enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */
@@ -79,6 +59,7 @@ typedef struct Client Client;
79struct Client { 59struct Client {
80 char name[256]; 60 char name[256];
81 int x, y, w, h; 61 int x, y, w, h;
62 int rx, ry, rw, rh;
82 int basew, baseh, incw, inch, maxw, maxh, minw, minh; 63 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
83 int minax, maxax, minay, maxay; 64 int minax, maxax, minay, maxay;
84 long flags; 65 long flags;
@@ -93,10 +74,6 @@ struct Client {
93 74
94typedef struct { 75typedef struct {
95 int x, y, w, h; 76 int x, y, w, h;
96} Column;
97
98typedef struct {
99 int x, y, w, h;
100 unsigned long norm[ColLast]; 77 unsigned long norm[ColLast];
101 unsigned long sel[ColLast]; 78 unsigned long sel[ColLast];
102 Drawable drawable; 79 Drawable drawable;
@@ -185,21 +162,18 @@ void run(void);
185void scan(void); 162void scan(void);
186void setclientstate(Client *c, long state); 163void setclientstate(Client *c, long state);
187void setlayout(const char *arg); 164void setlayout(const char *arg);
188void setmwfact(const char *arg);
189void setup(void); 165void setup(void);
190void spawn(const char *arg); 166void spawn(const char *arg);
191void tag(const char *arg); 167void tag(const char *arg);
192unsigned int textnw(const char *text, unsigned int len); 168unsigned int textnw(const char *text, unsigned int len);
193unsigned int textw(const char *text); 169unsigned int textw(const char *text);
194void tile(void); 170void tile(void);
195void togglebar(const char *arg);
196void togglefloating(const char *arg); 171void togglefloating(const char *arg);
197void toggletag(const char *arg); 172void toggletag(const char *arg);
198void toggleview(const char *arg); 173void toggleview(const char *arg);
199void unban(Client *c); 174void unban(Client *c);
200void unmanage(Client *c); 175void unmanage(Client *c);
201void unmapnotify(XEvent *e); 176void unmapnotify(XEvent *e);
202void updatebarpos(void);
203void updatesizehints(Client *c); 177void updatesizehints(Client *c);
204void updatetitle(Client *c); 178void updatetitle(Client *c);
205void updatewmhints(Client *c); 179void updatewmhints(Client *c);
@@ -214,7 +188,7 @@ void selectview(const char *arg);
214/* variables */ 188/* variables */
215char stext[256], buf[256]; 189char stext[256], buf[256];
216double mwfact; 190double mwfact;
217int screen, sx, sy, sw, sh, wax, way, waw, wah, ncols; 191int screen, sx, sy, sw, sh;
218int (*xerrorxlib)(Display *, XErrorEvent *); 192int (*xerrorxlib)(Display *, XErrorEvent *);
219unsigned int bh, bpos; 193unsigned int bh, bpos;
220unsigned int blw = 0; 194unsigned int blw = 0;
@@ -234,7 +208,6 @@ void (*handler[LASTEvent]) (XEvent *) = {
234 [UnmapNotify] = unmapnotify 208 [UnmapNotify] = unmapnotify
235}; 209};
236Atom wmatom[WMLast], netatom[NetLast]; 210Atom wmatom[WMLast], netatom[NetLast];
237Bool domwfact = True;
238Bool dozoom = True; 211Bool dozoom = True;
239Bool otherwm, readin; 212Bool otherwm, readin;
240Bool running = True; 213Bool running = True;
@@ -243,7 +216,6 @@ Bool *seltags;
243Client *clients = NULL; 216Client *clients = NULL;
244Client *sel = NULL; 217Client *sel = NULL;
245Client *stack = NULL; 218Client *stack = NULL;
246Column *cols = NULL;
247Cursor cursor[CurLast]; 219Cursor cursor[CurLast];
248Display *dpy; 220Display *dpy;
249DC dc = {0}; 221DC dc = {0};
@@ -350,8 +322,6 @@ buttonpress(XEvent *e) {
350 return; 322 return;
351 } 323 }
352 } 324 }
353 if((ev->x < x + blw) && ev->button == Button1)
354 setlayout(NULL);
355 } 325 }
356 else if((c = getclient(ev->window))) { 326 else if((c = getclient(ev->window))) {
357 focus(c); 327 focus(c);
@@ -437,13 +407,11 @@ configurenotify(XEvent *e) {
437 XConfigureEvent *ev = &e->xconfigure; 407 XConfigureEvent *ev = &e->xconfigure;
438 408
439 if(ev->window == root && (ev->width != sw || ev->height != sh)) { 409 if(ev->window == root && (ev->width != sw || ev->height != sh)) {
440 /* TODO -- use Xinerama dimensions here ? */
441 sw = ev->width; 410 sw = ev->width;
442 sh = ev->height; 411 sh = ev->height;
443 XFreePixmap(dpy, dc.drawable); 412 XFreePixmap(dpy, dc.drawable);
444 dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen)); 413 dc.drawable = XCreatePixmap(dpy, root, BW, bh, DefaultDepth(dpy, screen));
445 XResizeWindow(dpy, barwin, sw, bh); 414 XMoveResizeWindow(dpy, barwin, BX, BY, BW, bh);
446 updatebarpos();
447 arrange(); 415 arrange();
448 } 416 }
449} 417}
@@ -454,7 +422,6 @@ configurerequest(XEvent *e) {
454 XConfigureRequestEvent *ev = &e->xconfigurerequest; 422 XConfigureRequestEvent *ev = &e->xconfigurerequest;
455 XWindowChanges wc; 423 XWindowChanges wc;
456 424
457 /* TODO -- consider Xinerama if necessary when centering */
458 if((c = getclient(ev->window))) { 425 if((c = getclient(ev->window))) {
459 if(ev->value_mask & CWBorderWidth) 426 if(ev->value_mask & CWBorderWidth)
460 c->border = ev->border_width; 427 c->border = ev->border_width;
@@ -493,16 +460,6 @@ configurerequest(XEvent *e) {
493 XSync(dpy, False); 460 XSync(dpy, False);
494} 461}
495 462
496Bool
497conflicts(Client *c, unsigned int tidx) {
498 unsigned int i;
499
500 for(i = 0; i < LENGTH(tags); i++)
501 if(c->tags[i])
502 return True; /* conflict */
503 return False;
504}
505
506void 463void
507destroynotify(XEvent *e) { 464destroynotify(XEvent *e) {
508 Client *c; 465 Client *c;
@@ -554,10 +511,10 @@ drawbar(void) {
554 drawtext(lt->symbol, dc.norm, False); 511 drawtext(lt->symbol, dc.norm, False);
555 x = dc.x + dc.w; 512 x = dc.x + dc.w;
556 dc.w = textw(stext); 513 dc.w = textw(stext);
557 dc.x = sw - dc.w; 514 dc.x = BW - dc.w;
558 if(dc.x < x) { 515 if(dc.x < x) {
559 dc.x = x; 516 dc.x = x;
560 dc.w = sw - x; 517 dc.w = BW - x;
561 } 518 }
562 drawtext(stext, dc.norm, False); 519 drawtext(stext, dc.norm, False);
563 if((dc.w = dc.x - x) > bh) { 520 if((dc.w = dc.x - x) > bh) {
@@ -569,7 +526,7 @@ drawbar(void) {
569 else 526 else
570 drawtext(NULL, dc.norm, False); 527 drawtext(NULL, dc.norm, False);
571 } 528 }
572 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0); 529 XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, BW, bh, 0, 0);
573 XSync(dpy, False); 530 XSync(dpy, False);
574} 531}
575 532
@@ -677,7 +634,7 @@ void
677floating(void) { /* default floating layout */ 634floating(void) { /* default floating layout */
678 Client *c; 635 Client *c;
679 636
680 domwfact = dozoom = False; 637 dozoom = False;
681 for(c = clients; c; c = c->next) 638 for(c = clients; c; c = c->next)
682 if(isvisible(c)) 639 if(isvisible(c))
683 resize(c, c->x, c->y, c->w, c->h, True); 640 resize(c, c->x, c->y, c->w, c->h, True);
@@ -690,11 +647,22 @@ focus(Client *c) {
690 if(sel && sel != c) { 647 if(sel && sel != c) {
691 grabbuttons(sel, False); 648 grabbuttons(sel, False);
692 XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); 649 XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
650 if(lt->arrange == monocle)
651 resize(sel, sel->rx, sel->ry, sel->rw, sel->rh, True);
693 } 652 }
694 if(c) { 653 if(c) {
695 detachstack(c); 654 detachstack(c);
696 attachstack(c); 655 attachstack(c);
697 grabbuttons(c, True); 656 grabbuttons(c, True);
657 if(lt->arrange == monocle) {
658 if(sel != c) {
659 c->rx = c->x;
660 c->ry = c->y;
661 c->rw = c->w;
662 c->rh = c->h;
663 }
664 resize(c, MOX, MOY, MOW, MOH, RESIZEHINTS);
665 }
698 } 666 }
699 sel = c; 667 sel = c;
700 if(c) { 668 if(c) {
@@ -1016,10 +984,10 @@ manage(Window w, XWindowAttributes *wa) {
1016 c->tags = emallocz(TAGSZ); 984 c->tags = emallocz(TAGSZ);
1017 c->win = w; 985 c->win = w;
1018 986
1019 c->x = wa->x + sx; 987 c->x = c->rx = wa->x + sx;
1020 c->y = wa->y + sy; 988 c->y = c->ry = wa->y + sy;
1021 c->w = wa->width; 989 c->w = c->rw = wa->width;
1022 c->h = wa->height; 990 c->h = c->rh = wa->height;
1023 c->oldborder = wa->border_width; 991 c->oldborder = wa->border_width;
1024 992
1025 if(c->w == sw && c->h == sh) { 993 if(c->w == sw && c->h == sh) {
@@ -1028,14 +996,14 @@ manage(Window w, XWindowAttributes *wa) {
1028 c->border = wa->border_width; 996 c->border = wa->border_width;
1029 } 997 }
1030 else { 998 else {
1031 if(c->x + c->w + 2 * c->border > wax + waw) 999 if(c->x + c->w + 2 * c->border > sx + sw)
1032 c->x = wax + waw - c->w - 2 * c->border; 1000 c->x = sx + sw - c->w - 2 * c->border;
1033 if(c->y + c->h + 2 * c->border > way + wah) 1001 if(c->y + c->h + 2 * c->border > sy + sh)
1034 c->y = way + wah - c->h - 2 * c->border; 1002 c->y = sy + sh - c->h - 2 * c->border;
1035 if(c->x < wax) 1003 if(c->x < sx)
1036 c->x = wax; 1004 c->x = sx;
1037 if(c->y < way) 1005 if(c->y < sy)
1038 c->y = way; 1006 c->y = sy;
1039 c->border = BORDERPX; 1007 c->border = BORDERPX;
1040 } 1008 }
1041 wc.border_width = c->border; 1009 wc.border_width = c->border;
@@ -1087,11 +1055,7 @@ maprequest(XEvent *e) {
1087 1055
1088void 1056void
1089monocle(void) { 1057monocle(void) {
1090 Client *c; 1058 dozoom = False;
1091
1092 domwfact = dozoom = False;
1093 for(c = nexttiled(clients); c; c = nexttiled(c->next))
1094 resize(c, wax, way, waw - 2 * c->border, wah - 2 * c->border, RESIZEHINTS);
1095} 1059}
1096 1060
1097void 1061void
@@ -1122,14 +1086,14 @@ movemouse(Client *c) {
1122 XSync(dpy, False); 1086 XSync(dpy, False);
1123 nx = ocx + (ev.xmotion.x - x1); 1087 nx = ocx + (ev.xmotion.x - x1);
1124 ny = ocy + (ev.xmotion.y - y1); 1088 ny = ocy + (ev.xmotion.y - y1);
1125 if(abs(wax - nx) < SNAP) 1089 if(abs(sx - nx) < SNAP)
1126 nx = wax; 1090 nx = sx;
1127 else if(abs((wax + waw) - (nx + c->w + 2 * c->border)) < SNAP) 1091 else if(abs((sx + sw) - (nx + c->w + 2 * c->border)) < SNAP)
1128 nx = wax + waw - c->w - 2 * c->border; 1092 nx = sx + sw - c->w - 2 * c->border;
1129 if(abs(way - ny) < SNAP) 1093 if(abs(sy - ny) < SNAP)
1130 ny = way; 1094 ny = sy;
1131 else if(abs((way + wah) - (ny + c->h + 2 * c->border)) < SNAP) 1095 else if(abs((sy + sh) - (ny + c->h + 2 * c->border)) < SNAP)
1132 ny = way + wah - c->h - 2 * c->border; 1096 ny = sy + sh - c->h - 2 * c->border;
1133 if(!c->isfloating && (lt->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) 1097 if(!c->isfloating && (lt->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP))
1134 togglefloating(NULL); 1098 togglefloating(NULL);
1135 if((lt->arrange == floating) || c->isfloating) 1099 if((lt->arrange == floating) || c->isfloating)
@@ -1428,19 +1392,14 @@ void
1428setlayout(const char *arg) { 1392setlayout(const char *arg) {
1429 unsigned int i; 1393 unsigned int i;
1430 1394
1431 if(!arg) { 1395 if(!arg)
1432 lt++; 1396 return;
1433 if(lt == &layouts[LENGTH(layouts)]) 1397 for(i = 0; i < LENGTH(layouts); i++)
1434 lt = &layouts[0]; 1398 if(!strcmp(arg, layouts[i].symbol))
1435 } 1399 break;
1436 else { 1400 if(i == LENGTH(layouts))
1437 for(i = 0; i < LENGTH(layouts); i++) 1401 return;
1438 if(!strcmp(arg, layouts[i].symbol)) 1402 lt = &layouts[i];
1439 break;
1440 if(i == LENGTH(layouts))
1441 return;
1442 lt = &layouts[i];
1443 }
1444 if(sel) 1403 if(sel)
1445 arrange(); 1404 arrange();
1446 else 1405 else
@@ -1448,35 +1407,9 @@ setlayout(const char *arg) {
1448} 1407}
1449 1408
1450void 1409void
1451setmwfact(const char *arg) {
1452 double delta;
1453
1454 if(!domwfact)
1455 return;
1456 /* arg handling, manipulate mwfact */
1457 if(arg == NULL)
1458 mwfact = MWFACT;
1459 else if(sscanf(arg, "%lf", &delta) == 1) {
1460 if(arg[0] == '+' || arg[0] == '-')
1461 mwfact += delta;
1462 else
1463 mwfact = delta;
1464 if(mwfact < 0.1)
1465 mwfact = 0.1;
1466 else if(mwfact > 0.9)
1467 mwfact = 0.9;
1468 }
1469 arrange();
1470}
1471
1472void
1473setup(void) { 1410setup(void) {
1474 int screens = 1;
1475 unsigned int i; 1411 unsigned int i;
1476 XSetWindowAttributes wa; 1412 XSetWindowAttributes wa;
1477//#ifdef XINERAMA
1478 XineramaScreenInfo *info;
1479//#endif
1480 1413
1481 /* init screen */ 1414 /* init screen */
1482 screen = DefaultScreen(dpy); 1415 screen = DefaultScreen(dpy);
@@ -1485,14 +1418,6 @@ setup(void) {
1485 sy = 0; 1418 sy = 0;
1486 sw = DisplayWidth(dpy, screen); 1419 sw = DisplayWidth(dpy, screen);
1487 sh = DisplayHeight(dpy, screen); 1420 sh = DisplayHeight(dpy, screen);
1488 if(XineramaIsActive(dpy)) {
1489 if((info = XineramaQueryScreens(dpy, &screens))) {
1490 sx = info[0].x_org;
1491 sy = info[0].y_org;
1492 sw = info[0].width;
1493 sh = info[0].height;
1494 }
1495 }
1496 1421
1497 /* init atoms */ 1422 /* init atoms */
1498 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False); 1423 wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
@@ -1507,36 +1432,6 @@ setup(void) {
1507 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); 1432 cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
1508 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur); 1433 cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
1509 1434
1510 ncols = 2;
1511#if 0
1512 if(XineramaIsActive(dpy)) {
1513 if((info = XineramaQueryScreens(dpy, &screens))) {
1514 if(screens >= 1) {
1515 sx = info[0].x_org;
1516 sy = info[0].y_org;
1517 sw = info[0].width;
1518 sh = info[0].height;
1519 }
1520 else {
1521 ncols = screens;
1522 cols = emallocz(ncols * sizeof(Column));
1523 for(i = 0; i < ncols; i++) {
1524 cols[i].x = info[i].x_org;
1525 cols[i].y = info[i].y_org;
1526 cols[i].w = info[i].width;
1527 cols[i].h = info[i].height;
1528 }
1529 }
1530 XFree(info);
1531 }
1532 }
1533 else
1534 {
1535 cols = emallocz(ncols * sizeof(Column));
1536 cols[0].x = sx;
1537 cols[0].y = sy;
1538 }
1539#endif
1540 /* init appearance */ 1435 /* init appearance */
1541 dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR); 1436 dc.norm[ColBorder] = getcolor(NORMBORDERCOLOR);
1542 dc.norm[ColBG] = getcolor(NORMBGCOLOR); 1437 dc.norm[ColBG] = getcolor(NORMBGCOLOR);
@@ -1558,10 +1453,8 @@ setup(void) {
1558 seltags[0] = prevtags[0] = True; 1453 seltags[0] = prevtags[0] = True;
1559 1454
1560 /* init layouts */ 1455 /* init layouts */
1561 mwfact = MWFACT;
1562 lt = &layouts[0]; 1456 lt = &layouts[0];
1563 1457
1564 /* TODO: Xinerama hints ? */
1565 /* init bar */ 1458 /* init bar */
1566 for(blw = i = 0; i < LENGTH(layouts); i++) { 1459 for(blw = i = 0; i < LENGTH(layouts); i++) {
1567 i = textw(layouts[i].symbol); 1460 i = textw(layouts[i].symbol);
@@ -1569,16 +1462,14 @@ setup(void) {
1569 blw = i; 1462 blw = i;
1570 } 1463 }
1571 1464
1572 bpos = BARPOS;
1573 wa.override_redirect = 1; 1465 wa.override_redirect = 1;
1574 wa.background_pixmap = ParentRelative; 1466 wa.background_pixmap = ParentRelative;
1575 wa.event_mask = ButtonPressMask|ExposureMask; 1467 wa.event_mask = ButtonPressMask|ExposureMask;
1576 1468
1577 barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0, DefaultDepth(dpy, screen), 1469 barwin = XCreateWindow(dpy, root, BX, BY, BW, bh, 0, DefaultDepth(dpy, screen),
1578 CopyFromParent, DefaultVisual(dpy, screen), 1470 CopyFromParent, DefaultVisual(dpy, screen),
1579 CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); 1471 CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
1580 XDefineCursor(dpy, barwin, cursor[CurNormal]); 1472 XDefineCursor(dpy, barwin, cursor[CurNormal]);
1581 updatebarpos();
1582 XMapRaised(dpy, barwin); 1473 XMapRaised(dpy, barwin);
1583 strcpy(stext, "dwm-"VERSION); 1474 strcpy(stext, "dwm-"VERSION);
1584 drawbar(); 1475 drawbar();
@@ -1655,32 +1546,32 @@ tile(void) {
1655 unsigned int i, n, nx, ny, nw, nh, mw, th; 1546 unsigned int i, n, nx, ny, nw, nh, mw, th;
1656 Client *c, *mc; 1547 Client *c, *mc;
1657 1548
1658 domwfact = dozoom = True; 1549 dozoom = True;
1659 nx = wax; 1550 nx = MX;
1660 ny = way; 1551 ny = MY;
1661 nw = 0; 1552 nw = 0;
1662 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next)) 1553 for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
1663 n++; 1554 n++;
1664 1555
1665 /* window geoms */ 1556 /* window geoms */
1666 mw = (n == 1) ? waw : mwfact * waw; 1557 mw = (n == 1) ? MOW : MW;
1667 th = (n > 1) ? wah / (n - 1) : 0; 1558 th = (n > 1) ? TH / (n - 1) : 0;
1668 if(n > 1 && th < bh) 1559 if(n > 1 && th < bh)
1669 th = wah; 1560 th = TH;
1670 1561
1671 for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next)) { 1562 for(i = 0, c = mc = nexttiled(clients); c; c = nexttiled(c->next)) {
1672 if(i == 0) { /* master */ 1563 if(i == 0) { /* master */
1673 nw = mw - 2 * c->border; 1564 nw = mw - 2 * c->border;
1674 nh = wah - 2 * c->border; 1565 nh = MH - 2 * c->border;
1675 } 1566 }
1676 else { /* tile window */ 1567 else { /* tile window */
1677 if(i == 1) { 1568 if(i == 1) {
1678 ny = way; 1569 ny = TY;
1679 nx += mc->w + 2 * mc->border; 1570 nx = TX;
1680 nw = waw - mw - 2 * c->border; 1571 nw = TW - 2 * c->border;
1681 } 1572 }
1682 if(i + 1 == n) /* remainder */ 1573 if(i + 1 == n) /* remainder */
1683 nh = (way + wah) - ny - 2 * c->border; 1574 nh = (TY + TH) - ny - 2 * c->border;
1684 else 1575 else
1685 nh = th - 2 * c->border; 1576 nh = th - 2 * c->border;
1686 } 1577 }
@@ -1688,23 +1579,13 @@ tile(void) {
1688 if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw))) 1579 if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
1689 /* client doesn't accept size constraints */ 1580 /* client doesn't accept size constraints */
1690 resize(c, nx, ny, nw, nh, False); 1581 resize(c, nx, ny, nw, nh, False);
1691 if(n > 1 && th != wah) 1582 if(n > 1 && th != TH)
1692 ny = c->y + c->h + 2 * c->border; 1583 ny = c->y + c->h + 2 * c->border;
1693 i++; 1584 i++;
1694 } 1585 }
1695} 1586}
1696 1587
1697void 1588void
1698togglebar(const char *arg) {
1699 if(bpos == BarOff)
1700 bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
1701 else
1702 bpos = BarOff;
1703 updatebarpos();
1704 arrange();
1705}
1706
1707void
1708togglefloating(const char *arg) { 1589togglefloating(const char *arg) {
1709 if(!sel) 1590 if(!sel)
1710 return; 1591 return;
@@ -1721,8 +1602,6 @@ toggletag(const char *arg) {
1721 if(!sel) 1602 if(!sel)
1722 return; 1603 return;
1723 i = idxoftag(arg); 1604 i = idxoftag(arg);
1724 if(conflicts(sel, i))
1725 return;
1726 sel->tags[i] = !sel->tags[i]; 1605 sel->tags[i] = !sel->tags[i];
1727 for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++); 1606 for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++);
1728 if(j == LENGTH(tags)) 1607 if(j == LENGTH(tags))
@@ -1783,32 +1662,6 @@ unmapnotify(XEvent *e) {
1783} 1662}
1784 1663
1785void 1664void
1786updatebarpos(void) {
1787 XEvent ev;
1788
1789 wax = sx;
1790 way = sy;
1791 wah = sh;
1792 waw = sw;
1793 switch(bpos) {
1794 default:
1795 wah -= bh;
1796 way += bh;
1797 XMoveWindow(dpy, barwin, sx, sy);
1798 break;
1799 case BarBot:
1800 wah -= bh;
1801 XMoveWindow(dpy, barwin, sx, sy + wah);
1802 break;
1803 case BarOff:
1804 XMoveWindow(dpy, barwin, sx, sy - bh);
1805 break;
1806 }
1807 XSync(dpy, False);
1808 while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
1809}
1810
1811void
1812updatesizehints(Client *c) { 1665updatesizehints(Client *c) {
1813 long msize; 1666 long msize;
1814 XSizeHints size; 1667 XSizeHints size;