mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 00:11:28 +00:00
Prevent re-uploading the same cursor image multiple times
This commit is contained in:
parent
0c87bff5d1
commit
6767d8a593
|
@ -11,6 +11,7 @@ struct sway_cursor {
|
||||||
} previous;
|
} previous;
|
||||||
struct wlr_xcursor_manager *xcursor_manager;
|
struct wlr_xcursor_manager *xcursor_manager;
|
||||||
|
|
||||||
|
const char *image;
|
||||||
struct wl_client *image_client;
|
struct wl_client *image_client;
|
||||||
|
|
||||||
struct wl_listener motion;
|
struct wl_listener motion;
|
||||||
|
@ -37,4 +38,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
||||||
void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
|
void dispatch_cursor_button(struct sway_cursor *cursor, uint32_t time_msec,
|
||||||
uint32_t button, enum wlr_button_state state);
|
uint32_t button, enum wlr_button_state state);
|
||||||
|
|
||||||
|
void cursor_set_image(struct sway_cursor *cursor, const char *image,
|
||||||
|
struct wl_client *client);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -371,22 +371,16 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec,
|
||||||
// Reset cursor if switching between clients
|
// Reset cursor if switching between clients
|
||||||
struct wl_client *client = wl_resource_get_client(surface->resource);
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
||||||
if (client != cursor->image_client) {
|
if (client != cursor->image_client) {
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
|
cursor_set_image(cursor, "left_ptr", client);
|
||||||
"left_ptr", cursor->cursor);
|
|
||||||
cursor->image_client = client;
|
|
||||||
}
|
}
|
||||||
} else if (c && container_is_floating(c)) {
|
} else if (c && container_is_floating(c)) {
|
||||||
// Try a floating container's resize edge
|
// Try a floating container's resize edge
|
||||||
enum wlr_edges edge = find_resize_edge(c, cursor);
|
enum wlr_edges edge = find_resize_edge(c, cursor);
|
||||||
const char *image = edge == WLR_EDGE_NONE ?
|
const char *image = edge == WLR_EDGE_NONE ?
|
||||||
"left_ptr" : wlr_xcursor_get_resize_name(edge);
|
"left_ptr" : wlr_xcursor_get_resize_name(edge);
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image,
|
cursor_set_image(cursor, image, NULL);
|
||||||
cursor->cursor);
|
|
||||||
cursor->image_client = NULL;
|
|
||||||
} else {
|
} else {
|
||||||
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager,
|
cursor_set_image(cursor, "left_ptr", NULL);
|
||||||
"left_ptr", cursor->cursor);
|
|
||||||
cursor->image_client = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// send pointer enter/leave
|
// send pointer enter/leave
|
||||||
|
@ -725,6 +719,16 @@ static void handle_request_set_cursor(struct wl_listener *listener,
|
||||||
cursor->image_client = focused_client;
|
cursor->image_client = focused_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cursor_set_image(struct sway_cursor *cursor, const char *image,
|
||||||
|
struct wl_client *client) {
|
||||||
|
if (!cursor->image || strcmp(cursor->image, image) != 0) {
|
||||||
|
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, image,
|
||||||
|
cursor->cursor);
|
||||||
|
cursor->image = image;
|
||||||
|
}
|
||||||
|
cursor->image_client = client;
|
||||||
|
}
|
||||||
|
|
||||||
void sway_cursor_destroy(struct sway_cursor *cursor) {
|
void sway_cursor_destroy(struct sway_cursor *cursor) {
|
||||||
if (!cursor) {
|
if (!cursor) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue