aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-06-23 19:27:06 +0200
committerAlexander Orzechowski <alex@ozal.ski>2023-06-30 17:24:44 +0000
commitd1d6cd90083e67546a6ac70f57ad21fd527f0f43 (patch)
tree5ee68a00de0125885c12efa598214d72f941bdba
parent69c44de22fea57f4aaa5620c0701a33b6eeba700 (diff)
cursor: keep track of XCursor manager and name
Will be useful to apply the current cursor to new outputs.
-rw-r--r--types/wlr_cursor.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/types/wlr_cursor.c b/types/wlr_cursor.c
index 8f79046e..88ff4bb2 100644
--- a/types/wlr_cursor.c
+++ b/types/wlr_cursor.c
@@ -1,3 +1,4 @@
+#define _POSIX_C_SOURCE 200809L
#include <assert.h>
#include <limits.h>
#include <math.h>
@@ -87,6 +88,10 @@ struct wlr_cursor_state {
} surface_hotspot;
struct wl_listener surface_commit;
struct wl_listener surface_destroy;
+
+ // only when using an XCursor as the cursor image
+ struct wlr_xcursor_manager *xcursor_manager;
+ char *xcursor_name;
};
struct wlr_cursor *wlr_cursor_create(void) {
@@ -215,6 +220,10 @@ static void cursor_reset_image(struct wlr_cursor *cur) {
wl_list_init(&cur->state->surface_destroy.link);
wl_list_init(&cur->state->surface_commit.link);
cur->state->surface = NULL;
+
+ cur->state->xcursor_manager = NULL;
+ free(cur->state->xcursor_name);
+ cur->state->xcursor_name = NULL;
}
void wlr_cursor_destroy(struct wlr_cursor *cur) {
@@ -484,6 +493,12 @@ static void output_cursor_set_xcursor_image(struct wlr_cursor_output_cursor *out
void wlr_cursor_set_xcursor(struct wlr_cursor *cur,
struct wlr_xcursor_manager *manager, const char *name) {
+ if (manager == cur->state->xcursor_manager &&
+ cur->state->xcursor_name != NULL &&
+ strcmp(name, cur->state->xcursor_name) == 0) {
+ return;
+ }
+
cursor_reset_image(cur);
struct wlr_cursor_output_cursor *output_cursor;
@@ -499,6 +514,9 @@ void wlr_cursor_set_xcursor(struct wlr_cursor *cur,
output_cursor->xcursor = xcursor;
output_cursor_set_xcursor_image(output_cursor, 0);
}
+
+ cur->state->xcursor_manager = manager;
+ cur->state->xcursor_name = strdup(name);
}
static void cursor_handle_surface_destroy(