aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/input/cursor.h4
-rw-r--r--sway/input/cursor.c22
2 files changed, 17 insertions, 9 deletions
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h
index 5dd109ca..b0a3a7c5 100644
--- a/include/sway/input/cursor.h
+++ b/include/sway/input/cursor.h
@@ -11,6 +11,7 @@ struct sway_cursor {
11 } previous; 11 } previous;
12 struct wlr_xcursor_manager *xcursor_manager; 12 struct wlr_xcursor_manager *xcursor_manager;
13 13
14 const char *image;
14 struct wl_client *image_client; 15 struct wl_client *image_client;
15 16
16 struct wl_listener motion; 17 struct wl_listener motion;
@@ -37,4 +38,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
37void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec, 38void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
38 uint32_t button, enum wlr_button_state state); 39 uint32_t button, enum wlr_button_state state);
39 40
41void cursor_set_image(struct sway_cursor *cursor, const char *image,
42 struct wl_client *client);
43
40#endif 44#endif
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index ec83746e..43721d28 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -371,22 +371,16 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
371 // Reset cursor if switching between clients 371 // Reset cursor if switching between clients
372 struct wl_client *client = wl_resource_get_client(surface->resource); 372 struct wl_client *client = wl_resource_get_client(surface->resource);
373 if (client != cursor->image_client) { 373 if (client != cursor->image_client) {
374 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, 374 cursor_set_image(cursor, "left_ptr", client);
375 "left_ptr", cursor->cursor);
376 cursor->image_client = client;
377 } 375 }
378 } else if (c && container_is_floating(c)) { 376 } else if (c && container_is_floating(c)) {
379 // Try a floating container's resize edge 377 // Try a floating container's resize edge
380 enum wlr_edges edge = find_resize_edge(c, cursor); 378 enum wlr_edges edge = find_resize_edge(c, cursor);
381 const char *image = edge == WLR_EDGE_NONE ? 379 const char *image = edge == WLR_EDGE_NONE ?
382 "left_ptr" : wlr_xcursor_get_resize_name(edge); 380 "left_ptr" : wlr_xcursor_get_resize_name(edge);
383 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image, 381 cursor_set_image(cursor, image, NULL);
384 cursor->cursor);
385 cursor->image_client = NULL;
386 } else { 382 } else {
387 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, 383 cursor_set_image(cursor, "left_ptr", NULL);
388 "left_ptr", cursor->cursor);
389 cursor->image_client = NULL;
390 } 384 }
391 385
392 // send pointer enter/leave 386 // send pointer enter/leave
@@ -725,6 +719,16 @@ static void handle_request_set_cursor(struct wl_listener *listener,
725 cursor->image_client = focused_client; 719 cursor->image_client = focused_client;
726} 720}
727 721
722void cursor_set_image(struct sway_cursor *cursor, const char *image,
723 struct wl_client *client) {
724 if (!cursor->image || strcmp(cursor->image, image) != 0) {
725 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image,
726 cursor->cursor);
727 cursor->image = image;
728 }
729 cursor->image_client = client;
730}
731
728void sway_cursor_destroy(struct sway_cursor *cursor) { 732void sway_cursor_destroy(struct sway_cursor *cursor) {
729 if (!cursor) { 733 if (!cursor) {
730 return; 734 return;