diff options
author | Dudemanguy <random342@airmail.cc> | 2023-11-06 11:22:04 -0600 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-11-06 23:13:31 +0000 |
commit | f4c5fa12cb7f7111cc733efddc3f0d780221923d (patch) | |
tree | d32c35a3ec966aafa6d90022da48761a6cfa20b6 /video | |
parent | 953176ee423445069bae49bf8e9bc36f4390de4c (diff) | |
download | mpv-f4c5fa12cb7f7111cc733efddc3f0d780221923d.tar.bz2 mpv-f4c5fa12cb7f7111cc733efddc3f0d780221923d.tar.xz |
wayland: improve wl_output guessing before mpv window is mapped
There's some geometry-related things that mpv has to calculate before
the window is actually mapped onto the screen in wayland. But there's no
way to know which output the window will end up on before it happens, so
it's possible to calculate it using the wrong values. mpv corrects
itself later when the surface event happens, but making the initial
guess work better can help in certain cases.
find_output is the only thing that needs to be changed here. Its main
purpose is to grab the right output based on user settings when we're
trying to full screen and giving a fallback in case we don't have
wl->current_output yet. The x11 code already does something similar, so
we're basically just copying it. Allow user settings like --screen and
--screen-name to influence the initial wl_output guess. Those options
won't actually place the window on that specific screen since we can't
do that in wayland, but if the user knows where the window will end up
beforehand it makes sense to listen to the arguments they pass. If
something goes wrong, then we just fallback to 0 like before.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/wayland_common.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index 6fb3a0a339..381a934c30 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -1620,8 +1620,9 @@ static void guess_focus(struct vo_wayland_state *wl) static struct vo_wayland_output *find_output(struct vo_wayland_state *wl) { int index = 0; - int screen_id = wl->vo_opts->fsscreen_id; - char *screen_name = wl->vo_opts->fsscreen_name; + struct mp_vo_opts *opts = wl->vo_opts; + int screen_id = opts->fullscreen ? opts->fsscreen_id : opts->screen_id; + char *screen_name = opts->fullscreen ? opts->fsscreen_name : opts->screen_name; struct vo_wayland_output *output = NULL; struct vo_wayland_output *fallback_output = NULL; wl_list_for_each(output, &wl->output_list, link) { @@ -1639,9 +1640,9 @@ static struct vo_wayland_output *find_output(struct vo_wayland_state *wl) if (!fallback_output) { MP_ERR(wl, "No screens could be found!\n"); return NULL; - } else if (wl->vo_opts->fsscreen_id >= 0) { + } else if (screen_id >= 0) { MP_WARN(wl, "Screen index %i not found/unavailable! Falling back to screen 0!\n", screen_id); - } else if (wl->vo_opts->fsscreen_name) { + } else if (screen_name && screen_name[0]) { MP_WARN(wl, "Screen name %s not found/unavailable! Falling back to screen 0!\n", screen_name); } return fallback_output; |