Compare commits

...

4 Commits

Author SHA1 Message Date
2e4a63e36c rm todo.md 2025-01-24 10:22:29 -05:00
f24d073d0b add desktop entry to xsessions 2025-01-24 10:19:47 -05:00
ed5debbb62 add gappless grid layout 2025-01-24 10:17:48 -05:00
c4ab8a48ad remove remove border patch 2025-01-23 14:16:18 -05:00
9 changed files with 106 additions and 51 deletions

View File

@ -37,9 +37,12 @@ install: all
mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
mkdir -p ${DESTDIR}${PREFIX}/share/xsessions
cp -f dwm.desktop ${DESTDIR}/usr/share/xsessions
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
${DESTDIR}${MANPREFIX}/man1/dwm.1
${DESTDIR}${MANPREFIX}/man1/dwm.1 \
${DESTDIR}/usr/share/xsessions/dwm.desktop
.PHONY: all clean dist install uninstall

View File

@ -121,12 +121,14 @@ static const int nmaster = 1; /* number of clients in master area */
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
#include "gaplessgrid.c"
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
{ "[D]", deck },
{ "###", gaplessgrid },
};
/* key definitions */

13
dwm.c
View File

@ -2046,8 +2046,6 @@ void
resizeclient(Client *c, int x, int y, int w, int h)
{
XWindowChanges wc;
unsigned int n;
Client *nbc;
c->oldx = c->x; c->x = wc.x = x;
c->oldy = c->y; c->y = wc.y = y;
@ -2058,17 +2056,6 @@ resizeclient(Client *c, int x, int y, int w, int h)
if ((nexttiled(c->mon->clients) == c) && !(nexttiled(c->next)))
resetlayout(NULL);
for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
} else {
if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
wc.border_width = 0;
c->w = wc.width += c->bw * 2;
c->h = wc.height += c->bw * 2;
}
}
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);

9
dwm.desktop Normal file
View File

@ -0,0 +1,9 @@
[Desktop Entry]
Name=dwm
Comment=dynamic tiling window manager
Exec=dwm
TryExec=dwm
Type=Application
X-LightDM-DesktopName=dwm
DesktopNames=dwm
Keywords=tiling;wm;windowmanager;window;manager;

47
gaplessgrid.c Normal file
View File

@ -0,0 +1,47 @@
void
gaplessgrid(Monitor *m)
{
unsigned int i, n;
int x, y, cols, rows, ch, cw, cn, rn, rrest, crest; // counters
Client *c;
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
if ( n == 0 )
return;
/* grid dimensions */
for (cols = 0; cols <= n/2; cols++)
if (cols*cols >= n)
break;
if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2;
rows = n/cols;
cn = rn = 0; // reset column no, row no, client count
ch = (m->wh - 2*gappx - gappx * (rows - 1)) / rows;
cw = (m->ww - 2*gappx - gappx * (cols - 1)) / cols;
rrest = (m->wh - 2*gappx - gappx * (rows - 1)) - ch * rows;
crest = (m->ww - 2*gappx - gappx * (cols - 1)) - cw * cols;
x = m->wx + gappx;
y = m->wy + gappx;
for (i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
if (i/rows + 1 > cols - n%cols) {
rows = n/cols + 1;
ch = (m->wh - 2*gappx - gappx * (rows - 1)) / rows;
rrest = (m->wh - 2*gappx - gappx * (rows - 1)) - ch * rows;
}
resize(c,
x,
y + rn*(ch + gappx) + MIN(rn, rrest),
cw + (cn < crest ? 1 : 0) - 2*c->bw,
ch + (rn < rrest ? 1 : 0) - 2*c->bw,
0);
rn++;
if (rn >= rows) {
rn = 0;
x += cw + gappx + (cn < crest ? 1 : 0);
cn++;
}
}
}

View File

@ -1,31 +0,0 @@
diff --git a/dwm.c b/dwm.c
index 5646a5c..27e29df 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1283,12 +1283,26 @@ void
resizeclient(Client *c, int x, int y, int w, int h)
{
XWindowChanges wc;
+ unsigned int n;
+ Client *nbc;
c->oldx = c->x; c->x = wc.x = x;
c->oldy = c->y; c->y = wc.y = y;
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+
+ for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
+
+ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
+ } else {
+ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
+ wc.border_width = 0;
+ c->w = wc.width += c->bw * 2;
+ c->h = wc.height += c->bw * 2;
+ }
+ }
+
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);

View File

@ -0,0 +1,43 @@
URL: http://dwm.suckless.org/patches/gapless_grid
Add gapless grid layout.
Index: dwm/gaplessgrid.c
===================================================================
--- /dev/null
+++ dwm/gaplessgrid.c
@@ -0,0 +1,35 @@
+void
+gaplessgrid(Monitor *m) {
+ unsigned int n, cols, rows, cn, rn, i, cx, cy, cw, ch;
+ Client *c;
+
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++) ;
+ if(n == 0)
+ return;
+
+ /* grid dimensions */
+ for(cols = 0; cols <= n/2; cols++)
+ if(cols*cols >= n)
+ break;
+ if(n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+ rows = n/cols;
+
+ /* window geometries */
+ cw = cols ? m->ww / cols : m->ww;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ for(i = 0, c = nexttiled(m->clients); c; i++, c = nexttiled(c->next)) {
+ if(i/rows + 1 > cols - n%cols)
+ rows = n/cols + 1;
+ ch = rows ? m->wh / rows : m->wh;
+ cx = m->wx + cn*cw;
+ cy = m->wy + rn*ch;
+ resize(c, cx, cy, cw - 2 * c->bw, ch - 2 * c->bw, False);
+ rn++;
+ if(rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ }
+}

View File

@ -5,4 +5,5 @@ cat <<EOF | xmenu
><> Floating Layout 1
[M] Monocle Layout 2
[D] Deck Layout 3
### Grid Layout 4
EOF

View File

@ -1,6 +0,0 @@
# DWM Todo
## Bar
- [ ] add `config.def.h` options for window name & tag underline colors and
widths
- [ ] and drawbar is a mess from that ^ so clean it up