From ae1d865ac0cfdace4f5c6e97d8cc3cb88dfbc788 Mon Sep 17 00:00:00 2001 From: "arg@suckless.org" Date: Sun, 15 Jun 2008 23:27:08 +0200 Subject: [PATCH 01/16] s/tags ref/tags mask/ --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 95bb84c..075c8d5 100644 --- a/config.def.h +++ b/config.def.h @@ -21,7 +21,7 @@ static uint xidx = 0; /* Xinerama screen index to use static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static Rule rules[] = { - /* class instance title tags ref isfloating */ + /* class instance title tags mask isfloating */ { "Gimp", NULL, NULL, 0, True }, { "Firefox", NULL, NULL, 1 << 8, True }, }; -- 2.20.1 From 5a92420fce8d70a329a8294c1c77bb8c3c7eaad4 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Tue, 17 Jun 2008 09:57:13 +0100 Subject: [PATCH 02/16] restored y-coordinate fixing of client windows --- dwm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 64bafb7..f4b0540 100644 --- a/dwm.c +++ b/dwm.c @@ -913,7 +913,8 @@ manage(Window w, XWindowAttributes *wa) { if(c->y + c->h + 2 * c->bw > sy + sh) c->y = sy + sh - c->h - 2 * c->bw; c->x = MAX(c->x, sx); - c->y = MAX(c->y, by == 0 ? bh : sy); + /* only fix client y-offset, if the client center might cover the bar */ + c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) && (c->x + (c->w / 2) < wx + ww)) ? bh : sy); c->bw = borderpx; } -- 2.20.1 From f25cc5678fcc405a55df7f49e7b3189241933a97 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Tue, 17 Jun 2008 11:19:17 +0100 Subject: [PATCH 03/16] tiled layout resizehints should be respected by default --- config.def.h | 4 ++-- dwm.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.def.h b/config.def.h index 95bb84c..9bec26b 100644 --- a/config.def.h +++ b/config.def.h @@ -27,8 +27,8 @@ static Rule rules[] = { }; /* layout(s) */ -static float mfact = 0.55; -static Bool resizehints = False; /* False means respect size hints in tiled resizals */ +static float mfact = 0.55; +static Bool resizehints = True; /* False means respect size hints in tiled resizals */ static Layout layouts[] = { /* symbol arrange function */ diff --git a/dwm.c b/dwm.c index f4b0540..8ae4c0e 100644 --- a/dwm.c +++ b/dwm.c @@ -1094,11 +1094,11 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { w = MAX(w, c->minw); h = MAX(h, c->minh); - - if (c->maxw) + + if(c->maxw) w = MIN(w, c->maxw); - if (c->maxh) + if(c->maxh) h = MIN(h, c->maxh); } if(w <= 0 || h <= 0) -- 2.20.1 From cf98ea2a9ce0b8ccbb3bbb510421c48279a1b280 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Wed, 18 Jun 2008 18:22:54 +0100 Subject: [PATCH 04/16] Added tag 5.0 for changeset 06eb9644e2da --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index d6a90f0..bad502d 100644 --- a/.hgtags +++ b/.hgtags @@ -53,3 +53,4 @@ bcd7e18e196a00cc2e97ff3a4a58f3cdaba13856 4.6 d6d3085307d8d98b8b012b669e858fd787befeb1 4.7 607015ddb091d49cbd3457af41713691aa69f4d6 4.8 22c669b2dd3673785c3476b9976da21e8783f745 4.9 +06eb9644e2dad7667d97495eb7d7bc62aa0429e8 5.0 -- 2.20.1 From 79ecbeca7e4ca6d614bf233e7bc95d273df6e3b4 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Thu, 19 Jun 2008 09:11:11 +0100 Subject: [PATCH 05/16] non-zero --- config.mk | 2 +- dwm.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/config.mk b/config.mk index 6377fc0..bd98b47 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = 5.0 +VERSION = 5.0.1 # Customize below to fit your system diff --git a/dwm.c b/dwm.c index 8ae4c0e..85292a9 100644 --- a/dwm.c +++ b/dwm.c @@ -1496,14 +1496,22 @@ togglemax(const Arg *arg) { void toggletag(const Arg *arg) { - if(sel && (sel->tags ^= (arg->ui & TAGMASK))) + uint mask = sel->tags ^ (arg->ui & TAGMASK); + + if(sel && mask) { + sel->tags = mask; arrange(); + } } void toggleview(const Arg *arg) { - if((tagset[seltags] ^= (arg->ui & TAGMASK))) + uint mask = tagset[seltags] ^ (arg->ui & TAGMASK); + + if(mask) { + tagset[seltags] = mask; arrange(); + } } void -- 2.20.1 From 12ea925076c4f1c013502651b0be90c05e0febac Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Thu, 19 Jun 2008 11:38:53 +0100 Subject: [PATCH 06/16] untested monocle --- config.def.h | 15 ++++++----- config.mk | 2 +- dwm.1 | 11 +++++++- dwm.c | 72 +++++++++++++++++++++++++--------------------------- 4 files changed, 55 insertions(+), 45 deletions(-) diff --git a/config.def.h b/config.def.h index d2c5318..6cf3989 100644 --- a/config.def.h +++ b/config.def.h @@ -32,8 +32,9 @@ static Bool resizehints = True; /* False means respect size hints in tiled resiz static Layout layouts[] = { /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, /* first entry is default */ }; /* key definitions */ @@ -60,11 +61,13 @@ static Key keys[] = { { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY, XK_m, togglemax, {0} }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, - { MODKEY, XK_space, togglelayout, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, @@ -91,8 +94,8 @@ static Key keys[] = { * ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, togglelayout, {0} }, - { ClkLtSymbol, 0, Button3, togglemax, {0} }, + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, { ClkWinTitle, 0, Button2, zoom, {0} }, { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, { ClkClientWin, MODKEY, Button1, movemouse, {0} }, diff --git a/config.mk b/config.mk index bd98b47..254ec53 100644 --- a/config.mk +++ b/config.mk @@ -1,5 +1,5 @@ # dwm version -VERSION = 5.0.1 +VERSION = 5.1 # Customize below to fit your system diff --git a/dwm.1 b/dwm.1 index 7f87eb9..0e10778 100644 --- a/dwm.1 +++ b/dwm.1 @@ -60,8 +60,17 @@ Start .B Mod1\-b Toggles bar on and off. .TP +.B Mod1\-t +Sets tiled layout. +.TP +.B Mod1\-f +Sets floating layout. +.TP +.B Mod1\-f +Sets monocle layout. +.TP .B Mod1\-space -Toggles between layouts. +Toggles between current and previous layout. .TP .B Mod1\-j Focus next window. diff --git a/dwm.c b/dwm.c index 85292a9..f1d3641 100644 --- a/dwm.c +++ b/dwm.c @@ -89,7 +89,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; uint tags; - Bool isbanned, isfixed, isfloating, ismoved, isurgent; + Bool isbanned, isfixed, isfloating, isurgent; Client *next; Client *snext; Window win; @@ -168,6 +168,7 @@ static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); static void maprequest(XEvent *e); +static void monocle(void); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); static void propertynotify(XEvent *e); @@ -178,6 +179,7 @@ static void restack(void); static void run(void); static void scan(void); static void setclientstate(Client *c, long state); +static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void spawn(const Arg *arg); @@ -186,8 +188,6 @@ static int textnw(const char *text, uint len); static void tile(void); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); -static void togglelayout(const Arg *arg); -static void togglemax(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unmanage(Client *c); @@ -225,7 +225,6 @@ static void (*handler[LASTEvent]) (XEvent *) = { [UnmapNotify] = unmapnotify }; static Atom wmatom[WMLast], netatom[NetLast]; -static Bool ismax = False; static Bool otherwm, readin; static Bool running = True; static uint tagset[] = {1, 1}; /* after start, first tag is selected */ @@ -275,21 +274,17 @@ arrange(void) { for(c = clients; c; c = c->next) if(c->tags & tagset[seltags]) { /* is visible */ - if(ismax && !c->isfixed) { - XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw); - c->ismoved = True; - } - else if(!lt->arrange || c->isfloating) + if(!lt->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, True); c->isbanned = False; } else if(!c->isbanned) { XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); - c->isbanned = c->ismoved = True; + c->isbanned = True; } focus(NULL); - if(lt->arrange && !ismax) + if(lt->arrange) lt->arrange(); restack(); } @@ -418,8 +413,6 @@ configurerequest(XEvent *e) { if((c = getclient(ev->window))) { if(ev->value_mask & CWBorderWidth) c->bw = ev->border_width; - if(ismax && !c->isbanned && !c->isfixed) - XMoveResizeWindow(dpy, c->win, wx, wy, ww - 2 * c->bw, wh + 2 * c->bw); else if(c->isfloating || !lt->arrange) { if(ev->value_mask & CWX) c->x = sx + ev->x; @@ -507,7 +500,7 @@ drawbar(void) { } if(blw > 0) { dc.w = blw; - drawtext(lt->symbol, dc.norm, ismax); + drawtext(lt->symbol, dc.norm, False); x = dc.x + dc.w; } else @@ -966,6 +959,14 @@ maprequest(XEvent *e) { manage(ev->window, &wa); } +void +monocle(void) { + Client *c; + + for(c = nexttiled(clients); c; c = nexttiled(c->next)) + resize(c, wx, wy, ww, wh, resizehints); +} + void movemouse(const Arg *arg) { int x1, y1, ocx, ocy, di, nx, ny; @@ -1115,8 +1116,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { h = bh; if(w < bh) w = bh; - if(c->x != x || c->y != y || c->w != w || c->h != h || c->ismoved) { - c->ismoved = False; + if(c->x != x || c->y != y || c->w != w || c->h != h) { c->x = wc.x = x; c->y = wc.y = y; c->w = wc.width = w; @@ -1186,9 +1186,9 @@ restack(void) { drawbar(); if(!sel) return; - if(ismax || sel->isfloating || !lt->arrange) + if(sel->isfloating || !lt->arrange) XRaiseWindow(dpy, sel->win); - if(!ismax && lt->arrange) { + if(lt->arrange) { wc.stack_mode = Below; wc.sibling = barwin; for(c = stack; c; c = c->snext) @@ -1296,6 +1296,22 @@ setclientstate(Client *c, long state) { PropModeReplace, (unsigned char *)data, 2); } +void +setlayout(const Arg *arg) { + static Layout *prevlt = &layouts[1 % LENGTH(layouts)]; + + if(!arg || !arg->v || arg->v == lt) + lt = prevlt; + else { + prevlt = lt; + lt = (Layout *)arg->v; + } + if(sel) + arrange(); + else + drawbar(); +} + /* arg > 1.0 will set mfact absolutly */ void setmfact(const Arg *arg) { @@ -1476,24 +1492,6 @@ togglefloating(const Arg *arg) { arrange(); } -void -togglelayout(const Arg *arg) { - if(arg && arg->v) - lt = (Layout *)arg->v; - else if(++lt == &layouts[LENGTH(layouts)]) - lt = &layouts[0]; - if(sel) - arrange(); - else - drawbar(); -} - -void -togglemax(const Arg *arg) { - ismax = !ismax; - arrange(); -} - void toggletag(const Arg *arg) { uint mask = sel->tags ^ (arg->ui & TAGMASK); @@ -1693,7 +1691,7 @@ void zoom(const Arg *arg) { Client *c = sel; - if(ismax || !lt->arrange || (sel && sel->isfloating)) + if(!lt->arrange || lt->arrange == monocle || (sel && sel->isfloating)) return; if(c == nexttiled(clients)) if(!c || !(c = nexttiled(c->next))) -- 2.20.1 From 31da0b7525f4a6f98fb5b3258da86d04387a0382 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Thu, 19 Jun 2008 12:28:56 +0100 Subject: [PATCH 07/16] applied Gottox patch --- dwm.c | 46 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/dwm.c b/dwm.c index f1d3641..0615978 100644 --- a/dwm.c +++ b/dwm.c @@ -207,7 +207,7 @@ static void zoom(const Arg *arg); static char stext[256]; static int screen, sx, sy, sw, sh; static int by, bh, blw, wx, wy, ww, wh; -static uint seltags = 0; +static uint seltags = 0, sellt = 0; static int (*xerrorxlib)(Display *, XErrorEvent *); static uint numlockmask = 0; static void (*handler[LASTEvent]) (XEvent *) = { @@ -234,7 +234,7 @@ static Client *stack = NULL; static Cursor cursor[CurLast]; static Display *dpy; static DC dc = {0}; -static Layout *lt = NULL; +static Layout *lt[] = { NULL, NULL }; static Window root, barwin; /* configuration, allows nested code to access above variables */ #include "config.h" @@ -274,7 +274,7 @@ arrange(void) { for(c = clients; c; c = c->next) if(c->tags & tagset[seltags]) { /* is visible */ - if(!lt->arrange || c->isfloating) + if(!lt[sellt]->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, True); c->isbanned = False; } @@ -284,8 +284,8 @@ arrange(void) { } focus(NULL); - if(lt->arrange) - lt->arrange(); + if(lt[sellt]->arrange) + lt[sellt]->arrange(); restack(); } @@ -355,7 +355,7 @@ cleanup(void) { close(STDIN_FILENO); view(&a); - lt = &foo; + lt[sellt] = &foo; while(stack) unmanage(stack); if(dc.font.set) @@ -413,7 +413,7 @@ configurerequest(XEvent *e) { if((c = getclient(ev->window))) { if(ev->value_mask & CWBorderWidth) c->bw = ev->border_width; - else if(c->isfloating || !lt->arrange) { + else if(c->isfloating || !lt[sellt]->arrange) { if(ev->value_mask & CWX) c->x = sx + ev->x; if(ev->value_mask & CWY) @@ -500,7 +500,7 @@ drawbar(void) { } if(blw > 0) { dc.w = blw; - drawtext(lt->symbol, dc.norm, False); + drawtext(lt[sellt]->symbol, dc.norm, False); x = dc.x + dc.w; } else @@ -1009,10 +1009,10 @@ movemouse(const Arg *arg) { ny = wy; else if(abs((wy + wh) - (ny + c->h + 2 * c->bw)) < snap) ny = wy + wh - c->h - 2 * c->bw; - if(!c->isfloating && lt->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) + if(!c->isfloating && lt[sellt]->arrange && (abs(nx - c->x) > snap || abs(ny - c->y) > snap)) togglefloating(NULL); } - if(!lt->arrange || c->isfloating) + if(!lt[sellt]->arrange || c->isfloating) resize(c, nx, ny, c->w, c->h, False); break; } @@ -1166,11 +1166,11 @@ resizemouse(const Arg *arg) { if(snap && nw >= wx && nw <= wx + ww && nh >= wy && nh <= wy + wh) { - if(!c->isfloating && lt->arrange + if(!c->isfloating && lt[sellt]->arrange && (abs(nw - c->w) > snap || abs(nh - c->h) > snap)) togglefloating(NULL); } - if(!lt->arrange || c->isfloating) + if(!lt[sellt]->arrange || c->isfloating) resize(c, c->x, c->y, nw, nh, True); break; } @@ -1186,9 +1186,9 @@ restack(void) { drawbar(); if(!sel) return; - if(sel->isfloating || !lt->arrange) + if(sel->isfloating || !lt[sellt]->arrange) XRaiseWindow(dpy, sel->win); - if(lt->arrange) { + if(lt[sellt]->arrange) { wc.stack_mode = Below; wc.sibling = barwin; for(c = stack; c; c = c->snext) @@ -1298,14 +1298,9 @@ setclientstate(Client *c, long state) { void setlayout(const Arg *arg) { - static Layout *prevlt = &layouts[1 % LENGTH(layouts)]; - - if(!arg || !arg->v || arg->v == lt) - lt = prevlt; - else { - prevlt = lt; - lt = (Layout *)arg->v; - } + sellt ^= 1; + if(arg && arg->v && arg->v != lt[sellt]) + lt[sellt] = (Layout *)arg->v; if(sel) arrange(); else @@ -1317,7 +1312,7 @@ void setmfact(const Arg *arg) { float f; - if(!arg || !lt->arrange) + if(!arg || !lt[sellt]->arrange) return; f = arg->f < 1.0 ? arg->f + mfact : arg->f - 1.0; if(f < 0.1 || f > 0.9) @@ -1341,7 +1336,8 @@ setup(void) { sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); bh = dc.h = dc.font.height + 2; - lt = layouts; + lt[0] = &layouts[0]; + lt[1] = &layouts[1 % LENGTH(layouts)]; updategeom(); /* init atoms */ @@ -1691,7 +1687,7 @@ void zoom(const Arg *arg) { Client *c = sel; - if(!lt->arrange || lt->arrange == monocle || (sel && sel->isfloating)) + if(!lt[sellt]->arrange || lt[sellt]->arrange == monocle || (sel && sel->isfloating)) return; if(c == nexttiled(clients)) if(!c || !(c = nexttiled(c->next))) -- 2.20.1 From c853d5e9bbc9bec5880aabaf3c30d4ab0a0d981a Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Thu, 19 Jun 2008 14:01:40 +0100 Subject: [PATCH 08/16] resize should apply if !banned --- dwm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/dwm.c b/dwm.c index 0615978..5211ece 100644 --- a/dwm.c +++ b/dwm.c @@ -426,8 +426,7 @@ configurerequest(XEvent *e) { c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */ if((c->y - sy + c->h) > sh && c->isfloating) c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */ - if((ev->value_mask & (CWX|CWY)) - && !(ev->value_mask & (CWWidth|CWHeight))) + if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight))) configure(c); if(!c->isbanned) XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); @@ -1116,7 +1115,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { h = bh; if(w < bh) w = bh; - if(c->x != x || c->y != y || c->w != w || c->h != h) { + if(!c->isbanned || c->x != x || c->y != y || c->w != w || c->h != h) { c->x = wc.x = x; c->y = wc.y = y; c->w = wc.width = w; -- 2.20.1 From 6e0ce46365fb9a19c6b6e70d3039f3cbe53ec1db Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Thu, 19 Jun 2008 14:07:55 +0100 Subject: [PATCH 09/16] use sel instead of seeking the list --- dwm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dwm.c b/dwm.c index 5211ece..a94cacc 100644 --- a/dwm.c +++ b/dwm.c @@ -481,19 +481,17 @@ detachstack(Client *c) { void drawbar(void) { int i, x; - Client *c; dc.x = 0; - for(c = stack; c && c->isbanned; c = c->snext); for(i = 0; i < LENGTH(tags); i++) { dc.w = TEXTW(tags[i]); if(tagset[seltags] & 1 << i) { drawtext(tags[i], dc.sel, isurgent(i)); - drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel); + drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel); } else { drawtext(tags[i], dc.norm, isurgent(i)); - drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm); + drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm); } dc.x += dc.w; } @@ -513,9 +511,9 @@ drawbar(void) { drawtext(stext, dc.norm, False); if((dc.w = dc.x - x) > bh) { dc.x = x; - if(c) { - drawtext(c->name, dc.sel, False); - drawsquare(c->isfixed, c->isfloating, False, dc.sel); + if(sel) { + drawtext(sel->name, dc.sel, False); + drawsquare(sel->isfixed, sel->isfloating, False, dc.sel); } else drawtext(NULL, dc.norm, False); -- 2.20.1 From 2bd46d1ce62e35d2785f43bb9f6f331d3309f66f Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Thu, 19 Jun 2008 14:13:07 +0100 Subject: [PATCH 10/16] fix --- dwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index a94cacc..fcdab10 100644 --- a/dwm.c +++ b/dwm.c @@ -274,9 +274,9 @@ arrange(void) { for(c = clients; c; c = c->next) if(c->tags & tagset[seltags]) { /* is visible */ + c->isbanned = False; if(!lt[sellt]->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, True); - c->isbanned = False; } else if(!c->isbanned) { XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); -- 2.20.1 From c2a916bf3021d9e16419eccbd553d967404ad6e4 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Thu, 19 Jun 2008 14:58:19 +0100 Subject: [PATCH 11/16] made arrange again like it was once --- dwm.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/dwm.c b/dwm.c index fcdab10..3c5e6df 100644 --- a/dwm.c +++ b/dwm.c @@ -53,6 +53,7 @@ #define MOUSEMASK (BUTTONMASK|PointerMotionMask) #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) #define TEXTW(x) (textnw(x, strlen(x)) + dc.font.height) +#define ISVISIBLE(x) (x->tags & tagset[seltags]) /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ @@ -89,7 +90,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh; int bw, oldbw; uint tags; - Bool isbanned, isfixed, isfloating, isurgent; + Bool isfixed, isfloating, isurgent; Client *next; Client *snext; Window win; @@ -273,14 +274,13 @@ arrange(void) { Client *c; for(c = clients; c; c = c->next) - if(c->tags & tagset[seltags]) { /* is visible */ - c->isbanned = False; + if(ISVISIBLE(c)) { + XMoveWindow(dpy, c->win, c->x, c->y); if(!lt[sellt]->arrange || c->isfloating) resize(c, c->x, c->y, c->w, c->h, True); } - else if(!c->isbanned) { + else { XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y); - c->isbanned = True; } focus(NULL); @@ -428,7 +428,7 @@ configurerequest(XEvent *e) { c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */ if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight))) configure(c); - if(!c->isbanned) + if(ISVISIBLE(c)) XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); } else @@ -605,8 +605,8 @@ expose(XEvent *e) { void focus(Client *c) { - if(!c || c->isbanned) - for(c = stack; c && c->isbanned; c = c->snext); + if(!c || !ISVISIBLE(c)) + for(c = stack; c && !ISVISIBLE(c); c = c->snext); if(sel && sel != c) { grabbuttons(sel, False); XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); @@ -639,17 +639,17 @@ focusstack(const Arg *arg) { if(!sel) return; if (arg->i > 0) { - for(c = sel->next; c && c->isbanned; c = c->next); + for(c = sel->next; c && !ISVISIBLE(c); c = c->next); if(!c) - for(c = clients; c && c->isbanned; c = c->next); + for(c = clients; c && !ISVISIBLE(c); c = c->next); } else { for(i = clients; i != sel; i = i->next) - if (!i->isbanned) + if(ISVISIBLE(i)) c = i; if(!c) for(; i; i = i->next) - if (!i->isbanned) + if(ISVISIBLE(i)) c = i; } if(c) { @@ -1018,7 +1018,7 @@ movemouse(const Arg *arg) { Client * nexttiled(Client *c) { - for(; c && (c->isfloating || c->isbanned); c = c->next); + for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->next); return c; } @@ -1113,7 +1113,7 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) { h = bh; if(w < bh) w = bh; - if(!c->isbanned || c->x != x || c->y != y || c->w != w || c->h != h) { + if(c->x != x || c->y != y || c->w != w || c->h != h) { c->x = wc.x = x; c->y = wc.y = y; c->w = wc.width = w; @@ -1189,7 +1189,7 @@ restack(void) { wc.stack_mode = Below; wc.sibling = barwin; for(c = stack; c; c = c->snext) - if(!c->isfloating && !c->isbanned) { + if(!c->isfloating && ISVISIBLE(c)) { XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); wc.sibling = c->win; } -- 2.20.1 From b86c818599f8fecd42bcde564686b2489196d7ab Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Fri, 20 Jun 2008 16:52:07 +0100 Subject: [PATCH 12/16] applied Gottox' ClkTagBar patch --- config.def.h | 19 ++++--------------- dwm.c | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/config.def.h b/config.def.h index 6cf3989..fa2ed99 100644 --- a/config.def.h +++ b/config.def.h @@ -84,12 +84,6 @@ static Key keys[] = { }; /* button definitions */ -#define TAGBUTTONS(TAG) \ - { TAG, 0, Button1, view, {.ui = 1 << TAG} }, \ - { TAG, 0, Button3, toggleview, {.ui = 1 << TAG} }, \ - { TAG, MODKEY, Button1, tag, {.ui = 1 << TAG} }, \ - { TAG, MODKEY, Button3, toggletag, {.ui = 1 << TAG} }, - /* click can be a tag number (starting at 0), * ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { @@ -101,14 +95,9 @@ static Button buttons[] = { { ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - TAGBUTTONS(0) - TAGBUTTONS(1) - TAGBUTTONS(2) - TAGBUTTONS(3) - TAGBUTTONS(4) - TAGBUTTONS(5) - TAGBUTTONS(6) - TAGBUTTONS(7) - TAGBUTTONS(8) + { ClkTagBar, 0, Button1, view, {0} }, \ + { ClkTagBar, 0, Button3, toggleview, {0} }, \ + { ClkTagBar, MODKEY, Button1, tag, {0} }, \ + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; diff --git a/dwm.c b/dwm.c index 3c5e6df..a5a9de2 100644 --- a/dwm.c +++ b/dwm.c @@ -60,7 +60,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */ -enum { ClkLtSymbol = 64, ClkStatusText, ClkWinTitle, +enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ /* typedefs */ @@ -304,17 +304,18 @@ attachstack(Client *c) { void buttonpress(XEvent *e) { uint i, x, click; + Arg arg = {0}; Client *c; XButtonPressedEvent *ev = &e->xbutton; click = ClkRootWin; if(ev->window == barwin) { - i = x = 0; - do + for(i = x = 0; ev->x >= x && ++i < LENGTH(tags); i++) x += TEXTW(tags[i]); - while(ev->x >= x && ++i < LENGTH(tags)); - if(i < LENGTH(tags)) - click = i; + if(i < LENGTH(tags)) { + click = ClkTagBar; + arg.ui = 1 << i; + } else if(ev->x < x + blw) click = ClkLtSymbol; else if(ev->x > wx + ww - TEXTW(stext)) @@ -330,7 +331,7 @@ buttonpress(XEvent *e) { for(i = 0; i < LENGTH(buttons); i++) if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) - buttons[i].func(&buttons[i].arg); + buttons[i].func(click == ClkTagBar ? &arg : &buttons[i].arg); } void @@ -1295,8 +1296,9 @@ setclientstate(Client *c, long state) { void setlayout(const Arg *arg) { - sellt ^= 1; - if(arg && arg->v && arg->v != lt[sellt]) + if(!arg || !arg->v || arg->v != lt[sellt]) + sellt ^= 1; + if(arg && arg->v) lt[sellt] = (Layout *)arg->v; if(sel) arrange(); -- 2.20.1 From deef4c9bfd7d88937822b689946bd65df7fc618d Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Sat, 21 Jun 2008 13:49:43 +0100 Subject: [PATCH 13/16] fixed Gottox' buttonpress/ClkTagBar code --- dwm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dwm.c b/dwm.c index a5a9de2..d4ce1e4 100644 --- a/dwm.c +++ b/dwm.c @@ -310,8 +310,8 @@ buttonpress(XEvent *e) { click = ClkRootWin; if(ev->window == barwin) { - for(i = x = 0; ev->x >= x && ++i < LENGTH(tags); i++) - x += TEXTW(tags[i]); + i = x = 0; + do x += TEXTW(tags[i]); while(ev->x >= x && ++i < LENGTH(tags)); if(i < LENGTH(tags)) { click = ClkTagBar; arg.ui = 1 << i; -- 2.20.1 From 0c38ec7cd64dfc0bebccfcb0da2a2d250bf5f46e Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Sun, 22 Jun 2008 09:29:06 +0100 Subject: [PATCH 14/16] does this fix anything? --- dwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index a5a9de2..fe2dc1f 100644 --- a/dwm.c +++ b/dwm.c @@ -929,7 +929,7 @@ manage(Window w, XWindowAttributes *wa) { XRaiseWindow(dpy, c->win); attach(c); attachstack(c); - XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); /* some windows require this */ + XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ XMapWindow(dpy, c->win); setclientstate(c, NormalState); arrange(); -- 2.20.1 From 7f7c3140a9c0841e34fd8689dc5d46627c949147 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Sun, 22 Jun 2008 09:33:49 +0100 Subject: [PATCH 15/16] fix of monocle --- dwm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index 188e445..b7e937d 100644 --- a/dwm.c +++ b/dwm.c @@ -962,7 +962,7 @@ monocle(void) { Client *c; for(c = nexttiled(clients); c; c = nexttiled(c->next)) - resize(c, wx, wy, ww, wh, resizehints); + resize(c, wx, wy, ww - 2 * c->bw, wh - 2 * c->bw, resizehints); } void -- 2.20.1 From 7b4c512e627952015367993bb553e67e720cd716 Mon Sep 17 00:00:00 2001 From: Anselm R Garbe Date: Mon, 23 Jun 2008 08:59:19 +0100 Subject: [PATCH 16/16] applied James Turner's dwm.1 patch, thanks James! --- dwm.1 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dwm.1 b/dwm.1 index 0e10778..a6416e0 100644 --- a/dwm.1 +++ b/dwm.1 @@ -66,7 +66,7 @@ Sets tiled layout. .B Mod1\-f Sets floating layout. .TP -.B Mod1\-f +.B Mod1\-m Sets monocle layout. .TP .B Mod1\-space @@ -84,9 +84,6 @@ Decrease master area size. .B Mod1\-l Increase master area size. .TP -.B Mod1\-m -Toggle between maximisation meta-layout and active layout. -.TP .B Mod1\-Return Zooms/cycles focused window to/from master area (tiled layouts only). .TP -- 2.20.1