moveresizekb: support floating layout

This commit is contained in:
C4FE1
2026-06-10 20:04:36 -03:00
parent 0935f95e01
commit d8046ab6ec
2 changed files with 34 additions and 30 deletions
+2 -2
View File
@@ -13,8 +13,8 @@ This allows the user to change size and placement of floating windows using only
| <kbd>MODKEY</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | grow width 40px | | <kbd>MODKEY</kbd> + <kbd>Shift</kbd> + <kbd>Right</kbd> | grow width 40px |
### Download ### Download
- [git branch](https://codeberg.org/wochap/dwl/src/branch/v0.5/moveresizekb) - [v0.8](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/moveresizekb/moveresizekb.patch)
- [v0.5](https://codeberg.org/dwl/dwl-patches/raw/branch/main/patches/moveresizekb/moveresizekb.patch)
### Authors ### Authors
- [cana](https://codeberg.org/cana)
- [wochap](https://codeberg.org/wochap) - [wochap](https://codeberg.org/wochap)
+32 -28
View File
@@ -1,38 +1,38 @@
From c8af428f964679089599e4ffbe7d28d08a4e875f Mon Sep 17 00:00:00 2001 From f19c162ba64c2c4860e5d16e48e08cebd7a7e46c Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com> From: C4FE1 <heitorcdesousa13@gmail.com>
Date: Tue, 5 Mar 2024 23:42:55 -0500 Date: Wed, 10 Jun 2026 19:50:26 -0300
Subject: [PATCH] implement keybindings to move and resize focused floating Subject: [PATCH] Change moveresizekb logic to allow it's use in floating
window (NULL) Layout
--- ---
config.def.h | 8 ++++++++ config.def.h | 8 ++++++++
dwl.c | 19 +++++++++++++++++++ dwl.c | 23 +++++++++++++++++++++++
2 files changed, 27 insertions(+) 2 files changed, 31 insertions(+)
diff --git a/config.def.h b/config.def.h diff --git a/config.def.h b/config.def.h
index db0babc..d0570b8 100644 index 8a6eda0..b8398f9 100644
--- a/config.def.h --- a/config.def.h
+++ b/config.def.h +++ b/config.def.h
@@ -135,6 +135,14 @@ static const Key keys[] = { @@ -138,6 +138,14 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} }, { MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 40, 0, 0 }}}, + { MODKEY, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 40, 0, 0 }}},
+ { MODKEY, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, -40, 0, 0 }}}, + { MODKEY, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, -40, 0, 0 }}},
+ { MODKEY, XKB_KEY_Right, moveresizekb, {.v = (int []){ 40, 0, 0, 0 }}}, + { MODKEY, XKB_KEY_Right, moveresizekb, {.v = (int []){ 40, 0, 0, 0 }}},
+ { MODKEY, XKB_KEY_Left, moveresizekb, {.v = (int []){ -40, 0, 0, 0 }}}, + { MODKEY, XKB_KEY_Left, moveresizekb, {.v = (int []){ -40, 0, 0, 0 }}},
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 0, 0, 40 }}}, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Down, moveresizekb, {.v = (int []){ 0, 0, 0, 40 }}},
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, 0, 0, -40 }}}, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Up, moveresizekb, {.v = (int []){ 0, 0, 0, -40 }}},
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, moveresizekb, {.v = (int []){ 0, 0, 40, 0 }}}, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Right, moveresizekb, {.v = (int []){ 0, 0, 40, 0 }}},
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, moveresizekb, {.v = (int []){ 0, 0, -40, 0 }}}, + { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Left, moveresizekb, {.v = (int []){ 0, 0, -40, 0 }}},
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index ef27a1d..251472b 100644 index 44f3ad9..a6450f5 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -313,6 +313,7 @@ static void tagmon(const Arg *arg); @@ -336,6 +336,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m); static void tile(Monitor *m);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg); static void togglefullscreen(const Arg *arg);
@@ -40,7 +40,7 @@ index ef27a1d..251472b 100644
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg); static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data); static void unlocksession(struct wl_listener *listener, void *data);
@@ -2454,6 +2455,24 @@ togglefullscreen(const Arg *arg) @@ -2760,6 +2761,28 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen); setfullscreen(sel, !sel->isfullscreen);
} }
@@ -50,7 +50,11 @@ index ef27a1d..251472b 100644
+ Client *c = focustop(selmon); + Client *c = focustop(selmon);
+ Monitor *m = selmon; + Monitor *m = selmon;
+ +
+ if(!(m && arg && arg->v && c && c->isfloating)) { + if(!(m && arg && arg->v && c)){
+ return;
+ }
+
+ if(!(c->isfloating || m->lt[m->sellt]->arrange == NULL)){
+ return; + return;
+ } + }
+ +
@@ -66,5 +70,5 @@ index ef27a1d..251472b 100644
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {
-- --
2.42.0 2.54.0