diff options
author | Dudemanguy <random342@airmail.cc> | 2020-12-13 15:03:34 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2020-12-14 22:44:05 +0000 |
commit | 04018c306196888861775b248a8596ae494f122b (patch) | |
tree | 02162a85f00d1a7e0e726fd682670bad036ea20d /video/out | |
parent | 7ca14d646c7e405f3fb1e44600e2a67fc4607238 (diff) | |
download | mpv-04018c306196888861775b248a8596ae494f122b.tar.bz2 mpv-04018c306196888861775b248a8596ae494f122b.tar.xz |
wayland: update geometry/autofit opts on runtime
Additionally, do some cleanups in the resize/autofitting code to make
sure we don't do any wasteful VO_EVENT_RESIZE calls. Note that if
set_geometry is called, we must always perform a resize.
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/wayland_common.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 6435cd7c77..a0d9bf8340 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -846,6 +846,8 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface, struct wl_output *output) { struct vo_wayland_state *wl = data; + struct mp_rect old_output_geometry = wl->current_output->geometry; + struct mp_rect old_geometry = wl->geometry; wl->current_output = NULL; struct vo_wayland_output *o; @@ -857,8 +859,13 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface, } wl->current_output->has_surface = true; - set_geometry(wl); - wl->window_size = wl->vdparams; + bool force_resize = false; + + if (!mp_rect_equals(&old_output_geometry, &wl->current_output->geometry)) { + set_geometry(wl); + wl->window_size = wl->vdparams; + force_resize = true; + } if (wl->scaling != wl->current_output->scale && wl->vo_opts->hidpi_window_scale) { double factor = (double)wl->scaling / wl->current_output->scale; @@ -866,10 +873,11 @@ static void surface_handle_enter(void *data, struct wl_surface *wl_surface, rescale_geometry_dimensions(wl, factor); } - if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized) { + if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized) wl->geometry = wl->window_size; + + if (!mp_rect_equals(&old_geometry, &wl->geometry) || force_resize) wl->pending_vo_events |= VO_EVENT_RESIZE; - } MP_VERBOSE(wl, "Surface entered output %s %s (0x%x), scale = %i\n", o->make, o->model, o->id, wl->scaling); @@ -1600,6 +1608,15 @@ int vo_wayland_control(struct vo *vo, int *events, int request, void *arg) set_border_decorations(wl, opts->border); if (opt == &opts->appid) update_app_id(wl); + if (opt == &opts->geometry || opt == &opts->autofit || + opt == &opts->autofit_smaller || opt == &opts->autofit_larger) + { + set_geometry(wl); + wl->window_size = wl->vdparams; + if (!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized) + wl->geometry = wl->window_size; + wl->pending_vo_events |= VO_EVENT_RESIZE; + } } return VO_TRUE; } |