summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/interface-changes.rst1
-rw-r--r--DOCS/man/options.rst8
-rw-r--r--video/out/wayland_common.c31
-rw-r--r--video/out/wayland_common.h3
4 files changed, 41 insertions, 2 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 6629d3ee09..128d045a13 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -45,6 +45,7 @@ Interface changes
- add `--x11-present` for controlling whether to use xorg's present extension
- add `engine` option to the `rubberband` audio filter to support the new
engine introduced in rubberband 3.0.0. Defaults to `finer` (new engine).
+ - add `--wayland-configure-bounds` option
--- mpv 0.34.0 ---
- deprecate selecting by card number with `--drm-connector`, add
`--drm-device` which can be used instead
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 93e051af23..e00993cfac 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -5570,6 +5570,14 @@ them.
``--wayland-app-id=<string>``
Set the client app id for Wayland-based video output methods (default: ``mpv``).
+``--wayland-configure-bounds=<yes|no>``
+ Controls whether or not mpv opts into the configure bounds event if sent by the
+ compositor (default: yes). This restricts the initial size of the mpv window to
+ a certain maximum size intended by the compositor. In most cases, this simply
+ just prevents the mpv window from being larger than the size of the monitor when
+ it first renders. This option will take precedence over any ``autofit`` or
+ ``geometry`` type settings if the configure bounds are used.
+
``--wayland-disable-vsync=<yes|no>``
Disable mpv's internal vsync for Wayland-based video output (default: no).
This is mainly useful for benchmarking wayland VOs when combined with
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c
index 9d2e43b005..5feee0be61 100644
--- a/video/out/wayland_common.c
+++ b/video/out/wayland_common.c
@@ -112,6 +112,7 @@ static const struct mp_keymap keymap[] = {
#define OPT_BASE_STRUCT struct wayland_opts
const struct m_sub_options wayland_conf = {
.opts = (const struct m_option[]) {
+ {"wayland-configure-bounds", OPT_FLAG(configure_bounds)},
{"wayland-disable-vsync", OPT_FLAG(disable_vsync)},
{"wayland-edge-pixels-pointer", OPT_INT(edge_pixels_pointer),
M_RANGE(0, INT_MAX)},
@@ -121,6 +122,7 @@ const struct m_sub_options wayland_conf = {
},
.size = sizeof(struct wayland_opts),
.defaults = &(struct wayland_opts) {
+ .configure_bounds = true,
.disable_vsync = false,
.edge_pixels_pointer = 10,
.edge_pixels_touch = 32,
@@ -918,9 +920,22 @@ static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel)
mp_input_put_key(wl->vo->input_ctx, MP_KEY_CLOSE_WIN);
}
+#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
+static void handle_configure_bounds(void *data, struct xdg_toplevel *xdg_toplevel,
+ int32_t width, int32_t height)
+{
+ struct vo_wayland_state *wl = data;
+ wl->bounded_width = width;
+ wl->bounded_height = height;
+}
+#endif
+
static const struct xdg_toplevel_listener xdg_toplevel_listener = {
handle_toplevel_config,
handle_toplevel_close,
+#ifdef XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION
+ handle_configure_bounds,
+#endif
};
static void configure_decorations(void *data,
@@ -1117,7 +1132,7 @@ static void registry_handle_add(void *data, struct wl_registry *reg, uint32_t id
}
if (!strcmp(interface, xdg_wm_base_interface.name) && found++) {
- ver = MPMIN(ver, 2); /* We can use either 1 or 2 */
+ ver = MPMIN(ver, 4); /* Cap at 4 in case new events are added later. */
wl->wm_base = wl_registry_bind(reg, id, &xdg_wm_base_interface, ver);
xdg_wm_base_add_listener(wl->wm_base, &xdg_wm_base_listener, wl);
}
@@ -1477,6 +1492,14 @@ static void set_surface_scaling(struct vo_wayland_state *wl)
wl_surface_set_buffer_scale(wl->surface, wl->scaling);
}
+static void set_window_bounds(struct vo_wayland_state *wl)
+{
+ if (wl->bounded_width && wl->bounded_width < wl->window_size.x1)
+ wl->window_size.x1 = wl->bounded_width;
+ if (wl->bounded_height && wl->bounded_height < wl->window_size.y1)
+ wl->window_size.y1 = wl->bounded_height;
+}
+
static int spawn_cursor(struct vo_wayland_state *wl)
{
/* Reuse if size is identical */
@@ -1773,6 +1796,8 @@ int vo_wayland_init(struct vo *vo)
.display = wl_display_connect(NULL),
.vo = vo,
.log = mp_log_new(wl, vo->log, "wayland"),
+ .bounded_width = 0,
+ .bounded_height = 0,
.refresh_interval = 0,
.scaling = 1,
.wakeup_pipe = {-1, -1},
@@ -1885,9 +1910,11 @@ int vo_wayland_reconfig(struct vo *vo)
}
set_geometry(wl);
-
wl->window_size = wl->vdparams;
+ if (wl->opts->configure_bounds)
+ set_window_bounds(wl);
+
if ((!wl->vo_opts->fullscreen && !wl->vo_opts->window_maximized) ||
mp_rect_w(wl->geometry) == 0 || mp_rect_h(wl->geometry) == 0)
{
diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h
index 99c9769edd..365ae42dab 100644
--- a/video/out/wayland_common.h
+++ b/video/out/wayland_common.h
@@ -23,6 +23,7 @@
#include "vo.h"
struct wayland_opts {
+ int configure_bounds;
int disable_vsync;
int edge_pixels_pointer;
int edge_pixels_touch;
@@ -50,6 +51,8 @@ struct vo_wayland_state {
struct mp_rect window_size;
struct wl_list output_list;
struct vo_wayland_output *current_output;
+ int bounded_height;
+ int bounded_width;
int gcd;
int reduced_height;
int reduced_width;