diff options
author | Tudor Brindus <me@tbrindus.ca> | 2020-04-25 15:07:17 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-02 13:32:28 +0200 |
commit | 0dc1863dce163622371dc3ffb2c6073cbda17075 (patch) | |
tree | 4f0ff981ba6b2d513acb48b355c5c79d613f6909 /sway/input/cursor.c | |
parent | Add a secondary headless backend (diff) | |
download | sway-0dc1863dce163622371dc3ffb2c6073cbda17075.tar.gz sway-0dc1863dce163622371dc3ffb2c6073cbda17075.tar.zst sway-0dc1863dce163622371dc3ffb2c6073cbda17075.zip |
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
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r-- | sway/input/cursor.c | 21 |
1 files changed, 21 insertions, 0 deletions
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; |