diff --git a/dwm/dwm/config.def.h b/dwm/dwm/config.def.h index 3bcb155..29b6ddd 100644 --- a/dwm/dwm/config.def.h +++ b/dwm/dwm/config.def.h @@ -138,6 +138,12 @@ static const Key keys[] = { { MODKEY, XK_g, spawn, {.v = googlecmd } }, //---------------------------------------------------------------------------------- + + //------------------------------------ gaps ---------------------------- + { MODKEY|ShiftMask, XK_minus, setgaps, {.i = -1 } }, + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = +1 } }, + { MODKEY|ShiftMask, XK_0, setgaps, {.i = 0 } }, + //---------------------------------------------------------------------- { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, diff --git a/dwm/dwm/config.h b/dwm/dwm/config.h index 3bcb155..6a4e874 100644 --- a/dwm/dwm/config.h +++ b/dwm/dwm/config.h @@ -138,6 +138,12 @@ static const Key keys[] = { { MODKEY, XK_g, spawn, {.v = googlecmd } }, //---------------------------------------------------------------------------------- + //------------------------------------ gaps ---------------------------- + { MODKEY|ShiftMask, XK_minus, setgaps, {.i = -1 } }, + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = +1 } }, + { MODKEY|ShiftMask, XK_0, setgaps, {.i = 0 } }, + //---------------------------------------------------------------------- + { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, diff --git a/dwm/dwm/dwm b/dwm/dwm/dwm index bbc0676..62d08f4 100755 Binary files a/dwm/dwm/dwm and b/dwm/dwm/dwm differ diff --git a/dwm/dwm/dwm.c b/dwm/dwm/dwm.c index 6b5d20c..0c92415 100644 --- a/dwm/dwm/dwm.c +++ b/dwm/dwm/dwm.c @@ -119,6 +119,7 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + int gap; unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -200,6 +201,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 setgaps(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); @@ -641,6 +643,7 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; + m->gap = gap; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); @@ -1507,6 +1510,15 @@ setfullscreen(Client *c, int fullscreen) } } +void setgaps(const Arg *arg) { + if ((arg->i == 0) || (selmon->gap + arg->i < 0)) { + selmon->gap = 0; + } else { + selmon->gap += arg->i; + } + arrange(selmon); +} + void setlayout(const Arg *arg) { @@ -1695,23 +1707,39 @@ tile(Monitor *m) return; if (n > m->nmaster) - mw = m->nmaster ? (m->ww - gap) * m->mfact : 0; + mw = m->nmaster ? m->ww * m->mfact : 0; else - mw = m->ww; - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if (i < m->nmaster) { - r = MIN(n, m->nmaster) - i; - h = (m->wh - my - gap * (r - 1)) / r; - resize(c, m->wx + gap, m->wy + my + gap, mw - gap-gap - (2*c->bw), h - gap-gap - (2*c->bw), 0); - if (my + HEIGHT(c) < m->wh) - my += HEIGHT(c) + gap; - } else { - r = n - i; - h = (m->wh - ty - gap * (r - 1)) / r; - resize(c, m->wx + mw + gap, m->wy + ty + gap, m->ww - mw - gap-gap - (2*c->bw), h - gap-gap - (2*c->bw), 0); - if (ty + HEIGHT(c) + gap < m->wh) - ty += HEIGHT(c) + gap; + mw = m->ww - m->gap; + for (i = 0, my = ty = m->gap, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { + if (i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gap; + resize(c, m->wx + m->gap, m->wy + my, mw - (2*c->bw) - m->gap, h - (2*c->bw), 0); + if (my + HEIGHT(c) + m->gap < m->wh) { + my += HEIGHT(c) + m->gap; + } + } else { + h = (m->wh - ty) / (n - i) - m->gap; + resize(c, m->wx + mw + m->gap, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gap, h - (2*c->bw), 0); + if (ty + HEIGHT(c) + m->gap < m->wh) { + ty += HEIGHT(c) + m->gap; + } + } } + // mw = m->ww; + // for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + // if (i < m->nmaster) { + // r = MIN(n, m->nmaster) - i; + // h = (m->wh - my - gap * (r - 1)) / r; + // resize(c, m->wx + gap, m->wy + my + gap, mw - gap-gap - (2*c->bw), h - gap-gap - (2*c->bw), 0); + // if (my + HEIGHT(c) < m->wh) + // my += HEIGHT(c) + gap; + // } else { + // r = n - i; + // h = (m->wh - ty - gap * (r - 1)) / r; + // resize(c, m->wx + mw + gap, m->wy + ty + gap, m->ww - mw - gap-gap - (2*c->bw), h - gap-gap - (2*c->bw), 0); + // if (ty + HEIGHT(c) + gap < m->wh) + // ty += HEIGHT(c) + gap; + // } } void diff --git a/dwm/dwm/dwm.o b/dwm/dwm/dwm.o index f41f455..27d5ac0 100644 Binary files a/dwm/dwm/dwm.o and b/dwm/dwm/dwm.o differ diff --git a/dwm/dwm/patches/dwm-fullgaps-6.4.diff b/dwm/dwm/patches/dwm-fullgaps-6.4.diff new file mode 100644 index 0000000..dc52139 --- /dev/null +++ b/dwm/dwm/patches/dwm-fullgaps-6.4.diff @@ -0,0 +1,94 @@ +diff -up a/config.def.h b/config.def.h +--- a/config.def.h ++++ b/config.def.h +@@ -2,6 +2,7 @@ + + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ ++static const unsigned int gappx = 5; /* gaps between windows */ + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ +@@ -85,6 +86,9 @@ static const Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_minus, setgaps, {.i = -1 } }, ++ { MODKEY, XK_equal, setgaps, {.i = +1 } }, ++ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff -up a/dwm.c b/dwm.c +--- a/dwm.c 2023-04-30 ++++ b/dwm.c 2023-04-30 +@@ -119,6 +119,7 @@ struct Monitor { + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ ++ int gappx; /* gaps between windows */ + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; +@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor * + static void setclientstate(Client *c, long state); + static void setfocus(Client *c); + static void setfullscreen(Client *c, int fullscreen); ++static void setgaps(const Arg *arg); + static void setlayout(const Arg *arg); + static void setmfact(const Arg *arg); + static void setup(void); +@@ -641,6 +643,7 @@ createmon(void) + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; ++ m->gappx = gappx; + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); +@@ -1508,6 +1511,16 @@ setfullscreen(Client *c, int fullscreen) + } + + void ++setgaps(const Arg *arg) ++{ ++ if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) ++ selmon->gappx = 0; ++ else ++ selmon->gappx += arg->i; ++ arrange(selmon); ++} ++ ++void + setlayout(const Arg *arg) + { + if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) +@@ -1697,18 +1710,18 @@ tile(Monitor *m) + if (n > m->nmaster) + mw = m->nmaster ? m->ww * m->mfact : 0; + else +- mw = m->ww; +- for (i = my = ty = 0, 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); +- if (my + HEIGHT(c) < m->wh) +- my += HEIGHT(c); ++ mw = m->ww - m->gappx; ++ for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) ++ if (i < m->nmaster) { ++ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; ++ resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0); ++ if (my + HEIGHT(c) + m->gappx < m->wh) ++ my += HEIGHT(c) + m->gappx; + } 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); +- if (ty + HEIGHT(c) < m->wh) +- ty += HEIGHT(c); ++ h = (m->wh - ty) / (n - i) - m->gappx; ++ resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0); ++ if (ty + HEIGHT(c) + m->gappx < m->wh) ++ ty += HEIGHT(c) + m->gappx; + } + } diff --git a/dwm/dwm/patches/dwm-fullgaps-toggle-20200830.diff b/dwm/dwm/patches/dwm-fullgaps-toggle-20200830.diff new file mode 100644 index 0000000..2e64b80 --- /dev/null +++ b/dwm/dwm/patches/dwm-fullgaps-toggle-20200830.diff @@ -0,0 +1,148 @@ +diff --git a/config.def.h b/config.def.h +index 1c0b587..b172f63 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -2,6 +2,7 @@ + + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ ++static const Gap default_gap = {.isgap = 1, .realgap = 10, .gappx = 10}; + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ +@@ -84,6 +85,10 @@ static Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_minus, setgaps, {.i = -5 } }, ++ { MODKEY, XK_equal, setgaps, {.i = +5 } }, ++ { MODKEY|ShiftMask, XK_minus, setgaps, {.i = GAP_RESET } }, ++ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = GAP_TOGGLE} }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff --git a/dwm.c b/dwm.c +index 664c527..25bc9b7 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -57,6 +57,9 @@ + #define TAGMASK ((1 << LENGTH(tags)) - 1) + #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) + ++#define GAP_TOGGLE 100 ++#define GAP_RESET 0 ++ + /* enums */ + enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ + enum { SchemeNorm, SchemeSel }; /* color schemes */ +@@ -111,6 +114,12 @@ typedef struct { + void (*arrange)(Monitor *); + } Layout; + ++typedef struct { ++ int isgap; ++ int realgap; ++ int gappx; ++} Gap; ++ + struct Monitor { + char ltsymbol[16]; + float mfact; +@@ -119,6 +128,7 @@ struct Monitor { + int by; /* bar geometry */ + int mx, my, mw, mh; /* screen size */ + int wx, wy, ww, wh; /* window area */ ++ Gap *gap; + unsigned int seltags; + unsigned int sellt; + unsigned int tagset[2]; +@@ -169,6 +179,7 @@ static void focus(Client *c); + static void focusin(XEvent *e); + static void focusmon(const Arg *arg); + static void focusstack(const Arg *arg); ++static void gap_copy(Gap *to, const Gap *from); + static Atom getatomprop(Client *c, Atom prop); + static int getrootptr(int *x, int *y); + static long getstate(Window w); +@@ -200,6 +211,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 setgaps(const Arg *arg); + static void setlayout(const Arg *arg); + static void setmfact(const Arg *arg); + static void setup(void); +@@ -639,6 +651,8 @@ createmon(void) + m->nmaster = nmaster; + m->showbar = showbar; + m->topbar = topbar; ++ m->gap = malloc(sizeof(Gap)); ++ gap_copy(m->gap, &default_gap); + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); +@@ -1498,6 +1512,35 @@ setfullscreen(Client *c, int fullscreen) + } + } + ++void ++gap_copy(Gap *to, const Gap *from) ++{ ++ to->isgap = from->isgap; ++ to->realgap = from->realgap; ++ to->gappx = from->gappx; ++} ++ ++void ++setgaps(const Arg *arg) ++{ ++ Gap *p = selmon->gap; ++ switch(arg->i) ++ { ++ case GAP_TOGGLE: ++ p->isgap = 1 - p->isgap; ++ break; ++ case GAP_RESET: ++ gap_copy(p, &default_gap); ++ break; ++ default: ++ p->realgap += arg->i; ++ p->isgap = 1; ++ } ++ p->realgap = MAX(p->realgap, 0); ++ p->gappx = p->realgap * p->isgap; ++ arrange(selmon); ++} ++ + void + setlayout(const Arg *arg) + { +@@ -1684,18 +1727,18 @@ tile(Monitor *m) + if (n > m->nmaster) + mw = m->nmaster ? m->ww * 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 - m->gap->gappx; ++ for (i = 0, my = ty = m->gap->gappx, 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); +- if (my + HEIGHT(c) < m->wh) +- my += HEIGHT(c); ++ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gap->gappx; ++ resize(c, m->wx + m->gap->gappx, m->wy + my, mw - (2*c->bw) - m->gap->gappx, h - (2*c->bw), 0); ++ if (my + HEIGHT(c) + m->gap->gappx < m->wh) ++ my += HEIGHT(c) + m->gap->gappx; + } 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); +- if (ty + HEIGHT(c) < m->wh) +- ty += HEIGHT(c); ++ h = (m->wh - ty) / (n - i) - m->gap->gappx; ++ resize(c, m->wx + mw + m->gap->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gap->gappx, h - (2*c->bw), 0); ++ if (ty + HEIGHT(c) + m->gap->gappx < m->wh) ++ ty += HEIGHT(c) + m->gap->gappx; + } + } +