[wiki] [sites] Adding the "movekeyboard" dwm(6.4) patch, which adds the ability to move floating windows on the x and y axis through a keybinding/keyboard instead of only the mouse. || mrmine

From: <git_AT_suckless.org>
Date: Sun, 11 Dec 2022 23:55:19 +0100

commit 39de2531ba12c1391336c44b5e594ec49616506b
Author: mrmine <mrmine1_AT_proton.me>
Date: Sun Dec 11 23:44:32 2022 +0100

    Adding the "movekeyboard" dwm(6.4) patch, which adds the ability to move
    floating windows on the x and y axis through a keybinding/keyboard
    instead of only the mouse.

diff --git a/dwm.suckless.org/patches/movekeyboard/dwm-movekeyboard-6.4.diff b/dwm.suckless.org/patches/movekeyboard/dwm-movekeyboard-6.4.diff
new file mode 100644
index 00000000..677ed45e
--- /dev/null
+++ b/dwm.suckless.org/patches/movekeyboard/dwm-movekeyboard-6.4.diff
_AT_@ -0,0 +1,136 @@
+From daf4eab44e319d78cffecf4133f8309c826fe6b9 Mon Sep 17 00:00:00 2001
+From: mrmine <mrmine1_AT_proton.me>
+Date: Sun, 11 Dec 2022 23:31:46 +0100
+Subject: [PATCH] This Patch adds the ability to move floating windows on the x
+ and y axis with the keyboard, instead of only the mouse. This is achieved by
+ adding the two functions "movekeyboard-x" and "movekeyboard-y".
+
+---
+ config.def.h | 4 +++
+ dwm.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 92 insertions(+)
+
+diff --git a/config.def.h b/config.def.h
+index 9efa774..a1ca89c 100644
+--- a/config.def.h
++++ b/config.def.h
+_AT_@ -85,6 +85,10 @@ 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|ControlMask, XK_l, movekeyboard_x, {.i = 20}},
++ { MODKEY|ControlMask, XK_h, movekeyboard_x, {.i = -20}},
++ { MODKEY|ControlMask, XK_j, movekeyboard_y, {.i = 20}},
++ { MODKEY|ControlMask, XK_k, movekeyboard_y, {.i = -20}},
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff --git a/dwm.c b/dwm.c
+index 03baf42..e8a9f28 100644
+--- a/dwm.c
++++ b/dwm.c
+_AT_@ -184,6 +184,8 @@ static void maprequest(XEvent *e);
+ static void monocle(Monitor *m);
+ static void motionnotify(XEvent *e);
+ static void movemouse(const Arg *arg);
++static void movekeyboard_x(const Arg *arg);
++static void movekeyboard_y(const Arg *arg);
+ static Client *nexttiled(Client *c);
+ static void pop(Client *c);
+ static void propertynotify(XEvent *e);
+_AT_@ -1203,6 +1205,92 @@ movemouse(const Arg *arg)
+ }
+ }
+
++void
++movekeyboard_x(const Arg *arg){
++ int ocx, ocy, nx, ny;
++ Client *c;
++ Monitor *m;
++
++ if (!(c = selmon->sel))
++ return;
++
++ if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
++ return;
++
++ restack(selmon);
++
++ ocx = c->x;
++ ocy = c->y;
++
++ nx = ocx + arg->i;
++ ny = ocy;
++
++ if (abs(selmon->wx - nx) < snap)
++ nx = selmon->wx;
++ else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
++ nx = selmon->wx + selmon->ww - WIDTH(c);
++
++ if (abs(selmon->wy - ny) < snap)
++ ny = selmon->wy;
++ else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
++ ny = selmon->wy + selmon->wh - HEIGHT(c);
++
++ if (!c->isfloating)
++ togglefloating(NULL);
++
++ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
++ resize(c, nx, ny, c->w, c->h, 1);
++
++ if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
++ sendmon(c, m);
++ selmon = m;
++ focus(NULL);
++ }
++}
++
++void
++movekeyboard_y(const Arg *arg){
++ int ocx, ocy, nx, ny;
++ Client *c;
++ Monitor *m;
++
++ if (!(c = selmon->sel))
++ return;
++
++ if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
++ return;
++
++ restack(selmon);
++
++ ocx = c->x;
++ ocy = c->y;
++
++ nx = ocx;
++ ny = ocy + arg->i;
++
++ if (abs(selmon->wx - nx) < snap)
++ nx = selmon->wx;
++ else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < snap)
++ nx = selmon->wx + selmon->ww - WIDTH(c);
++
++ if (abs(selmon->wy - ny) < snap)
++ ny = selmon->wy;
++ else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
++ ny = selmon->wy + selmon->wh - HEIGHT(c);
++
++ if (!c->isfloating)
++ togglefloating(NULL);
++
++ if (!selmon->lt[selmon->sellt]->arrange || c->isfloating)
++ resize(c, nx, ny, c->w, c->h, 1);
++
++ if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
++ sendmon(c, m);
++ selmon = m;
++ focus(NULL);
++ }
++}
++
+ Client *
+ nexttiled(Client *c)
+ {
+--
+2.38.1
+
diff --git a/dwm.suckless.org/patches/movekeyboard/index.md b/dwm.suckless.org/patches/movekeyboard/index.md
new file mode 100644
index 00000000..5be14ff1
--- /dev/null
+++ b/dwm.suckless.org/patches/movekeyboard/index.md
_AT_@ -0,0 +1,19 @@
+========
+
+Description
+-----------
+This Patch adds the ability to move floating windows on the x and y axis with the keyboard, instead of only the mouse. This is achieved by adding the two functions "movekeyboard-x" and "movekeyboard-y".
+
+Default bindings:
+modkey + ctrl + l : x + 20
+modkey + ctrl + h : x - 20
+modkey + ctrl + j : y + 20
+modkey + ctrl + k : y - 20
+
+Download
+--------
+* [dwm-movekeyboard-6.4.diff](dwm-movekeyboard-6.4.diff)
+
+Authors
+-------
+* mrmine - <mrmine1_AT_proton.me>
Received on Sun Dec 11 2022 - 23:55:19 CET

This archive was generated by hypermail 2.3.0 : Mon Dec 12 2022 - 00:01:04 CET