diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-21 13:52:13 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-21 13:52:13 +0300 |
commit | ce928050f3f48db8c1dc46030f36fefc705de987 (patch) | |
tree | 59d75732f25df72240942e8365fe1eb42d6f5692 /src | |
parent | 12270ac15efb99c447c1d04bd4b4e811fef1e41b (diff) |
macOS: Window size/mode restoration tweaks
Don't bother with maximized mode, it causes a needless animation at launch.
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 18 | ||||
-rw-r--r-- | src/ui/window.c | 15 |
2 files changed, 16 insertions, 17 deletions
@@ -142,25 +142,15 @@ static iString *serializePrefs_App_(const iApp *d) { | |||
142 | y = d->window->lastRect.pos.y; | 142 | y = d->window->lastRect.pos.y; |
143 | w = d->window->lastRect.size.x; | 143 | w = d->window->lastRect.size.x; |
144 | h = d->window->lastRect.size.y; | 144 | h = d->window->lastRect.size.y; |
145 | #if 0 | ||
146 | SDL_GetWindowSize(d->window->win, &w, &h); | ||
147 | SDL_GetWindowPosition(d->window->win, &x, &y); | ||
148 | #i f defined (iPlatformLinux) | ||
149 | /* Workaround for window position being unaffected by decorations on creation. */ { | ||
150 | int bl, bt; | ||
151 | SDL_GetWindowBordersSize(d->window->win, &bt, &bl, NULL, NULL); | ||
152 | x -= bl; | ||
153 | y -= bt; | ||
154 | x = iMax(0, x); | ||
155 | y = iMax(0, y); | ||
156 | } | ||
157 | } | ||
158 | #endif | ||
159 | appendFormat_String(str, "window.setrect width:%d height:%d coord:%d %d\n", w, h, x, y); | 145 | appendFormat_String(str, "window.setrect width:%d height:%d coord:%d %d\n", w, h, x, y); |
160 | appendFormat_String(str, "sidebar.width arg:%d\n", width_SidebarWidget(sidebar)); | 146 | appendFormat_String(str, "sidebar.width arg:%d\n", width_SidebarWidget(sidebar)); |
147 | /* On macOS, maximization should be applied at creation time or the window will take | ||
148 | a moment to animate to its maximized size. */ | ||
149 | #if !defined (iPlatformApple) | ||
161 | if (isMaximized) { | 150 | if (isMaximized) { |
162 | appendFormat_String(str, "~window.maximize\n"); | 151 | appendFormat_String(str, "~window.maximize\n"); |
163 | } | 152 | } |
153 | #endif | ||
164 | } | 154 | } |
165 | if (isVisible_Widget(sidebar)) { | 155 | if (isVisible_Widget(sidebar)) { |
166 | appendCStr_String(str, "sidebar.toggle\n"); | 156 | appendCStr_String(str, "sidebar.toggle\n"); |
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) { | |||
597 | return d->render; | 597 | return d->render; |
598 | } | 598 | } |
599 | 599 | ||
600 | static iBool isMaximized_Window_(const iWindow *d) { | ||
601 | #if !defined (iPlatformApple) | ||
602 | return (SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED)) != 0; | ||
603 | #else | ||
604 | iUnused(d); | ||
605 | return iFalse; /* There is fullscreen mode but that is not handled at the moment. */ | ||
606 | #endif | ||
607 | } | ||
608 | |||
600 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | 609 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { |
601 | switch (ev->event) { | 610 | switch (ev->event) { |
602 | #if defined (LAGRANGE_ENABLE_WINDOWPOS_FIX) | 611 | #if defined (LAGRANGE_ENABLE_WINDOWPOS_FIX) |
@@ -610,10 +619,10 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
610 | return iFalse; | 619 | return iFalse; |
611 | #endif | 620 | #endif |
612 | case SDL_WINDOWEVENT_MOVED: { | 621 | case SDL_WINDOWEVENT_MOVED: { |
613 | if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { | 622 | if (!isMaximized_Window_(d)) { |
614 | d->lastRect.pos = init_I2(ev->data1, ev->data2); | 623 | d->lastRect.pos = init_I2(ev->data1, ev->data2); |
615 | iInt2 border = zero_I2(); | 624 | iInt2 border = zero_I2(); |
616 | #if defined (iPlatformMsys) || defined (iPlatformLinux) | 625 | #if !defined (iPlatformApple) |
617 | SDL_GetWindowBordersSize(d->win, &border.y, &border.x, NULL, NULL); | 626 | SDL_GetWindowBordersSize(d->win, &border.y, &border.x, NULL, NULL); |
618 | #endif | 627 | #endif |
619 | d->lastRect.pos = max_I2(zero_I2(), sub_I2(d->lastRect.pos, border)); | 628 | 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) { | |||
622 | } | 631 | } |
623 | case SDL_WINDOWEVENT_RESIZED: | 632 | case SDL_WINDOWEVENT_RESIZED: |
624 | case SDL_WINDOWEVENT_SIZE_CHANGED: | 633 | case SDL_WINDOWEVENT_SIZE_CHANGED: |
625 | if (!(SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { | 634 | if (!isMaximized_Window_(d)) { |
626 | d->lastRect.size = init_I2(ev->data1, ev->data2); | 635 | d->lastRect.size = init_I2(ev->data1, ev->data2); |
627 | } | 636 | } |
628 | updateRootSize_Window_(d); | 637 | updateRootSize_Window_(d); |