diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-15 16:47:02 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-18 09:18:32 +1000 |
commit | a36625a482585e86d465df1eaa3669c1c4390a20 (patch) | |
tree | fcc64fb33bea1347c634b8a2363cdbc13b93ab4b /sway/input/cursor.c | |
parent | Merge pull request #2472 from RyanDwyer/refactor-seat-get-focus (diff) | |
download | sway-a36625a482585e86d465df1eaa3669c1c4390a20.tar.gz sway-a36625a482585e86d465df1eaa3669c1c4390a20.tar.zst sway-a36625a482585e86d465df1eaa3669c1c4390a20.zip |
Implement mousedown operation
This allows you to move the cursor off the surface while dragging its
scrollbar.
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 23 |
1 files changed, 23 insertions, 0 deletions
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, | |||
215 | return edge; | 215 | return edge; |
216 | } | 216 | } |
217 | 217 | ||
218 | static void handle_mousedown_motion(struct sway_seat *seat, | ||
219 | struct sway_cursor *cursor, uint32_t time_msec) { | ||
220 | struct sway_container *con = seat->op_container; | ||
221 | if (seat_is_input_allowed(seat, con->sway_view->surface)) { | ||
222 | double moved_x = cursor->cursor->x - seat->op_ref_lx; | ||
223 | double moved_y = cursor->cursor->y - seat->op_ref_ly; | ||
224 | double sx = seat->op_ref_con_lx + moved_x; | ||
225 | double sy = seat->op_ref_con_ly + moved_y; | ||
226 | wlr_seat_pointer_notify_motion(seat->wlr_seat, time_msec, sx, sy); | ||
227 | } | ||
228 | } | ||
229 | |||
218 | static void handle_move_motion(struct sway_seat *seat, | 230 | static void handle_move_motion(struct sway_seat *seat, |
219 | struct sway_cursor *cursor) { | 231 | struct sway_cursor *cursor) { |
220 | struct sway_container *con = seat->op_container; | 232 | struct sway_container *con = seat->op_container; |
@@ -397,6 +409,9 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
397 | 409 | ||
398 | if (seat->operation != OP_NONE) { | 410 | if (seat->operation != OP_NONE) { |
399 | switch (seat->operation) { | 411 | switch (seat->operation) { |
412 | case OP_MOUSEDOWN: | ||
413 | handle_mousedown_motion(seat, cursor, time_msec); | ||
414 | break; | ||
400 | case OP_MOVE: | 415 | case OP_MOVE: |
401 | handle_move_motion(seat, cursor); | 416 | handle_move_motion(seat, cursor); |
402 | break; | 417 | break; |
@@ -743,6 +758,14 @@ void dispatch_cursor_button(struct sway_cursor *cursor, | |||
743 | } | 758 | } |
744 | } | 759 | } |
745 | 760 | ||
761 | // Handle mousedown on a container surface | ||
762 | if (surface && cont && state == WLR_BUTTON_PRESSED) { | ||
763 | seat_set_focus(seat, cont); | ||
764 | seat_pointer_notify_button(seat, time_msec, button, state); | ||
765 | seat_begin_mousedown(seat, cont, button, sx, sy); | ||
766 | return; | ||
767 | } | ||
768 | |||
746 | // Handle clicking a container surface | 769 | // Handle clicking a container surface |
747 | if (cont) { | 770 | if (cont) { |
748 | seat_set_focus(seat, cont); | 771 | seat_set_focus(seat, cont); |