From a36625a482585e86d465df1eaa3669c1c4390a20 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 15 Aug 2018 16:47:02 +1000 Subject: Implement mousedown operation This allows you to move the cursor off the surface while dragging its scrollbar. --- sway/input/cursor.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'sway/input/cursor.c') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 3b70b471..bd0030f0 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -215,6 +215,18 @@ static enum wlr_edges find_resize_edge(struct sway_container *cont, return edge; } +static void handle_mousedown_motion(struct sway_seat *seat, + struct sway_cursor *cursor, uint32_t time_msec) { + struct sway_container *con = seat->op_container; + if (seat_is_input_allowed(seat, con->sway_view->surface)) { + double moved_x = cursor->cursor->x - seat->op_ref_lx; + double moved_y = cursor->cursor->y - seat->op_ref_ly; + double sx = seat->op_ref_con_lx + moved_x; + double sy = seat->op_ref_con_ly + moved_y; + wlr_seat_pointer_notify_motion(seat->wlr_seat, time_msec, sx, sy); + } +} + static void handle_move_motion(struct sway_seat *seat, struct sway_cursor *cursor) { struct sway_container *con = seat->op_container; @@ -397,6 +409,9 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, if (seat->operation != OP_NONE) { switch (seat->operation) { + case OP_MOUSEDOWN: + handle_mousedown_motion(seat, cursor, time_msec); + break; case OP_MOVE: handle_move_motion(seat, cursor); break; @@ -743,6 +758,14 @@ void dispatch_cursor_button(struct sway_cursor *cursor, } } + // Handle mousedown on a container surface + if (surface && cont && state == WLR_BUTTON_PRESSED) { + seat_set_focus(seat, cont); + seat_pointer_notify_button(seat, time_msec, button, state); + seat_begin_mousedown(seat, cont, button, sx, sy); + return; + } + // Handle clicking a container surface if (cont) { seat_set_focus(seat, cont); -- cgit v1.2.3 From b637b61a7a25219991280717d9bf8a463ed4d8a8 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 16 Aug 2018 09:12:48 +1000 Subject: Rename mousedown to down and make seat operation a named enum --- sway/input/cursor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sway/input/cursor.c') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index bd0030f0..5a2743e3 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -215,7 +215,7 @@ static enum wlr_edges find_resize_edge(struct sway_container *cont, return edge; } -static void handle_mousedown_motion(struct sway_seat *seat, +static void handle_down_motion(struct sway_seat *seat, struct sway_cursor *cursor, uint32_t time_msec) { struct sway_container *con = seat->op_container; if (seat_is_input_allowed(seat, con->sway_view->surface)) { @@ -409,8 +409,8 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, if (seat->operation != OP_NONE) { switch (seat->operation) { - case OP_MOUSEDOWN: - handle_mousedown_motion(seat, cursor, time_msec); + case OP_DOWN: + handle_down_motion(seat, cursor, time_msec); break; case OP_MOVE: handle_move_motion(seat, cursor); @@ -762,7 +762,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor, if (surface && cont && state == WLR_BUTTON_PRESSED) { seat_set_focus(seat, cont); seat_pointer_notify_button(seat, time_msec, button, state); - seat_begin_mousedown(seat, cont, button, sx, sy); + seat_begin_down(seat, cont, button, sx, sy); return; } -- cgit v1.2.3 From 07a897b3b797b99022a9dfffffc0af2ff50aea85 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 18 Aug 2018 09:29:18 +1000 Subject: Don't send motion if the cursor hasn't moved Prevents GTK+ comboboxes from immediately closing. --- sway/input/cursor.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sway/input/cursor.c') diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 5a2743e3..37fb203d 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -225,6 +225,7 @@ static void handle_down_motion(struct sway_seat *seat, double sy = seat->op_ref_con_ly + moved_y; wlr_seat_pointer_notify_motion(seat->wlr_seat, time_msec, sx, sy); } + seat->op_moved = true; } static void handle_move_motion(struct sway_seat *seat, -- cgit v1.2.3