Better pos/resize code in SDL setWindowState()

This commit is contained in:
and3md 2017-04-08 14:29:41 +02:00
parent 71789a55b3
commit c8bc160e58
1 changed files with 12 additions and 21 deletions

View File

@ -301,29 +301,20 @@ class SDLWindow : Window {
// change size and/or position // change size and/or position
if (newWindowRect != RECT_VALUE_IS_NOT_SET && (newState == WindowState.normal || newState == WindowState.unspecified)) { if (newWindowRect != RECT_VALUE_IS_NOT_SET && (newState == WindowState.normal || newState == WindowState.unspecified)) {
if (newWindowRect.top == int.min || newWindowRect.left == int.min) { // change position
// no position specified if (newWindowRect.top != int.min && newWindowRect.left != int.min) {
if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) {
// change size only
SDL_SetWindowSize(_win, newWindowRect.right, newWindowRect.bottom);
res = true;
}
} else {
if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) {
// change size and position
SDL_SetWindowPosition(_win, newWindowRect.left, newWindowRect.top);
SDL_SetWindowSize(_win, newWindowRect.right, newWindowRect.bottom);
res = true;
} else {
// change position only
SDL_SetWindowPosition(_win, newWindowRect.left, newWindowRect.top); SDL_SetWindowPosition(_win, newWindowRect.left, newWindowRect.top);
res = true; res = true;
} }
// change size
if (newWindowRect.bottom != int.min && newWindowRect.right != int.min) {
SDL_SetWindowSize(_win, newWindowRect.right, newWindowRect.bottom);
res = true;
} }
} }
if (activate) if (activate) {
{
SDL_RaiseWindow(_win); SDL_RaiseWindow(_win);
res = true; res = true;
} }