Fix setWindowState() on windows, change resize behavior to be compatible with SDL.

This commit is contained in:
and3md 2017-06-29 20:22:54 +02:00
parent ab1ddc7529
commit c8ebb6bd68
1 changed files with 19 additions and 11 deletions

View File

@ -488,26 +488,34 @@ class Win32Window : Window {
default:
break;
}
res = true;
}
return true;
break;
case WindowState.maximized:
if (_windowState != WindowState.maximized || activate)
if (_windowState != WindowState.maximized || activate) {
ShowWindow(_hwnd, activate ? SW_SHOWMAXIMIZED : SW_MAXIMIZE);
return true;
res = true;
}
break;
case WindowState.minimized:
if (_windowState != WindowState.minimized || activate)
if (_windowState != WindowState.minimized || activate) {
ShowWindow(_hwnd, activate ? SW_SHOWMINIMIZED : SW_MINIMIZE);
return true;
res = true;
}
break;
case WindowState.hidden:
if (_windowState != WindowState.hidden)
if (_windowState != WindowState.hidden) {
ShowWindow(_hwnd, SW_HIDE);
return true;
case WindowState.normal:
res = true;
}
break;
case WindowState.normal:
if (_windowState != WindowState.normal || activate) {
ShowWindow(_hwnd, activate ? SW_SHOWNORMAL : SW_SHOWNA); // SW_RESTORE
res = true;
}
res = true;
break;
default:
break;
}
@ -520,13 +528,13 @@ class Win32Window : Window {
// no position specified
if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) {
// change size only
SetWindowPos(_hwnd, NULL, 0, 0, newWindowRect.right, newWindowRect.bottom, flags | SWP_NOMOVE);
SetWindowPos(_hwnd, NULL, 0, 0, newWindowRect.right + 2 * GetSystemMetrics(SM_CXDLGFRAME), newWindowRect.bottom + GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYDLGFRAME), flags | SWP_NOMOVE);
return true;
}
} else {
if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) {
// change size and position
SetWindowPos(_hwnd, NULL, newWindowRect.left, newWindowRect.top, newWindowRect.width, newWindowRect.height, flags);
SetWindowPos(_hwnd, NULL, newWindowRect.left, newWindowRect.top, newWindowRect.right + 2 * GetSystemMetrics(SM_CXDLGFRAME), newWindowRect.bottom + GetSystemMetrics(SM_CYCAPTION) + 2 * GetSystemMetrics(SM_CYDLGFRAME), flags);
return true;
} else {
// change position only