summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-08-12 20:45:16 +0300
committeravih <avih@users.noreply.github.com>2021-09-06 10:16:10 +0300
commit2b1579b1c81500ffd0e49954bb380b7016ff33c3 (patch)
tree8d8d62f774504bd0d0d7005983b79abe1f5035c5
parent6f23aa0d3ee91aec54cf46dd52509d98a41f09f2 (diff)
downloadmpv-2b1579b1c81500ffd0e49954bb380b7016ff33c3.tar.bz2
mpv-2b1579b1c81500ffd0e49954bb380b7016ff33c3.tar.xz
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.
-rw-r--r--video/out/win_state.c23
-rw-r--r--video/out/win_state.h3
2 files changed, 21 insertions, 5 deletions
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;
+
+ 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, scr_w, scr_h, &out_geo->monitor_par, &d_w, &d_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