aboutsummaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-10-20 16:36:58 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-10-20 16:36:58 +0100
commit17f5dfa8143adc702d4be59f40da344986cbdecd (patch)
tree2b6467d2e8ace8bc45615c1b6cb3e8304d54ec28 /dwm.c
parent84d550ca9b1dd51a0cee4e0f53d3f8c02f2f5636 (diff)
downloaddwm-17f5dfa8143adc702d4be59f40da344986cbdecd.tar.gz
dwm-17f5dfa8143adc702d4be59f40da344986cbdecd.tar.bz2
dwm-17f5dfa8143adc702d4be59f40da344986cbdecd.zip
Added patch to move floating windows via the keyboard
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/dwm.c b/dwm.c
index e2b1929..a109b3d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -190,6 +190,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);
@@ -1339,6 +1341,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)
{