aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-30 11:09:57 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-30 11:09:57 +0000
commita87b39f6eb18b5b3674afcb3f24816d933eab319 (patch)
tree933724a0e283576d4d52edf68126124a07f81791
parentinput: update xcursor on terminal with *keyboard* focus when modifiers change (diff)
wayland: track current xcursor, and don't update if same
We may have many windows open, which tries to update/change the xcursor at various points. Track which cursor is currently loaded, regardless of which window it was set by. If someone tries to load that very same xcursor again, simply skip it. One example is when we've moused over a window that does *not* have keyboard focus, and then the user clicks, or by some other mean gives that window keyboard focus. In many cases it will then try to set the same cursor again (most of the times, the cursor is the same regardless of keyboard focus, but not always).
-rw-r--r--wayland.c10
-rw-r--r--wayland.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/wayland.c b/wayland.c
index 3cc86429..938056ac 100644
--- a/wayland.c
+++ b/wayland.c
@@ -801,11 +801,19 @@ wayl_cursor_set(struct wayland *wayl, const struct terminal *term)
if (wayl->pointer.theme == NULL)
return false;
+ if (wayl->moused == NULL) {
+ wayl->pointer.xcursor = NULL;
+ return true;
+ }
+
if (wayl->moused != term) {
/* This terminal doesn't have mouse focus */
return true;
}
+ if (wayl->pointer.xcursor == term->xcursor)
+ return true;
+
wayl->pointer.cursor = wl_cursor_theme_get_cursor(wayl->pointer.theme, term->xcursor);
if (wayl->pointer.cursor == NULL) {
LOG_ERR("%s: failed to load xcursor pointer '%s'",
@@ -813,6 +821,8 @@ wayl_cursor_set(struct wayland *wayl, const struct terminal *term)
return false;
}
+ wayl->pointer.xcursor = term->xcursor;
+
const int scale = term->scale;
struct wl_cursor_image *image = wayl->pointer.cursor->images[0];
diff --git a/wayland.h b/wayland.h
index a5084d83..fb681dd6 100644
--- a/wayland.h
+++ b/wayland.h
@@ -132,6 +132,7 @@ struct wayland {
struct wl_cursor *cursor;
int size;
char *theme_name;
+ const char *xcursor;
} pointer;
struct {