summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-09-21 15:16:01 -0500
committerDudemanguy <random342@airmail.cc>2023-09-21 15:31:26 -0500
commit4c39e79169f666c1ba6075c1dd66184190eee328 (patch)
tree9445229e3cad5b662c4f8ba49eeac6cbc37daef0 /video
parent3e7a8b6213ae3c1d3afccdf4ff744a6a0433be0e (diff)
downloadmpv-4c39e79169f666c1ba6075c1dd66184190eee328.tar.bz2
mpv-4c39e79169f666c1ba6075c1dd66184190eee328.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/out/wayland_common.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 53d3c97450..48fbbf2bca 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -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);
}