From 98c7cd9d6753ddd9be423ec7e304de7f51cb025c Mon Sep 17 00:00:00 2001 From: Keshto Date: Fri, 15 Jul 2022 18:28:32 +0000 Subject: [PATCH 1/2] Properly handle cursor motion when button is held. --- tinywl/tinywl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 4fc8477c7..79337524d 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -31,6 +31,7 @@ enum tinywl_cursor_mode { TINYWL_CURSOR_PASSTHROUGH, TINYWL_CURSOR_MOVE, TINYWL_CURSOR_RESIZE, + TINYWL_CURSOR_DOWN, }; struct tinywl_server { @@ -447,7 +448,12 @@ static void process_cursor_motion(struct tinywl_server *server, uint32_t time) { wlr_xcursor_manager_set_cursor_image( server->cursor_mgr, "left_ptr", server->cursor); } - if (surface) { + if (server->cursor_mode == TINYWL_CURSOR_DOWN && view != server->grabbed_view) { + /* Send pointer events to the view which the mouse button is down on. */ + view = server->grabbed_view; + sx = server->cursor->x - view->x; + sy = server->cursor->y - view->y; + } else if (surface) { /* * Send pointer enter and motion events. * @@ -519,6 +525,10 @@ static void server_cursor_button(struct wl_listener *listener, void *data) { } else { /* Focus that client if the button was _pressed_ */ focus_view(view, surface); + + /* Change the cursor_mode while the button is pressed */ + server->grabbed_view = view; + server->cursor_mode = TINYWL_CURSOR_DOWN; } } From d9a7896fb93d59f26c6adfd5c20871dc9f28db4d Mon Sep 17 00:00:00 2001 From: Keshto Date: Sat, 16 Jul 2022 15:01:44 +0000 Subject: [PATCH 2/2] Forgot notify --- tinywl/tinywl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tinywl/tinywl.c b/tinywl/tinywl.c index 79337524d..6e766099d 100644 --- a/tinywl/tinywl.c +++ b/tinywl/tinywl.c @@ -453,6 +453,7 @@ static void process_cursor_motion(struct tinywl_server *server, uint32_t time) { view = server->grabbed_view; sx = server->cursor->x - view->x; sy = server->cursor->y - view->y; + wlr_seat_pointer_notify_motion(seat, time, sx, sy); } else if (surface) { /* * Send pointer enter and motion events.