Add floatwindowkeybinds patch

This commit is contained in:
Gavin M 2024-03-15 17:15:56 -05:00
parent 0150cfebbc
commit 871f0b9fac

View File

@ -0,0 +1,95 @@
From ac77e10df2a684bf906ce5e600f02b5bab490f80 Mon Sep 17 00:00:00 2001
From: Gavin M <github@gavinm.us>
Date: Fri, 15 Mar 2024 17:14:14 -0500
Subject: [PATCH] Added floatingwindowkeybinds
---
config.def.h | 8 ++++++++
dwl.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/config.def.h b/config.def.h
index 9009517..3497602 100644
--- a/config.def.h
+++ b/config.def.h
@@ -130,6 +130,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
+ { MODKEY|WLR_MODIFIER_ALT, XKB_KEY_j, setfloatingy, {.i = 40} },
+ { MODKEY|WLR_MODIFIER_ALT, XKB_KEY_k, setfloatingy, {.i = -40} },
+ { MODKEY|WLR_MODIFIER_ALT, XKB_KEY_l, setfloatingx, {.i = 40} },
+ { MODKEY|WLR_MODIFIER_ALT, XKB_KEY_h, setfloatingx, {.i = -40} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_j, setfloatingheight,{.i = 40} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_k, setfloatingheight,{.i = -40} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_l, setfloatingwidth,{.i = 40} },
+ { MODKEY|WLR_MODIFIER_CTRL, XKB_KEY_h, setfloatingwidth,{.i = -40} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
diff --git a/dwl.c b/dwl.c
index 5867b0c..d5bd6ed 100644
--- a/dwl.c
+++ b/dwl.c
@@ -317,6 +317,11 @@ static void run(char *startup_cmd);
static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
+static void setfloatingbox(int x, int y, int width, int height);
+static void setfloatingx(const Arg *arg);
+static void setfloatingy(const Arg *arg);
+static void setfloatingwidth(const Arg *arg);
+static void setfloatingheight(const Arg *arg);
static void setfullscreen(Client *c, int fullscreen);
static void setgamma(struct wl_listener *listener, void *data);
static void setlayout(const Arg *arg);
@@ -2158,6 +2163,46 @@ setfloating(Client *c, int floating)
printstatus();
}
+void
+setfloatingbox(int x, int y, int width, int height)
+{
+ Client *c;
+ wl_list_for_each(c, &fstack, flink) {
+ if (VISIBLEON(c, selmon)) {
+ if (!c->isfloating || selmon->lt[selmon->sellt]->arrange)
+ continue;
+ resize(c, (struct wlr_box){.x = c->geom.x + x, .y = c->geom.y + y,
+ .width = c->geom.width + width, .height = c->geom.height + height}, 0);
+ return;
+ }
+ }
+ return;
+}
+
+void
+setfloatingx(const Arg *arg)
+{
+ setfloatingbox(arg->i, 0, 0, 0);
+}
+
+void
+setfloatingy(const Arg *arg)
+{
+ setfloatingbox(0, arg->i, 0, 0);
+}
+
+void
+setfloatingwidth(const Arg *arg)
+{
+ setfloatingbox(0, 0, arg->i, 0);
+}
+
+void
+setfloatingheight(const Arg *arg)
+{
+ setfloatingbox(0, 0, 0, arg->i);
+}
+
void
setfullscreen(Client *c, int fullscreen)
{
--
2.44.0