diff --git a/video/out/win_state.c b/video/out/win_state.c index 96857160cf..b4bc9fdb7b 100644 --- a/video/out/win_state.c +++ b/video/out/win_state.c @@ -67,8 +67,9 @@ static void apply_autofit(int *w, int *h, int scr_w, int scr_h, // Compute the "suggested" window size and position and return it in *out_geo. // screen is the bounding box of the current screen within the virtual desktop. // Does not change *vo. -// screen: position of the screen on virtual desktop on which the window -// should be placed +// screen: position of the area on virtual desktop on which the video-content +// should be placed (maybe after excluding decorations, taskbars, etc) +// monitor: position of the monitor on virtual desktop (used for pixelaspect). // dpi_scale: the DPI multiplier to get from virtual to real coordinates // (>1 for "hidpi") // Use vo_apply_window_geometry() to copy the result into the vo. @@ -76,7 +77,8 @@ static void apply_autofit(int *w, int *h, int scr_w, int scr_h, // geometry additional to this code. This is to deal with initial window // placement, fullscreen handling, avoiding resize on reconfig() with no // size change, multi-monitor stuff, and possibly more. -void vo_calc_window_geometry2(struct vo *vo, const struct mp_rect *screen, +void vo_calc_window_geometry3(struct vo *vo, const struct mp_rect *screen, + const struct mp_rect *monitor, double dpi_scale, struct vo_win_geometry *out_geo) { struct mp_vo_opts *opts = vo->opts; @@ -103,9 +105,13 @@ void vo_calc_window_geometry2(struct vo *vo, const struct mp_rect *screen, int scr_w = screen->x1 - screen->x0; int scr_h = screen->y1 - screen->y0; - MP_DBG(vo, "screen size: %dx%d\n", scr_w, scr_h); + int mon_w = monitor->x1 - monitor->x0; + int mon_h = monitor->y1 - monitor->y0; - calc_monitor_aspect(opts, scr_w, scr_h, &out_geo->monitor_par, &d_w, &d_h); + MP_DBG(vo, "max content size: %dx%d\n", scr_w, scr_h); + MP_DBG(vo, "monitor size: %dx%d\n", mon_w, mon_h); + + calc_monitor_aspect(opts, mon_w, mon_h, &out_geo->monitor_par, &d_w, &d_h); apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit, true, true); apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit_smaller, true, false); @@ -125,6 +131,13 @@ void vo_calc_window_geometry2(struct vo *vo, const struct mp_rect *screen, out_geo->flags |= VO_WIN_FORCE_POS; } +// same as vo_calc_window_geometry3 with monitor assumed same as screen +void vo_calc_window_geometry2(struct vo *vo, const struct mp_rect *screen, + double dpi_scale, struct vo_win_geometry *out_geo) +{ + vo_calc_window_geometry3(vo, screen, screen, dpi_scale, out_geo); +} + void vo_calc_window_geometry(struct vo *vo, const struct mp_rect *screen, struct vo_win_geometry *out_geo) { diff --git a/video/out/win_state.h b/video/out/win_state.h index d495377bac..a253efa758 100644 --- a/video/out/win_state.h +++ b/video/out/win_state.h @@ -27,6 +27,9 @@ void vo_calc_window_geometry(struct vo *vo, const struct mp_rect *screen, struct vo_win_geometry *out_geo); void vo_calc_window_geometry2(struct vo *vo, const struct mp_rect *screen, double dpi_scale, struct vo_win_geometry *out_geo); +void vo_calc_window_geometry3(struct vo *vo, const struct mp_rect *screen, + const struct mp_rect *monitor, + double dpi_scale, struct vo_win_geometry *out_geo); void vo_apply_window_geometry(struct vo *vo, const struct vo_win_geometry *geo); #endif