dwm-movekeyboard-6.4.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-movekeyboard-6.4.diff (3693B) | |
--- | |
1 From daf4eab44e319d78cffecf4133f8309c826fe6b9 Mon Sep 17 00:00:00 2001 | |
2 From: mrmine <[email protected]> | |
3 Date: Sun, 11 Dec 2022 23:31:46 +0100 | |
4 Subject: [PATCH] This Patch adds the ability to move floating windows on… | |
5 and y axis with the keyboard, instead of only the mouse. This is achiev… | |
6 adding the two functions "movekeyboard-x" and "movekeyboard-y". | |
7 | |
8 --- | |
9 config.def.h | 4 +++ | |
10 dwm.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
11 2 files changed, 92 insertions(+) | |
12 | |
13 diff --git a/config.def.h b/config.def.h | |
14 index 9efa774..a1ca89c 100644 | |
15 --- a/config.def.h | |
16 +++ b/config.def.h | |
17 @@ -85,6 +85,10 @@ static const Key keys[] = { | |
18 { MODKEY, XK_period, focusmon, {.i … | |
19 { MODKEY|ShiftMask, XK_comma, tagmon, {.i … | |
20 { MODKEY|ShiftMask, XK_period, tagmon, {.i … | |
21 + { MODKEY|ControlMask, XK_l, movekeyboar… | |
22 + { MODKEY|ControlMask, XK_h, movekeyboar… | |
23 + { MODKEY|ControlMask, XK_j, movekeyboar… | |
24 + { MODKEY|ControlMask, XK_k, movekeyboar… | |
25 TAGKEYS( XK_1, 0) | |
26 TAGKEYS( XK_2, 1) | |
27 TAGKEYS( XK_3, 2) | |
28 diff --git a/dwm.c b/dwm.c | |
29 index 03baf42..e8a9f28 100644 | |
30 --- a/dwm.c | |
31 +++ b/dwm.c | |
32 @@ -184,6 +184,8 @@ static void maprequest(XEvent *e); | |
33 static void monocle(Monitor *m); | |
34 static void motionnotify(XEvent *e); | |
35 static void movemouse(const Arg *arg); | |
36 +static void movekeyboard_x(const Arg *arg); | |
37 +static void movekeyboard_y(const Arg *arg); | |
38 static Client *nexttiled(Client *c); | |
39 static void pop(Client *c); | |
40 static void propertynotify(XEvent *e); | |
41 @@ -1203,6 +1205,92 @@ movemouse(const Arg *arg) | |
42 } | |
43 } | |
44 | |
45 +void | |
46 +movekeyboard_x(const Arg *arg){ | |
47 + int ocx, ocy, nx, ny; | |
48 + Client *c; | |
49 + Monitor *m; | |
50 + | |
51 + if (!(c = selmon->sel)) | |
52 + return; | |
53 + | |
54 + if (c->isfullscreen) /* no support moving fullscreen windows by… | |
55 + return; | |
56 + | |
57 + restack(selmon); | |
58 + | |
59 + ocx = c->x; | |
60 + ocy = c->y; | |
61 + | |
62 + nx = ocx + arg->i; | |
63 + ny = ocy; | |
64 + | |
65 + if (abs(selmon->wx - nx) < snap) | |
66 + nx = selmon->wx; | |
67 + else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < sna… | |
68 + nx = selmon->wx + selmon->ww - WIDTH(c); | |
69 + | |
70 + if (abs(selmon->wy - ny) < snap) | |
71 + ny = selmon->wy; | |
72 + else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < sn… | |
73 + ny = selmon->wy + selmon->wh - HEIGHT(c); | |
74 + | |
75 + if (!c->isfloating) | |
76 + togglefloating(NULL); | |
77 + | |
78 + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) | |
79 + resize(c, nx, ny, c->w, c->h, 1); | |
80 + | |
81 + if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { | |
82 + sendmon(c, m); | |
83 + selmon = m; | |
84 + focus(NULL); | |
85 + } | |
86 +} | |
87 + | |
88 +void | |
89 +movekeyboard_y(const Arg *arg){ | |
90 + int ocx, ocy, nx, ny; | |
91 + Client *c; | |
92 + Monitor *m; | |
93 + | |
94 + if (!(c = selmon->sel)) | |
95 + return; | |
96 + | |
97 + if (c->isfullscreen) /* no support moving fullscreen windows by… | |
98 + return; | |
99 + | |
100 + restack(selmon); | |
101 + | |
102 + ocx = c->x; | |
103 + ocy = c->y; | |
104 + | |
105 + nx = ocx; | |
106 + ny = ocy + arg->i; | |
107 + | |
108 + if (abs(selmon->wx - nx) < snap) | |
109 + nx = selmon->wx; | |
110 + else if (abs((selmon->wx + selmon->ww) - (nx + WIDTH(c))) < sna… | |
111 + nx = selmon->wx + selmon->ww - WIDTH(c); | |
112 + | |
113 + if (abs(selmon->wy - ny) < snap) | |
114 + ny = selmon->wy; | |
115 + else if (abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < sn… | |
116 + ny = selmon->wy + selmon->wh - HEIGHT(c); | |
117 + | |
118 + if (!c->isfloating) | |
119 + togglefloating(NULL); | |
120 + | |
121 + if (!selmon->lt[selmon->sellt]->arrange || c->isfloating) | |
122 + resize(c, nx, ny, c->w, c->h, 1); | |
123 + | |
124 + if ((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) { | |
125 + sendmon(c, m); | |
126 + selmon = m; | |
127 + focus(NULL); | |
128 + } | |
129 +} | |
130 + | |
131 Client * | |
132 nexttiled(Client *c) | |
133 { | |
134 -- | |
135 2.38.1 | |
136 |