aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-08-18 09:32:04 -0400
committerLibravatar GitHub <noreply@github.com>2018-08-18 09:32:04 -0400
commitd4a32800d5eb938a769d7802b23f4a0f43cadaef (patch)
tree3e6b7b1c065ce043fc4f96a5250f88d9bf3d040c /sway/input/cursor.c
parentMerge pull request #2481 from RyanDwyer/rename-functions (diff)
parentDon't send motion if the cursor hasn't moved (diff)
downloadsway-d4a32800d5eb938a769d7802b23f4a0f43cadaef.tar.gz
sway-d4a32800d5eb938a769d7802b23f4a0f43cadaef.tar.zst
sway-d4a32800d5eb938a769d7802b23f4a0f43cadaef.zip
Merge pull request #2460 from RyanDwyer/implement-mousedown
Implement mousedown operation
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 6208ce32..762b8081 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -215,6 +215,19 @@ static enum wlr_edges find_resize_edge(struct sway_container *cont,
215 return edge; 215 return edge;
216} 216}
217 217
218static void handle_down_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 seat->op_moved = true;
229}
230
218static void handle_move_motion(struct sway_seat *seat, 231static void handle_move_motion(struct sway_seat *seat,
219 struct sway_cursor *cursor) { 232 struct sway_cursor *cursor) {
220 struct sway_container *con = seat->op_container; 233 struct sway_container *con = seat->op_container;
@@ -397,6 +410,9 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
397 410
398 if (seat->operation != OP_NONE) { 411 if (seat->operation != OP_NONE) {
399 switch (seat->operation) { 412 switch (seat->operation) {
413 case OP_DOWN:
414 handle_down_motion(seat, cursor, time_msec);
415 break;
400 case OP_MOVE: 416 case OP_MOVE:
401 handle_move_motion(seat, cursor); 417 handle_move_motion(seat, cursor);
402 break; 418 break;
@@ -743,6 +759,14 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
743 } 759 }
744 } 760 }
745 761
762 // Handle mousedown on a container surface
763 if (surface && cont && state == WLR_BUTTON_PRESSED) {
764 seat_set_focus(seat, cont);
765 seat_pointer_notify_button(seat, time_msec, button, state);
766 seat_begin_down(seat, cont, button, sx, sy);
767 return;
768 }
769
746 // Handle clicking a container surface 770 // Handle clicking a container surface
747 if (cont) { 771 if (cont) {
748 seat_set_focus(seat, cont); 772 seat_set_focus(seat, cont);