diff --git a/video/out/gl_wayland.c b/video/out/gl_wayland.c index 3decda4bb6..83c8af7503 100644 --- a/video/out/gl_wayland.c +++ b/video/out/gl_wayland.c @@ -127,9 +127,7 @@ static bool egl_create_context(struct vo_wayland_state *wl, return true; } -static void egl_create_window(struct vo_wayland_state *wl, - uint32_t width, - uint32_t height) +static void egl_create_window(struct vo_wayland_state *wl) { wl->egl_context.egl_window = wl_egl_window_create(wl->window.video_surface, wl->window.width, @@ -157,7 +155,7 @@ static bool config_window_wayland(struct MPGLContext *ctx, bool enable_alpha = !!(flags & VOFLAG_ALPHA); bool ret = false; - if (!vo_wayland_config(ctx->vo, d_width, d_height, flags)) + if (!vo_wayland_config(ctx->vo, flags)) return false; if (!wl->egl_context.egl.ctx) { @@ -167,7 +165,7 @@ static bool config_window_wayland(struct MPGLContext *ctx, /* If successfully created the context and we don't want to hide the * window than also create the window immediately */ if (ret && !(VOFLAG_HIDDEN & flags)) - egl_create_window(wl, d_width, d_height); + egl_create_window(wl); return ret; } @@ -176,7 +174,7 @@ static bool config_window_wayland(struct MPGLContext *ctx, /* If the context exists and the hidden flag is unset then * create the window */ if (!(VOFLAG_HIDDEN & flags)) - egl_create_window(wl, d_width, d_height); + egl_create_window(wl); } return true; } diff --git a/video/out/vo_wayland.c b/video/out/vo_wayland.c index 715db800d2..d9b953b7b9 100644 --- a/video/out/vo_wayland.c +++ b/video/out/vo_wayland.c @@ -805,7 +805,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *fmt, int flags) buffer_pool_reinit(p, &p->osd_bufpool, MAX_OSD_PARTS, p->width, p->height, &fmttable[DEFAULT_ALPHA_FORMAT_ENTRY], p->wl->display.shm); - vo_wayland_config(vo, vo->dwidth, vo->dheight, flags); + vo_wayland_config(vo, flags); if (p->wl->window.events & VO_EVENT_RESIZE) resize(p); diff --git a/video/out/wayland_common.c b/video/out/wayland_common.c index b109446d32..55896b8210 100644 --- a/video/out/wayland_common.c +++ b/video/out/wayland_common.c @@ -39,7 +39,7 @@ #include "wayland_common.h" #include "vo.h" -#include "aspect.h" +#include "win_state.h" #include "osdep/timer.h" #include "input/input.h" @@ -1039,7 +1039,7 @@ static int vo_wayland_check_events (struct vo *vo) return wl->window.events; } -static void vo_wayland_update_screeninfo (struct vo *vo) +static void vo_wayland_update_screeninfo(struct vo *vo, struct mp_rect *screenrc) { struct vo_wayland_state *wl = vo->wayland; struct mp_vo_opts *opts = vo->opts; @@ -1047,7 +1047,7 @@ static void vo_wayland_update_screeninfo (struct vo *vo) wl_display_roundtrip(wl->display.display); - vo->xinerama_x = vo->xinerama_y = 0; + *screenrc = (struct mp_rect){0}; int screen_id = 0; @@ -1077,20 +1077,20 @@ static void vo_wayland_update_screeninfo (struct vo *vo) if (fsscreen_output) { wl->display.fs_output = fsscreen_output->output; - opts->screenwidth = fsscreen_output->width; - opts->screenheight = fsscreen_output->height; + screenrc->x1 = fsscreen_output->width; + screenrc->y1 = fsscreen_output->height; } else { wl->display.fs_output = NULL; /* current output is always 0 */ if (first_output) { - opts->screenwidth = first_output->width; - opts->screenheight = first_output->height; + screenrc->x1 = first_output->width; + screenrc->y1 = first_output->height; } } - wl->window.fs_width = opts->screenwidth; - wl->window.fs_height = opts->screenheight; + wl->window.fs_width = screenrc->x1; + wl->window.fs_height = screenrc->y1; } int vo_wayland_control (struct vo *vo, int *events, int request, void *arg) @@ -1112,9 +1112,6 @@ int vo_wayland_control (struct vo *vo, int *events, int request, void *arg) vo_wayland_border(vo); *events |= VO_EVENT_RESIZE; return VO_TRUE; - case VOCTRL_UPDATE_SCREENINFO: - vo_wayland_update_screeninfo(vo); - return VO_TRUE; case VOCTRL_GET_WINDOW_SIZE: { int *s = arg; s[0] = wl->window.width; @@ -1145,19 +1142,25 @@ int vo_wayland_control (struct vo *vo, int *events, int request, void *arg) return VO_NOTIMPL; } -bool vo_wayland_config (struct vo *vo, uint32_t d_width, - uint32_t d_height, uint32_t flags) +bool vo_wayland_config (struct vo *vo, uint32_t flags) { struct vo_wayland_state *wl = vo->wayland; - wl->window.p_width = d_width; - wl->window.p_height = d_height; - wl->window.aspect = d_width / (float) MPMAX(d_height, 1); + struct mp_rect screenrc; + vo_wayland_update_screeninfo(vo, &screenrc); + + struct vo_win_geometry geo; + vo_calc_window_geometry(vo, &screenrc, &geo); + vo_apply_window_geometry(vo, &geo); + + wl->window.p_width = vo->dwidth; + wl->window.p_height = vo->dheight; + wl->window.aspect = vo->dwidth / (float) MPMAX(vo->dheight, 1); if (!(flags & VOFLAG_HIDDEN)) { if (!wl->window.is_init) { - wl->window.width = d_width; - wl->window.height = d_height; + wl->window.width = vo->dwidth; + wl->window.height = vo->dheight; } if (vo->opts->fullscreen) { diff --git a/video/out/wayland_common.h b/video/out/wayland_common.h index 020282761a..dbfa41140f 100644 --- a/video/out/wayland_common.h +++ b/video/out/wayland_common.h @@ -140,7 +140,7 @@ struct vo_wayland_state { int vo_wayland_init(struct vo *vo); void vo_wayland_uninit(struct vo *vo); -bool vo_wayland_config(struct vo *vo, uint32_t d_width, uint32_t d_height, uint32_t flags); +bool vo_wayland_config(struct vo *vo, uint32_t flags); int vo_wayland_control(struct vo *vo, int *events, int request, void *arg); #endif /* MPLAYER_WAYLAND_COMMON_H */