From c8af428f964679089599e4ffbe7d28d08a4e875f Mon Sep 17 00:00:00 2001 From: wochap Date: Tue, 5 Mar 2024 23:42:55 -0500 Subject: [PATCH] implement keybindings to move and resize focused floating window --- config.def.h | 8 ++++++++ dwl.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/config.def.h b/config.def.h index db0babc..d0570b8 100644 --- a/config.def.h +++ b/config.def.h @@ -135,6 +135,14 @@ static const Key keys[] = { { MODKEY, XKB_KEY_space, setlayout, {0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} }, { MODKEY, XKB_KEY_e, togglefullscreen, {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_Right, 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_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_Left, moveresizekb, {.v = (int []){ 0, 0, -40, 0 }}}, { MODKEY, XKB_KEY_0, view, {.ui = ~0} }, { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} }, { MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} }, diff --git a/dwl.c b/dwl.c index ef27a1d..251472b 100644 --- a/dwl.c +++ b/dwl.c @@ -313,6 +313,7 @@ static void tagmon(const Arg *arg); static void tile(Monitor *m); static void togglefloating(const Arg *arg); static void togglefullscreen(const Arg *arg); +static void moveresizekb(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unlocksession(struct wl_listener *listener, void *data); @@ -2454,6 +2455,24 @@ togglefullscreen(const Arg *arg) setfullscreen(sel, !sel->isfullscreen); } +void +moveresizekb(const Arg *arg) +{ + Client *c = focustop(selmon); + Monitor *m = selmon; + + if(!(m && arg && arg->v && c && c->isfloating)) { + return; + } + + resize(c, (struct wlr_box){ + .x = c->geom.x + ((int *)arg->v)[0], + .y = c->geom.y + ((int *)arg->v)[1], + .width = c->geom.width + ((int *)arg->v)[2], + .height = c->geom.height + ((int *)arg->v)[3], + }, 1); +} + void toggletag(const Arg *arg) { -- 2.42.0