feat: applied swapwindows patch

This commit is contained in:
Solomon Laing 2026-04-02 20:03:20 +10:30
parent 16fd459352
commit bae8a1588e
2 changed files with 47 additions and 0 deletions

View File

@ -86,6 +86,7 @@ static const Key keys[] = {
{ MODKEY, XK_period, focusmon, {.i = +1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_slash, swapwindow, {0} },
TAGKEYS( XK_1, 0) TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1) TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2) TAGKEYS( XK_3, 2)

46
dwm.c
View File

@ -232,6 +232,7 @@ static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg); static void zoom(const Arg *arg);
static void swapwindow(const Arg *arg);
/* variables */ /* variables */
static const char broken[] = "broken"; static const char broken[] = "broken";
@ -2140,6 +2141,51 @@ zoom(const Arg *arg)
pop(c); pop(c);
} }
void
swapwindow(const Arg *arg)
{
if (!selmon || !selmon->sel || !mons->next)
return;
Monitor *m1 = selmon;
Monitor *m2 = dirtomon(+1);
Client *c1 = m1->sel;
Client *c2 = m2->sel;
if (!c2) {
detach(c1);
detachstack(c1);
c1->mon = m2;
attach(c1);
attachstack(c1);
focus(c1);
selmon = m2;
arrange(m1);
arrange(m2);
return;
}
detach(c1);
detachstack(c1);
detach(c2);
detachstack(c2);
c1->mon = m2;
attach(c1);
attachstack(c1);
focus(c1);
c2->mon = m1;
attach(c2);
attachstack(c2);
focus(c2);
selmon = m1;
arrange(m1);
arrange(m2);
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {