mirror of https://github.com/mpv-player/mpv
wayland: ensure at least a scale factor of 1 when drawing cursor
With the addition of fractional scaling support, wl->scaling was converted to a double. Some compositors (Plasma) can report values under 1 for fractional scaling, so this meant wl->scaling could be some small fractional value. This is fine except that when using the legacy code for drawing the mouse cursor (i.e. not the cursor-shape protocol), it still uses the old integer scaling method in core wayland. The reason for this is simply because fractionally scaling the mouse cursor surface is nonsense and nobody even has cursor images for anything besides a select few sizes anyways (32x32, 48x48, etc.). The existing integer scaling sort of works but it's pretty bad too and you can get some weird sizes anyway. This is why cursor-shape is preferred since it fixes this. Anyways, since buffer scaling for the cursor only takes integers, there could be truncation to 0 in the previously mentioned fractional scale this. This naturally causes the compositor to send us an error and mpv quits. The fix is to always make sure that the scale value used for the cursor is at least 1. Anything less makes no sense. Fixes #12309.
This commit is contained in:
parent
3e7a8b6213
commit
4c39e79169
|
@ -1759,9 +1759,10 @@ static int set_cursor_visibility(struct vo_wayland_state *wl, bool on)
|
|||
struct wl_buffer *buffer = wl_cursor_image_get_buffer(img);
|
||||
if (!buffer)
|
||||
return VO_FALSE;
|
||||
int scale = MPMAX(wl->scaling, 1);
|
||||
wl_pointer_set_cursor(wl->pointer, wl->pointer_id, wl->cursor_surface,
|
||||
img->hotspot_x/wl->scaling, img->hotspot_y/wl->scaling);
|
||||
wl_surface_set_buffer_scale(wl->cursor_surface, wl->scaling);
|
||||
img->hotspot_x / scale, img->hotspot_y / scale);
|
||||
wl_surface_set_buffer_scale(wl->cursor_surface, scale);
|
||||
wl_surface_attach(wl->cursor_surface, buffer, 0, 0);
|
||||
wl_surface_damage_buffer(wl->cursor_surface, 0, 0, img->width, img->height);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue