summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app.c6
-rw-r--r--src/ui/window.c34
2 files changed, 34 insertions, 6 deletions
diff --git a/src/app.c b/src/app.c
index 16cf14d4..9e00c408 100644
--- a/src/app.c
+++ b/src/app.c
@@ -859,11 +859,11 @@ void processEvents_App(enum iAppEventMode eventMode) {
859 case SDL_APP_LOWMEMORY: 859 case SDL_APP_LOWMEMORY:
860 clearCache_App_(); 860 clearCache_App_();
861 break; 861 break;
862 case SDL_APP_WILLENTERFOREGROUND: 862 case SDL_APP_DIDENTERFOREGROUND:
863 postRefresh_App(); 863 postRefresh_App();
864 break; 864 break;
865 case SDL_APP_TERMINATING:
866 case SDL_APP_WILLENTERBACKGROUND: 865 case SDL_APP_WILLENTERBACKGROUND:
866 case SDL_APP_TERMINATING:
867 savePrefs_App_(d); 867 savePrefs_App_(d);
868 saveState_App_(d); 868 saveState_App_(d);
869 break; 869 break;
@@ -1023,7 +1023,9 @@ static int run_App_(iApp *d) {
1023 arrange_Widget(findWidget_App("root")); 1023 arrange_Widget(findWidget_App("root"));
1024 d->isRunning = iTrue; 1024 d->isRunning = iTrue;
1025 SDL_EventState(SDL_DROPFILE, SDL_ENABLE); /* open files via drag'n'drop */ 1025 SDL_EventState(SDL_DROPFILE, SDL_ENABLE); /* open files via drag'n'drop */
1026#if defined (iPlatformDesktop)
1026 SDL_AddEventWatch(resizeWatcher_, d); 1027 SDL_AddEventWatch(resizeWatcher_, d);
1028#endif
1027 while (d->isRunning) { 1029 while (d->isRunning) {
1028 processEvents_App(waitForNewEvents_AppEventMode); 1030 processEvents_App(waitForNewEvents_AppEventMode);
1029 runTickers_App_(d); 1031 runTickers_App_(d);
diff --git a/src/ui/window.c b/src/ui/window.c
index 5b65f173..edbbf0e9 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -111,7 +111,9 @@ static iBool handleRootCommands_(iWidget *root, const char *cmd) {
111 return iTrue; 111 return iTrue;
112 } 112 }
113 else if (equal_Command(cmd, "window.focus.lost")) { 113 else if (equal_Command(cmd, "window.focus.lost")) {
114#if !defined (iPlatformMobile) /* apps don't share input focus on mobile */
114 setFocus_Widget(NULL); 115 setFocus_Widget(NULL);
116#endif
115 setTextColor_LabelWidget(findWidget_App("winbar.app"), uiAnnotation_ColorId); 117 setTextColor_LabelWidget(findWidget_App("winbar.app"), uiAnnotation_ColorId);
116 setTextColor_LabelWidget(findWidget_App("winbar.title"), uiAnnotation_ColorId); 118 setTextColor_LabelWidget(findWidget_App("winbar.title"), uiAnnotation_ColorId);
117 return iFalse; 119 return iFalse;
@@ -1544,6 +1546,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
1544 } 1546 }
1545#endif 1547#endif
1546 return iFalse; 1548 return iFalse;
1549#if defined (iPlatformDesktop)
1547 case SDL_WINDOWEVENT_MOVED: { 1550 case SDL_WINDOWEVENT_MOVED: {
1548 if (d->isMinimized) { 1551 if (d->isMinimized) {
1549 return iFalse; 1552 return iFalse;
@@ -1585,7 +1588,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
1585 return iTrue; 1588 return iTrue;
1586 } 1589 }
1587 } 1590 }
1588#endif 1591#endif /* defined LAGRANGE_CUSTOM_FRAME */
1589 //printf("MOVED: %d, %d\n", ev->data1, ev->data2); fflush(stdout); 1592 //printf("MOVED: %d, %d\n", ev->data1, ev->data2); fflush(stdout);
1590 if (unsnap_Window_(d, &newPos)) { 1593 if (unsnap_Window_(d, &newPos)) {
1591 return iTrue; 1594 return iTrue;
@@ -1627,6 +1630,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
1627 case SDL_WINDOWEVENT_MINIMIZED: 1630 case SDL_WINDOWEVENT_MINIMIZED:
1628 d->isMinimized = iTrue; 1631 d->isMinimized = iTrue;
1629 return iTrue; 1632 return iTrue;
1633#endif
1630 case SDL_WINDOWEVENT_LEAVE: 1634 case SDL_WINDOWEVENT_LEAVE:
1631 unhover_Widget(); 1635 unhover_Widget();
1632 d->isMouseInside = iFalse; 1636 d->isMouseInside = iFalse;
@@ -1636,18 +1640,29 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
1636 d->isMouseInside = iTrue; 1640 d->isMouseInside = iTrue;
1637 postCommand_App("window.mouse.entered"); 1641 postCommand_App("window.mouse.entered");
1638 return iTrue; 1642 return iTrue;
1639 case SDL_WINDOWEVENT_TAKE_FOCUS: 1643#if defined (iPlatformMobile)
1640 SDL_SetWindowInputFocus(d->win); 1644 case SDL_WINDOWEVENT_RESIZED:
1645 /* On mobile, this occurs when the display is rotated. */
1646 invalidate_Window_(d);
1641 postRefresh_App(); 1647 postRefresh_App();
1642 return iTrue; 1648 return iTrue;
1649#endif
1643 case SDL_WINDOWEVENT_FOCUS_GAINED: 1650 case SDL_WINDOWEVENT_FOCUS_GAINED:
1644 d->focusGainedAt = SDL_GetTicks(); 1651 d->focusGainedAt = SDL_GetTicks();
1645 setCapsLockDown_Keys(iFalse); 1652 setCapsLockDown_Keys(iFalse);
1646 postCommand_App("window.focus.gained"); 1653 postCommand_App("window.focus.gained");
1654#if defined (iPlatformMobile)
1655 /* Returned to foreground, may have lost buffered content. */
1656 invalidate_Window_(d);
1657#endif
1647 return iFalse; 1658 return iFalse;
1648 case SDL_WINDOWEVENT_FOCUS_LOST: 1659 case SDL_WINDOWEVENT_FOCUS_LOST:
1649 postCommand_App("window.focus.lost"); 1660 postCommand_App("window.focus.lost");
1650 return iFalse; 1661 return iFalse;
1662 case SDL_WINDOWEVENT_TAKE_FOCUS:
1663 SDL_SetWindowInputFocus(d->win);
1664 postRefresh_App();
1665 return iTrue;
1651 default: 1666 default:
1652 break; 1667 break;
1653 } 1668 }
@@ -1775,7 +1790,18 @@ void draw_Window(iWindow *d) {
1775 if (d->isDrawFrozen) { 1790 if (d->isDrawFrozen) {
1776 return; 1791 return;
1777 } 1792 }
1778 const int winFlags = SDL_GetWindowFlags(d->win); 1793#if defined (iPlatformMobile)
1794 /* Check if root needs resizing. */ {
1795 iInt2 renderSize;
1796 SDL_GetRendererOutputSize(d->render, &renderSize.x, &renderSize.y);
1797 if (!isEqual_I2(renderSize, d->root->rect.size)) {
1798 updatePadding_Window_(d);
1799 updateRootSize_Window_(d, iTrue);
1800 processEvents_App(postedEventsOnly_AppEventMode);
1801 }
1802 }
1803#endif
1804 const int winFlags = SDL_GetWindowFlags(d->win);
1779 const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0; 1805 const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0;
1780 /* Clear the window. The clear color is visible as a border around the window 1806 /* Clear the window. The clear color is visible as a border around the window
1781 when the custom frame is being used. */ { 1807 when the custom frame is being used. */ {