different borderwidth for floating windows

This commit is contained in:
Alexander Bocken 2020-08-29 21:51:05 +02:00
parent 182be07914
commit d3a2b97102
2 changed files with 18 additions and 3 deletions

View File

@ -2,6 +2,7 @@
/* appearance */ /* appearance */
static const unsigned int borderpx = 3; /* border pixel of windows */ 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 unsigned int snap = 10; /* snap pixel */
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom 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|ShiftMask, XK_c, spawn, SHCMD("hover center") },
{ MODKEY, XK_v, spawn, SHCMD("st -e $EDITOR -c \"VimwikiIndex\"") }, { MODKEY, XK_v, spawn, SHCMD("st -e $EDITOR -c \"VimwikiIndex\"") },
{ MODKEY|ShiftMask, XK_v, setfloating, {0} }, { MODKEY|ShiftMask, XK_v, setfloating, {0} },
{ MODKEY|ShiftMask, XK_v, setsticky, {0} },
{ MODKEY|ShiftMask, XK_v, spawn, SHCMD("hover left") }, { MODKEY|ShiftMask, XK_v, spawn, SHCMD("hover left") },
{ MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_b, togglebar, {0} },
{ MODKEY|ShiftMask, XK_b, spawn, SHCMD("bt") }, { MODKEY|ShiftMask, XK_b, spawn, SHCMD("bt") },
{ MODKEY, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+13 dwmblocks") }, { MODKEY, XK_n, spawn, SHCMD("st -e newsboat; pkill -RTMIN+13 dwmblocks") },
{ MODKEY|ShiftMask, XK_n, setfloating, {0} }, { MODKEY|ShiftMask, XK_n, setfloating, {0} },
{ MODKEY|ShiftMask, XK_n, setsticky, {0} },
{ MODKEY|ShiftMask, XK_n, spawn, SHCMD("hover right") }, { MODKEY|ShiftMask, XK_n, spawn, SHCMD("hover right") },
{ MODKEY, XK_m, spawn, SHCMD("st -e ncmpcpp") }, { 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") }, { MODKEY|ShiftMask, XK_m, spawn, SHCMD("mpc toggle; notify-send \"DUNST_COMMAND_TOGGLE\"; pkill -RTMIN+10 dwmblocks") },

18
dwm.c
View File

@ -210,6 +210,7 @@ static void setfloating(const Arg *arg);
static void setfullscreen(Client *c, int fullscreen); static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
static void setsticky(const Arg *arg);
static void setup(void); static void setup(void);
static void seturgent(Client *c, int urg); static void seturgent(Client *c, int urg);
static void showhide(Client *c); 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 */ /* 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->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->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; wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc); XConfigureWindow(dpy, w, CWBorderWidth, &wc);
@ -1827,6 +1828,8 @@ togglefloating(const Arg *arg)
if (selmon->sel->isfloating) if (selmon->sel->isfloating)
resize(selmon->sel, selmon->sel->x, selmon->sel->y, resize(selmon->sel, selmon->sel->x, selmon->sel->y,
selmon->sel->w, selmon->sel->h, 0); 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); arrange(selmon);
} }
@ -1838,8 +1841,9 @@ setfloating(const Arg *arg)
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
return; return;
selmon->sel->isfloating = True; selmon->sel->isfloating = True;
resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->bw = borderfloatpx;
selmon->sel->w, selmon->sel->h, 0); //needed to redraw new thinner border
resizeclient(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h);
arrange(selmon); arrange(selmon);
} }
@ -1859,6 +1863,14 @@ togglesticky(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
setsticky(const Arg *arg)
{
if (!selmon->sel)
return;
selmon->sel->issticky = True;
arrange(selmon);
}
void void
togglescratch(const Arg *arg) togglescratch(const Arg *arg)
{ {