diff options
author | Campbell Barton <campbell@blender.org> | 2022-06-17 10:35:27 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-06-17 10:35:44 +0300 |
commit | 9830603620762b5784983dddc076bc7945dc1e16 (patch) | |
tree | 9b9d0f45f561a1b472fe7179a71b3005fa9a66a1 /intern/ghost | |
parent | f59418fd92f1d27556ea6bc15fabbdb138cc8e95 (diff) |
GHOST/Wayland: skip cursor surface operations when hiding the cursor
Also set the buffer scale before setting the cursor (matching SDL).
Diffstat (limited to 'intern/ghost')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemWayland.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp index 4b5fa2bf3fb..2b0abd2cc41 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cpp +++ b/intern/ghost/intern/GHOST_SystemWayland.cpp @@ -2476,8 +2476,12 @@ static void set_cursor_buffer(input_t *input, wl_buffer *buffer) const int32_t hotspot_x = int32_t(c->wl_image.hotspot_x) / c->scale; const int32_t hotspot_y = int32_t(c->wl_image.hotspot_y) / c->scale; - wl_surface_attach(c->wl_surface, buffer, 0, 0); - wl_surface_damage(c->wl_surface, 0, 0, image_size_x, image_size_y); + if (buffer) { + wl_surface_set_buffer_scale(c->wl_surface, c->scale); + wl_surface_attach(c->wl_surface, buffer, 0, 0); + wl_surface_damage(c->wl_surface, 0, 0, image_size_x, image_size_y); + wl_surface_commit(c->wl_surface); + } wl_pointer_set_cursor(input->wl_pointer, input->pointer_serial, @@ -2485,25 +2489,25 @@ static void set_cursor_buffer(input_t *input, wl_buffer *buffer) hotspot_x, hotspot_y); - wl_surface_commit(c->wl_surface); - /* Set the cursor for all tablet tools as well. */ for (struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2 : input->tablet_tools) { tablet_tool_input_t *tool_input = static_cast<tablet_tool_input_t *>( zwp_tablet_tool_v2_get_user_data(zwp_tablet_tool_v2)); - /* FIXME: for some reason cursor scale is applied twice (when the scale isn't 1x), - * this happens both in gnome-shell & KDE. Setting the surface scale here doesn't help. */ - // wl_surface_set_buffer_scale(tool_input->cursor_surface, 1); - wl_surface_attach(tool_input->cursor_surface, buffer, 0, 0); - wl_surface_damage(tool_input->cursor_surface, 0, 0, image_size_x, image_size_y); + + if (buffer) { + /* FIXME: for some reason cursor scale is applied twice (when the scale isn't 1x), + * this happens both in gnome-shell & KDE. Setting the surface scale here doesn't help. */ + wl_surface_set_buffer_scale(tool_input->cursor_surface, c->scale); + wl_surface_attach(tool_input->cursor_surface, buffer, 0, 0); + wl_surface_damage(tool_input->cursor_surface, 0, 0, image_size_x, image_size_y); + wl_surface_commit(tool_input->cursor_surface); + } zwp_tablet_tool_v2_set_cursor(zwp_tablet_tool_v2, input->tablet_serial, c->visible ? tool_input->cursor_surface : nullptr, hotspot_x, hotspot_y); - - wl_surface_commit(tool_input->cursor_surface); } } |