From c8bc160e58affe00c45e490c3ac6e53174521bc1 Mon Sep 17 00:00:00 2001 From: and3md Date: Sat, 8 Apr 2017 14:29:41 +0200 Subject: [PATCH] Better pos/resize code in SDL setWindowState() --- src/dlangui/platforms/sdl/sdlapp.d | 33 +++++++++++------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 173c09c9..c88e5878 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -300,30 +300,21 @@ class SDLWindow : Window { } // change size and/or position if (newWindowRect != RECT_VALUE_IS_NOT_SET && (newState == WindowState.normal || newState == WindowState.unspecified)) { - - if (newWindowRect.top == int.min || newWindowRect.left == int.min) { - // no position specified - 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); - res = true; - } + + // change position + if (newWindowRect.top != int.min && newWindowRect.left != int.min) { + SDL_SetWindowPosition(_win, newWindowRect.left, newWindowRect.top); + 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); res = true; }