diff options
author | nanahi <130121847+na-na-hi@users.noreply.github.com> | 2024-02-14 11:12:22 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-03-18 01:58:53 +0000 |
commit | 2be8976d59e01c181aefc4038a0b88975ca2804a (patch) | |
tree | 3109945b9496b3f4c9556f496f609c4170fc33b2 | |
parent | ead9f892b3dbe6999b625b6ce3e01c50e59ee69a (diff) | |
download | mpv-2be8976d59e01c181aefc4038a0b88975ca2804a.tar.bz2 mpv-2be8976d59e01c181aefc4038a0b88975ca2804a.tar.xz |
win32: fix window maximized state after setting window size
With runtime geometry change, currently it only results in a
SetWindowPos call to resize the window. However, SetWindowPos doesn't
change the window maximized state, so Windows still thinks that the
window is maximized even though it no longer covers the whole workspace.
This results in visual glitches, and if the window is dragged afterwards
it's "restored" again.
Fix this by correctly setting the window maximized state in this case.
-rw-r--r-- | video/out/w32_common.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 35351cfeaa..1d122ca5b8 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -185,6 +185,7 @@ struct vo_w32_state { BOOL win_arranging; bool conversion_mode_init; + bool unmaximize; }; static void adjust_window_rect(struct vo_w32_state *w32, HWND hwnd, RECT *rc) @@ -1081,6 +1082,19 @@ static void update_window_state(struct vo_w32_state *w32) wr.left, wr.top, rect_w(wr), rect_h(wr), SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOOWNERZORDER); + // Unmaximize the window if a size change is requested because SetWindowPos + // doesn't change the window maximized state. + // ShowWindow(SW_SHOWNOACTIVATE) can't be used here because it tries to + // "restore" the window to its size before it's maximized. + if (w32->unmaximize) { + WINDOWPLACEMENT wp = { .length = sizeof wp }; + GetWindowPlacement(w32->window, &wp); + wp.showCmd = SW_SHOWNOACTIVATE; + wp.rcNormalPosition = wr; + SetWindowPlacement(w32->window, &wp); + w32->unmaximize = false; + } + // Show the window if it's not yet visible if (!is_visible(w32->window)) { if (w32->opts->window_minimized) { @@ -2084,6 +2098,9 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) } else if (changed_option == &vo_opts->geometry || changed_option == &vo_opts->autofit || changed_option == &vo_opts->autofit_smaller || changed_option == &vo_opts->autofit_larger) { + if (w32->opts->window_maximized) { + w32->unmaximize = true; + } window_reconfig(w32, true); } } @@ -2120,6 +2137,9 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) RECT *rc = w32->current_fs ? &w32->prev_windowrc : &w32->windowrc; resize_and_move_rect(w32, rc, s[0], s[1]); + if (w32->opts->window_maximized) { + w32->unmaximize = true; + } w32->fit_on_screen = true; reinit_window_state(w32); return VO_TRUE; |