| [dwm][patches][swapwindows] Added patch - sites - public wiki contents of suckl… | |
| git clone git://git.suckless.org/sites | |
| Log | |
| Files | |
| Refs | |
| --- | |
| commit e7b79242613cd2f6af9e191aee6deeaef3971845 | |
| parent db9bcf402ef83cc1fffbc0ba1ceeb873048ef534 | |
| Author: jameel-sawafta <[email protected]> | |
| Date: Sat, 10 May 2025 18:12:01 +0300 | |
| [dwm][patches][swapwindows] Added patch | |
| Diffstat: | |
| A dwm.suckless.org/patches/swapwindo… | 90 +++++++++++++++++++++++++++… | |
| A dwm.suckless.org/patches/swapwindo… | 33 +++++++++++++++++++++++++++… | |
| 2 files changed, 123 insertions(+), 0 deletions(-) | |
| --- | |
| diff --git a/dwm.suckless.org/patches/swapwindows/dwm-swapwindows-20250510-cfb8… | |
| @@ -0,0 +1,90 @@ | |
| +From 00ea4c4e2d221c7f2979bcf403e4c23abf4b3f79 Mon Sep 17 00:00:00 2001 | |
| +From: jameel-sawafta <[email protected]> | |
| +Date: Fri, 9 May 2025 22:51:56 +0300 | |
| +Subject: [PATCH] dwm: add swapwindow function to swap focused clients between | |
| + monitors | |
| + | |
| +--- | |
| + config.def.h | 1 + | |
| + dwm.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ | |
| + 2 files changed, 47 insertions(+) | |
| + | |
| +diff --git a/config.def.h b/config.def.h | |
| +index 9efa774..ec0a706 100644 | |
| +--- a/config.def.h | |
| ++++ b/config.def.h | |
| +@@ -85,6 +85,7 @@ static const Key keys[] = { | |
| + { MODKEY, XK_period, focusmon, {.i = +1 }… | |
| + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 }… | |
| + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 }… | |
| ++ { MODKEY|ShiftMask, XK_slash, swapwindow, {0} }, | |
| + TAGKEYS( XK_1, 0) | |
| + TAGKEYS( XK_2, 1) | |
| + TAGKEYS( XK_3, 2) | |
| +diff --git a/dwm.c b/dwm.c | |
| +index 1443802..ee7658f 100644 | |
| +--- a/dwm.c | |
| ++++ b/dwm.c | |
| +@@ -232,6 +232,7 @@ static int xerror(Display *dpy, XErrorEvent *ee); | |
| + static int xerrordummy(Display *dpy, XErrorEvent *ee); | |
| + static int xerrorstart(Display *dpy, XErrorEvent *ee); | |
| + static void zoom(const Arg *arg); | |
| ++static void swapwindow(const Arg *arg); | |
| + | |
| + /* variables */ | |
| + static const char broken[] = "broken"; | |
| +@@ -2139,6 +2140,51 @@ zoom(const Arg *arg) | |
| + 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 | |
| + main(int argc, char *argv[]) | |
| + { | |
| +-- | |
| +2.49.0 | |
| + | |
| diff --git a/dwm.suckless.org/patches/swapwindows/index.md b/dwm.suckless.org/p… | |
| @@ -0,0 +1,33 @@ | |
| +# swapwindows | |
| + | |
| +## Description | |
| + | |
| +This patch allows swapping the selected client (window) with the selected wind… | |
| +on the other monitor. Useful for moving a window to the other monitor while | |
| +preserving the window focus and order. | |
| + | |
| +## Usage | |
| + | |
| +After applying the patch, the following key binding will be available by defau… | |
| + | |
| +MODKEY + Shift + / | |
| + | |
| +This keybinding will: | |
| + | |
| +- Swap the currently focused window with the focused window on the next monito… | |
| +- If the other monitor has no selected client, it will just move the current f… | |
| +- Rearrange and refocus appropriately after the operation. | |
| + | |
| +> You can customize this keybinding in your `config.def.h`: | |
| +> | |
| +> ```c | |
| +> { MODKEY|ShiftMask, XK_slash, swapwindow, {0} }, | |
| +> ``` | |
| + | |
| +## Download | |
| + | |
| +- [dwm-swapwindows-20250510-cfb8627.diff](dwm-swapwindows-20250510-cfb8627.dif… | |
| + | |
| +## Author | |
| + | |
| +Jameel Sawafta <[email protected]> |