From 0dc1863dce163622371dc3ffb2c6073cbda17075 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Sat, 25 Apr 2020 15:07:17 -0400 Subject: input/cursor: make cursor rebasing cursor type-agnostic This commit refactors `cursor_rebase` into `cursor_update_image`, and moves sending pointer events to the two existing call sites. This will enable this code to be reused for tablets. Refs #5232 --- sway/input/cursor.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sway/input/cursor.c') 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) { } } +void cursor_update_image(struct sway_cursor *cursor, + struct sway_node *node) { + if (node && node->type == N_CONTAINER) { + // Try a node's resize edge + enum wlr_edges edge = find_resize_edge(node->sway_container, NULL, cursor); + if (edge == WLR_EDGE_NONE) { + cursor_set_image(cursor, "left_ptr", NULL); + } else if (container_is_floating(node->sway_container)) { + cursor_set_image(cursor, wlr_xcursor_get_resize_name(edge), NULL); + } else { + if (edge & (WLR_EDGE_LEFT | WLR_EDGE_RIGHT)) { + cursor_set_image(cursor, "col-resize", NULL); + } else { + cursor_set_image(cursor, "row-resize", NULL); + } + } + } else { + cursor_set_image(cursor, "left_ptr", NULL); + } +} + static void cursor_hide(struct sway_cursor *cursor) { wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); cursor->hidden = true; -- cgit v1.2.3-54-g00ecf