summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-08-20 18:27:46 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-08-20 18:27:46 +0300
commitb7fe868ef9eda18ab1a537e5b77c269d4f1fd1b8 (patch)
tree30f49f9b1fcf1fa055e29617b40139dd10e1cf23 /src/ui/window.c
parente482b978ab37177a949fdeb7522e26672d440b0e (diff)
Added build options to force phone/tablet mobile UI
These options are mostly useful on mobile platforms that are not iOS or Android, and for testing purposes.
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index febf5fe8..3bafd9a4 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -440,7 +440,11 @@ void init_Window(iWindow *d, iRect rect) {
440 if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) { 440 if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) {
441 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); 441 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect));
442 } 442 }
443#if defined (iPlatformMobile)
444 const iInt2 minSize = zero_I2(); /* windows aren't independently resizable */
445#else
443 const iInt2 minSize = init_I2(425, 325); 446 const iInt2 minSize = init_I2(425, 325);
447#endif
444 SDL_SetWindowMinimumSize(d->win, minSize.x, minSize.y); 448 SDL_SetWindowMinimumSize(d->win, minSize.x, minSize.y);
445 SDL_SetWindowTitle(d->win, "Lagrange"); 449 SDL_SetWindowTitle(d->win, "Lagrange");
446 /* Some info. */ { 450 /* Some info. */ {
@@ -709,7 +713,6 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
709 } 713 }
710 } 714 }
711#endif /* defined LAGRANGE_ENABLE_CUSTOM_FRAME */ 715#endif /* defined LAGRANGE_ENABLE_CUSTOM_FRAME */
712 //printf("MOVED: %d, %d\n", ev->data1, ev->data2); fflush(stdout);
713 if (unsnap_Window_(d, &newPos)) { 716 if (unsnap_Window_(d, &newPos)) {
714 return iTrue; 717 return iTrue;
715 } 718 }
@@ -750,7 +753,13 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
750 case SDL_WINDOWEVENT_MINIMIZED: 753 case SDL_WINDOWEVENT_MINIMIZED:
751 d->isMinimized = iTrue; 754 d->isMinimized = iTrue;
752 return iTrue; 755 return iTrue;
753#endif /* defined (iPlatformDesktop) */ 756#else /* if defined (!iPlatformDesktop) */
757 case SDL_WINDOWEVENT_RESIZED:
758 /* On mobile, this occurs when the display is rotated. */
759 invalidate_Window(d);
760 postRefresh_App();
761 return iTrue;
762#endif
754 case SDL_WINDOWEVENT_LEAVE: 763 case SDL_WINDOWEVENT_LEAVE:
755 unhover_Widget(); 764 unhover_Widget();
756 d->isMouseInside = iFalse; 765 d->isMouseInside = iFalse;
@@ -760,19 +769,12 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
760 d->isMouseInside = iTrue; 769 d->isMouseInside = iTrue;
761 postCommand_App("window.mouse.entered"); 770 postCommand_App("window.mouse.entered");
762 return iTrue; 771 return iTrue;
763#if defined (iPlatformMobile)
764 case SDL_WINDOWEVENT_RESIZED:
765 /* On mobile, this occurs when the display is rotated. */
766 invalidate_Window(d);
767 postRefresh_App();
768 return iTrue;
769#endif
770 case SDL_WINDOWEVENT_FOCUS_GAINED: 772 case SDL_WINDOWEVENT_FOCUS_GAINED:
771 d->focusGainedAt = SDL_GetTicks(); 773 d->focusGainedAt = SDL_GetTicks();
772 setCapsLockDown_Keys(iFalse); 774 setCapsLockDown_Keys(iFalse);
773 postCommand_App("window.focus.gained"); 775 postCommand_App("window.focus.gained");
774 d->isExposed = iTrue; 776 d->isExposed = iTrue;
775#if defined (iPlatformMobile) 777#if !defined (iPlatformDesktop)
776 /* Returned to foreground, may have lost buffered content. */ 778 /* Returned to foreground, may have lost buffered content. */
777 invalidate_Window_(d, iTrue); 779 invalidate_Window_(d, iTrue);
778 postCommand_App("window.unfreeze"); 780 postCommand_App("window.unfreeze");
@@ -780,7 +782,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
780 return iFalse; 782 return iFalse;
781 case SDL_WINDOWEVENT_FOCUS_LOST: 783 case SDL_WINDOWEVENT_FOCUS_LOST:
782 postCommand_App("window.focus.lost"); 784 postCommand_App("window.focus.lost");
783#if defined (iPlatformMobile) 785#if !defined (iPlatformDesktop)
784 setFreezeDraw_Window(d, iTrue); 786 setFreezeDraw_Window(d, iTrue);
785#endif 787#endif
786 return iFalse; 788 return iFalse;
@@ -1020,7 +1022,6 @@ void draw_Window(iWindow *d) {
1020 if (d->isDrawFrozen) { 1022 if (d->isDrawFrozen) {
1021 return; 1023 return;
1022 } 1024 }
1023//#if defined (iPlatformMobile)
1024 /* Check if root needs resizing. */ { 1025 /* Check if root needs resizing. */ {
1025 iInt2 renderSize; 1026 iInt2 renderSize;
1026 SDL_GetRendererOutputSize(d->render, &renderSize.x, &renderSize.y); 1027 SDL_GetRendererOutputSize(d->render, &renderSize.x, &renderSize.y);
@@ -1029,7 +1030,6 @@ void draw_Window(iWindow *d) {
1029 processEvents_App(postedEventsOnly_AppEventMode); 1030 processEvents_App(postedEventsOnly_AppEventMode);
1030 } 1031 }
1031 } 1032 }
1032//#endif
1033 const int winFlags = SDL_GetWindowFlags(d->win); 1033 const int winFlags = SDL_GetWindowFlags(d->win);
1034 const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0; 1034 const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0;
1035 iPaint p; 1035 iPaint p;
@@ -1037,7 +1037,7 @@ void draw_Window(iWindow *d) {
1037 /* Clear the window. The clear color is visible as a border around the window 1037 /* Clear the window. The clear color is visible as a border around the window
1038 when the custom frame is being used. */ { 1038 when the custom frame is being used. */ {
1039 setCurrent_Root(d->roots[0]); 1039 setCurrent_Root(d->roots[0]);
1040#if defined (iPlatformAppleMobile) 1040#if defined (iPlatformMobile)
1041 iColor back = get_Color(uiBackground_ColorId); 1041 iColor back = get_Color(uiBackground_ColorId);
1042 if (deviceType_App() == phone_AppDeviceType) { 1042 if (deviceType_App() == phone_AppDeviceType) {
1043 /* Page background extends to safe area, so fill it completely. */ 1043 /* Page background extends to safe area, so fill it completely. */