update relative-mouse-resize for HEAD

This commit is contained in:
wochap 2024-04-11 18:20:49 -05:00
parent b828e21717
commit 655fd2916c
No known key found for this signature in database
GPG Key ID: FE4CF844E73095E1

View File

@ -1,20 +1,20 @@
From cd7dec8ff61fef268a5c5053d33eb202b09ea3f6 Mon Sep 17 00:00:00 2001 From 67e4ca7a35e38c6874aa614a04da4c1b04577c19 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com> From: wochap <gean.marroquin@gmail.com>
Date: Wed, 6 Mar 2024 09:51:29 -0500 Date: Thu, 11 Apr 2024 14:17:30 -0500
Subject: [PATCH] implement relative mouse resize Subject: [PATCH] mouse resize the window in the quadrant that the resize
starts at
the mouse willresize the window in the quadrant that the resize starts at
inspiration: https://github.com/djpohly/dwl/wiki/relativemouseresize inspiration: https://github.com/djpohly/dwl/wiki/relativemouseresize
--- ---
dwl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- dwl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 59 insertions(+), 7 deletions(-) 1 file changed, 59 insertions(+), 7 deletions(-)
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index ef27a1d..deb8c76 100644 index bf763df..f78ac34 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -370,7 +370,8 @@ static struct wlr_seat *seat; @@ -398,7 +398,8 @@ static KeyboardGroup vkb_group = {0};
static struct wl_list keyboards; static struct wlr_surface *held_grab;
static unsigned int cursor_mode; static unsigned int cursor_mode;
static Client *grabc; static Client *grabc;
-static int grabcx, grabcy; /* client-relative */ -static int grabcx, grabcy; /* client-relative */
@ -23,37 +23,37 @@ index ef27a1d..deb8c76 100644
static struct wlr_output_layout *output_layout; static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom; static struct wlr_box sgeom;
@@ -1645,8 +1646,27 @@ motionnotify(uint32_t time) @@ -1737,8 +1738,27 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
.width = grabc->geom.width, .height = grabc->geom.height}, 1); .width = grabc->geom.width, .height = grabc->geom.height}, 1);
return; return;
} else if (cursor_mode == CurResize) { } else if (cursor_mode == CurResize) {
- resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y, - resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
- .width = cursor->x - grabc->geom.x, .height = cursor->y - grabc->geom.y}, 1); - .width = ROUND(cursor->x) - grabc->geom.x, .height = ROUND(cursor->y) - grabc->geom.y}, 1);
+ if (grabcenterx < grabx) { + if (grabcenterx < grabx) {
+ if (grabcentery < graby) { + if (grabcentery < graby) {
+ /* bottom-right */ + /* bottom-right */
+ resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = initial_grabc.geom.y, + resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = initial_grabc.geom.y,
+ .width = cursor->x - initial_grabc.geom.x, .height = cursor->y - initial_grabc.geom.y}, 1); + .width = ROUND(cursor->x) - initial_grabc.geom.x, .height = ROUND(cursor->y) - initial_grabc.geom.y}, 1);
+ } else { + } else {
+ /* top-right */ + /* top-right */
+ resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = cursor->y, + resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = ROUND(cursor->y),
+ .width = cursor->x - initial_grabc.geom.x, .height = initial_grabc.geom.y + initial_grabc.geom.height - cursor->y}, 1); + .width = ROUND(cursor->x) - initial_grabc.geom.x, .height = initial_grabc.geom.y + initial_grabc.geom.height - ROUND(cursor->y)}, 1);
+ } + }
+ } else { + } else {
+ if (grabcentery < graby) { + if (grabcentery < graby) {
+ /* bottom-left */ + /* bottom-left */
+ resize(grabc, (struct wlr_box){.x = cursor->x, .y = initial_grabc.geom.y, + resize(grabc, (struct wlr_box){.x = ROUND(cursor->x), .y = initial_grabc.geom.y,
+ .width = initial_grabc.geom.x + initial_grabc.geom.width - cursor->x, .height = cursor->y - initial_grabc.geom.y}, 1); + .width = initial_grabc.geom.x + initial_grabc.geom.width - ROUND(cursor->x), .height = ROUND(cursor->y) - initial_grabc.geom.y}, 1);
+ } else { + } else {
+ /* top-left */ + /* top-left */
+ resize(grabc, (struct wlr_box){.x = cursor->x, .y = cursor->y, + resize(grabc, (struct wlr_box){.x = ROUND(cursor->x), .y = ROUND(cursor->y),
+ .width = initial_grabc.geom.x + initial_grabc.geom.width - cursor->x, .height = initial_grabc.geom.y + initial_grabc.geom.height - cursor->y}, 1); + .width = initial_grabc.geom.x + initial_grabc.geom.width - ROUND(cursor->x), .height = initial_grabc.geom.y + initial_grabc.geom.height - ROUND(cursor->y)}, 1);
+ } + }
+ } + }
return; return;
} }
@@ -1707,10 +1727,42 @@ moveresize(const Arg *arg) @@ -1797,10 +1817,42 @@ moveresize(const Arg *arg)
case CurResize: case CurResize:
/* Doesn't work for X11 output - the next absolute motion event /* Doesn't work for X11 output - the next absolute motion event
* returns the cursor to where it started */ * returns the cursor to where it started */
@ -62,10 +62,10 @@ index ef27a1d..deb8c76 100644
- grabc->geom.y + grabc->geom.height); - grabc->geom.y + grabc->geom.height);
- wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize"); - wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize");
+ initial_grabc = *grabc; + initial_grabc = *grabc;
+ grabx = cursor->x; + grabx = ROUND(cursor->x);
+ graby = cursor->y; + graby = ROUND(cursor->y);
+ grabcx = cursor->x - grabc->geom.x; + grabcx = ROUND(cursor->x) - grabc->geom.x;
+ grabcy = cursor->y - grabc->geom.y; + grabcy = ROUND(cursor->y) - grabc->geom.y;
+ grabcenterx = grabc->geom.width / 2 + grabc->geom.x; + grabcenterx = grabc->geom.width / 2 + grabc->geom.x;
+ grabcentery = grabc->geom.height / 2 + grabc->geom.y; + grabcentery = grabc->geom.height / 2 + grabc->geom.y;
+ if (grabcenterx < grabx) { + if (grabcenterx < grabx) {
@ -101,6 +101,5 @@ index ef27a1d..deb8c76 100644
} }
} }
-- --
2.42.0 2.43.2