diff options
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r-- | sway/input/seat.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c index fa41904a..045bf91a 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -954,6 +954,17 @@ struct seat_config *seat_get_config(struct sway_seat *seat) { | |||
954 | return NULL; | 954 | return NULL; |
955 | } | 955 | } |
956 | 956 | ||
957 | void seat_begin_mousedown(struct sway_seat *seat, struct sway_container *con, | ||
958 | uint32_t button, double sx, double sy) { | ||
959 | seat->operation = OP_MOUSEDOWN; | ||
960 | seat->op_container = con; | ||
961 | seat->op_button = button; | ||
962 | seat->op_ref_lx = seat->cursor->cursor->x; | ||
963 | seat->op_ref_ly = seat->cursor->cursor->y; | ||
964 | seat->op_ref_con_lx = sx; | ||
965 | seat->op_ref_con_ly = sy; | ||
966 | } | ||
967 | |||
957 | void seat_begin_move(struct sway_seat *seat, struct sway_container *con, | 968 | void seat_begin_move(struct sway_seat *seat, struct sway_container *con, |
958 | uint32_t button) { | 969 | uint32_t button) { |
959 | if (!seat->cursor) { | 970 | if (!seat->cursor) { |
@@ -1007,6 +1018,7 @@ void seat_begin_resize_tiling(struct sway_seat *seat, | |||
1007 | } | 1018 | } |
1008 | 1019 | ||
1009 | void seat_end_mouse_operation(struct sway_seat *seat) { | 1020 | void seat_end_mouse_operation(struct sway_seat *seat) { |
1021 | int operation = seat->operation; | ||
1010 | if (seat->operation == OP_MOVE) { | 1022 | if (seat->operation == OP_MOVE) { |
1011 | // We "move" the container to its own location so it discovers its | 1023 | // We "move" the container to its own location so it discovers its |
1012 | // output again. | 1024 | // output again. |
@@ -1015,7 +1027,17 @@ void seat_end_mouse_operation(struct sway_seat *seat) { | |||
1015 | } | 1027 | } |
1016 | seat->operation = OP_NONE; | 1028 | seat->operation = OP_NONE; |
1017 | seat->op_container = NULL; | 1029 | seat->op_container = NULL; |
1018 | cursor_set_image(seat->cursor, "left_ptr", NULL); | 1030 | if (operation == OP_MOUSEDOWN) { |
1031 | // Set the cursor's previous coords to the x/y at the start of the | ||
1032 | // operation, so the container change will be detected if using | ||
1033 | // focus_follows_mouse and the cursor moved off the original container | ||
1034 | // during the operation. | ||
1035 | seat->cursor->previous.x = seat->op_ref_lx; | ||
1036 | seat->cursor->previous.y = seat->op_ref_ly; | ||
1037 | cursor_send_pointer_motion(seat->cursor, 0, true); | ||
1038 | } else { | ||
1039 | cursor_set_image(seat->cursor, "left_ptr", NULL); | ||
1040 | } | ||
1019 | } | 1041 | } |
1020 | 1042 | ||
1021 | void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, | 1043 | void seat_pointer_notify_button(struct sway_seat *seat, uint32_t time_msec, |