From 27b6b4b024948b79950767e38698d45babdca49c Mon Sep 17 00:00:00 2001 From: bakkeby Date: Sat, 7 Sep 2019 00:03:04 +0200 Subject: [PATCH] Adding focusonnetactive and losefullscreen patches --- README.md | 11 ++++++++++- dwm.c | 20 ++++++++++++++++++++ patches.h | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3cd382a..f6584e5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: -2019-09-06 - Added attachabove, attachaside, attachbelow, attachbottom and autostart patches +2019-09-06 - Added attachabove, attachaside, attachbelow, attachbottom, autostart, fancybar, focusonnetactive and losefullscreen patches 2019-09-05 - Alpha, systray, togglefullscreen, tagallmon, tagmonfixfs, tagswapmon, pertag and zoomswap patches added @@ -38,6 +38,15 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - [fancybar](https://dwm.suckless.org/patches/fancybar/) - shows the titles of all visible windows in the status bar + - [focusonnetactive](https://dwm.suckless.org/patches/focusonnetactive/) + - by default, dwm responds to \_NET_ACTIVE_WINDOW client messages by setting the urgency bit on the named window + - this patch activates the window instead + + - [losefullscreen](https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-losefullscreen-6.2.diff) + - by default in dwm it is possible to make an application fullscreen, then use the focusstack keybindings to focus on other windows beneath the current window + - it is also possible to spawn new windows (e.g. a terminal) that end up getting focus while the previous window remains in fullscreen + - this patch ensures that in such scenarios the previous window loses fullscreen + - [pertag](https://dwm.suckless.org/patches/pertag/) - adds nmaster, mfact, layouts and more per tag rather than per monitor diff --git a/dwm.c b/dwm.c index 134334f..67d04dc 100644 --- a/dwm.c +++ b/dwm.c @@ -564,6 +564,9 @@ clientmessage(XEvent *e) #endif // SYSTRAY_PATCH XClientMessageEvent *cme = &e->xclient; Client *c = wintoclient(cme->window); + #if FOCUSONNETACTIVE_PATCH + unsigned int i; + #endif // FOCUSONNETACTIVE_PATCH #if SYSTRAY_PATCH if (showsystray && cme->window == systray->win && cme->message_type == netatom[NetSystemTrayOP]) { @@ -618,8 +621,19 @@ clientmessage(XEvent *e) setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); } else if (cme->message_type == netatom[NetActiveWindow]) { + #if FOCUSONNETACTIVE_PATCH + for (i = 0; i < LENGTH(tags) && !((1 << i) & c->tags); i++); + if (i < LENGTH(tags)) { + const Arg a = {.ui = 1 << i}; + selmon = c->mon; + view(&a); + focus(c); + restack(selmon); + } + #else if (c != selmon->sel && !c->isurgent) seturgent(c, 1); + #endif // FOCUSONNETACTIVE_PATCH } } @@ -1001,6 +1015,12 @@ focus(Client *c) XDeleteProperty(dpy, root, netatom[NetActiveWindow]); } selmon->sel = c; + #if LOSEFULLSCREEN_PATCH + Client *at; + for (at = selmon->clients; at; at = at->next) + if (at != c && at->isfullscreen && ISVISIBLE(at)) + setfullscreen(at, 0); + #endif // LOSEFULLSCREEN_PATCH drawbars(); } diff --git a/patches.h b/patches.h index 4a61a3e..6a9d2ce 100644 --- a/patches.h +++ b/patches.h @@ -50,6 +50,21 @@ */ #define FANCYBAR_PATCH 0 +/* By default, dwm responds to _NET_ACTIVE_WINDOW client messages by setting + * the urgency bit on the named window. This patch activates the window instead. + * https://dwm.suckless.org/patches/focusonnetactive/ + */ +#define FOCUSONNETACTIVE_PATCH 0 + +/* By default in dwm it is possible to make an application fullscreen, then use + * the focusstack keybindings to focus on other windows beneath the current window. + * It is also possible to spawn new windows (e.g. a terminal) that end up getting + * focus while the previous window remains in fullscreen. This patch ensures that + * in such scenarios the previous window loses fullscreen. + * https://github.com/bakkeby/dwm-vanitygaps/blob/master/patches/dwm-losefullscreen-6.2.diff + */ +#define LOSEFULLSCREEN_PATCH 0 + /* The pertag patch adds nmaster, mfacts and layouts per tag rather * than per monitor (default). * https://dwm.suckless.org/patches/pertag/