From be2490022d445bef2c5c00336aecf2bd9dd25ee7 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 8 Jul 2020 18:08:39 +0200 Subject: multi-seat: enable xcursor theme support again --- render.c | 90 +++++++++++++++++++++++++++++----------------------------------- 1 file changed, 40 insertions(+), 50 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 2a8869ee..8fb0fd6f 100644 --- a/render.c +++ b/render.c @@ -1938,77 +1938,72 @@ render_resize_force(struct terminal *term, int width, int height) { return maybe_resize(term, width, height, true); } -#if 0 + static void xcursor_callback( void *data, struct wl_callback *wl_callback, uint32_t callback_data); static const struct wl_callback_listener xcursor_listener = { .done = &xcursor_callback, }; -#endif -#if 0 static void -render_xcursor_update(struct wayland *wayl, const struct terminal *term) +render_xcursor_update(struct seat *seat, const struct terminal *term) { /* If called from a frame callback, we may no longer have mouse focus */ - if (wayl->mouse_focus != term) + if (seat->mouse_focus != term) return; - wayl->pointer.cursor = wl_cursor_theme_get_cursor(wayl->pointer.theme, term->xcursor); - if (wayl->pointer.cursor == NULL) { + seat->pointer.cursor = wl_cursor_theme_get_cursor(seat->pointer.theme, term->xcursor); + if (seat->pointer.cursor == NULL) { LOG_ERR("%s: failed to load xcursor pointer '%s'", - wayl->pointer.theme_name, term->xcursor); + seat->pointer.theme_name, term->xcursor); return; } - wayl->pointer.xcursor = term->xcursor; + seat->pointer.xcursor = term->xcursor; const int scale = term->scale; - struct wl_cursor_image *image = wayl->pointer.cursor->images[0]; + struct wl_cursor_image *image = seat->pointer.cursor->images[0]; wl_surface_attach( - wayl->pointer.surface, wl_cursor_image_get_buffer(image), 0, 0); + seat->pointer.surface, wl_cursor_image_get_buffer(image), 0, 0); wl_pointer_set_cursor( - wayl->pointer.pointer, wayl->pointer.serial, - wayl->pointer.surface, + seat->wl_pointer, seat->pointer.serial, + seat->pointer.surface, image->hotspot_x / scale, image->hotspot_y / scale); wl_surface_damage_buffer( - wayl->pointer.surface, 0, 0, INT32_MAX, INT32_MAX); + seat->pointer.surface, 0, 0, INT32_MAX, INT32_MAX); - wl_surface_set_buffer_scale(wayl->pointer.surface, scale); + wl_surface_set_buffer_scale(seat->pointer.surface, scale); - assert(wayl->pointer.xcursor_callback == NULL); - wayl->pointer.xcursor_callback = wl_surface_frame(wayl->pointer.surface); - wl_callback_add_listener(wayl->pointer.xcursor_callback, &xcursor_listener, wayl); + assert(seat->pointer.xcursor_callback == NULL); + seat->pointer.xcursor_callback = wl_surface_frame(seat->pointer.surface); + wl_callback_add_listener(seat->pointer.xcursor_callback, &xcursor_listener, seat); - wl_surface_commit(wayl->pointer.surface); + wl_surface_commit(seat->pointer.surface); } -#endif -#if 0 static void xcursor_callback(void *data, struct wl_callback *wl_callback, uint32_t callback_data) { - struct wayland *wayl = data; + struct seat *seat = data; - assert(wayl->pointer.xcursor_callback == wl_callback); + assert(seat->pointer.xcursor_callback == wl_callback); wl_callback_destroy(wl_callback); - wayl->pointer.xcursor_callback = NULL; + seat->pointer.xcursor_callback = NULL; - if (wayl->pointer.pending_terminal != NULL) { - render_xcursor_update(wayl, wayl->pointer.pending_terminal); - wayl->pointer.pending_terminal = NULL; + if (seat->pointer.pending_terminal != NULL) { + render_xcursor_update(seat, seat->pointer.pending_terminal); + seat->pointer.pending_terminal = NULL; } } -#endif static void fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data) { struct renderer *renderer = data; - //struct wayland *wayl = renderer->wayl; + struct wayland *wayl = renderer->wayl; tll_foreach(renderer->wayl->terms, it) { struct terminal *term = it->item; @@ -2065,16 +2060,16 @@ fdm_hook_refresh_pending_terminals(struct fdm *fdm, void *data) } } -#if 0 - if (wayl->pointer.pending_terminal != NULL) { - if (wayl->pointer.xcursor_callback == NULL) { - render_xcursor_update(wayl, wayl->pointer.pending_terminal); - wayl->pointer.pending_terminal = NULL; - } else { - /* Frame callback will call render_xcursor_update() */ + tll_foreach(wayl->seats, it) { + if (it->item.pointer.pending_terminal != NULL) { + if (it->item.pointer.xcursor_callback == NULL) { + render_xcursor_update(&it->item, it->item.pointer.pending_terminal); + it->item.pointer.pending_terminal = NULL; + } else { + /* Frame callback will call render_xcursor_update() */ + } } } -#endif } void @@ -2104,31 +2099,26 @@ render_refresh_search(struct terminal *term) } bool -render_xcursor_set(struct terminal *term) +render_xcursor_set(struct seat *seat, struct terminal *term) { -#if 0 - struct wayland *wayl = term->wl; - - if (wayl->pointer.theme == NULL) + if (seat->pointer.theme == NULL) return false; - if (wayl->mouse_focus == NULL) { - wayl->pointer.xcursor = NULL; - wayl->pointer.pending_terminal = NULL; + if (seat->mouse_focus == NULL) { + seat->pointer.xcursor = NULL; + seat->pointer.pending_terminal = NULL; return true; } - if (wayl->mouse_focus != term) { + if (seat->mouse_focus != term) { /* This terminal doesn't have mouse focus */ return true; } - if (wayl->pointer.xcursor == term->xcursor) + if (seat->pointer.xcursor == term->xcursor) return true; /* FDM hook takes care of actual rendering */ - wayl->pointer.pending_terminal = term; - return true; -#endif + seat->pointer.pending_terminal = term; return true; } -- cgit v1.3