From ce928050f3f48db8c1dc46030f36fefc705de987 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 21 Sep 2020 13:52:13 +0300 Subject: macOS: Window size/mode restoration tweaks Don't bother with maximized mode, it causes a needless animation at launch. --- src/ui/window.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/ui/window.c') diff --git a/src/ui/window.c b/src/ui/window.c index 6c7775ee..19432691 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -597,6 +597,15 @@ SDL_Renderer *renderer_Window(const iWindow *d) { return d->render; } +static iBool isMaximized_Window_(const iWindow *d) { +#if !defined (iPlatformApple) + return (SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED)) != 0; +#else + iUnused(d); + return iFalse; /* There is fullscreen mode but that is not handled at the moment. */ +#endif +} + static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { switch (ev->event) { #if defined (LAGRANGE_ENABLE_WINDOWPOS_FIX) @@ -610,10 +619,10 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { return iFalse; #endif case SDL_WINDOWEVENT_MOVED: { - if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { + if (!isMaximized_Window_(d)) { d->lastRect.pos = init_I2(ev->data1, ev->data2); iInt2 border = zero_I2(); -#if defined (iPlatformMsys) || defined (iPlatformLinux) +#if !defined (iPlatformApple) SDL_GetWindowBordersSize(d->win, &border.y, &border.x, NULL, NULL); #endif d->lastRect.pos = max_I2(zero_I2(), sub_I2(d->lastRect.pos, border)); @@ -622,7 +631,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { } case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_SIZE_CHANGED: - if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { + if (!isMaximized_Window_(d)) { d->lastRect.size = init_I2(ev->data1, ev->data2); } updateRootSize_Window_(d); -- cgit v1.2.3