1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-19 14:26:57 +00:00

win_state: remove redundant vo_calc_window_geometry functions

There's really no reason to have all these extra variants. It's not like
this is public API. Collapse it all into one vo_calc_window_geometry
function and callers can simply just pass the appropriate parameters to
get the same behavior as before. I'm about to edit this function again
in a future commit and I really don't want to make a
vo_calc_window_geometry4 for this so let's clean it up.
This commit is contained in:
Dudemanguy 2024-09-27 21:32:33 -05:00
parent 493cab7efc
commit 8b30a2386f
7 changed files with 12 additions and 27 deletions

View File

@ -426,7 +426,7 @@ class Common: NSObject {
y1: Int32(originY + rv.size.height))
var geo: vo_win_geometry = vo_win_geometry()
vo_calc_window_geometry2(vo, &screenRC, Double(screen.backingScaleFactor), &geo)
vo_calc_window_geometry(vo, &screenRC, &screenRC, Double(screen.backingScaleFactor), &geo)
vo_apply_window_geometry(vo, &geo)
let height = CGFloat(geo.win.y1 - geo.win.y0)

View File

@ -453,7 +453,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
struct mp_rect screenrc;
update_screeninfo(vo, &screenrc);
vo_calc_window_geometry(vo, &screenrc, &geo);
vo_calc_window_geometry(vo, &screenrc, &screenrc, 1.0, &geo);
vo_apply_window_geometry(vo, &geo);
int win_w = vo->dwidth;

View File

@ -1920,7 +1920,7 @@ static void window_reconfig(struct vo_w32_state *w32, bool force)
if (w32->dpi_scale == 0)
force_update_display_info(w32);
vo_calc_window_geometry3(vo, &screen, &mon, w32->dpi_scale, &geo);
vo_calc_window_geometry(vo, &screen, &mon, w32->dpi_scale, &geo);
vo_apply_window_geometry(vo, &geo);
bool reset_size = ((w32->o_dwidth != vo->dwidth ||

View File

@ -2320,7 +2320,7 @@ static void set_geometry(struct vo_wayland_state *wl, bool resize)
struct vo_win_geometry geo;
struct mp_rect screenrc = wl->current_output->geometry;
vo_calc_window_geometry2(vo, &screenrc, wl->scaling_factor, &geo);
vo_calc_window_geometry(vo, &screenrc, &screenrc, wl->scaling_factor, &geo);
vo_apply_window_geometry(vo, &geo);
int gcd = greatest_common_divisor(vo->dwidth, vo->dheight);

View File

@ -69,6 +69,8 @@ static void apply_autofit(int *w, int *h, int scr_w, int scr_h,
// Does not change *vo.
// screen: position of the area on virtual desktop on which the video-content
// should be placed (maybe after excluding decorations, taskbars, etc)
// can be the same as monitor for platforms that don't try to take into
// account 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")
@ -77,9 +79,9 @@ 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_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_calc_window_geometry(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;
@ -131,19 +133,6 @@ void vo_calc_window_geometry3(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)
{
vo_calc_window_geometry2(vo, screen, 1.0, out_geo);
}
// Copy the parameters in *geo to the vo fields.
// (Doesn't do anything else - windowing backends should trigger VO_EVENT_RESIZE
// to ensure that the VO reinitializes rendering properly.)

View File

@ -24,12 +24,8 @@ struct vo_win_geometry {
};
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);
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

View File

@ -1809,7 +1809,7 @@ void vo_x11_config_vo_window(struct vo *vo)
vo_x11_update_screeninfo(vo);
struct vo_win_geometry geo;
vo_calc_window_geometry2(vo, &x11->screenrc, x11->dpi_scale, &geo);
vo_calc_window_geometry(vo, &x11->screenrc, &x11->screenrc, x11->dpi_scale, &geo);
vo_apply_window_geometry(vo, &geo);
struct mp_rect rc = geo.win;