dwm-winview-gaplessgrid-gridall-6.5.diff (4397B)
1 diff -upN _dwm-6.5/config.def.h dwm-6.5_gridall/config.def.h 2 --- _dwm-6.5/config.def.h 2024-03-19 08:24:52.000000000 -0300 3 +++ dwm-6.5_gridall/config.def.h 2025-06-13 08:50:53.706890303 -0300 4 @@ -1,4 +1,5 @@ 5 /* See LICENSE file for copyright and license details. */ 6 +#include "gaplessgrid.c" 7 8 /* appearance */ 9 static const unsigned int borderpx = 1; /* border pixel of windows */ 10 @@ -42,6 +43,7 @@ static const Layout layouts[] = { 11 { "[]=", tile }, /* first entry is default */ 12 { "><>", NULL }, /* no layout function means floating behavior */ 13 { "[M]", monocle }, 14 + { "HHH", gaplessgrid }, 15 }; 16 17 /* key definitions */ 18 @@ -95,6 +97,9 @@ static const Key keys[] = { 19 TAGKEYS( XK_8, 7) 20 TAGKEYS( XK_9, 8) 21 { MODKEY|ShiftMask, XK_q, quit, {0} }, 22 + { MODKEY, XK_o, winview, {0} }, 23 + { MODKEY, XK_g, gridall, {} }, 24 + { MODKEY, XK_r, winviewmono, {} }, 25 }; 26 27 /* button definitions */ 28 diff -upN _dwm-6.5/dwm.1 dwm-6.5_gridall/dwm.1 29 --- _dwm-6.5/dwm.1 2024-03-19 08:24:52.000000000 -0300 30 +++ dwm-6.5_gridall/dwm.1 2025-06-13 08:47:30.480858739 -0300 31 @@ -110,6 +110,9 @@ Increase master area size. 32 .B Mod1\-h 33 Decrease master area size. 34 .TP 35 +.B Mod1\-o 36 +Select view of the window in focus. The list of tags to be displayed is matched to the window tag list. 37 +.TP 38 .B Mod1\-Return 39 Zooms/cycles focused window to/from master area (tiled layouts only). 40 .TP 41 diff -upN _dwm-6.5/dwm.c dwm-6.5_gridall/dwm.c 42 --- _dwm-6.5/dwm.c 2024-03-19 08:24:52.000000000 -0300 43 +++ dwm-6.5_gridall/dwm.c 2025-06-13 08:49:14.708874297 -0300 44 @@ -229,10 +229,13 @@ static void updatewmhints(Client *c); 45 static void view(const Arg *arg); 46 static Client *wintoclient(Window w); 47 static Monitor *wintomon(Window w); 48 +static void winview(const Arg* arg); 49 static int xerror(Display *dpy, XErrorEvent *ee); 50 static int xerrordummy(Display *dpy, XErrorEvent *ee); 51 static int xerrorstart(Display *dpy, XErrorEvent *ee); 52 static void zoom(const Arg *arg); 53 +static void gridall(const Arg *arg); 54 +static void winviewmono(const Arg *arg); 55 56 /* variables */ 57 static const char broken[] = "broken"; 58 @@ -2092,6 +2095,41 @@ wintomon(Window w) 59 return selmon; 60 } 61 62 +/* Selects for the view of the focused window. The list of tags */ 63 +/* to be displayed is matched to the focused window tag list. */ 64 +void 65 +winview(const Arg* arg){ 66 + Window win, win_r, win_p, *win_c; 67 + unsigned nc; 68 + int unused; 69 + Client* c; 70 + Arg a; 71 + 72 + if (!XGetInputFocus(dpy, &win, &unused)) return; 73 + while(XQueryTree(dpy, win, &win_r, &win_p, &win_c, &nc) 74 + && win_p != win_r) win = win_p; 75 + 76 + if (!(c = wintoclient(win))) return; 77 + 78 + a.ui = c->tags; 79 + view(&a); 80 +} 81 + 82 +/* by desgua */ 83 +void 84 +gridall(const Arg *arg) 85 +{ 86 + setlayout(&(Arg){.v = &layouts[3]}); 87 + view(&(Arg){.ui = ~0}); 88 +} 89 + 90 +void 91 +winviewmono(const Arg *arg) 92 +{ 93 + winview(&(Arg){0}); 94 + setlayout(&(Arg){.v = &layouts[2]}); 95 +} 96 + 97 /* There's no way to check accesses to destroyed windows, thus those cases are 98 * ignored (especially on UnmapNotify's). Other types of errors call Xlibs 99 * default error handler, which may call exit. */ 100 diff -upN _dwm-6.5/gaplessgrid.c dwm-6.5_gridall/gaplessgrid.c 101 --- _dwm-6.5/gaplessgrid.c 1969-12-31 21:00:00.000000000 -0300 102 +++ dwm-6.5_gridall/gaplessgrid.c 2025-06-13 08:47:30.480858739 -0300 103 @@ -0,0 +1,35 @@ 104 +void 105 +gaplessgrid(Monitor *m) { 106 + unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch; 107 + Client *c; 108 + 109 + for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ; 110 + if(n == 0) 111 + return; 112 + 113 + /* grid dimensions */ 114 + for(cols = 0; cols <= n/2; cols++) 115 + if(cols*cols >= n) 116 + break; 117 + if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */ 118 + cols = 2; 119 + rows = n/cols; 120 + 121 + /* window geometries */ 122 + cw = cols ? m->ww / cols : m->ww; 123 + cn = 0; /* current column number */ 124 + rn = 0; /* current row number */ 125 + for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) { 126 + if(i/rows + 1 > cols - n%cols) 127 + rows = n/cols + 1; 128 + ch = rows ? m->wh / rows : m->wh; 129 + cx = m->wx + cn*cw; 130 + cy = m->wy + rn*ch; 131 + resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False); 132 + rn++; 133 + if(rn >= rows) { 134 + rn = 0; 135 + cn++; 136 + } 137 + } 138 +}