diff options
-rw-r--r-- | include/sway/input/cursor.h | 1 | ||||
-rw-r--r-- | include/sway/input/seat.h | 3 | ||||
-rw-r--r-- | sway/input/cursor.c | 21 | ||||
-rw-r--r-- | sway/input/seatop_default.c | 57 |
4 files changed, 45 insertions, 37 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 3f46c548..1b31143d 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -85,6 +85,7 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat); | |||
85 | */ | 85 | */ |
86 | void cursor_rebase(struct sway_cursor *cursor); | 86 | void cursor_rebase(struct sway_cursor *cursor); |
87 | void cursor_rebase_all(void); | 87 | void cursor_rebase_all(void); |
88 | void cursor_update_image(struct sway_cursor *cursor, struct sway_node *node); | ||
88 | 89 | ||
89 | void cursor_handle_activity(struct sway_cursor *cursor, | 90 | void cursor_handle_activity(struct sway_cursor *cursor, |
90 | enum sway_input_idle_source idle_source); | 91 | enum sway_input_idle_source idle_source); |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 6d7495dd..ad7cac75 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -220,6 +220,9 @@ bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); | |||
220 | 220 | ||
221 | void drag_icon_update_position(struct sway_drag_icon *icon); | 221 | void drag_icon_update_position(struct sway_drag_icon *icon); |
222 | 222 | ||
223 | enum wlr_edges find_resize_edge(struct sway_container *cont, | ||
224 | struct wlr_surface *surface, struct sway_cursor *cursor); | ||
225 | |||
223 | void seatop_begin_default(struct sway_seat *seat); | 226 | void seatop_begin_default(struct sway_seat *seat); |
224 | 227 | ||
225 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, | 228 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index a28da999..f7a3c54e 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -212,6 +212,27 @@ void cursor_rebase_all(void) { | |||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | void cursor_update_image(struct sway_cursor *cursor, | ||
216 | struct sway_node *node) { | ||
217 | if (node && node->type == N_CONTAINER) { | ||
218 | // Try a node's resize edge | ||
219 | enum wlr_edges edge = find_resize_edge(node->sway_container, NULL, cursor); | ||
220 | if (edge == WLR_EDGE_NONE) { | ||
221 | cursor_set_image(cursor, "left_ptr", NULL); | ||
222 | } else if (container_is_floating(node->sway_container)) { | ||
223 | cursor_set_image(cursor, wlr_xcursor_get_resize_name(edge), NULL); | ||
224 | } else { | ||
225 | if (edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)) { | ||
226 | cursor_set_image(cursor, "col-resize", NULL); | ||
227 | } else { | ||
228 | cursor_set_image(cursor, "row-resize", NULL); | ||
229 | } | ||
230 | } | ||
231 | } else { | ||
232 | cursor_set_image(cursor, "left_ptr", NULL); | ||
233 | } | ||
234 | } | ||
235 | |||
215 | static void cursor_hide(struct sway_cursor *cursor) { | 236 | static void cursor_hide(struct sway_cursor *cursor) { |
216 | wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); | 237 | wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); |
217 | cursor->hidden = true; | 238 | cursor->hidden = true; |
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index 8513e314..d9f9e371 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -91,7 +91,7 @@ static enum wlr_edges find_edge(struct sway_container *cont, | |||
91 | * If the cursor is over a _resizable_ edge, return the edge. | 91 | * If the cursor is over a _resizable_ edge, return the edge. |
92 | * Edges that can't be resized are edges of the workspace. | 92 | * Edges that can't be resized are edges of the workspace. |
93 | */ | 93 | */ |
94 | static enum wlr_edges find_resize_edge(struct sway_container *cont, | 94 | enum wlr_edges find_resize_edge(struct sway_container *cont, |
95 | struct wlr_surface *surface, struct sway_cursor *cursor) { | 95 | struct wlr_surface *surface, struct sway_cursor *cursor) { |
96 | enum wlr_edges edge = find_edge(cont, surface, cursor); | 96 | enum wlr_edges edge = find_edge(cont, surface, cursor); |
97 | if (edge && !container_is_floating(cont) && edge_is_external(cont, edge)) { | 97 | if (edge && !container_is_floating(cont) && edge_is_external(cont, edge)) { |
@@ -192,38 +192,6 @@ static void state_add_button(struct seatop_default_event *e, uint32_t button) { | |||
192 | e->pressed_button_count++; | 192 | e->pressed_button_count++; |
193 | } | 193 | } |
194 | 194 | ||
195 | static void cursor_do_rebase(struct sway_cursor *cursor, uint32_t time_msec, | ||
196 | struct sway_node *node, struct wlr_surface *surface, | ||
197 | double sx, double sy) { | ||
198 | struct wlr_seat *wlr_seat = cursor->seat->wlr_seat; | ||
199 | if (surface) { | ||
200 | if (seat_is_input_allowed(cursor->seat, surface)) { | ||
201 | wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy); | ||
202 | } | ||
203 | } else if (node && node->type == N_CONTAINER) { | ||
204 | // Try a node's resize edge | ||
205 | enum wlr_edges edge = find_resize_edge(node->sway_container, surface, cursor); | ||
206 | if (edge == WLR_EDGE_NONE) { | ||
207 | cursor_set_image(cursor, "left_ptr", NULL); | ||
208 | } else if (container_is_floating(node->sway_container)) { | ||
209 | cursor_set_image(cursor, wlr_xcursor_get_resize_name(edge), NULL); | ||
210 | } else { | ||
211 | if (edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)) { | ||
212 | cursor_set_image(cursor, "col-resize", NULL); | ||
213 | } else { | ||
214 | cursor_set_image(cursor, "row-resize", NULL); | ||
215 | } | ||
216 | } | ||
217 | } else { | ||
218 | cursor_set_image(cursor, "left_ptr", NULL); | ||
219 | } | ||
220 | |||
221 | if (surface == NULL) { | ||
222 | wlr_seat_pointer_notify_enter(wlr_seat, NULL, 0, 0); | ||
223 | wlr_seat_pointer_clear_focus(wlr_seat); | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /*----------------------------------\ | 195 | /*----------------------------------\ |
228 | * Functions used by handle_button / | 196 | * Functions used by handle_button / |
229 | *--------------------------------*/ | 197 | *--------------------------------*/ |
@@ -483,9 +451,15 @@ static void handle_motion(struct sway_seat *seat, uint32_t time_msec, | |||
483 | check_focus_follows_mouse(seat, e, node); | 451 | check_focus_follows_mouse(seat, e, node); |
484 | } | 452 | } |
485 | 453 | ||
486 | cursor_do_rebase(cursor, time_msec, node, surface, sx, sy); | 454 | if (surface) { |
487 | if (surface && seat_is_input_allowed(cursor->seat, surface)) { | 455 | if (seat_is_input_allowed(seat, surface)) { |
488 | wlr_seat_pointer_notify_motion(seat->wlr_seat, time_msec, sx, sy); | 456 | wlr_seat_pointer_notify_enter(seat->wlr_seat, surface, sx, sy); |
457 | wlr_seat_pointer_notify_motion(seat->wlr_seat, time_msec, sx, sy); | ||
458 | } | ||
459 | } else { | ||
460 | cursor_update_image(cursor, node); | ||
461 | wlr_seat_pointer_notify_enter(seat->wlr_seat, NULL, 0, 0); | ||
462 | wlr_seat_pointer_clear_focus(seat->wlr_seat); | ||
489 | } | 463 | } |
490 | 464 | ||
491 | struct sway_drag_icon *drag_icon; | 465 | struct sway_drag_icon *drag_icon; |
@@ -622,7 +596,16 @@ static void handle_rebase(struct sway_seat *seat, uint32_t time_msec) { | |||
622 | double sx = 0.0, sy = 0.0; | 596 | double sx = 0.0, sy = 0.0; |
623 | e->previous_node = node_at_coords(seat, | 597 | e->previous_node = node_at_coords(seat, |
624 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | 598 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
625 | cursor_do_rebase(cursor, time_msec, e->previous_node, surface, sx, sy); | 599 | |
600 | if (surface) { | ||
601 | if (seat_is_input_allowed(seat, surface)) { | ||
602 | wlr_seat_pointer_notify_enter(seat->wlr_seat, surface, sx, sy); | ||
603 | } | ||
604 | } else { | ||
605 | cursor_update_image(cursor, e->previous_node); | ||
606 | wlr_seat_pointer_notify_enter(seat->wlr_seat, NULL, 0, 0); | ||
607 | wlr_seat_pointer_clear_focus(seat->wlr_seat); | ||
608 | } | ||
626 | } | 609 | } |
627 | 610 | ||
628 | static const struct sway_seatop_impl seatop_impl = { | 611 | static const struct sway_seatop_impl seatop_impl = { |