[wiki] [sites] [dwm][patch][movecenter] Move focused floating window to the center || Philip Thomas Kanianthara

From: <git_AT_suckless.org>
Date: Sun, 31 Oct 2021 06:43:34 +0100

commit 56c72b06e7465f454df0cc830ad41d65cace2be7
Author: Philip Thomas Kanianthara <philip.kanianthara_AT_gmail.com>
Date: Sun Oct 31 13:40:18 2021 +0800

    [dwm][patch][movecenter] Move focused floating window to the center

diff --git a/dwm.suckless.org/patches/movecenter/dwm-movecenter-6.2.diff b/dwm.suckless.org/patches/movecenter/dwm-movecenter-6.2.diff
new file mode 100644
index 00000000..4be852f7
--- /dev/null
+++ b/dwm.suckless.org/patches/movecenter/dwm-movecenter-6.2.diff
_AT_@ -0,0 +1,39 @@
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..c5b14ba 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -84,6 +84,7 @@ static Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY, XK_x, movecenter, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff --git a/dwm.c b/dwm.c
+index 4465af1..292c70e 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -183,6 +183,7 @@ static void maprequest(XEvent *e);
+ static void monocle(Monitor *m);
+ static void motionnotify(XEvent *e);
+ static void movemouse(const Arg *arg);
++static void movecenter(const Arg *arg);
+ static Client *nexttiled(Client *c);
+ static void pop(Client *);
+ static void propertynotify(XEvent *e);
+_AT_@ -1192,6 +1193,14 @@ movemouse(const Arg *arg)
+ }
+ }
+
++void
++movecenter(const Arg *arg)
++{
++ selmon->sel->x = selmon->sel->mon->mx + (selmon->sel->mon->mw - WIDTH(selmon->sel)) / 2;
++ selmon->sel->y = selmon->sel->mon->my + (selmon->sel->mon->mh - HEIGHT(selmon->sel)) / 2;
++ arrange(selmon);
++}
++
+ Client *
+ nexttiled(Client *c)
+ {
diff --git a/dwm.suckless.org/patches/movecenter/index.md b/dwm.suckless.org/patches/movecenter/index.md
new file mode 100644
index 00000000..43e86aca
--- /dev/null
+++ b/dwm.suckless.org/patches/movecenter/index.md
_AT_@ -0,0 +1,21 @@
+movecenter
+====================
+
+Description
+-----------
+This patch provides a keybinding to center focused windows.
+
+Press MOD + x to center the focused floating window.
+
+It does NOT uncenter the window back to its previous location.
+It does not center windows that are not floating.
+
+The original code is from the [togglefloatingcenter](../togglefloatingcenter/) patch.
+
+Download
+--------
+* [dwm-movecenter-6.2.diff](dwm-movecenter-6.2.diff) - 2021-10-31
+
+Author
+------
+* Philip Thomas K. - <philtomk_AT_gmail.com>
Received on Sun Oct 31 2021 - 06:43:34 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 31 2021 - 06:48:44 CET