dwm-floatborderwidth-6.3.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-floatborderwidth-6.3.diff (2555B)
       ---
            1 From 54b88e6663364d561fc0feb3ea9d4c79c0f4e3b0 Mon Sep 17 00:00:00 2001
            2 From: Dylan Cairns-Howarth <dairnarth@dylancairns.co.uk>
            3 Date: Sun, 20 Feb 2022 07:48:59 +0000
            4 Subject: [PATCH] Floating Windows have seperate border width
            5 
            6 This dwm patch adds the int fborderpx to config.def.h that assigns a
            7 border width to floating windows.
            8 
            9 By default, this patch sets borderpx to 0 and fborderpx to 1 (no borders
           10 for tiled windows and a 1px border for floating windows).
           11 ---
           12  config.def.h |  4 ++--
           13  dwm.c        | 13 +++++++++++--
           14  2 files changed, 13 insertions(+), 4 deletions(-)
           15 
           16 diff --git a/config.def.h b/config.def.h
           17 index a2ac963..ce35589 100644
           18 --- a/config.def.h
           19 +++ b/config.def.h
           20 @@ -1,7 +1,8 @@
           21  /* See LICENSE file for copyright and license details. */
           22  
           23  /* appearance */
           24 -static const unsigned int borderpx  = 1;        /* border pixel of windows */
           25 +static const unsigned int borderpx  = 0;        /* border pixel of windows */
           26 +static const unsigned int fborderpx = 1;        /* border pixel of floating windows */
           27  static const unsigned int snap      = 32;       /* snap pixel */
           28  static const int showbar            = 1;        /* 0 means no bar */
           29  static const int topbar             = 1;        /* 0 means bottom bar */
           30 @@ -113,4 +114,3 @@ static Button buttons[] = {
           31          { ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
           32          { ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
           33  };
           34 -
           35 diff --git a/dwm.c b/dwm.c
           36 index a96f33c..a63e9cd 100644
           37 --- a/dwm.c
           38 +++ b/dwm.c
           39 @@ -1052,6 +1052,8 @@ manage(Window w, XWindowAttributes *wa)
           40          c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx)
           41                  && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
           42          c->bw = borderpx;
           43 +        if (c->isfloating)
           44 +                c->bw = fborderpx;
           45  
           46          wc.border_width = c->bw;
           47          XConfigureWindow(dpy, w, CWBorderWidth, &wc);
           48 @@ -1719,9 +1721,16 @@ togglefloating(const Arg *arg)
           49          if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
           50                  return;
           51          selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
           52 -        if (selmon->sel->isfloating)
           53 +        if (selmon->sel->isfloating) {
           54 +                selmon->sel->bw = fborderpx;
           55 +                configure(selmon->sel);
           56 +        int borderdiff = (fborderpx - borderpx) * 2;
           57                  resize(selmon->sel, selmon->sel->x, selmon->sel->y,
           58 -                        selmon->sel->w, selmon->sel->h, 0);
           59 +                        selmon->sel->w - borderdiff, selmon->sel->h - borderdiff, 0);
           60 +        } else {
           61 +                selmon->sel->bw = borderpx;
           62 +                configure(selmon->sel);
           63 +        }
           64          arrange(selmon);
           65  }
           66  
           67 -- 
           68 2.35.1
           69