From 0bd725d0786248e1dfedbe6aa7453edfe736de43 Mon Sep 17 00:00:00 2001 From: wochap Date: Tue, 9 Jul 2024 15:34:37 +0000 Subject: [PATCH] sync patch with latest dwl --- .../relative-mouse-resize.patch | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/patches/relative-mouse-resize/relative-mouse-resize.patch b/patches/relative-mouse-resize/relative-mouse-resize.patch index 55e7470..e1dfc57 100644 --- a/patches/relative-mouse-resize/relative-mouse-resize.patch +++ b/patches/relative-mouse-resize/relative-mouse-resize.patch @@ -1,20 +1,18 @@ -From 67e4ca7a35e38c6874aa614a04da4c1b04577c19 Mon Sep 17 00:00:00 2001 +From 5c75c67fe49e5ab89e4a61dfb2fe74c768477b90 Mon Sep 17 00:00:00 2001 From: wochap -Date: Thu, 11 Apr 2024 14:17:30 -0500 -Subject: [PATCH] mouse resize the window in the quadrant that the resize - starts at +Date: Fri, 5 Jul 2024 11:13:53 -0500 +Subject: [PATCH] implement relative-muse-resize -inspiration: https://github.com/djpohly/dwl/wiki/relativemouseresize --- dwl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/dwl.c b/dwl.c -index bf763df..f78ac34 100644 +index dc0437e..ebf9ef1 100644 --- a/dwl.c +++ b/dwl.c -@@ -398,7 +398,8 @@ static KeyboardGroup vkb_group = {0}; - static struct wlr_surface *held_grab; +@@ -401,7 +401,8 @@ static struct wlr_seat *seat; + static KeyboardGroup *kb_group; static unsigned int cursor_mode; static Client *grabc; -static int grabcx, grabcy; /* client-relative */ @@ -23,37 +21,37 @@ index bf763df..f78ac34 100644 static struct wlr_output_layout *output_layout; static struct wlr_box sgeom; -@@ -1737,8 +1738,27 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d +@@ -1821,8 +1822,27 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d .width = grabc->geom.width, .height = grabc->geom.height}, 1); return; } else if (cursor_mode == CurResize) { - resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y, -- .width = ROUND(cursor->x) - grabc->geom.x, .height = ROUND(cursor->y) - grabc->geom.y}, 1); +- .width = (int)round(cursor->x) - grabc->geom.x, .height = (int)round(cursor->y) - grabc->geom.y}, 1); + if (grabcenterx < grabx) { + if (grabcentery < graby) { + /* bottom-right */ + resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = initial_grabc.geom.y, -+ .width = ROUND(cursor->x) - initial_grabc.geom.x, .height = ROUND(cursor->y) - initial_grabc.geom.y}, 1); ++ .width = (int)round(cursor->x) - initial_grabc.geom.x, .height = (int)round(cursor->y) - initial_grabc.geom.y}, 1); + } else { + /* top-right */ -+ resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = ROUND(cursor->y), -+ .width = ROUND(cursor->x) - initial_grabc.geom.x, .height = initial_grabc.geom.y + initial_grabc.geom.height - ROUND(cursor->y)}, 1); ++ resize(grabc, (struct wlr_box){.x = initial_grabc.geom.x, .y = (int)round(cursor->y), ++ .width = (int)round(cursor->x) - initial_grabc.geom.x, .height = initial_grabc.geom.y + initial_grabc.geom.height - (int)round(cursor->y)}, 1); + } + } else { + if (grabcentery < graby) { + /* bottom-left */ -+ resize(grabc, (struct wlr_box){.x = ROUND(cursor->x), .y = initial_grabc.geom.y, -+ .width = initial_grabc.geom.x + initial_grabc.geom.width - ROUND(cursor->x), .height = ROUND(cursor->y) - initial_grabc.geom.y}, 1); ++ resize(grabc, (struct wlr_box){.x = (int)round(cursor->x), .y = initial_grabc.geom.y, ++ .width = initial_grabc.geom.x + initial_grabc.geom.width - (int)round(cursor->x), .height = (int)round(cursor->y) - initial_grabc.geom.y}, 1); + } else { + /* top-left */ -+ resize(grabc, (struct wlr_box){.x = ROUND(cursor->x), .y = ROUND(cursor->y), -+ .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); ++ resize(grabc, (struct wlr_box){.x = (int)round(cursor->x), .y = (int)round(cursor->y), ++ .width = initial_grabc.geom.x + initial_grabc.geom.width - (int)round(cursor->x), .height = initial_grabc.geom.y + initial_grabc.geom.height - (int)round(cursor->y)}, 1); + } + } return; } -@@ -1797,10 +1817,42 @@ moveresize(const Arg *arg) +@@ -1870,10 +1890,42 @@ moveresize(const Arg *arg) case CurResize: /* Doesn't work for X11 output - the next absolute motion event * returns the cursor to where it started */ @@ -62,10 +60,10 @@ index bf763df..f78ac34 100644 - grabc->geom.y + grabc->geom.height); - wlr_cursor_set_xcursor(cursor, cursor_mgr, "se-resize"); + initial_grabc = *grabc; -+ grabx = ROUND(cursor->x); -+ graby = ROUND(cursor->y); -+ grabcx = ROUND(cursor->x) - grabc->geom.x; -+ grabcy = ROUND(cursor->y) - grabc->geom.y; ++ grabx = (int)round(cursor->x); ++ graby = (int)round(cursor->y); ++ grabcx = (int)round(cursor->x) - grabc->geom.x; ++ grabcy = (int)round(cursor->y) - grabc->geom.y; + grabcenterx = grabc->geom.width / 2 + grabc->geom.x; + grabcentery = grabc->geom.height / 2 + grabc->geom.y; + if (grabcenterx < grabx) { @@ -101,5 +99,4 @@ index bf763df..f78ac34 100644 } } -- -2.43.2 - +2.45.1 \ No newline at end of file