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: default:
break; break;
} }
res = true;
} }
return true; break;
case WindowState.maximized: case WindowState.maximized:
if (_windowState != WindowState.maximized || activate) if (_windowState != WindowState.maximized || activate) {
ShowWindow(_hwnd, activate ? SW_SHOWMAXIMIZED : SW_MAXIMIZE); ShowWindow(_hwnd, activate ? SW_SHOWMAXIMIZED : SW_MAXIMIZE);
return true; res = true;
}
break;
case WindowState.minimized: case WindowState.minimized:
if (_windowState != WindowState.minimized || activate) if (_windowState != WindowState.minimized || activate) {
ShowWindow(_hwnd, activate ? SW_SHOWMINIMIZED : SW_MINIMIZE); ShowWindow(_hwnd, activate ? SW_SHOWMINIMIZED : SW_MINIMIZE);
return true; res = true;
}
break;
case WindowState.hidden: case WindowState.hidden:
if (_windowState != WindowState.hidden) if (_windowState != WindowState.hidden) {
ShowWindow(_hwnd, SW_HIDE); ShowWindow(_hwnd, SW_HIDE);
return true; res = true;
}
break;
case WindowState.normal: case WindowState.normal:
if (_windowState != WindowState.normal || activate) { if (_windowState != WindowState.normal || activate) {
ShowWindow(_hwnd, activate ? SW_SHOWNORMAL : SW_SHOWNA); // SW_RESTORE ShowWindow(_hwnd, activate ? SW_SHOWNORMAL : SW_SHOWNA); // SW_RESTORE
}
res = true; res = true;
}
break; break;
default: default:
break; break;
} }
@ -520,13 +528,13 @@ class Win32Window : Window {
// no position specified // no position specified
if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) { if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) {
// change size only // 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; return true;
} }
} else { } else {
if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) { if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) {
// change size and position // 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; return true;
} else { } else {
// change position only // change position only