From a41f6e7247e0966eb7cbf64095a2654cc4dd01de Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Sun, 17 May 2020 20:24:42 +0530 Subject: patched dwm --- dwm/config.h | 83 +++++-- dwm/patches/dwm-fullscreen-6.2.diff | 56 +++++ dwm/patches/dwm-hide_vacant_tags-6.2.diff | 55 +++++ dwm/patches/dwm-scratchpad-6.2.diff | 90 +++++++ dwm/patches/dwm-statuscolors-20181008-b69c870.diff | 94 ++++++++ dwm/patches/dwm-vanitygaps-20190508-6.2.diff | 259 +++++++++++++++++++++ 6 files changed, 621 insertions(+), 16 deletions(-) create mode 100644 dwm/patches/dwm-fullscreen-6.2.diff create mode 100644 dwm/patches/dwm-hide_vacant_tags-6.2.diff create mode 100644 dwm/patches/dwm-scratchpad-6.2.diff create mode 100644 dwm/patches/dwm-statuscolors-20181008-b69c870.diff create mode 100644 dwm/patches/dwm-vanitygaps-20190508-6.2.diff (limited to 'dwm') diff --git a/dwm/config.h b/dwm/config.h index ccaface..495e8fe 100644 --- a/dwm/config.h +++ b/dwm/config.h @@ -1,25 +1,36 @@ /* See LICENSE file for copyright and license details. */ - +#include /* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int borderpx = 0; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int gappih = 8; /* horiz inner gap between windows */ +static const unsigned int gappiv = 8; /* vert inner gap between windows */ +static const unsigned int gappoh = 8; /* horiz outer gap between windows and screen edge */ +static const unsigned int gappov = 8; /* vert outer gap between windows and screen edge */ +static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "Hermit:pixelsize=12:antialias:true:autohint=true" }; -static const char dmenufont[] = "Hermit:pixelsize=12:antialias:true:autohint=true"; -static const char col_gray1[] = "#222222"; +static const char *fonts[] = { "Hermit:pixelsize=11:antialias=true:autohint=true" }; +static const char col_gray1[] = "#000000"; static const char col_gray2[] = "#444444"; static const char col_gray3[] = "#bbbbbb"; -static const char col_gray4[] = "#eeeeee"; -static const char col_cyan[] = "#005577"; +static const char col_gray4[] = "#000000"; +static const char col_cyan[] = "#84a0c6"; +static const char col_black[] = "#000000"; +static const char col_red[] = "#ff0000"; +static const char col_yellow[] = "#ffff00"; +static const char col_white[] = "#ffffff"; + static const char *colors[][3] = { - /* fg bg border */ - [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, - [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, + [SchemeWarn] = { col_black, col_yellow, col_red }, + [SchemeUrgent]= { col_white, col_red, col_red }, }; /* tagging */ -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static const char *tags[] = { "term", "web", "music", "file", "virt", "hack", "7", "8", "9" }; static const Rule rules[] = { /* xprop(1): @@ -28,11 +39,11 @@ static const Rule rules[] = { */ /* class instance title tags mask isfloating monitor */ { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + { "Firefox", NULL, NULL, 2, 0, -1 }, }; /* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */ static const int nmaster = 1; /* number of clients in master area */ static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */ @@ -56,13 +67,36 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ -static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; +static const char *dmenucmd[] = { "menu", NULL }; static const char *termcmd[] = { "st", NULL }; +static const char scratchpadname[] = "scratchpad"; +static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; + +/* volume */ +static const char *upvol[] = { "pulsemixer", "--change-volume", "+5", NULL }; +static const char *downvol[] = { "pulsemixer", "--change-volume", "-5", NULL }; +static const char *mutevol[] = { "pulsemixer", "--toggle-mute", NULL }; +static const char *shut[] = { "shut", NULL }; + +/* brightness */ +static const char *brightup[] = { "doas", "bup", NULL }; +static const char *brightdown[] = { "doas", "bdown", NULL }; + +/* lock */ +static const char *lock[] = { "xset", "s", "activate", NULL }; static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, - { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } }, + { MODKEY, XK_x, spawn, {.v = shut } }, + { 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } }, + { 0, XF86XK_AudioMute, spawn, {.v = mutevol } }, + { 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } }, + { 0, XF86XK_MonBrightnessUp, spawn, {.v = brightup } }, + { 0, XF86XK_MonBrightnessDown, spawn, {.v = brightdown } }, + { MODKEY|ShiftMask, XK_Delete, spawn, {.v = lock } }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, @@ -70,12 +104,29 @@ static Key keys[] = { { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, + { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, + { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, + { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, + { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, + { MODKEY, XK_y, incrihgaps, {.i = +1 } }, + { MODKEY, XK_o, incrihgaps, {.i = -1 } }, + { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, + { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } }, + { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } }, + { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } }, + { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, + { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, { MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, - { MODKEY, XK_w, killclient, {0} }, + { MODKEY, XK_w, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_f, fullscreen, {0} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, diff --git a/dwm/patches/dwm-fullscreen-6.2.diff b/dwm/patches/dwm-fullscreen-6.2.diff new file mode 100644 index 0000000..36e3140 --- /dev/null +++ b/dwm/patches/dwm-fullscreen-6.2.diff @@ -0,0 +1,56 @@ +From 54719285bd1a984e2efce6e8a8eab184fec11abf Mon Sep 17 00:00:00 2001 +From: Sermak +Date: Mon, 8 Jul 2019 01:06:44 +0200 +Subject: [PATCH] Simulate toggleable fullscreen mode + +--- + config.def.h | 1 + + dwm.c | 14 ++++++++++++++ + 2 files changed, 15 insertions(+) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..f774cc5 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -76,6 +76,7 @@ static Key keys[] = { + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, ++ { MODKEY|ShiftMask, XK_f, fullscreen, {0} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, +diff --git a/dwm.c b/dwm.c +index 4465af1..04b1e06 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -199,6 +199,7 @@ static void sendmon(Client *c, Monitor *m); + static void setclientstate(Client *c, long state); + static void setfocus(Client *c); + static void setfullscreen(Client *c, int fullscreen); ++static void fullscreen(const Arg *arg); + static void setlayout(const Arg *arg); + static void setmfact(const Arg *arg); + static void setup(void); +@@ -1497,6 +1498,19 @@ setfullscreen(Client *c, int fullscreen) + } + } + ++Layout *last_layout; ++void ++fullscreen(const Arg *arg) ++{ ++ if (selmon->showbar) { ++ for(last_layout = (Layout *)layouts; last_layout != selmon->lt[selmon->sellt]; last_layout++); ++ setlayout(&((Arg) { .v = &layouts[2] })); ++ } else { ++ setlayout(&((Arg) { .v = last_layout })); ++ } ++ togglebar(arg); ++} ++ + void + setlayout(const Arg *arg) + { +-- +2.22.0 diff --git a/dwm/patches/dwm-hide_vacant_tags-6.2.diff b/dwm/patches/dwm-hide_vacant_tags-6.2.diff new file mode 100644 index 0000000..a981b23 --- /dev/null +++ b/dwm/patches/dwm-hide_vacant_tags-6.2.diff @@ -0,0 +1,55 @@ +diff --git a/dwm.c b/dwm.c +index 4465af1..c4aa3de 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -416,7 +416,7 @@ attachstack(Client *c) + void + buttonpress(XEvent *e) + { +- unsigned int i, x, click; ++ unsigned int i, x, click, occ = 0; + Arg arg = {0}; + Client *c; + Monitor *m; +@@ -431,9 +431,14 @@ buttonpress(XEvent *e) + } + if (ev->window == selmon->barwin) { + i = x = 0; +- do ++ for (c = m->clients; c; c = c->next) ++ occ |= c->tags == 255 ? 0 : c->tags; ++ do { ++ /* do not reserve space for vacant tags */ ++ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) ++ continue; + x += TEXTW(tags[i]); +- while (ev->x >= x && ++i < LENGTH(tags)); ++ } while (ev->x >= x && ++i < LENGTH(tags)); + if (i < LENGTH(tags)) { + click = ClkTagBar; + arg.ui = 1 << i; +@@ -709,19 +714,19 @@ drawbar(Monitor *m) + } + + for (c = m->clients; c; c = c->next) { +- occ |= c->tags; ++ occ |= c->tags == 255 ? 0 : c->tags; + if (c->isurgent) + urg |= c->tags; + } + x = 0; + for (i = 0; i < LENGTH(tags); i++) { ++ /* do not draw vacant tags */ ++ if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) ++ continue; ++ + w = TEXTW(tags[i]); + drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); + drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); +- if (occ & 1 << i) +- drw_rect(drw, x + boxs, boxs, boxw, boxw, +- m == selmon && selmon->sel && selmon->sel->tags & 1 << i, +- urg & 1 << i); + x += w; + } + w = blw = TEXTW(m->ltsymbol); diff --git a/dwm/patches/dwm-scratchpad-6.2.diff b/dwm/patches/dwm-scratchpad-6.2.diff new file mode 100644 index 0000000..2062263 --- /dev/null +++ b/dwm/patches/dwm-scratchpad-6.2.diff @@ -0,0 +1,90 @@ +diff -up a/config.def.h b/config.def.h +--- a/config.def.h 2019-06-06 21:23:27.006661784 +0200 ++++ b/config.def.h 2019-06-20 15:05:59.083102462 +0200 +@@ -58,11 +58,14 @@ static const Layout layouts[] = { + static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ + static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; + static const char *termcmd[] = { "st", NULL }; ++static const char scratchpadname[] = "scratchpad"; ++static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; + + static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_p, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, ++ { MODKEY, XK_grave, togglescratch, {.v = scratchpadcmd } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, +diff -up a/dwm.c b/dwm.c +--- a/dwm.c 2019-06-06 21:23:27.023328450 +0200 ++++ b/dwm.c 2019-06-20 15:07:01.089767947 +0200 +@@ -213,6 +213,7 @@ static void tagmon(const Arg *arg); + static void tile(Monitor *); + static void togglebar(const Arg *arg); + static void togglefloating(const Arg *arg); ++static void togglescratch(const Arg *arg); + static void toggletag(const Arg *arg); + static void toggleview(const Arg *arg); + static void unfocus(Client *c, int setfocus); +@@ -273,6 +274,8 @@ static Window root, wmcheckwin; + /* configuration, allows nested code to access above variables */ + #include "config.h" + ++static unsigned int scratchtag = 1 << LENGTH(tags); ++ + /* compile-time check if all tags fit into an unsigned int bit array. */ + struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; + +@@ -1052,6 +1055,14 @@ manage(Window w, XWindowAttributes *wa) + && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); + c->bw = borderpx; + ++ selmon->tagset[selmon->seltags] &= ~scratchtag; ++ if (!strcmp(c->name, scratchpadname)) { ++ c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag; ++ c->isfloating = True; ++ c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); ++ c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); ++ } ++ + wc.border_width = c->bw; + XConfigureWindow(dpy, w, CWBorderWidth, &wc); + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); +@@ -1661,6 +1672,7 @@ spawn(const Arg *arg) + { + if (arg->v == dmenucmd) + dmenumon[0] = '0' + selmon->num; ++ selmon->tagset[selmon->seltags] &= ~scratchtag; + if (fork() == 0) { + if (dpy) + close(ConnectionNumber(dpy)); +@@ -1748,6 +1760,28 @@ togglefloating(const Arg *arg) + } + + void ++togglescratch(const Arg *arg) ++{ ++ Client *c; ++ unsigned int found = 0; ++ ++ for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next); ++ if (found) { ++ unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; ++ if (newtagset) { ++ selmon->tagset[selmon->seltags] = newtagset; ++ focus(NULL); ++ arrange(selmon); ++ } ++ if (ISVISIBLE(c)) { ++ focus(c); ++ restack(selmon); ++ } ++ } else ++ spawn(arg); ++} ++ ++void + toggletag(const Arg *arg) + { + unsigned int newtags; diff --git a/dwm/patches/dwm-statuscolors-20181008-b69c870.diff b/dwm/patches/dwm-statuscolors-20181008-b69c870.diff new file mode 100644 index 0000000..8c7869a --- /dev/null +++ b/dwm/patches/dwm-statuscolors-20181008-b69c870.diff @@ -0,0 +1,94 @@ +From 35418d156fccb922710f6ca80a1f3972ba88b42f Mon Sep 17 00:00:00 2001 +From: Danny O'Brien +Date: Mon, 8 Oct 2018 19:21:29 -0700 +Subject: [PATCH] Add colors to status message in bar. + +This patch matches the format used by +https://dwm.suckless.org/patches/statuscolors/ -- An \x01 character +switches to the normal foreground/color combo, \x02 switches to the +color combo used for selected tags, \03 is set by default to black on +yellow, \04 is white on red. + +These color settings are defined in the colors array in config.def.h. +More can be added, but don't have more than 32, or you'll start hitting +real ASCII. + +This applies cleanly on mainline dwm from commit 022d076 (Sat Jan 7 +17:21:29 2017 +0100) until at least b69c870 (Sat Jun 2 17:15:42 2018 ++020). + +--- + config.def.h | 13 ++++++++++--- + dwm.c | 18 ++++++++++++++++-- + 2 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..df92695 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -12,10 +12,17 @@ static const char col_gray2[] = "#444444"; + static const char col_gray3[] = "#bbbbbb"; + static const char col_gray4[] = "#eeeeee"; + static const char col_cyan[] = "#005577"; ++static const char col_black[] = "#000000"; ++static const char col_red[] = "#ff0000"; ++static const char col_yellow[] = "#ffff00"; ++static const char col_white[] = "#ffffff"; ++ + static const char *colors[][3] = { +- /* fg bg border */ +- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, +- [SchemeSel] = { col_gray4, col_cyan, col_cyan }, ++ /* fg bg border */ ++ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, ++ [SchemeSel] = { col_gray4, col_cyan, col_cyan }, ++ [SchemeWarn] = { col_black, col_yellow, col_red }, ++ [SchemeUrgent]= { col_white, col_red, col_red }, + }; + + /* tagging */ +diff --git a/dwm.c b/dwm.c +index 4465af1..9d9d46f 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -59,7 +59,7 @@ + + /* enums */ + enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ +-enum { SchemeNorm, SchemeSel }; /* color schemes */ ++enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent }; /* color schemes */ + enum { NetSupported, NetWMName, NetWMState, NetWMCheck, + NetWMFullscreen, NetActiveWindow, NetWMWindowType, + NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ +@@ -699,13 +699,27 @@ drawbar(Monitor *m) + int boxs = drw->fonts->h / 9; + int boxw = drw->fonts->h / 6 + 2; + unsigned int i, occ = 0, urg = 0; ++ char *ts = stext; ++ char *tp = stext; ++ int tx = 0; ++ char ctmp; + Client *c; + + /* draw status first so it can be overdrawn by tags later */ + if (m == selmon) { /* status is only drawn on selected monitor */ + drw_setscheme(drw, scheme[SchemeNorm]); + sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ +- drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); ++ while (1) { ++ if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; } ++ ctmp = *ts; ++ *ts = '\0'; ++ drw_text(drw, m->ww - sw + tx, 0, sw - tx, bh, 0, tp, 0); ++ tx += TEXTW(tp) -lrpad; ++ if (ctmp == '\0') { break; } ++ drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]); ++ *ts = ctmp; ++ tp = ++ts; ++ } + } + + for (c = m->clients; c; c = c->next) { +-- +2.19.1 + diff --git a/dwm/patches/dwm-vanitygaps-20190508-6.2.diff b/dwm/patches/dwm-vanitygaps-20190508-6.2.diff new file mode 100644 index 0000000..ea22e23 --- /dev/null +++ b/dwm/patches/dwm-vanitygaps-20190508-6.2.diff @@ -0,0 +1,259 @@ +From 20967685d6879bd611a856ade154df19da9ddc7b Mon Sep 17 00:00:00 2001 +From: Stein Gunnar Bakkeby +Date: Wed, 8 May 2019 08:07:14 +0200 +Subject: [PATCH] Vanity gaps - allows control of both inner and outer gaps + between windows and screen edge + +--- + config.def.h | 21 +++++++++ + dwm.c | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- + 2 files changed, 161 insertions(+), 10 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..0927c2d 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -3,6 +3,11 @@ + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ + static const unsigned int snap = 32; /* snap pixel */ ++static const unsigned int gappih = 10; /* horiz inner gap between windows */ ++static const unsigned int gappiv = 10; /* vert inner gap between windows */ ++static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */ ++static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */ ++static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ + static const char *fonts[] = { "monospace:size=10" }; +@@ -70,6 +75,22 @@ static Key keys[] = { + { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, ++ { MODKEY|Mod4Mask, XK_h, incrgaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask, XK_l, incrgaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_h, incrogaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_l, incrogaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask|ControlMask, XK_h, incrigaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask|ControlMask, XK_l, incrigaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_0, togglegaps, {0} }, ++ { MODKEY|Mod4Mask|ShiftMask, XK_0, defaultgaps, {0} }, ++ { MODKEY, XK_y, incrihgaps, {.i = +1 } }, ++ { MODKEY, XK_o, incrihgaps, {.i = -1 } }, ++ { MODKEY|ControlMask, XK_y, incrivgaps, {.i = +1 } }, ++ { MODKEY|ControlMask, XK_o, incrivgaps, {.i = -1 } }, ++ { MODKEY|Mod4Mask, XK_y, incrohgaps, {.i = +1 } }, ++ { MODKEY|Mod4Mask, XK_o, incrohgaps, {.i = -1 } }, ++ { MODKEY|ShiftMask, XK_y, incrovgaps, {.i = +1 } }, ++ { MODKEY|ShiftMask, XK_o, incrovgaps, {.i = -1 } }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, +diff --git a/dwm.c b/dwm.c +index 4465af1..88f3e04 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -119,6 +119,10 @@ struct Monitor { + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ ++ int gappih; /* horizontal gap between windows */ ++ int gappiv; /* vertical gap between windows */ ++ int gappoh; /* horizontal outer gaps */ ++ int gappov; /* vertical outer gaps */ + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; +@@ -199,6 +203,16 @@ static void sendmon(Client *c, Monitor *m); + static void setclientstate(Client *c, long state); + static void setfocus(Client *c); + static void setfullscreen(Client *c, int fullscreen); ++static void setgaps(int oh, int ov, int ih, int iv); ++static void incrgaps(const Arg *arg); ++static void incrigaps(const Arg *arg); ++static void incrogaps(const Arg *arg); ++static void incrohgaps(const Arg *arg); ++static void incrovgaps(const Arg *arg); ++static void incrihgaps(const Arg *arg); ++static void incrivgaps(const Arg *arg); ++static void togglegaps(const Arg *arg); ++static void defaultgaps(const Arg *arg); + static void setlayout(const Arg *arg); + static void setmfact(const Arg *arg); + static void setup(void); +@@ -240,6 +254,7 @@ static char stext[256]; + static int screen; + static int sw, sh; /* X display screen geometry width, height */ + static int bh, blw = 0; /* bar geometry */ ++static int enablegaps = 1; /* enables gaps, used by togglegaps */ + static int lrpad; /* sum of left and right padding for text */ + static int (*xerrorxlib)(Display *, XErrorEvent *); + static unsigned int numlockmask = 0; +@@ -638,6 +653,10 @@ createmon(void) + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; ++ m->gappih = gappih; ++ m->gappiv = gappiv; ++ m->gappoh = gappoh; ++ m->gappov = gappov; + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); +@@ -1498,6 +1517,111 @@ setfullscreen(Client *c, int fullscreen) + } + + void ++setgaps(int oh, int ov, int ih, int iv) ++{ ++ if (oh < 0) oh = 0; ++ if (ov < 0) ov = 0; ++ if (ih < 0) ih = 0; ++ if (iv < 0) iv = 0; ++ ++ selmon->gappoh = oh; ++ selmon->gappov = ov; ++ selmon->gappih = ih; ++ selmon->gappiv = iv; ++ arrange(selmon); ++} ++ ++void ++togglegaps(const Arg *arg) ++{ ++ enablegaps = !enablegaps; ++ arrange(selmon); ++} ++ ++void ++defaultgaps(const Arg *arg) ++{ ++ setgaps(gappoh, gappov, gappih, gappiv); ++} ++ ++void ++incrgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh + arg->i, ++ selmon->gappov + arg->i, ++ selmon->gappih + arg->i, ++ selmon->gappiv + arg->i ++ ); ++} ++ ++void ++incrigaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov, ++ selmon->gappih + arg->i, ++ selmon->gappiv + arg->i ++ ); ++} ++ ++void ++incrogaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh + arg->i, ++ selmon->gappov + arg->i, ++ selmon->gappih, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrohgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh + arg->i, ++ selmon->gappov, ++ selmon->gappih, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrovgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov + arg->i, ++ selmon->gappih, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrihgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov, ++ selmon->gappih + arg->i, ++ selmon->gappiv ++ ); ++} ++ ++void ++incrivgaps(const Arg *arg) ++{ ++ setgaps( ++ selmon->gappoh, ++ selmon->gappov, ++ selmon->gappih, ++ selmon->gappiv + arg->i ++ ); ++} ++ ++void + setlayout(const Arg *arg) + { + if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) +@@ -1673,26 +1797,32 @@ tagmon(const Arg *arg) + void + tile(Monitor *m) + { +- unsigned int i, n, h, mw, my, ty; ++ unsigned int i, n, h, r, oe = enablegaps, ie = enablegaps, mw, my, ty; + Client *c; + + for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); + if (n == 0) + return; + ++ if (smartgaps == n) { ++ oe = 0; // outer gaps disabled ++ } ++ + if (n > m->nmaster) +- mw = m->nmaster ? m->ww * m->mfact : 0; ++ mw = m->nmaster ? (m->ww + m->gappiv*ie) * m->mfact : 0; + else +- mw = m->ww; +- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ mw = m->ww - 2*m->gappov*oe + m->gappiv*ie; ++ for (i = 0, my = ty = m->gappoh*oe, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if (i < m->nmaster) { +- h = (m->wh - my) / (MIN(n, m->nmaster) - i); +- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); +- my += HEIGHT(c); ++ r = MIN(n, m->nmaster) - i; ++ h = (m->wh - my - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; ++ resize(c, m->wx + m->gappov*oe, m->wy + my, mw - (2*c->bw) - m->gappiv*ie, h - (2*c->bw), 0); ++ my += HEIGHT(c) + m->gappih*ie; + } else { +- h = (m->wh - ty) / (n - i); +- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); +- ty += HEIGHT(c); ++ r = n - i; ++ h = (m->wh - ty - m->gappoh*oe - m->gappih*ie * (r - 1)) / r; ++ resize(c, m->wx + mw + m->gappov*oe, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappov*oe, h - (2*c->bw), 0); ++ ty += HEIGHT(c) + m->gappih*ie; + } + } + +-- +2.7.4 + -- cgit v1.2.3