From d3a2b971026582c8fd093622c0b440b0288d9742 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Sat, 29 Aug 2020 21:51:05 +0200 Subject: [PATCH] different borderwidth for floating windows --- config.h | 3 +++ dwm.c | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config.h b/config.h index 74b1cd1..e310a20 100644 --- a/config.h +++ b/config.h @@ -2,6 +2,7 @@ /* appearance */ static const unsigned int borderpx = 3; /* border pixel of windows */ +static const unsigned int borderfloatpx = 1; /* border pixel of windows */ static const unsigned int snap = 10; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ @@ -196,11 +197,13 @@ static Key keys[] = { { MODKEY|ShiftMask, XK_c, spawn, SHCMD("hover center") }, { MODKEY, XK_v, spawn, SHCMD("st -e $EDITOR -c \"VimwikiIndex\"") }, { MODKEY|ShiftMask, XK_v, setfloating, {0} }, + { MODKEY|ShiftMask, XK_v, setsticky, {0} }, { MODKEY|ShiftMask, XK_v, spawn, SHCMD("hover left") }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY|ShiftMask, XK_b, spawn, SHCMD("bt") }, { MODKEY, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+13 dwmblocks") }, { MODKEY|ShiftMask, XK_n, setfloating, {0} }, + { MODKEY|ShiftMask, XK_n, setsticky, {0} }, { MODKEY|ShiftMask, XK_n, spawn, SHCMD("hover right") }, { MODKEY, XK_m, spawn, SHCMD("st -e ncmpcpp") }, { MODKEY|ShiftMask, XK_m, spawn, SHCMD("mpc toggle; notify-send \"DUNST_COMMAND_TOGGLE\"; pkill -RTMIN+10 dwmblocks") }, diff --git a/dwm.c b/dwm.c index 9f02624..619d921 100644 --- a/dwm.c +++ b/dwm.c @@ -210,6 +210,7 @@ static void setfloating(const Arg *arg); static void setfullscreen(Client *c, int fullscreen); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); +static void setsticky(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); @@ -1128,7 +1129,7 @@ manage(Window w, XWindowAttributes *wa) /* only fix client y-offset, if the client center might cover the bar */ c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); - c->bw = borderpx; + c->bw = c->isfloating ? borderfloatpx : borderpx; wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); @@ -1827,6 +1828,8 @@ togglefloating(const Arg *arg) if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h, 0); + selmon->sel->bw= selmon->sel->isfloating ? borderfloatpx : borderpx; + resizeclient(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h); arrange(selmon); } @@ -1838,8 +1841,9 @@ setfloating(const Arg *arg) if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ return; selmon->sel->isfloating = True; - resize(selmon->sel, selmon->sel->x, selmon->sel->y, - selmon->sel->w, selmon->sel->h, 0); + selmon->sel->bw = borderfloatpx; + //needed to redraw new thinner border + resizeclient(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h); arrange(selmon); } @@ -1859,6 +1863,14 @@ togglesticky(const Arg *arg) arrange(selmon); } +void +setsticky(const Arg *arg) +{ + if (!selmon->sel) + return; + selmon->sel->issticky = True; + arrange(selmon); +} void togglescratch(const Arg *arg) {