diff options
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 99430a05..abdc363d 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -171,19 +171,6 @@ int numRoots_Window(const iWindow *d) { | |||
171 | return num; | 171 | return num; |
172 | } | 172 | } |
173 | 173 | ||
174 | static void setupUserInterface_Window(iWindow *d) { | ||
175 | #if defined (iPlatformAppleDesktop) | ||
176 | insertMacMenus_(); | ||
177 | #endif | ||
178 | /* One root is created by default. */ | ||
179 | d->roots[0] = new_Root(); | ||
180 | setCurrent_Root(d->roots[0]); | ||
181 | createUserInterface_Root(d->roots[0]); | ||
182 | setCurrent_Root(NULL); | ||
183 | /* One of the roots always has keyboard input focus. */ | ||
184 | d->keyRoot = d->roots[0]; | ||
185 | } | ||
186 | |||
187 | static void windowSizeChanged_Window_(iWindow *d) { | 174 | static void windowSizeChanged_Window_(iWindow *d) { |
188 | const int numRoots = numRoots_Window(d); | 175 | const int numRoots = numRoots_Window(d); |
189 | const iInt2 rootSize = d->size; | 176 | const iInt2 rootSize = d->size; |
@@ -214,6 +201,19 @@ static void windowSizeChanged_Window_(iWindow *d) { | |||
214 | } | 201 | } |
215 | } | 202 | } |
216 | 203 | ||
204 | static void setupUserInterface_Window(iWindow *d) { | ||
205 | #if defined (iPlatformAppleDesktop) | ||
206 | insertMacMenus_(); | ||
207 | #endif | ||
208 | /* One root is created by default. */ | ||
209 | d->roots[0] = new_Root(); | ||
210 | setCurrent_Root(d->roots[0]); | ||
211 | createUserInterface_Root(d->roots[0]); | ||
212 | setCurrent_Root(NULL); | ||
213 | /* One of the roots always has keyboard input focus. */ | ||
214 | d->keyRoot = d->roots[0]; | ||
215 | } | ||
216 | |||
217 | static void updateSize_Window_(iWindow *d, iBool notifyAlways) { | 217 | static void updateSize_Window_(iWindow *d, iBool notifyAlways) { |
218 | iInt2 *size = &d->size; | 218 | iInt2 *size = &d->size; |
219 | const iInt2 oldSize = *size; | 219 | const iInt2 oldSize = *size; |
@@ -515,15 +515,15 @@ void init_Window(iWindow *d, iRect rect) { | |||
515 | 515 | ||
516 | void deinit_Window(iWindow *d) { | 516 | void deinit_Window(iWindow *d) { |
517 | iRecycle(); | 517 | iRecycle(); |
518 | if (theWindow_ == d) { | ||
519 | theWindow_ = NULL; | ||
520 | } | ||
521 | iForIndices(i, d->roots) { | 518 | iForIndices(i, d->roots) { |
522 | if (d->roots[i]) { | 519 | if (d->roots[i]) { |
523 | setCurrent_Root(d->roots[i]); | 520 | setCurrent_Root(d->roots[i]); |
524 | deinit_Root(d->roots[i]); | 521 | deinit_Root(d->roots[i]); |
525 | } | 522 | } |
526 | } | 523 | } |
524 | if (theWindow_ == d) { | ||
525 | theWindow_ = NULL; | ||
526 | } | ||
527 | setCurrent_Root(NULL); | 527 | setCurrent_Root(NULL); |
528 | delete_String(d->pendingSplitUrl); | 528 | delete_String(d->pendingSplitUrl); |
529 | deinit_Text(); | 529 | deinit_Text(); |
@@ -761,7 +761,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
761 | #if defined (iPlatformMobile) | 761 | #if defined (iPlatformMobile) |
762 | case SDL_WINDOWEVENT_RESIZED: | 762 | case SDL_WINDOWEVENT_RESIZED: |
763 | /* On mobile, this occurs when the display is rotated. */ | 763 | /* On mobile, this occurs when the display is rotated. */ |
764 | invalidate_Window_(d); | 764 | invalidate_Window(d); |
765 | postRefresh_App(); | 765 | postRefresh_App(); |
766 | return iTrue; | 766 | return iTrue; |
767 | #endif | 767 | #endif |
@@ -772,7 +772,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
772 | d->isExposed = iTrue; | 772 | d->isExposed = iTrue; |
773 | #if defined (iPlatformMobile) | 773 | #if defined (iPlatformMobile) |
774 | /* Returned to foreground, may have lost buffered content. */ | 774 | /* Returned to foreground, may have lost buffered content. */ |
775 | invalidate_Window_(d); | 775 | invalidate_Window(d); |
776 | postCommand_App("window.unfreeze"); | 776 | postCommand_App("window.unfreeze"); |
777 | #endif | 777 | #endif |
778 | return iFalse; | 778 | return iFalse; |
@@ -995,7 +995,7 @@ void draw_Window(iWindow *d) { | |||
995 | /* Check if root needs resizing. */ { | 995 | /* Check if root needs resizing. */ { |
996 | iInt2 renderSize; | 996 | iInt2 renderSize; |
997 | SDL_GetRendererOutputSize(d->render, &renderSize.x, &renderSize.y); | 997 | SDL_GetRendererOutputSize(d->render, &renderSize.x, &renderSize.y); |
998 | if (!isEqual_I2(renderSize, d->root->rect.size)) { | 998 | if (!isEqual_I2(renderSize, d->size)) { |
999 | updateSize_Window_(d, iTrue); | 999 | updateSize_Window_(d, iTrue); |
1000 | processEvents_App(postedEventsOnly_AppEventMode); | 1000 | processEvents_App(postedEventsOnly_AppEventMode); |
1001 | } | 1001 | } |
@@ -1007,8 +1007,13 @@ void draw_Window(iWindow *d) { | |||
1007 | init_Paint(&p); | 1007 | init_Paint(&p); |
1008 | /* Clear the window. The clear color is visible as a border around the window | 1008 | /* Clear the window. The clear color is visible as a border around the window |
1009 | when the custom frame is being used. */ { | 1009 | when the custom frame is being used. */ { |
1010 | setCurrent_Root(d->roots[0]); | ||
1010 | #if defined (iPlatformAppleMobile) | 1011 | #if defined (iPlatformAppleMobile) |
1011 | const iColor back = get_Color(tmBackground_ColorId); | 1012 | iColor back = get_Color(uiBackground_ColorId); |
1013 | if (deviceType_App() == phone_AppDeviceType) { | ||
1014 | /* Page background extends to safe area, so fill it completely. */ | ||
1015 | back = get_Color(tmBackground_ColorId); | ||
1016 | } | ||
1012 | #else | 1017 | #else |
1013 | const iColor back = get_Color(gotFocus && d->place.snap != maximized_WindowSnap && | 1018 | const iColor back = get_Color(gotFocus && d->place.snap != maximized_WindowSnap && |
1014 | ~winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP | 1019 | ~winFlags & SDL_WINDOW_FULLSCREEN_DESKTOP |