From 4370dc0cb6c4ec29e4ba0055458c2e2fc8d5da82 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sun, 3 Mar 2024 13:57:56 -0500 Subject: win32: support runtime geometry update Similar to other platforms. Also make sure that the x/y positions are set on geometry update. --- video/out/w32_common.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'video/out/w32_common.c') diff --git a/video/out/w32_common.c b/video/out/w32_common.c index eb9f18948a..35351cfeaa 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1739,9 +1739,8 @@ static void run_message_loop(struct vo_w32_state *w32) mp_dispatch_queue_process(w32->dispatch, 1000); } -static void gui_thread_reconfig(void *ptr) +static void window_reconfig(struct vo_w32_state *w32, bool force) { - struct vo_w32_state *w32 = ptr; struct vo *vo = w32->vo; RECT r = get_working_area(w32); @@ -1764,14 +1763,14 @@ static void gui_thread_reconfig(void *ptr) vo_calc_window_geometry3(vo, &screen, &mon, w32->dpi_scale, &geo); vo_apply_window_geometry(vo, &geo); - bool reset_size = (w32->o_dwidth != vo->dwidth || + bool reset_size = ((w32->o_dwidth != vo->dwidth || w32->o_dheight != vo->dheight) && - w32->opts->auto_window_resize; + w32->opts->auto_window_resize) || force; w32->o_dwidth = vo->dwidth; w32->o_dheight = vo->dheight; - if (!w32->parent && !w32->window_bounds_initialized) { + if (!w32->parent && (!w32->window_bounds_initialized || force)) { SetRect(&w32->windowrc, geo.win.x0, geo.win.y0, geo.win.x0 + vo->dwidth, geo.win.y0 + vo->dheight); w32->prev_windowrc = w32->windowrc; @@ -1802,6 +1801,11 @@ finish: reinit_window_state(w32); } +static void gui_thread_reconfig(void *ptr) +{ + window_reconfig(ptr, false); +} + // Resize the window. On the first call, it's also made visible. void vo_w32_config(struct vo *vo) { @@ -2077,6 +2081,10 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) update_maximized_state(w32); } else if (changed_option == &vo_opts->window_corners) { update_corners_pref(w32); + } else if (changed_option == &vo_opts->geometry || changed_option == &vo_opts->autofit || + changed_option == &vo_opts->autofit_smaller || changed_option == &vo_opts->autofit_larger) + { + window_reconfig(w32, true); } } -- cgit v1.2.3