diff --git a/README.md b/README.md index 13f9223..00598ae 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,7 @@ These binds can be activated using your mouse - Layout indicator (Right click) - Switch to the previous layout - Layout indicator (Middle click) - Open a dmenu list of all layouts (requires speedwm-extras) - Layout indicator (Scrolling up/down) - Switch to the next/previous layout +- Window title (Left click) - Show/hide the window - Window title (Right click) - Open speedwm-utils (requires speedwm-extras) - Focused window (Super+Alt+Left click) - Move the focused window around - Focused window (Super+Alt+Middle click) - Make the focused window floating diff --git a/bar/title.c b/bar/title.c index 7d95dec..9ca16cc 100644 --- a/bar/title.c +++ b/bar/title.c @@ -37,15 +37,18 @@ draw_title(Bar *bar, BarDrawArg *a) if (!ISVISIBLE(c)) continue; - if (bar->mon->sel == c && colorselectedtitle) + if (bar->mon->sel == c) scm = SchemeTitleSel; - else if (!colorselectedtitle) - scm = SchemeTitleNorm; - else if (HIDDEN(c) && !selmon->hideunselectedtitle) + else if (HIDDEN(c)) scm = SchemeTitleHidden; - else + else scm = SchemeTitleNorm; + if (!colorselectedtitle && !HIDDEN(c)) + scm = SchemeTitleNorm; + else if (!colorselectedtitle && HIDDEN(c)) + scm = SchemeTitleHidden; + /* hide unselected title */ if (bar->mon->sel != c && selmon->hideunselectedtitle) { continue; diff --git a/docs/keybinds b/docs/keybinds index 044955e..41bf461 100644 --- a/docs/keybinds +++ b/docs/keybinds @@ -183,6 +183,7 @@ These binds can be activated using your mouse - Layout indicator (Right click) - Switch to the previous layout - Layout indicator (Middle click) - Open a dmenu list of all layouts (requires speedwm-extras) - Layout indicator (Scrolling up/down) - Switch to the next/previous layout +- Window title (Left click) - Show/hide the window - Window title (Right click) - Open speedwm-utils (requires speedwm-extras) - Focused window (Super+Alt+Left click) - Move the focused window around - Focused window (Super+Alt+Middle click) - Make the focused window floating diff --git a/mouse.h b/mouse.h index 040e8fc..6d9c61b 100644 --- a/mouse.h +++ b/mouse.h @@ -37,6 +37,7 @@ static const Button buttons[] = { { clickstatusbar, 0, Button2, spawn, {.v = clickstatus } }, { clickstatusbar, 0, Button3, spawn, {.v = clickstatus } }, { clicktitle, 0, Button3, spawn, cmd( "speedwm-utils" ) }, + { clicktitle, 0, Button1, togglewin, {0} }, { clickroot, 0, Button3, spawn, cmd( "j4-dmenu-desktop --term=st --dmenu='dmenu -l 20 -p Open:'" ) }, { clicktags, 0, Button1, view, {0} }, { clicktags, 0, Button4, viewtoleft, {0} }, diff --git a/speedwm.1 b/speedwm.1 index 0305cd3..eb16639 100644 --- a/speedwm.1 +++ b/speedwm.1 @@ -471,6 +471,8 @@ Layout indicator (Middle click) - Open a dmenu list of all layouts Layout indicator (Scrolling up/down) - Switch to the next/previous layout .IP \[bu] 2 +Window title (Left click) - Show/hide the window +.IP \[bu] 2 Window title (Right click) - Open speedwm-utils (requires speedwm-extras) .IP \[bu] 2 diff --git a/speedwm.c b/speedwm.c index 41ba3ee..32cc964 100644 --- a/speedwm.c +++ b/speedwm.c @@ -533,6 +533,7 @@ static int sendevent(Client *c, Atom proto); static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static void grabbuttons(Client *c, int focused); static void hide(const Arg *arg); +static void togglewin(const Arg *arg); static void hidewin(Client *c); static void incmastercount(const Arg *arg); #if USEIPC @@ -1426,7 +1427,7 @@ buttonpress(XEvent *e) for (i = 0; i < LENGTH(buttons); i++) { if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) { - buttons[i].func(click == clicktags && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); + buttons[i].func((click == clicktags || click == clicktitle) && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); } } } @@ -6689,5 +6690,30 @@ centerwindow(const Arg *arg) resizeclient(selmon->sel, (selmon->mw - selmon->mw * 0.5) / 2, (selmon->mh - selmon->mh * 0.5) / 2, selmon->mw * 0.5, selmon->mh * 0.5); } +void +togglewin(const Arg *arg) +{ + Client *c = (Client*)arg->v; + if (!c) + c = selmon->sel; + if (!c) + return; + + /* because it's useless with only one window */ + if (selmon->hideunselectedtitle) { + return; + } + + if (HIDDEN(c)) { + showwin(c); + } else { + hidewin(c); + } + + restack(c->mon); + focus(c); + arrange(selmon); +} + /* Layout code */ #include "layouts.c" /* Enable patched layouts */