GHOST/Wayland: skip cursor surface operations when hiding the cursor

Also set the buffer scale before setting the cursor (matching SDL).
This commit is contained in:
Campbell Barton 2022-06-17 17:35:27 +10:00
parent f59418fd92
commit 9830603620
1 changed files with 15 additions and 11 deletions

View File

@ -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);
}
}