aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/cursor.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-21 10:57:14 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-07-22 23:10:19 +1000
commit6767d8a593723a9b69d018eed13d24a789be9516 (patch)
tree06d971d2e76b0d3706d2f627b2102572f9c9cecd /sway/input/cursor.c
parentReplace static handle_end_operation with seat_end_mouse_operation (diff)
downloadsway-6767d8a593723a9b69d018eed13d24a789be9516.tar.gz
sway-6767d8a593723a9b69d018eed13d24a789be9516.tar.zst
sway-6767d8a593723a9b69d018eed13d24a789be9516.zip
Prevent re-uploading the same cursor image multiple times
Diffstat (limited to 'sway/input/cursor.c')
-rw-r--r--sway/input/cursor.c22
1 files changed, 13 insertions, 9 deletions
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;