mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding focusmaster-return patch variant ref. #398
This commit is contained in:
parent
d86ea2de25
commit
817db8c3ca
@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
|
||||
|
||||
### Changelog:
|
||||
|
||||
2023-11-12 - Added the focusmaster-return patch variant
|
||||
|
||||
2023-06-27 - Added the focusfollowmouse and unmanaged patches
|
||||
|
||||
2023-06-25 - Added the toggletopbar patch
|
||||
@ -442,6 +444,10 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
|
||||
- [focusmaster](https://dwm.suckless.org/patches/focusmaster/)
|
||||
- a simple patch that just puts focus back to the master client
|
||||
|
||||
- [focusmaster-return](https://dwm.suckless.org/patches/focusmaster/)
|
||||
- a simple patch that just puts focus back to the master client
|
||||
- additionally allows focus to be switched back to the previous client
|
||||
|
||||
- [focusonclick](https://dwm.suckless.org/patches/focusonclick/)
|
||||
- this patch makes you switch focus only by mouse click and not sloppy (focus follows mouse
|
||||
pointer)
|
||||
|
@ -914,9 +914,9 @@ static const Key keys[] = {
|
||||
#if TAB_PATCH
|
||||
{ MODKEY|ControlMask, XK_b, tabmode, {-1} },
|
||||
#endif // TAB_PATCH
|
||||
#if FOCUSMASTER_PATCH
|
||||
#if FOCUSMASTER_PATCH || FOCUSMASTER_RETURN_PATCH
|
||||
{ MODKEY|ControlMask, XK_space, focusmaster, {0} },
|
||||
#endif // FOCUSMASTER_PATCH
|
||||
#endif // FOCUSMASTER_PATCH / FOCUSMASTER_RETURN_PATCH
|
||||
#if STACKER_PATCH
|
||||
STACKKEYS(MODKEY, focus)
|
||||
STACKKEYS(MODKEY|ShiftMask, push)
|
||||
|
24
dwm.c
24
dwm.c
@ -504,6 +504,9 @@ struct Monitor {
|
||||
Client *clients;
|
||||
Client *sel;
|
||||
Client *stack;
|
||||
#if FOCUSMASTER_RETURN_PATCH
|
||||
Client *tagmarked[32];
|
||||
#endif // FOCUSMASTER_RETURN_PATCH
|
||||
Monitor *next;
|
||||
Bar *bar;
|
||||
const Layout *lt[2];
|
||||
@ -1818,6 +1821,11 @@ detach(Client *c)
|
||||
#if SEAMLESS_RESTART_PATCH
|
||||
c->idx = 0;
|
||||
#endif // SEAMLESS_RESTART_PATCH
|
||||
#if FOCUSMASTER_RETURN_PATCH
|
||||
for (int i = 1; i < NUMTAGS; i++)
|
||||
if (c == c->mon->tagmarked[i])
|
||||
c->mon->tagmarked[i] = NULL;
|
||||
#endif // FOCUSMASTER_RETURN_PATCH
|
||||
|
||||
for (tc = &c->mon->clients; *tc && *tc != c; tc = &(*tc)->next);
|
||||
*tc = c->next;
|
||||
@ -2846,6 +2854,13 @@ nexttiled(Client *c)
|
||||
void
|
||||
pop(Client *c)
|
||||
{
|
||||
#if FOCUSMASTER_RETURN_PATCH
|
||||
int i;
|
||||
for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
|
||||
i++;
|
||||
|
||||
c->mon->tagmarked[i] = nexttiled(c->mon->clients);
|
||||
#endif // FOCUSMASTER_RETURN_PATCH
|
||||
detach(c);
|
||||
attach(c);
|
||||
focus(c);
|
||||
@ -5086,6 +5101,9 @@ void
|
||||
zoom(const Arg *arg)
|
||||
{
|
||||
Client *c = selmon->sel;
|
||||
#if FOCUSMASTER_RETURN_PATCH && ZOOMSWAP_PATCH
|
||||
int i;
|
||||
#endif // FOCUSMASTER_RETURN_PATCH
|
||||
if (arg && arg->v)
|
||||
c = (Client*)arg->v;
|
||||
if (!c)
|
||||
@ -5139,6 +5157,12 @@ zoom(const Arg *arg)
|
||||
cold = nexttiled(c->mon->clients);
|
||||
if (c != cold && !at)
|
||||
at = findbefore(c);
|
||||
#if FOCUSMASTER_RETURN_PATCH
|
||||
for (i = 0; !(selmon->tagset[selmon->seltags] & 1 << i); i++);
|
||||
i++;
|
||||
|
||||
c->mon->tagmarked[i] = cold;
|
||||
#endif // FOCUSMASTER_RETURN_PATCH
|
||||
detach(c);
|
||||
attach(c);
|
||||
/* swap windows instead of pushing the previous one down */
|
||||
|
@ -1,14 +1,41 @@
|
||||
void
|
||||
focusmaster(const Arg *arg)
|
||||
{
|
||||
Client *c;
|
||||
Client *master;
|
||||
Monitor *m = selmon;
|
||||
#if FOCUSMASTER_RETURN_PATCH
|
||||
int i;
|
||||
#endif // FOCUSMASTER_RETURN_PATCH
|
||||
|
||||
if (selmon->nmaster < 1)
|
||||
if (m->nmaster < 1)
|
||||
return;
|
||||
#if !FAKEFULLSCREEN_PATCH
|
||||
#if FAKEFULLSCREEN_CLIENT_PATCH
|
||||
if (!m->sel || (m->sel->isfullscreen && m->sel->fakefullscreen != 1 && lockfullscreen))
|
||||
return;
|
||||
#else
|
||||
if (!m->sel || (m->sel->isfullscreen && lockfullscreen))
|
||||
return;
|
||||
#endif // FAKEFULLSCREEN_CLIENT_PATCH
|
||||
#endif // FAKEFULLSCREEN_PATCH
|
||||
|
||||
master = nexttiled(m->clients);
|
||||
|
||||
if (!master)
|
||||
return;
|
||||
|
||||
c = nexttiled(selmon->clients);
|
||||
#if FOCUSMASTER_RETURN_PATCH
|
||||
for (i = 0; !(m->tagset[m->seltags] & 1 << i); i++);
|
||||
i++;
|
||||
|
||||
if (c)
|
||||
focus(c);
|
||||
if (m->sel == master) {
|
||||
if (m->tagmarked[i] && ISVISIBLE(m->tagmarked[i]))
|
||||
focus(m->tagmarked[i]);
|
||||
} else {
|
||||
m->tagmarked[i] = m->sel;
|
||||
focus(master);
|
||||
}
|
||||
#else
|
||||
focus(master);
|
||||
#endif // FOCUSMASTER_RETURN_PATCH
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@
|
||||
#if FOCUSFOLLOWMOUSE_PATCH
|
||||
#include "focusfollowmouse.c"
|
||||
#endif
|
||||
#if FOCUSMASTER_PATCH
|
||||
#if FOCUSMASTER_PATCH || FOCUSMASTER_RETURN_PATCH
|
||||
#include "focusmaster.c"
|
||||
#endif
|
||||
#if FOCUSURGENT_PATCH
|
||||
|
@ -157,7 +157,7 @@
|
||||
#if FOCUSFOLLOWMOUSE_PATCH
|
||||
#include "focusfollowmouse.h"
|
||||
#endif
|
||||
#if FOCUSMASTER_PATCH
|
||||
#if FOCUSMASTER_PATCH || FOCUSMASTER_RETURN_PATCH
|
||||
#include "focusmaster.h"
|
||||
#endif
|
||||
#if FOCUSURGENT_PATCH
|
||||
|
@ -657,6 +657,12 @@
|
||||
*/
|
||||
#define FOCUSMASTER_PATCH 0
|
||||
|
||||
/* A variant of the focusmaster patch that additionally allows the focus to be returned to the
|
||||
* previously focused client
|
||||
* https://dwm.suckless.org/patches/focusmaster/
|
||||
*/
|
||||
#define FOCUSMASTER_RETURN_PATCH 0
|
||||
|
||||
/* Switch focus only by mouse click and not sloppy (focus follows mouse pointer).
|
||||
* https://dwm.suckless.org/patches/focusonclick/
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user