video/out/win_state: allow internal size constraint for window_geometry
Will be useful to limit the size directly based on platform requirement.
This commit is contained in:
1 parent
8142c831f0
commit
a34ecb5284
7 files changed
+24
-7
No files matched your search
@@ -428,7 +428,7 @@ class Common: NSObject {
|
||||
y1: Int32(originY + rv.size.height))
|
||||
|
||||
var geo: vo_win_geometry = vo_win_geometry()
|
||||
vo_calc_window_geometry(vo, vo.pointee.opts, &screenRC, &screenRC, Double(screen.backingScaleFactor), false, &geo)
|
||||
vo_calc_window_geometry(vo, vo.pointee.opts, &screenRC, &screenRC, Double(screen.backingScaleFactor), false, &geo, nil)
|
||||
vo_apply_window_geometry(vo, &geo)
|
||||
|
||||
let height = CGFloat(geo.win.y1 - geo.win.y0)
|
||||
|
||||
+1
-1
@@ -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, vc->opts_cache->opts, &screenrc, &screenrc, 1.0, false, &geo);
|
||||
vo_calc_window_geometry(vo, vc->opts_cache->opts, &screenrc, &screenrc, 1.0, false, &geo, NULL);
|
||||
vo_apply_window_geometry(vo, &geo);
|
||||
|
||||
int win_w = vo->dwidth;
|
||||
|
||||
@@ -1963,7 +1963,7 @@ static void window_reconfig(struct vo_w32_state *w32, bool force)
|
||||
force_update_display_info(w32);
|
||||
|
||||
vo_calc_window_geometry(vo, w32->opts, &screen, &mon, w32->dpi_scale,
|
||||
!w32->window_bounds_initialized, &geo);
|
||||
!w32->window_bounds_initialized, &geo, NULL);
|
||||
vo_apply_window_geometry(vo, &geo);
|
||||
|
||||
bool reset_size = ((w32->o_dwidth != vo->dwidth ||
|
||||
|
||||
@@ -3781,7 +3781,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_geometry(vo, wl->opts, &screenrc, &screenrc, wl->scaling_factor, false, &geo);
|
||||
vo_calc_window_geometry(vo, wl->opts, &screenrc, &screenrc, wl->scaling_factor, false, &geo, NULL);
|
||||
vo_apply_window_geometry(vo, &geo);
|
||||
|
||||
int gcd = greatest_common_divisor(vo->dwidth, vo->dheight);
|
||||
|
||||
+16
-1
@@ -77,6 +77,9 @@ static void apply_autofit(int *w, int *h, int scr_w, int scr_h,
|
||||
// force_center: force centering x/y in the middle of the given screen even if
|
||||
// opts->force_window_position is not set. ignored if the user
|
||||
// supplies valid x/y coordinates on their own.
|
||||
// size_constraint: if non-NULL, the resulting size will be limited by the size
|
||||
// specified in this geometry. This applies to both autofit
|
||||
// and geometry options.
|
||||
// Use vo_apply_window_geometry() to copy the result into the vo.
|
||||
// NOTE: currently, all windowing backends do their own handling of window
|
||||
// geometry additional to this code. This is to deal with initial window
|
||||
@@ -85,7 +88,8 @@ static void apply_autofit(int *w, int *h, int scr_w, int scr_h,
|
||||
void vo_calc_window_geometry(struct vo *vo, struct mp_vo_opts *opts,
|
||||
const struct mp_rect *screen,
|
||||
const struct mp_rect *monitor, double dpi_scale,
|
||||
bool force_center, struct vo_win_geometry *out_geo)
|
||||
bool force_center, struct vo_win_geometry *out_geo,
|
||||
struct m_geometry *size_constraint)
|
||||
{
|
||||
*out_geo = (struct vo_win_geometry){0};
|
||||
|
||||
@@ -120,6 +124,8 @@ void vo_calc_window_geometry(struct vo *vo, struct mp_vo_opts *opts,
|
||||
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);
|
||||
apply_autofit(&d_w, &d_h, scr_w, scr_h, &opts->autofit_larger, false, true);
|
||||
if (size_constraint)
|
||||
apply_autofit(&d_w, &d_h, scr_w, scr_h, size_constraint, false, true);
|
||||
|
||||
out_geo->win.x0 = (int)(scr_w - d_w) / 2;
|
||||
out_geo->win.y0 = (int)(scr_h - d_h) / 2;
|
||||
@@ -128,6 +134,15 @@ void vo_calc_window_geometry(struct vo *vo, struct mp_vo_opts *opts,
|
||||
m_geometry_apply(&out_geo->win.x0, &out_geo->win.y0, &d_w, &d_h,
|
||||
scr_w, scr_h, center, &opts->geometry);
|
||||
|
||||
if (size_constraint) {
|
||||
int old_w = d_w, old_h = d_h;
|
||||
apply_autofit(&d_w, &d_h, scr_w, scr_h, size_constraint, false, true);
|
||||
if (!opts->geometry.xy_valid) {
|
||||
out_geo->win.x0 += (old_w - d_w) / 2;
|
||||
out_geo->win.y0 += (old_h - d_h) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
out_geo->win.x0 += screen->x0;
|
||||
out_geo->win.y0 += screen->y0;
|
||||
out_geo->win.x1 = out_geo->win.x0 + d_w;
|
||||
|
||||
@@ -24,11 +24,13 @@ struct vo_win_geometry {
|
||||
};
|
||||
|
||||
struct mp_vo_opts;
|
||||
struct m_geometry;
|
||||
|
||||
void vo_calc_window_geometry(struct vo *vo, struct mp_vo_opts *opts,
|
||||
const struct mp_rect *screen,
|
||||
const struct mp_rect *monitor, double dpi_scale,
|
||||
bool force_center, struct vo_win_geometry *out_geo);
|
||||
bool force_center, struct vo_win_geometry *out_geo,
|
||||
struct m_geometry *size_constraint);
|
||||
void vo_apply_window_geometry(struct vo *vo, const struct vo_win_geometry *geo);
|
||||
|
||||
#endif
|
||||
@@ -1806,7 +1806,7 @@ void vo_x11_config_vo_window(struct vo *vo)
|
||||
|
||||
struct vo_win_geometry geo;
|
||||
vo_calc_window_geometry(vo, opts, &x11->screenrc, &x11->screenrc, x11->dpi_scale,
|
||||
!x11->pseudo_mapped, &geo);
|
||||
!x11->pseudo_mapped, &geo, NULL);
|
||||
vo_apply_window_geometry(vo, &geo);
|
||||
|
||||
struct mp_rect rc = !x11->pseudo_mapped || opts->auto_window_resize || opts->geometry.wh_valid ||
|
||||
|
||||
Reference in new issue
Block a user