mirror of
https://github.com/mpv-player/mpv
synced 2025-02-19 14:26:57 +00:00
win32: fix window size restore after maximize state
This remembers and sets window-scale when exiting maximized state. Also fixes not staying in maximized state when exiting fullscreen mode. Fixes: #14126
This commit is contained in:
parent
62abcbdd88
commit
6667b9723e
@ -1069,7 +1069,7 @@ static void update_fullscreen_state(struct vo_w32_state *w32)
|
||||
m_config_cache_write_opt(w32->opts_cache,
|
||||
&w32->opts->fullscreen);
|
||||
|
||||
if (toggle_fs) {
|
||||
if (toggle_fs && (!w32->opts->window_maximized || w32->unmaximize)) {
|
||||
if (w32->current_fs) {
|
||||
// Save window rect when switching to fullscreen.
|
||||
w32->prev_windowrc = w32->windowrc;
|
||||
@ -1104,6 +1104,8 @@ static void update_minimized_state(struct vo_w32_state *w32)
|
||||
}
|
||||
}
|
||||
|
||||
static void update_window_state(struct vo_w32_state *w32);
|
||||
|
||||
static void update_maximized_state(struct vo_w32_state *w32, bool leaving_fullscreen)
|
||||
{
|
||||
if (w32->parent)
|
||||
@ -1115,6 +1117,8 @@ static void update_maximized_state(struct vo_w32_state *w32, bool leaving_fullsc
|
||||
if (w32->current_fs && !leaving_fullscreen)
|
||||
return;
|
||||
|
||||
bool toggle = !w32->opts->window_maximized && IsMaximized(w32->window);
|
||||
|
||||
WINDOWPLACEMENT wp = { .length = sizeof wp };
|
||||
GetWindowPlacement(w32->window, &wp);
|
||||
|
||||
@ -1134,6 +1138,11 @@ static void update_maximized_state(struct vo_w32_state *w32, bool leaving_fullsc
|
||||
ShowWindow(w32->window, SW_SHOWNOACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
if (toggle && !w32->current_fs) {
|
||||
w32->windowrc = w32->prev_windowrc;
|
||||
update_window_state(w32);
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_visible(HWND window)
|
||||
@ -1168,7 +1177,7 @@ static void update_window_state(struct vo_w32_state *w32)
|
||||
// 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) {
|
||||
if (w32->unmaximize && !w32->current_fs) {
|
||||
WINDOWPLACEMENT wp = { .length = sizeof wp };
|
||||
GetWindowPlacement(w32->window, &wp);
|
||||
wp.showCmd = SW_SHOWNOACTIVATE;
|
||||
@ -2268,7 +2277,8 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg)
|
||||
if (!w32->window_bounds_initialized)
|
||||
return VO_FALSE;
|
||||
|
||||
RECT *rc = w32->current_fs ? &w32->prev_windowrc : &w32->windowrc;
|
||||
RECT *rc = (w32->current_fs || w32->opts->window_maximized)
|
||||
? &w32->prev_windowrc : &w32->windowrc;
|
||||
s[0] = rect_w(*rc);
|
||||
s[1] = rect_h(*rc);
|
||||
return VO_TRUE;
|
||||
@ -2282,7 +2292,7 @@ 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) {
|
||||
if (w32->opts->window_maximized && !w32->current_fs) {
|
||||
w32->unmaximize = true;
|
||||
}
|
||||
w32->fit_on_screen = true;
|
||||
|
Loading…
Reference in New Issue
Block a user