Skip to content

Commit 9eaa705

Browse files
committed
Merge pull request godotengine#112534 from Noojuno/fix-windows-minimize-bug
Windows: Fix window_get_size_with_decorations returning an invalid size when restoring from minimize
2 parents 734fe45 + 3497a5d commit 9eaa705

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

platform/windows/display_server_windows.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,11 @@ Size2i DisplayServerWindows::window_get_size_with_decorations(WindowID p_window)
23002300
ERR_FAIL_COND_V(!windows.has(p_window), Size2i());
23012301
const WindowData &wd = windows[p_window];
23022302

2303+
// GetWindowRect() returns a zero rect for a minimized window, so we need to get the size in another way.
2304+
if (wd.minimized) {
2305+
return Size2(wd.width_with_decorations, wd.height_with_decorations);
2306+
}
2307+
23032308
RECT r;
23042309
if (GetWindowRect(wd.hWnd, &r)) { // Retrieves area inside of window border, including decoration.
23052310
int off_x = (wd.multiwindow_fs || (!wd.fullscreen && wd.borderless && wd.maximized)) ? FS_TRANSP_BORDER : 0;
@@ -5803,6 +5808,8 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
58035808
if (!window.minimized) {
58045809
window.width = window_client_rect.size.width;
58055810
window.height = window_client_rect.size.height;
5811+
window.width_with_decorations = window_rect.size.width;
5812+
window.height_with_decorations = window_rect.size.height;
58065813

58075814
rect_changed = true;
58085815
}

platform/windows/display_server_windows.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ class DisplayServerWindows : public DisplayServer {
341341
Size2 min_size;
342342
Size2 max_size;
343343
int width = 0, height = 0;
344+
int width_with_decorations = 0, height_with_decorations = 0;
344345

345346
Size2 window_rect;
346347
Point2 last_pos;

0 commit comments

Comments
 (0)