Skip to content

Commit

Permalink
win32: fix resizing window when maximized
Browse files Browse the repository at this point in the history
This remembers and sets window-scale when exiting maximized state. Also
fixes not staying in maximized state when exiting fullscreen mode.

Fixes: mpv-player#14126
  • Loading branch information
kasper93 committed May 12, 2024
1 parent 3874145 commit a318efe
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions video/out/w32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,14 +1082,14 @@ static void update_fullscreen_state(struct vo_w32_state *w32)
&w32->opts->fullscreen);

if (toggle_fs) {
if (w32->current_fs) {
// Save window rect when switching to fullscreen.
if (w32->current_fs || IsMaximized(w32->window)) {
// Save window rect when switching to fullscreen or maximizing.
w32->prev_windowrc = w32->windowrc;
MP_VERBOSE(w32, "save window bounds: %d:%d:%d:%d\n",
(int)w32->windowrc.left, (int)w32->windowrc.top,
(int)rect_w(w32->windowrc), (int)rect_h(w32->windowrc));
} else {
// Restore window rect when switching from fullscreen.
// Restore window rect when switching from fullscreen or maximized.
w32->windowrc = w32->prev_windowrc;
}
}
Expand Down Expand Up @@ -1449,7 +1449,6 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
w32->windowrc.right = w32->windowrc.left + w;
w32->windowrc.bottom = w32->windowrc.top + h;
signal_events(w32, VO_EVENT_RESIZE);
MP_VERBOSE(w32, "resize window: %d:%d\n", w, h);
}

// Window may have been minimized, maximized or restored
Expand Down Expand Up @@ -2291,7 +2290,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 || IsMaximized(w32->window))
? &w32->prev_windowrc : &w32->windowrc;
s[0] = rect_w(*rc);
s[1] = rect_h(*rc);
return VO_TRUE;
Expand All @@ -2302,7 +2302,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 || IsMaximized(w32->window))
? &w32->prev_windowrc : &w32->windowrc;
resize_and_move_rect(w32, rc, s[0], s[1]);

if (w32->opts->window_maximized) {
Expand Down

0 comments on commit a318efe

Please sign in to comment.