summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2021-08-07 18:07:09 -0500
committerDudemanguy <random342@airmail.cc>2021-08-07 18:36:41 -0500
commit84362e820e88dd7348b2fa35dd640288616c1fb5 (patch)
treedd4c4d18df723b83ea658aab096a59d349e43a6d
parent25cfc815f564a233ead68c77ad14fae638ebd30a (diff)
downloadmpv-84362e820e88dd7348b2fa35dd640288616c1fb5.tar.bz2
mpv-84362e820e88dd7348b2fa35dd640288616c1fb5.tar.xz
wayland: correct window-scale behavior
The way the window-scale option is supposed to behave wasn't really ever documented until 25cfc81. It turns out that different OS/WMs may do slightly different things. For wayland, we need to fix two things. First, only return the wl->window_size in GET_UNFS (aka don't return the fullscreen size). For SET_UNFS, we need to change the behavior for the maximized window case. If the window is maximized, first attempt to unmaximize it and send the wayland event. If the compositor allows this to happen, then go ahead and set the new dimensions and resize it. In the case that the attempt to unmaximize is not successful, then don't attempt the resize and just save the window size dimensions for later to be used when the user unmaximizes the window.
-rw-r--r--video/out/wayland_common.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 2bc9cf3297..d472a68ed3 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -1599,8 +1599,8 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
}
case VOCTRL_GET_UNFS_WINDOW_SIZE: {
int *s = arg;
- s[0] = mp_rect_w(wl->geometry) * wl->scaling;
- s[1] = mp_rect_h(wl->geometry) * wl->scaling;
+ s[0] = mp_rect_w(wl->window_size) * wl->scaling;
+ s[1] = mp_rect_h(wl->window_size) * wl->scaling;
return VO_TRUE;
}
case VOCTRL_SET_UNFS_WINDOW_SIZE: {
@@ -1609,7 +1609,14 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg)
wl->window_size.y0 = 0;
wl->window_size.x1 = s[0] / wl->scaling;
wl->window_size.y1 = s[1] / wl->scaling;
- if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized) {
+ if (!wl->vo_opts->fullscreen) {
+ if (wl->vo_opts->window_maximized) {
+ xdg_toplevel_unset_maximized(wl->xdg_toplevel);
+ wl_display_dispatch_pending(wl->display);
+ /* Make sure the compositor let us unmaximize */
+ if (wl->vo_opts->window_maximized)
+ return VO_TRUE;
+ }
wl->geometry = wl->window_size;
wl->pending_vo_events |= VO_EVENT_RESIZE;
}