Adding swapfocus patch

pull/32/head
bakkeby 4 years ago
parent 21ba1d7bb3
commit 5e75da8dd1

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2020-01-29 - Added swapfocus patch
2020-01-26 - Added transfer patch
2020-01-24 - Added barpadding patch (incl. statusallmons, statuspadding, statuscolors, systray, alpha, holdbar and extrabar patch compatibility). Moved patches.h to patches.def.h to mimic the config pattern of having default and personal settings.
@ -293,6 +295,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- clients marked with isterminal in config.h swallow a window opened by any child process, e.g. running xclock in a terminal
- closing the xclock window restores the terminal window in the current position
- [swapfocus](https://dwm.suckless.org/patches/swapfocus/)
- this patch depends on the pertag patch and makes it possible to switch focus with a single shortcut (mod-s) instead of having to think if you should use mod-j or mod-k for reaching the previously used window
- [switchcol](https://dwm.suckless.org/patches/switchcol/)
- allows you to switch focus between the master and stack columns using a single keybinding

@ -527,6 +527,9 @@ static Key keys[] = {
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
#if SWAPFOCUS_PATCH && PERTAG_PATCH
{ MODKEY, XK_s, swapfocus, {.i = -1 } },
#endif // SWAPFOCUS_PATCH
#if SWITCHCOL_PATCH
{ MODKEY, XK_v, switchcol, {0} },
#endif // SWITCHCOL_PATCH
@ -644,7 +647,7 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_f, fullscreen, {0} },
#endif // FULLSCREEN_PATCH
#if STICKY_PATCH
{ MODKEY, XK_s, togglesticky, {0} },
{ MODKEY|ShiftMask, XK_s, togglesticky, {0} },
#endif // STICKY_PATCH
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },

31
dwm.c

@ -1945,6 +1945,9 @@ killclient(const Arg *arg)
XSetErrorHandler(xerror);
XUngrabServer(dpy);
}
#if SWAPFOCUS_PATCH && PERTAG_PATCH
selmon->pertag->prevclient[selmon->pertag->curtag] = NULL;
#endif // SWAPFOCUS_PATCH
}
void
@ -3096,6 +3099,9 @@ tag(const Arg *arg)
if (selmon->sel && arg->ui & TAGMASK) {
selmon->sel->tags = arg->ui & TAGMASK;
focus(NULL);
#if SWAPFOCUS_PATCH && PERTAG_PATCH
selmon->pertag->prevclient[selmon->pertag->curtag] = NULL;
#endif // SWAPFOCUS_PATCH
arrange(selmon);
#if VIEWONTAG_PATCH
view(arg);
@ -3306,6 +3312,9 @@ unfocus(Client *c, int setfocus)
{
if (!c)
return;
#if SWAPFOCUS_PATCH && PERTAG_PATCH
selmon->pertag->prevclient[selmon->pertag->curtag] = c;
#endif // SWAPFOCUS_PATCH
grabbuttons(c, 0);
#if FLOAT_BORDER_COLOR_PATCH
if (c->isfloating)
@ -3782,11 +3791,17 @@ view(const Arg *arg)
selmon->seltags ^= 1; /* toggle sel tagset */
#if PERTAG_PATCH
pertagview(arg);
#if SWAPFOCUS_PATCH
Client *unmodified = selmon->pertag->prevclient[selmon->pertag->curtag];
#endif // SWAPFOCUS_PATCH
#else
if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
#endif // PERTAG_PATCH
focus(NULL);
#if SWAPFOCUS_PATCH && PERTAG_PATCH
selmon->pertag->prevclient[selmon->pertag->curtag] = unmodified;
#endif // SWAPFOCUS_PATCH
arrange(selmon);
#if EWMHTAGS_PATCH
updatecurrentdesktop();
@ -3871,6 +3886,10 @@ zoom(const Arg *arg)
Client *at = NULL, *cold, *cprevious = NULL, *p;
#endif // ZOOMSWAP_PATCH
#if SWAPFOCUS_PATCH && PERTAG_PATCH
selmon->pertag->prevclient[selmon->pertag->curtag] = nexttiled(selmon->clients);
#endif // SWAPFOCUS_PATCH
if (!selmon->lt[selmon->sellt]->arrange
|| (selmon->sel && selmon->sel->isfloating)
#if ZOOMSWAP_PATCH
@ -3895,10 +3914,18 @@ zoom(const Arg *arg)
#else
prevzoom = NULL;
#endif // PERTAG_PATCH
#if SWAPFOCUS_PATCH && PERTAG_PATCH
if (!c || !(c = selmon->pertag->prevclient[selmon->pertag->curtag] = nexttiled(c->next)))
#else
if (!c || !(c = nexttiled(c->next)))
#endif // SWAPFOCUS_PATCH
return;
} else
#if SWAPFOCUS_PATCH && PERTAG_PATCH
c = selmon->pertag->prevclient[selmon->pertag->curtag] = cprevious;
#else
c = cprevious;
#endif // SWAPFOCUS_PATCH
}
cold = nexttiled(selmon->clients);
@ -3923,7 +3950,11 @@ zoom(const Arg *arg)
arrange(c->mon);
#else
if (c == nexttiled(selmon->clients))
#if SWAPFOCUS_PATCH && PERTAG_PATCH
if (!c || !(c = selmon->pertag->prevclient[selmon->pertag->curtag] = nexttiled(c->next)))
#else
if (!c || !(c = nexttiled(c->next)))
#endif // SWAPFOCUS_PATCH
return;
pop(c);
#endif // ZOOMSWAP_PATCH

@ -47,12 +47,6 @@ updateholdbarpos(Monitor *m)
{
m->wy = m->my;
m->wh = m->mh;
// if (m->showbar) {
// m->by = m->topbar ? m->wy : m->wy + m->wh - bh;
// m->wy = m->topbar ? m->wy - bh + bh : m->wy;
// } else {
// m->by = -bh;
// }
#if EXTRABAR_PATCH
#if BARPADDING_PATCH
m->wh = m->wh - vertpad * m->showbar * 2 - bh * m->showbar * 2;

@ -101,7 +101,10 @@
#endif
#if SWALLOW_PATCH
#include "swallow.c"
#endif // SWALLOW_PATCH
#endif
#if SWAPFOCUS_PATCH && PERTAG_PATCH
#include "swapfocus.c"
#endif
#if SWITCHCOL_PATCH
#include "switchcol.c"
#endif

@ -101,7 +101,10 @@
#endif
#if SWALLOW_PATCH
#include "swallow.h"
#endif // SWALLOW_PATCH
#endif
#if SWAPFOCUS_PATCH && PERTAG_PATCH
#include "swapfocus.h"
#endif
#if SWITCHCOL_PATCH
#include "switchcol.h"
#endif
@ -183,4 +186,4 @@
#endif
#if TILE_LAYOUT
#include "tile.h"
#endif
#endif

@ -16,6 +16,9 @@ struct Pertag {
#if ZOOMSWAP_PATCH
Client *prevzooms[LENGTH(tags) + 1]; /* store zoom information */
#endif // ZOOMSWAP_PATCH
#if SWAPFOCUS_PATCH
Client *prevclient[LENGTH(tags) + 1];
#endif // SWAPFOCUS_PATCH
};
void
@ -56,6 +59,4 @@ pertagview(const Arg *arg)
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
togglebar(NULL);
#endif // PERTAGBAR_PATCH
// strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); // ??
// strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
}

@ -0,0 +1,21 @@
void
swapfocus(const Arg *arg)
{
if (!selmon->sel)
return;
if (selmon->pertag->prevclient[selmon->pertag->curtag] != NULL
&& ISVISIBLE(selmon->pertag->prevclient[selmon->pertag->curtag])) {
focus(selmon->pertag->prevclient[selmon->pertag->curtag]);
restack(selmon->pertag->prevclient[selmon->pertag->curtag]->mon);
}
else {
Client *c = NULL;
for (c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
if (!c)
for (c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
if (c) {
focus(c);
restack(selmon);
}
}
}

@ -0,0 +1 @@
static void swapfocus(const Arg *arg);

@ -436,6 +436,13 @@
*/
#define SWALLOW_PATCH 0
/* This patch depends on the pertag patch and makes it possible to switch focus with a single
* shortcut (mod-s) instead of having to think if you should use mod-j or mod-k for reaching
* the previously used window.
* https://dwm.suckless.org/patches/swapfocus/
*/
#define SWAPFOCUS_PATCH 0
/* Switch focus between the master and stack columns using a single keybinding.
* https://dwm.suckless.org/patches/switchcol/
*/

Loading…
Cancel
Save