init
This commit is contained in:
148
dwm-6.6/patches/dwm-fullgaps-toggle-20200830.diff
Normal file
148
dwm-6.6/patches/dwm-fullgaps-toggle-20200830.diff
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user