From 7e3ca8238cb657091879a811b2f3cd254bd6d050 Mon Sep 17 00:00:00 2001 From: speckitor Date: Fri, 3 Apr 2026 12:43:17 +0700 Subject: [PATCH] fix resizing and moving window when cursor is not inside of it --- src/cursor.c | 2 +- src/server.c | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/cursor.c b/src/cursor.c index eba306f..accc1ea 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -47,7 +47,7 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new if (max_height == 0) max_height = 10000; - + if (new_geometry->width - 2 * bw >= min_width && new_geometry->width - 2 * bw <= max_width) { toplevel->geometry.x = new_geometry->x; toplevel->geometry.width = new_geometry->width; diff --git a/src/server.c b/src/server.c index faca282..2b9eb26 100644 --- a/src/server.c +++ b/src/server.c @@ -149,22 +149,23 @@ void server_cursor_button(struct wl_listener *listener, void *data) double sx, sy; struct wlr_surface *surface = NULL; struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy); - focus_toplevel(toplevel); - struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(server->seat); - uint32_t mods = wlr_keyboard_get_modifiers(keyboard); - if (mods & ABSINTHE_CURSOR_MOD) { - if (event->button == ABSINTHE_CURSOR_MOVE_BUTTON) { - server->cursor_mode = ABSINTHE_CURSOR_MOVE; - wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "all-scroll"); - handled = true; - } else if (event->button == ABSINTHE_CURSOR_RESIZE_BUTTON) { - server->cursor_mode = ABSINTHE_CURSOR_RESIZE; - handled = true; - } - } if (toplevel) { + struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(server->seat); + uint32_t mods = wlr_keyboard_get_modifiers(keyboard); + if (mods & ABSINTHE_CURSOR_MOD) { + if (event->button == ABSINTHE_CURSOR_MOVE_BUTTON) { + server->cursor_mode = ABSINTHE_CURSOR_MOVE; + wlr_cursor_set_xcursor(server->cursor, server->cursor_mgr, "all-scroll"); + handled = true; + } else if (event->button == ABSINTHE_CURSOR_RESIZE_BUTTON) { + server->cursor_mode = ABSINTHE_CURSOR_RESIZE; + handled = true; + } + } + + focus_toplevel(toplevel); server->grab_x = server->cursor->x; server->grab_y = server->cursor->y;