wl_surface::set_cursor with singleton cursor surface
Chromium uses the following code for setting the cursor:
wl_surface_damage(pointer_surface_.get(), 0, 0, buffer_width, buffer_height);
// Note: should the offset be non-zero, use wl_surface_offset() to set it.
wl_surface_attach(pointer_surface_.get(), buffer, 0, 0);
wl_surface_commit(pointer_surface_.get());
wl_pointer_set_cursor(pointer_->wl_object(), pointer_enter_serial->value,
pointer_surface_.get(), hotspot_x_dip, hotspot_y_dip);
pointer_surface_
is a singleton. There is only ever one such surface. If pointer_enter_serial
is not the last enter serial sent to the application, then the spec requires that the call is ignored. However, it is unclear to me how to handle this correctly in the compositor.
Consider the case where pointer_surface_
is already the current cursor surface. Then the commit
call will change the surface but not update the hotspot. If the compositor ignores the set_cursor
call, then the hotspot will be incorrect.
Maybe the requirement that serial be the last enter serial should be removed? The other requirement, "The cursor actually changes only if the pointer focus for this device is one of the requesting client's surfaces or the surface parameter is the current pointer surface", seems sufficient.