diff options
author | Forrest Bushstone <fgb.1@protonmail.com> | 2024-06-12 14:04:43 -0400 |
---|---|---|
committer | Leonardo Hernández Hernández <leohdz172@proton.me> | 2024-06-14 01:43:32 -0600 |
commit | c2e7350f2ef4f07810c8fa49bed3e8db37faa058 (patch) | |
tree | 8d8fd1562ce439498ba62d0d9d08de5f36fbc48e | |
parent | 7570dc0a41c4b2a1952f7275327d7168e45129fa (diff) |
Make sure toplevel_from_wlr_surface is called with a valid surface pointer
-rw-r--r-- | dwl.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -397,7 +397,6 @@ static struct wl_listener lock_listener = {.notify = locksession}; static struct wlr_seat *seat; static KeyboardGroup *kb_group; -static struct wlr_surface *held_grab; static unsigned int cursor_mode; static Client *grabc; static int grabcx, grabcy; /* client-relative */ @@ -603,7 +602,6 @@ buttonpress(struct wl_listener *listener, void *data) switch (event->state) { case WLR_BUTTON_PRESSED: cursor_mode = CurPressed; - held_grab = seat->pointer_state.focused_surface; if (locked) break; @@ -623,7 +621,6 @@ buttonpress(struct wl_listener *listener, void *data) } break; case WLR_BUTTON_RELEASED: - held_grab = NULL; /* If you released any buttons, we exit interactive move/resize mode. */ /* TODO should reset to the pointer focus's current setcursor */ if (!locked && cursor_mode != CurNormal && cursor_mode != CurPressed) { @@ -1757,6 +1754,18 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d struct wlr_surface *surface = NULL; struct wlr_pointer_constraint_v1 *constraint; + /* Find the client under the pointer and send the event along. */ + xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy); + + if (cursor_mode == CurPressed && !seat->drag + && surface != seat->pointer_state.focused_surface + && toplevel_from_wlr_surface(seat->pointer_state.focused_surface, &w, &l) >= 0) { + c = w; + surface = seat->pointer_state.focused_surface; + sx = cursor->x - (l ? l->geom.x : w->geom.x); + sy = cursor->y - (l ? l->geom.y : w->geom.y); + } + /* time is 0 in internal calls meant to restore pointer focus. */ if (time) { wlr_relative_pointer_manager_v1_send_relative_motion( @@ -1805,17 +1814,6 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d return; } - /* Find the client under the pointer and send the event along. */ - xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy); - - if (cursor_mode == CurPressed && !seat->drag && surface != held_grab - && toplevel_from_wlr_surface(held_grab, &w, &l) >= 0) { - c = w; - surface = held_grab; - sx = cursor->x - (l ? l->geom.x : w->geom.x); - sy = cursor->y - (l ? l->geom.y : w->geom.y); - } - /* If there's no client surface under the cursor, set the cursor image to a * default. This is what makes the cursor image appear when you move it * off of a client or over its border. */ |