summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2024-02-24 22:59:27 -0600
committerDudemanguy <random342@airmail.cc>2024-02-27 22:18:12 +0000
commitf0a6578259f508a8863afcf9a1487872d7ae1878 (patch)
treef82cdd918621744a9c7e509079efa40737cea6b0 /video
parent34c0a67ace7c0dcc8c53ee2ca1879135add4dc7d (diff)
downloadmpv-f0a6578259f508a8863afcf9a1487872d7ae1878.tar.bz2
mpv-f0a6578259f508a8863afcf9a1487872d7ae1878.tar.xz
wayland: drop buffer scale for cursor as well
Could have been done in e32554cd570d984efb712a7214a40237233a3cea, but I skipped it there. However, using viewporter is actually a win here. There's been a longstanding issue in upstream wayland* exactly related to this. I even forgot about cd7a7a1de8d8bffa05170befef25b251711c994a which was made for this exactly problem and explains the random spawn_cursor calls. Anyways, just not using buffer scale and instead scaling the cursor surface via viewporter works just fine and completely sidesteps this problem. This means we can drop the random looking spawn_cursor calls and some additional checks. *: https://gitlab.freedesktop.org/wayland/wayland/-/issues/194
Diffstat (limited to 'video')
-rw-r--r--video/out/wayland_common.c16
-rw-r--r--video/out/wayland_common.h1
2 files changed, 10 insertions, 7 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 275767070a..d551686424 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -870,7 +870,6 @@ static void output_handle_done(void *data, struct wl_output *wl_output)
* geometry and scaling should be recalculated. */
if (wl->current_output && wl->current_output->output == wl_output) {
set_surface_scaling(wl);
- spawn_cursor(wl);
set_geometry(wl, false);
prepare_resize(wl, 0, 0);
}
@@ -934,7 +933,6 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface,
if (wl->scaling != wl->current_output->scale) {
set_surface_scaling(wl);
- spawn_cursor(wl);
force_resize = true;
}
@@ -1656,6 +1654,7 @@ static bool create_input(struct vo_wayland_state *wl)
static int create_viewports(struct vo_wayland_state *wl)
{
wl->viewport = wp_viewporter_get_viewport(wl->viewporter, wl->surface);
+ wl->cursor_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->cursor_surface);
wl->osd_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->osd_surface);
wl->video_viewport = wp_viewporter_get_viewport(wl->viewporter, wl->video_surface);
@@ -1968,7 +1967,8 @@ static int set_cursor_visibility(struct vo_wayland_seat *s, bool on)
int scale = MPMAX(wl->scaling, 1);
wl_pointer_set_cursor(s->pointer, s->pointer_serial, wl->cursor_surface,
img->hotspot_x / scale, img->hotspot_y / scale);
- wl_surface_set_buffer_scale(wl->cursor_surface, scale);
+ wp_viewport_set_destination(wl->cursor_viewport, lround(img->width / scale),
+ img->height / scale);
wl_surface_attach(wl->cursor_surface, buffer, 0, 0);
wl_surface_damage_buffer(wl->cursor_surface, 0, 0, img->width, img->height);
}
@@ -2085,12 +2085,11 @@ static void set_window_bounds(struct vo_wayland_state *wl)
static int spawn_cursor(struct vo_wayland_state *wl)
{
- if (wl->cursor_shape_manager)
- return 0;
- if (wl->allocated_cursor_scale == wl->scaling)
+ if (wl->allocated_cursor_scale == wl->scaling) {
return 0;
- else if (wl->cursor_theme)
+ } else if (wl->cursor_theme) {
wl_cursor_theme_destroy(wl->cursor_theme);
+ }
const char *xcursor_theme = getenv("XCURSOR_THEME");
const char *size_str = getenv("XCURSOR_SIZE");
@@ -2669,6 +2668,9 @@ void vo_wayland_uninit(struct vo *vo)
if (wl->viewport)
wp_viewport_destroy(wl->viewport);
+ if (wl->cursor_viewport)
+ wp_viewport_destroy(wl->cursor_viewport);
+
if (wl->osd_viewport)
wp_viewport_destroy(wl->osd_viewport);
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index f45c732ee1..845632d06f 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -133,6 +133,7 @@ struct vo_wayland_state {
/* viewporter */
struct wp_viewporter *viewporter;
struct wp_viewport *viewport;
+ struct wp_viewport *cursor_viewport;
struct wp_viewport *osd_viewport;
struct wp_viewport *video_viewport;