summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/context_wayland.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2016-05-30 18:34:31 +0100
committerwm4 <wm4@nowhere>2016-05-30 20:17:26 +0200
commit098ff4174c6c9cc59e65c6f09b23b3adaee03983 (patch)
treeac5c85fcb7519e6d394df6367a3422bd2652c553 /video/out/opengl/context_wayland.c
parent9009601c2d3b2a6d7806d63346c900e0a4c9e2ca (diff)
downloadmpv-098ff4174c6c9cc59e65c6f09b23b3adaee03983.tar.bz2
mpv-098ff4174c6c9cc59e65c6f09b23b3adaee03983.tar.xz
wayland: implement HIDPI support
The wayland protocol exposes scaling done by the compositor to compensate for small window sizes on small high DPI displays. If the program ignores the scaling done, what'll happen is the compositor is going to ask the program to be scaled down by N times the window size and then it'll upscale the program's surface by N times. The scaling algorithm seems to be bilinear so the scaling is quite obvious. This commit sets up callbacks to listen for the scaling factor of each output and, on rescale events, notifies the compositor that the surface's scale is what the compositor asked for and changes the player's surface to the appropriate size, causing no scaling to be done by the compositor. Compositors not supporting this interface will ignore the callbacks and do nothing, keeping program behaviour the same. For compositors supporting and using this interface (mutter), this will fix the rendering to be pixel precise as it should be. Both the opengl wayland backend and the wayland vo have been fixed to support this. Verified to not break either on weston and mutter. Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'video/out/opengl/context_wayland.c')
-rw-r--r--video/out/opengl/context_wayland.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/video/out/opengl/context_wayland.c b/video/out/opengl/context_wayland.c
index a100073780..e74132bcf2 100644
--- a/video/out/opengl/context_wayland.c
+++ b/video/out/opengl/context_wayland.c
@@ -25,10 +25,14 @@ static void egl_resize(struct vo_wayland_state *wl)
int32_t y = wl->window.sh_y;
int32_t width = wl->window.sh_width;
int32_t height = wl->window.sh_height;
+ int32_t scale = 1;
if (!wl->egl_context.egl_window)
return;
+ if (wl->display.current_output)
+ scale = wl->display.current_output->scale;
+
// get the real size of the window
// this improves moving the window while resizing it
wl_egl_window_get_attached_size(wl->egl_context.egl_window,
@@ -46,14 +50,15 @@ static void egl_resize(struct vo_wayland_state *wl)
if (y != 0)
y = wl->window.height - height;
- wl_egl_window_resize(wl->egl_context.egl_window, width, height, x, y);
+ wl_surface_set_buffer_scale(wl->window.video_surface, scale);
+ wl_egl_window_resize(wl->egl_context.egl_window, scale*width, scale*height, x, y);
wl->window.width = width;
wl->window.height = height;
/* set size for mplayer */
- wl->vo->dwidth = wl->window.width;
- wl->vo->dheight = wl->window.height;
+ wl->vo->dwidth = scale*wl->window.width;
+ wl->vo->dheight = scale*wl->window.height;
wl->vo->want_redraw = true;
wl->window.events = 0;