mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-10 04:27:45 -05:00
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).
This commit is contained in:
parent
841e20b75b
commit
a87b39f6eb
2 changed files with 11 additions and 0 deletions
10
wayland.c
10
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];
|
||||
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ struct wayland {
|
|||
struct wl_cursor *cursor;
|
||||
int size;
|
||||
char *theme_name;
|
||||
const char *xcursor;
|
||||
} pointer;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue