[dwm][patches][unfocusednoborders] add new version - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit 5b7aee94a23873af9abedf44e19d885c93c61a1f
 (DIR) parent 28e1a4801b7015812ad1be6ee005d4d409d978ef
 (HTM) Author: Jakub Skowron <jakubskowron676@gmail.com>
       Date:   Thu, 26 Jun 2025 13:30:33 +0200
       
       [dwm][patches][unfocusednoborders] add new version
       
       Diffstat:
         A dwm.suckless.org/patches/unfocused… |     120 +++++++++++++++++++++++++++++++
         M dwm.suckless.org/patches/unfocused… |       7 +++++--
       
       2 files changed, 125 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/dwm.suckless.org/patches/unfocusednoborders/dwm-unfocusednoborders-floating-6.5.diff b/dwm.suckless.org/patches/unfocusednoborders/dwm-unfocusednoborders-floating-6.5.diff
       @@ -0,0 +1,120 @@
       +From f5073e9663578dbf5cf64695e60d7cc19dcafadf Mon Sep 17 00:00:00 2001
       +From: Jakub Skowron <jakubskowron676@gmail.com>
       +Date: Thu, 26 Jun 2025 13:18:36 +0200
       +Subject: [PATCH] remove/add borders around floating windows
       +
       +This update adds functionality for floating windows to have the
       +same behavior as tiled windows, which means their borders will be
       +removed when unfocused and added back in when focused.
       +---
       + dwm.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
       + 1 file changed, 50 insertions(+), 9 deletions(-)
       +
       +diff --git a/dwm.c b/dwm.c
       +index 7b2bc88..f9e1477 100644
       +--- a/dwm.c
       ++++ b/dwm.c
       +@@ -141,6 +141,7 @@ typedef struct {
       + } Rule;
       + 
       + /* function declarations */
       ++static void addborders(Client *c);
       + static void applyrules(Client *c);
       + static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
       + static void arrange(Monitor *m);
       +@@ -188,6 +189,7 @@ static void pop(Client *c);
       + static void propertynotify(XEvent *e);
       + static void quit(const Arg *arg);
       + static Monitor *recttomon(int x, int y, int w, int h);
       ++static void removeborders(Client *c);
       + static void resize(Client *c, int x, int y, int w, int h, int interact);
       + static void resizeclient(Client *c, int x, int y, int w, int h);
       + static void resizemouse(const Arg *arg);
       +@@ -274,6 +276,30 @@ static Window root, wmcheckwin;
       + struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
       + 
       + /* function implementations */
       ++void
       ++addborders(Client *c)
       ++{
       ++    if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
       ++        XWindowChanges wc;
       ++
       ++        wc.width = c->oldw;
       ++        wc.height = c->oldh;
       ++        wc.border_width = borderpx;
       ++
       ++        c->w = wc.width += c->bw * 2;
       ++        c->h = wc.height += c->bw * 2;
       ++
       ++        XConfigureWindow(dpy, c->win, CWWidth | CWHeight | CWBorderWidth, &wc);
       ++        XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
       ++        configure(c);
       ++        XSync(dpy, False);
       ++    } else {
       ++        c->bw = borderpx;
       ++        XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
       ++        arrange(c->mon);
       ++    }
       ++}
       ++
       + void
       + applyrules(Client *c)
       + {
       +@@ -800,11 +826,7 @@ focus(Client *c)
       +                 detachstack(c);
       +                 attachstack(c);
       +                 grabbuttons(c, 1);
       +-
       +-        c->bw = borderpx;
       +-                XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
       +-        arrange(c->mon);
       +-
       ++        addborders(c);
       +                 setfocus(c);
       +         } else {
       +                 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
       +@@ -1278,6 +1300,28 @@ recttomon(int x, int y, int w, int h)
       +         return r;
       + }
       + 
       ++void
       ++removeborders(Client *c)
       ++{
       ++    if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
       ++        XWindowChanges wc;
       ++
       ++        wc.width = c->w;
       ++        wc.height = c->h;
       ++        wc.border_width = 0;
       ++
       ++        c->w = wc.width += c->bw * 2;
       ++        c->h = wc.height += c->bw * 2;
       ++
       ++        XConfigureWindow(dpy, c->win, CWWidth | CWHeight | CWBorderWidth, &wc);
       ++        configure(c);
       ++        XSync(dpy, False);
       ++    } else {
       ++        c->bw = 0;
       ++        arrange(c->mon);
       ++    }
       ++}
       ++
       + void
       + resize(Client *c, int x, int y, int w, int h, int interact)
       + {
       +@@ -1771,10 +1815,7 @@ unfocus(Client *c, int setfocus)
       +         if (!c)
       +                 return;
       +         grabbuttons(c, 0);
       +-
       +-    c->bw = 0;
       +-    arrange(c->mon);
       +-
       ++    removeborders(c);
       +         if (setfocus) {
       +                 XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
       +                 XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
       +-- 
       +2.50.0
       +
 (DIR) diff --git a/dwm.suckless.org/patches/unfocusednoborders/index.md b/dwm.suckless.org/patches/unfocusednoborders/index.md
       @@ -6,12 +6,15 @@ Description
        This patch removes borders from all windows that are not focused and adds
        them back in once they are (e.g. once hovered over).
        
       -The patch has been tested and is confirmed to work on dwm version 6.4.
       -
        Download
        --------
        * [dwm-unfocusednoborders-6.5.diff](dwm-unfocusednoborders-6.5.diff) (1.2K) (20250624)
        
       +Apply the patch below after the first one to get the same functionality
       +for floating windows.
       +
       +* [dwm-unfocusednoborders-floating-6.5.diff](dwm-unfocusednoborders-floating-6.5.diff) (3.5K) (20250626)
       +
        Authors
        -------
        * Jakub Skowron - <jakubskowron676@gmail.com>