win_state: add vo_calc_window_geometry3

vo_calc_window_geometry2 (VCWG2) calculates both the pixelaspect and
the autofit sizes based on one "screen" rectangle.

However, these two calculations might need two different "screen"
rects if the fit should take into account decorations and/or taskbar
etc, while pixelaspect should be based on the full (monitor) rect.

VCWG3 does just that. It's the same as VCWG2, but with an additional
monitor rect which is used exclussively to calculate pixelaspect,
while the "screen" argument is used for fitting (like before).

VCWG2 now uses/calls VCWG3 with the same screen and monitor rects.

Currently yet unused.
This commit is contained in:
Avi Halachmi (:avih) 2021-08-12 20:45:16 +03:00 committed by avih
parent 6f23aa0d3e
commit 2b1579b1c8
2 changed files with 21 additions and 5 deletions

View File

@ -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)
{

View File

@ -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