deal with window click to show/hide support

This commit is contained in:
speedie 2023-01-12 21:44:05 +01:00
parent d49e4dab44
commit e324a890d5
6 changed files with 40 additions and 6 deletions

View file

@ -234,6 +234,7 @@ These binds can be activated using your mouse
- Layout indicator (Right click) - Switch to the previous layout - 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 (Middle click) - Open a dmenu list of all layouts (requires speedwm-extras)
- Layout indicator (Scrolling up/down) - Switch to the next/previous layout - 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) - 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+Left click) - Move the focused window around
- Focused window (Super+Alt+Middle click) - Make the focused window floating - Focused window (Super+Alt+Middle click) - Make the focused window floating

View file

@ -37,15 +37,18 @@ draw_title(Bar *bar, BarDrawArg *a)
if (!ISVISIBLE(c)) if (!ISVISIBLE(c))
continue; continue;
if (bar->mon->sel == c && colorselectedtitle) if (bar->mon->sel == c)
scm = SchemeTitleSel; scm = SchemeTitleSel;
else if (!colorselectedtitle) else if (HIDDEN(c))
scm = SchemeTitleNorm;
else if (HIDDEN(c) && !selmon->hideunselectedtitle)
scm = SchemeTitleHidden; scm = SchemeTitleHidden;
else else
scm = SchemeTitleNorm; scm = SchemeTitleNorm;
if (!colorselectedtitle && !HIDDEN(c))
scm = SchemeTitleNorm;
else if (!colorselectedtitle && HIDDEN(c))
scm = SchemeTitleHidden;
/* hide unselected title */ /* hide unselected title */
if (bar->mon->sel != c && selmon->hideunselectedtitle) { if (bar->mon->sel != c && selmon->hideunselectedtitle) {
continue; continue;

View file

@ -183,6 +183,7 @@ These binds can be activated using your mouse
- Layout indicator (Right click) - Switch to the previous layout - 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 (Middle click) - Open a dmenu list of all layouts (requires speedwm-extras)
- Layout indicator (Scrolling up/down) - Switch to the next/previous layout - 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) - 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+Left click) - Move the focused window around
- Focused window (Super+Alt+Middle click) - Make the focused window floating - Focused window (Super+Alt+Middle click) - Make the focused window floating

View file

@ -37,6 +37,7 @@ static const Button buttons[] = {
{ clickstatusbar, 0, Button2, spawn, {.v = clickstatus } }, { clickstatusbar, 0, Button2, spawn, {.v = clickstatus } },
{ clickstatusbar, 0, Button3, spawn, {.v = clickstatus } }, { clickstatusbar, 0, Button3, spawn, {.v = clickstatus } },
{ clicktitle, 0, Button3, spawn, cmd( "speedwm-utils" ) }, { 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:'" ) }, { clickroot, 0, Button3, spawn, cmd( "j4-dmenu-desktop --term=st --dmenu='dmenu -l 20 -p Open:'" ) },
{ clicktags, 0, Button1, view, {0} }, { clicktags, 0, Button1, view, {0} },
{ clicktags, 0, Button4, viewtoleft, {0} }, { clicktags, 0, Button4, viewtoleft, {0} },

View file

@ -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 indicator (Scrolling up/down) - Switch to the next/previous
layout layout
.IP \[bu] 2 .IP \[bu] 2
Window title (Left click) - Show/hide the window
.IP \[bu] 2
Window title (Right click) - Open speedwm-utils (requires Window title (Right click) - Open speedwm-utils (requires
speedwm-extras) speedwm-extras)
.IP \[bu] 2 .IP \[bu] 2

View file

@ -533,6 +533,7 @@ static int sendevent(Client *c, Atom proto);
static int gettextprop(Window w, Atom atom, char *text, unsigned int size); static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, int focused); static void grabbuttons(Client *c, int focused);
static void hide(const Arg *arg); static void hide(const Arg *arg);
static void togglewin(const Arg *arg);
static void hidewin(Client *c); static void hidewin(Client *c);
static void incmastercount(const Arg *arg); static void incmastercount(const Arg *arg);
#if USEIPC #if USEIPC
@ -1426,7 +1427,7 @@ buttonpress(XEvent *e)
for (i = 0; i < LENGTH(buttons); i++) { for (i = 0; i < LENGTH(buttons); i++) {
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) { && 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); 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 */ /* Layout code */
#include "layouts.c" /* Enable patched layouts */ #include "layouts.c" /* Enable patched layouts */