From 7d503df5508965da76cca467f85cd30156da8760 Mon Sep 17 00:00:00 2001 From: speedie Date: Sun, 11 Dec 2022 17:16:20 +0100 Subject: [PATCH] add signals for toggling the borders --- README.md | 18 ++++++++++-------- docs/example.signal | 18 ++++++++++-------- signal.h | 2 ++ speedwm.1 | 20 ++++++++++++-------- speedwm.c | 26 ++++++++++++++++++++++++-- 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 58c029e..09ab680 100644 --- a/README.md +++ b/README.md @@ -535,9 +535,9 @@ Below is a list of all signums and what they do. - 30 - Kill the focused window - 31 - Rotate the stack up - 32 - Rotate the stack down -- 33 - Increase number of clients in the master stack -- 34 - Decrease number of clients in the master stack -- 35 - Focus the Master client +- 33 - Increase number of windows in the master stack +- 34 - Decrease number of windows in the master stack +- 35 - Focus the Master window - 36 - Switch focus between windows +1 - 37 - Switch focus between windows -1 - 38 - Switch focus between hidden windows +1 @@ -555,7 +555,7 @@ Below is a list of all signums and what they do. - 50 - Decrease inner gaps by 1 - 51 - Increase outer gaps by 1 - 52 - Decrease outer gaps by 1 -- 53 - Kill all clients except focused +- 53 - Kill all windows except focused - 54 - Focus the next monitor - 55 - Focus the previous monitor - 56 - Show the scratchpad @@ -615,13 +615,15 @@ Below is a list of all signums and what they do. - 110 - Rotate backwards in the stack axis - 111 - Rotate backwards in the secondary stack axis - 112 - Mirror the layout -- 113 - Enter an empty layout where all clients are hidden +- 113 - Enter an empty layout where all windows are hidden - 114 - Increase barpadding and gaps by 1 - 115 - Decrease barpadding and gaps by 1 -- 116 - Toggle mark on a client. -- 117 - Swap focus with the marked client. -- 118 - Swap the focused client with the marked client. +- 116 - Toggle mark on a window. +- 117 - Swap focus with the marked window. +- 118 - Swap the focused window with the marked window. - 119 - Center the focused window +- 120 - Toggle border for the focused window +- 121 - Toggle border for when there's only one window. ## Status bar diff --git a/docs/example.signal b/docs/example.signal index a0c57dc..85f0277 100644 --- a/docs/example.signal +++ b/docs/example.signal @@ -30,9 +30,9 @@ - 30 - Kill the focused window - 31 - Rotate the stack up - 32 - Rotate the stack down -- 33 - Increase number of clients in the master stack -- 34 - Decrease number of clients in the master stack -- 35 - Focus the Master client +- 33 - Increase number of windows in the master stack +- 34 - Decrease number of windows in the master stack +- 35 - Focus the Master window - 36 - Switch focus between windows +1 - 37 - Switch focus between windows -1 - 38 - Switch focus between hidden windows +1 @@ -50,7 +50,7 @@ - 50 - Decrease inner gaps by 1 - 51 - Increase outer gaps by 1 - 52 - Decrease outer gaps by 1 -- 53 - Kill all clients except focused +- 53 - Kill all windows except focused - 54 - Focus the next monitor - 55 - Focus the previous monitor - 56 - Show the scratchpad @@ -110,11 +110,13 @@ - 110 - Rotate backwards in the stack axis - 111 - Rotate backwards in the secondary stack axis - 112 - Mirror the layout -- 113 - Enter an empty layout where all clients are hidden +- 113 - Enter an empty layout where all windows are hidden - 114 - Increase barpadding and gaps by 1 - 115 - Decrease barpadding and gaps by 1 -- 116 - Toggle mark on a client. -- 117 - Swap focus with the marked client. -- 118 - Swap the focused client with the marked client. +- 116 - Toggle mark on a window. +- 117 - Swap focus with the marked window. +- 118 - Swap the focused window with the marked window. - 119 - Center the focused window +- 120 - Toggle border for the focused window +- 121 - Toggle border for when there's only one window. diff --git a/signal.h b/signal.h index 9a18250..922704b 100644 --- a/signal.h +++ b/signal.h @@ -132,4 +132,6 @@ static Signal signals[] = { { 117, swapfocus, {0} }, { 118, swapclient, {0} }, { 119, centerwindow, {0} }, + { 120, toggleborder, {0} }, + { 121, togglesingleborder, {0} }, }; diff --git a/speedwm.1 b/speedwm.1 index 5af14cc..32317cc 100644 --- a/speedwm.1 +++ b/speedwm.1 @@ -1059,11 +1059,11 @@ Below is a list of all signums and what they do. .IP \[bu] 2 32 - Rotate the stack down .IP \[bu] 2 -33 - Increase number of clients in the master stack +33 - Increase number of windows in the master stack .IP \[bu] 2 -34 - Decrease number of clients in the master stack +34 - Decrease number of windows in the master stack .IP \[bu] 2 -35 - Focus the Master client +35 - Focus the Master window .IP \[bu] 2 36 - Switch focus between windows +1 .IP \[bu] 2 @@ -1099,7 +1099,7 @@ Below is a list of all signums and what they do. .IP \[bu] 2 52 - Decrease outer gaps by 1 .IP \[bu] 2 -53 - Kill all clients except focused +53 - Kill all windows except focused .IP \[bu] 2 54 - Focus the next monitor .IP \[bu] 2 @@ -1219,19 +1219,23 @@ Below is a list of all signums and what they do. .IP \[bu] 2 112 - Mirror the layout .IP \[bu] 2 -113 - Enter an empty layout where all clients are hidden +113 - Enter an empty layout where all windows are hidden .IP \[bu] 2 114 - Increase barpadding and gaps by 1 .IP \[bu] 2 115 - Decrease barpadding and gaps by 1 .IP \[bu] 2 -116 - Toggle mark on a client. +116 - Toggle mark on a window. .IP \[bu] 2 -117 - Swap focus with the marked client. +117 - Swap focus with the marked window. .IP \[bu] 2 -118 - Swap the focused client with the marked client. +118 - Swap the focused window with the marked window. .IP \[bu] 2 119 - Center the focused window +.IP \[bu] 2 +120 - Toggle border for the focused window +.IP \[bu] 2 +121 - Toggle border for when there\[cq]s only one window. .SS Status bar .PP speedwm has a status bar. diff --git a/speedwm.c b/speedwm.c index 0efdb3b..163df12 100644 --- a/speedwm.c +++ b/speedwm.c @@ -334,6 +334,8 @@ struct Monitor { /* bar items */ int hidelayout; int hidetitle; + int hideborder; + int hidesingleborder; int hidestatus; int hideicon; int hidetags; @@ -668,6 +670,10 @@ static void togglebarfloat(const Arg *arg); static void togglefloating(const Arg *arg); static void toggleopacity(const Arg *arg); static void togglefullscr(const Arg *arg); +static void toggleborder(const Arg *arg); +static void togglesingleborder(const Arg *arg); + +/* barheight */ static void setbarheight(const Arg *arg); static void resetbarheight(const Arg *arg); @@ -1740,6 +1746,8 @@ createmon(void) /* bar items */ m->hidelayout = hidelayout; m->hidetitle = hidetitle; + m->hideborder = hideborder; + m->hidesingleborder = hidesingleborder; m->hidestatus = hidestatus; m->hideicon = hideicon; m->hidetags = hidetags; @@ -4573,7 +4581,7 @@ resizeclient(Client *c, int x, int y, int w, int h) if ((nexttiled(c->mon->clients) == c) && !(nexttiled(c->next))) reset_layout(NULL); - if ((nexttiled(c->mon->clients) == c && !nexttiled(c->next) && hidesingleborder) + if ((nexttiled(c->mon->clients) == c && !nexttiled(c->next) && selmon->hidesingleborder) && !c->isfullscreen && !c->isfloating && NULL != c->mon->lt[c->mon->sellt]->arrange) { c->w = wc.width += c->bw * 2; @@ -4581,7 +4589,7 @@ resizeclient(Client *c, int x, int y, int w, int h) wc.border_width = 0; } - if (hideborder) { + if (selmon->hideborder) { c->w = wc.width += c->bw * 2; c->h = wc.height += c->bw * 2; wc.border_width = 0; @@ -5504,6 +5512,20 @@ togglesystray(const Arg *arg) updatestatus(); } #endif + +void +toggleborder(const Arg *arg) +{ + selmon->sel->bw = (selmon->sel->bw == bordersize ? 0 : bordersize); + arrange(selmon); +} + +void +togglesingleborder(const Arg *arg) +{ + selmon->hidesingleborder = !selmon->hidesingleborder; + arrange(selmon); +} void togglebartags(const Arg *arg)