wayland: add auto choice to wayland-configure-bounds

Previously, this defaulted to yes and configure-bounds from the
compositor would always apply. In the case where the user explicitly set
autofit or geometry, this could be confusing because configure-bounds
would take precedence over it. Instead, let's add an auto choice and
make that the default. If we detect that the option is on auto and that
there is autofit/geometry being set, then ignore the event. This should
be more intuitive since someone who bothers to explicitly set mpv's
geometry would naturally expect that geometry to actually apply.
This commit is contained in:
Dudemanguy 2023-01-26 14:21:58 -06:00
parent adc04dbba0
commit da81a6d532
2 changed files with 16 additions and 6 deletions

View File

@ -5610,13 +5610,13 @@ them.
``--wayland-app-id=<string>`` ``--wayland-app-id=<string>``
Set the client app id for Wayland-based video output methods (default: ``mpv``). Set the client app id for Wayland-based video output methods (default: ``mpv``).
``--wayland-configure-bounds=<yes|no>`` ``--wayland-configure-bounds=<auto|yes|no>``
Controls whether or not mpv opts into the configure bounds event if sent by the 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 compositor (default: auto). This restricts the initial size of the mpv window to
a certain maximum size intended by the compositor. In most cases, this simply 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 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 it first renders. With the default value of ``auto``, configure-bounds will
``geometry`` type settings if the configure bounds are used. silently be ignored if any ``autofit`` or ``geometry`` type option is also set.
``--wayland-content-type=<auto|none|photo|video|game>`` ``--wayland-content-type=<auto|none|photo|video|game>``
If supported by the compositor, mpv will send a hint using the content-type If supported by the compositor, mpv will send a hint using the content-type

View File

@ -131,7 +131,8 @@ static const struct mp_keymap keymap[] = {
#define OPT_BASE_STRUCT struct wayland_opts #define OPT_BASE_STRUCT struct wayland_opts
const struct m_sub_options wayland_conf = { const struct m_sub_options wayland_conf = {
.opts = (const struct m_option[]) { .opts = (const struct m_option[]) {
{"wayland-configure-bounds", OPT_FLAG(configure_bounds)}, {"wayland-configure-bounds", OPT_CHOICE(configure_bounds,
{"auto", -1}, {"no", 0}, {"yes", 1})},
{"wayland-disable-vsync", OPT_FLAG(disable_vsync)}, {"wayland-disable-vsync", OPT_FLAG(disable_vsync)},
{"wayland-edge-pixels-pointer", OPT_INT(edge_pixels_pointer), {"wayland-edge-pixels-pointer", OPT_INT(edge_pixels_pointer),
M_RANGE(0, INT_MAX)}, M_RANGE(0, INT_MAX)},
@ -141,7 +142,7 @@ const struct m_sub_options wayland_conf = {
}, },
.size = sizeof(struct wayland_opts), .size = sizeof(struct wayland_opts),
.defaults = &(struct wayland_opts) { .defaults = &(struct wayland_opts) {
.configure_bounds = true, .configure_bounds = -1,
.disable_vsync = false, .disable_vsync = false,
.edge_pixels_pointer = 10, .edge_pixels_pointer = 10,
.edge_pixels_touch = 32, .edge_pixels_touch = 32,
@ -1706,6 +1707,15 @@ static void set_surface_scaling(struct vo_wayland_state *wl)
static void set_window_bounds(struct vo_wayland_state *wl) static void set_window_bounds(struct vo_wayland_state *wl)
{ {
// If the user has set geometry/autofit and the option is auto,
// don't use these.
if (wl->opts->configure_bounds == -1 && (wl->vo_opts->geometry.wh_valid ||
wl->vo_opts->autofit.wh_valid || wl->vo_opts->autofit_larger.wh_valid ||
wl->vo_opts->autofit_smaller.wh_valid))
{
return;
}
if (wl->bounded_width && wl->bounded_width < wl->window_size.x1) if (wl->bounded_width && wl->bounded_width < wl->window_size.x1)
wl->window_size.x1 = wl->bounded_width; wl->window_size.x1 = wl->bounded_width;
if (wl->bounded_height && wl->bounded_height < wl->window_size.y1) if (wl->bounded_height && wl->bounded_height < wl->window_size.y1)