dwm-ru_gaps-6.3.diff (5182B)
1 From dee230eb56b95c5bc336ad5494675009e76830d1 Mon Sep 17 00:00:00 2001 2 From: save196 <saverioturetta@protonmail.com> 3 Date: Tue, 22 Mar 2022 22:10:05 +0200 4 Subject: [PATCH] fixes and updated to work with dwm 6.3 5 version 6 7 - Fix bug where windows moved incorrectly while dragged with the mouse 8 in the floating layout 9 - Updated patch to work with dwm 6.3 10 --- 11 config.def.h | 4 ++++ 12 dwm.c | 57 ++++++++++++++++++++++++++++++++++++++++------------ 13 2 files changed, 48 insertions(+), 13 deletions(-) 14 15 diff --git a/config.def.h b/config.def.h 16 index a2ac963..8f3da2b 100644 17 --- a/config.def.h 18 +++ b/config.def.h 19 @@ -2,6 +2,7 @@ 20 21 /* appearance */ 22 static const unsigned int borderpx = 1; /* border pixel of windows */ 23 +static const int gappx = 5; /* gaps between windows */ 24 static const unsigned int snap = 32; /* snap pixel */ 25 static const int showbar = 1; /* 0 means no bar */ 26 static const int topbar = 1; /* 0 means bottom bar */ 27 @@ -85,6 +86,9 @@ static Key keys[] = { 28 { MODKEY, XK_period, focusmon, {.i = +1 } }, 29 { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, 30 { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, 31 + { MODKEY, XK_minus, setgaps, {.i = -5 } }, 32 + { MODKEY, XK_equal, setgaps, {.i = +5 } }, 33 + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, 34 TAGKEYS( XK_1, 0) 35 TAGKEYS( XK_2, 1) 36 TAGKEYS( XK_3, 2) 37 diff --git a/dwm.c b/dwm.c 38 index 5f16260..506bb1a 100644 39 --- a/dwm.c 40 +++ b/dwm.c 41 @@ -119,6 +119,7 @@ struct Monitor { 42 int by; /* bar geometry */ 43 int mx, my, mw, mh; /* screen size */ 44 int wx, wy, ww, wh; /* window area */ 45 + int gappx; /* gaps between windows */ 46 unsigned int seltags; 47 unsigned int sellt; 48 unsigned int tagset[2]; 49 @@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m); 50 static void setclientstate(Client *c, long state); 51 static void setfocus(Client *c); 52 static void setfullscreen(Client *c, int fullscreen); 53 +static void setgaps(const Arg *arg); 54 static void setlayout(const Arg *arg); 55 static void setmfact(const Arg *arg); 56 static void setup(void); 57 @@ -640,6 +642,7 @@ createmon(void) 58 m->nmaster = nmaster; 59 m->showbar = showbar; 60 m->topbar = topbar; 61 + m->gappx = gappx; 62 m->lt[0] = &layouts[0]; 63 m->lt[1] = &layouts[1 % LENGTH(layouts)]; 64 strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); 65 @@ -1287,6 +1290,15 @@ resizeclient(Client *c, int x, int y, int w, int h) 66 c->oldw = c->w; c->w = wc.width = w; 67 c->oldh = c->h; c->h = wc.height = h; 68 wc.border_width = c->bw; 69 + if (((nexttiled(c->mon->clients) == c && !nexttiled(c->next)) 70 + || &monocle == c->mon->lt[c->mon->sellt]->arrange) 71 + && !c->isfullscreen && !c->isfloating 72 + && c->mon->lt[c->mon->sellt]->arrange) 73 + { 74 + c->w = wc.width += c->bw * 2; 75 + c->h = wc.height += c->bw * 2; 76 + wc.border_width = 0; 77 + } 78 XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); 79 configure(c); 80 XSync(dpy, False); 81 @@ -1502,6 +1514,16 @@ setfullscreen(Client *c, int fullscreen) 82 } 83 } 84 85 +void 86 +setgaps(const Arg *arg) 87 +{ 88 + if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) 89 + selmon->gappx = 0; 90 + else 91 + selmon->gappx += arg->i; 92 + arrange(selmon); 93 +} 94 + 95 void 96 setlayout(const Arg *arg) 97 { 98 @@ -1678,28 +1700,37 @@ tagmon(const Arg *arg) 99 void 100 tile(Monitor *m) 101 { 102 - unsigned int i, n, h, mw, my, ty; 103 + unsigned int i, n, h, mw, my, ty, ns; 104 Client *c; 105 106 for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); 107 if (n == 0) 108 return; 109 + if(n == 1){ 110 + c = nexttiled(m->clients); 111 + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0); 112 + return; 113 + } 114 115 - if (n > m->nmaster) 116 + if (n > m->nmaster) { 117 mw = m->nmaster ? m->ww * m->mfact : 0; 118 - else 119 - mw = m->ww; 120 - for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 121 + ns = m->nmaster > 0 ? 2 : 1; 122 + } 123 + else{ 124 + mw = m->ww - m->gappx; 125 + ns = 1; 126 + } 127 + for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) 128 if (i < m->nmaster) { 129 - h = (m->wh - my) / (MIN(n, m->nmaster) - i); 130 - resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0); 131 - if (my + HEIGHT(c) < m->wh) 132 - my += HEIGHT(c); 133 + h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx; 134 + resize(c, m->wx + m->gappx, m->wy + my, mw - 2*c->bw - m->gappx*(5-ns)/2, h - 2*c->bw, 0); 135 + if(my + HEIGHT(c) + m->gappx < m->wh) 136 + my += HEIGHT(c) + m->gappx; 137 } else { 138 - h = (m->wh - ty) / (n - i); 139 - resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0); 140 - if (ty + HEIGHT(c) < m->wh) 141 - ty += HEIGHT(c); 142 + h = (m->wh - ty) / (n - i) - m->gappx; 143 + resize(c, m->wx + mw + m->gappx/ns, m->wy + ty, m->ww - mw - (2*c->bw) - m->gappx*(5-ns)/2, h - 2*c->bw, 0); 144 + if(ty + HEIGHT(c) + m->gappx < m->wh) 145 + ty += HEIGHT(c) + m->gappx; 146 } 147 } 148 149 -- 150 2.35.1 151