Merge pull request #24078 from marcelofg55/win_min_bug
Fix wrong size and position when windows is minimized on Windows
This commit is contained in:
commit
49573817b8
2 changed files with 32 additions and 9 deletions
|
@ -727,16 +727,28 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WM_SIZE: {
|
case WM_MOVE: {
|
||||||
int window_w = LOWORD(lParam);
|
if (!IsIconic(hWnd)) {
|
||||||
int window_h = HIWORD(lParam);
|
int x = LOWORD(lParam);
|
||||||
if (window_w > 0 && window_h > 0 && !preserve_window_size) {
|
int y = HIWORD(lParam);
|
||||||
video_mode.width = window_w;
|
last_pos = Point2(x, y);
|
||||||
video_mode.height = window_h;
|
|
||||||
} else {
|
|
||||||
preserve_window_size = false;
|
|
||||||
set_window_size(Size2(video_mode.width, video_mode.height));
|
|
||||||
}
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case WM_SIZE: {
|
||||||
|
// Ignore size when a SIZE_MINIMIZED event is triggered
|
||||||
|
if (wParam != SIZE_MINIMIZED) {
|
||||||
|
int window_w = LOWORD(lParam);
|
||||||
|
int window_h = HIWORD(lParam);
|
||||||
|
if (window_w > 0 && window_h > 0 && !preserve_window_size) {
|
||||||
|
video_mode.width = window_w;
|
||||||
|
video_mode.height = window_h;
|
||||||
|
} else {
|
||||||
|
preserve_window_size = false;
|
||||||
|
set_window_size(Size2(video_mode.width, video_mode.height));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (wParam == SIZE_MAXIMIZED) {
|
if (wParam == SIZE_MAXIMIZED) {
|
||||||
maximized = true;
|
maximized = true;
|
||||||
minimized = false;
|
minimized = false;
|
||||||
|
@ -1685,6 +1697,10 @@ int OS_Windows::get_screen_dpi(int p_screen) const {
|
||||||
|
|
||||||
Point2 OS_Windows::get_window_position() const {
|
Point2 OS_Windows::get_window_position() const {
|
||||||
|
|
||||||
|
if (minimized) {
|
||||||
|
return last_pos;
|
||||||
|
}
|
||||||
|
|
||||||
RECT r;
|
RECT r;
|
||||||
GetWindowRect(hWnd, &r);
|
GetWindowRect(hWnd, &r);
|
||||||
return Point2(r.left, r.top);
|
return Point2(r.left, r.top);
|
||||||
|
@ -1705,9 +1721,15 @@ void OS_Windows::set_window_position(const Point2 &p_position) {
|
||||||
ClientToScreen(hWnd, (POINT *)&rect.right);
|
ClientToScreen(hWnd, (POINT *)&rect.right);
|
||||||
ClipCursor(&rect);
|
ClipCursor(&rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_pos = p_position;
|
||||||
}
|
}
|
||||||
Size2 OS_Windows::get_window_size() const {
|
Size2 OS_Windows::get_window_size() const {
|
||||||
|
|
||||||
|
if (minimized) {
|
||||||
|
return Size2(video_mode.width, video_mode.height);
|
||||||
|
}
|
||||||
|
|
||||||
RECT r;
|
RECT r;
|
||||||
if (GetClientRect(hWnd, &r)) { // Only area inside of window border
|
if (GetClientRect(hWnd, &r)) { // Only area inside of window border
|
||||||
return Size2(r.right - r.left, r.bottom - r.top);
|
return Size2(r.right - r.left, r.bottom - r.top);
|
||||||
|
|
|
@ -93,6 +93,7 @@ class OS_Windows : public OS {
|
||||||
HDC hDC; // Private GDI Device Context
|
HDC hDC; // Private GDI Device Context
|
||||||
HINSTANCE hInstance; // Holds The Instance Of The Application
|
HINSTANCE hInstance; // Holds The Instance Of The Application
|
||||||
HWND hWnd;
|
HWND hWnd;
|
||||||
|
Point2 last_pos;
|
||||||
|
|
||||||
HBITMAP hBitmap; //DIB section for layered window
|
HBITMAP hBitmap; //DIB section for layered window
|
||||||
uint8_t *dib_data;
|
uint8_t *dib_data;
|
||||||
|
|
Loading…
Reference in a new issue