diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 14 | ||||
-rw-r--r-- | src/app.h | 7 | ||||
-rw-r--r-- | src/ui/util.c | 16 | ||||
-rw-r--r-- | src/ui/window.c | 7 |
4 files changed, 32 insertions, 12 deletions
@@ -1281,8 +1281,7 @@ void processEvents_App(enum iAppEventMode eventMode) { | |||
1281 | #endif | 1281 | #endif |
1282 | /* Per-window processing. */ | 1282 | /* Per-window processing. */ |
1283 | iBool wasUsed = iFalse; | 1283 | iBool wasUsed = iFalse; |
1284 | const iPtrArray *windows = listWindows_App_(d); | 1284 | iConstForEach(PtrArray, iter, listWindows_App_(d)) { |
1285 | iConstForEach(PtrArray, iter, windows) { | ||
1286 | iWindow *window = iter.ptr; | 1285 | iWindow *window = iter.ptr; |
1287 | setCurrent_Window(window); | 1286 | setCurrent_Window(window); |
1288 | window->lastHover = window->hover; | 1287 | window->lastHover = window->hover; |
@@ -1312,7 +1311,7 @@ void processEvents_App(enum iAppEventMode eventMode) { | |||
1312 | handleCommand_MacOS(command_UserEvent(&ev)); | 1311 | handleCommand_MacOS(command_UserEvent(&ev)); |
1313 | #endif | 1312 | #endif |
1314 | if (isMetricsChange_UserEvent(&ev)) { | 1313 | if (isMetricsChange_UserEvent(&ev)) { |
1315 | iConstForEach(PtrArray, iter, windows) { | 1314 | iConstForEach(PtrArray, iter, listWindows_App_(d)) { |
1316 | iWindow *window = iter.ptr; | 1315 | iWindow *window = iter.ptr; |
1317 | iForIndices(i, window->roots) { | 1316 | iForIndices(i, window->roots) { |
1318 | iRoot *root = window->roots[i]; | 1317 | iRoot *root = window->roots[i]; |
@@ -1331,7 +1330,7 @@ void processEvents_App(enum iAppEventMode eventMode) { | |||
1331 | free(ev.user.data1); | 1330 | free(ev.user.data1); |
1332 | } | 1331 | } |
1333 | /* Refresh after hover changes. */ { | 1332 | /* Refresh after hover changes. */ { |
1334 | iConstForEach(PtrArray, iter, windows) { | 1333 | iConstForEach(PtrArray, iter, listWindows_App_(d)) { |
1335 | iWindow *window = iter.ptr; | 1334 | iWindow *window = iter.ptr; |
1336 | if (window->lastHover != window->hover) { | 1335 | if (window->lastHover != window->hover) { |
1337 | refresh_Widget(window->lastHover); | 1336 | refresh_Widget(window->lastHover); |
@@ -3030,3 +3029,10 @@ iStringSet *listOpenURLs_App(void) { | |||
3030 | iMainWindow *mainWindow_App(void) { | 3029 | iMainWindow *mainWindow_App(void) { |
3031 | return app_.window; | 3030 | return app_.window; |
3032 | } | 3031 | } |
3032 | |||
3033 | void closePopups_App(void) { | ||
3034 | iApp *d = &app_; | ||
3035 | iConstForEach(PtrArray, i, &d->popupWindows) { | ||
3036 | postCommand_Root(((const iWindow *) i.ptr)->roots[0], "cancel"); | ||
3037 | } | ||
3038 | } | ||
@@ -134,7 +134,8 @@ iLocalDef void postCommand_App(const char *command) { | |||
134 | 134 | ||
135 | iDocumentWidget * document_Command (const char *cmd); | 135 | iDocumentWidget * document_Command (const char *cmd); |
136 | 136 | ||
137 | void openInDefaultBrowser_App (const iString *url); | 137 | void openInDefaultBrowser_App(const iString *url); |
138 | void revealPath_App (const iString *path); | 138 | void revealPath_App (const iString *path); |
139 | 139 | ||
140 | iMainWindow *mainWindow_App(void); | 140 | iMainWindow * mainWindow_App (void); |
141 | void closePopups_App (void); | ||
diff --git a/src/ui/util.c b/src/ui/util.c index 2a0c89dc..c2bc8f08 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1047,10 +1047,15 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) { | |||
1047 | SDL_GetWindowSize(sdlWin, &winSize.x, &winSize.y); | 1047 | SDL_GetWindowSize(sdlWin, &winSize.x, &winSize.y); |
1048 | menuPos = sub_I2(add_I2(winPos, divi_I2(winSize, 2)), divi_I2(menuSize, 2)); | 1048 | menuPos = sub_I2(add_I2(winPos, divi_I2(winSize, 2)), divi_I2(menuSize, 2)); |
1049 | } | 1049 | } |
1050 | SDL_Rect displayRect; | 1050 | iRect displayRect = zero_Rect(); |
1051 | SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(get_Window()->win), &displayRect); | 1051 | for (int i = 0; i < SDL_GetNumVideoDisplays(); i++) { |
1052 | menuPos.x = iMin(menuPos.x, displayRect.x + displayRect.w - menuSize.x); | 1052 | SDL_Rect dispBounds; |
1053 | menuPos.y = iMin(menuPos.y, displayRect.y + displayRect.h - menuSize.y); | 1053 | SDL_GetDisplayBounds(i, &dispBounds); |
1054 | displayRect = union_Rect( | ||
1055 | displayRect, init_Rect(dispBounds.x, dispBounds.y, dispBounds.w, dispBounds.h)); | ||
1056 | } | ||
1057 | menuPos.x = iMin(menuPos.x, right_Rect(displayRect) - menuSize.x); | ||
1058 | menuPos.y = iMin(menuPos.y, bottom_Rect(displayRect) - menuSize.y); | ||
1054 | } | 1059 | } |
1055 | iWindow *win = newPopup_Window(menuPos, d); /* window takes the widget */ | 1060 | iWindow *win = newPopup_Window(menuPos, d); /* window takes the widget */ |
1056 | SDL_SetWindowTitle(win->win, "Menu"); | 1061 | SDL_SetWindowTitle(win->win, "Menu"); |
@@ -1080,6 +1085,9 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) { | |||
1080 | d->rect.pos = init_I2(0, rootSize.y); | 1085 | d->rect.pos = init_I2(0, rootSize.y); |
1081 | } | 1086 | } |
1082 | } | 1087 | } |
1088 | else if (menuOpenFlags & center_MenuOpenFlags) { | ||
1089 | d->rect.pos = sub_I2(divi_I2(size_Root(d->root), 2), divi_I2(d->rect.size, 2)); | ||
1090 | } | ||
1083 | else { | 1091 | else { |
1084 | d->rect.pos = windowToLocal_Widget(d, windowCoord); | 1092 | d->rect.pos = windowToLocal_Widget(d, windowCoord); |
1085 | } | 1093 | } |
diff --git a/src/ui/window.c b/src/ui/window.c index 77e49dbb..80493845 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -750,6 +750,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
750 | if (d->base.isMinimized) { | 750 | if (d->base.isMinimized) { |
751 | return iFalse; | 751 | return iFalse; |
752 | } | 752 | } |
753 | closePopups_App(); | ||
753 | checkPixelRatioChange_Window_(as_Window(d)); | 754 | checkPixelRatioChange_Window_(as_Window(d)); |
754 | const iInt2 newPos = init_I2(ev->data1, ev->data2); | 755 | const iInt2 newPos = init_I2(ev->data1, ev->data2); |
755 | if (isEqual_I2(newPos, init1_I2(-32000))) { /* magic! */ | 756 | if (isEqual_I2(newPos, init1_I2(-32000))) { /* magic! */ |
@@ -808,6 +809,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
808 | // updateSize_Window_(d, iTrue); | 809 | // updateSize_Window_(d, iTrue); |
809 | return iTrue; | 810 | return iTrue; |
810 | } | 811 | } |
812 | closePopups_App(); | ||
811 | if (unsnap_MainWindow_(d, NULL)) { | 813 | if (unsnap_MainWindow_(d, NULL)) { |
812 | return iTrue; | 814 | return iTrue; |
813 | } | 815 | } |
@@ -827,6 +829,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
827 | return iTrue; | 829 | return iTrue; |
828 | case SDL_WINDOWEVENT_MINIMIZED: | 830 | case SDL_WINDOWEVENT_MINIMIZED: |
829 | d->base.isMinimized = iTrue; | 831 | d->base.isMinimized = iTrue; |
832 | closePopups_App(); | ||
830 | return iTrue; | 833 | return iTrue; |
831 | #else /* if defined (!iPlatformDesktop) */ | 834 | #else /* if defined (!iPlatformDesktop) */ |
832 | case SDL_WINDOWEVENT_RESIZED: | 835 | case SDL_WINDOWEVENT_RESIZED: |
@@ -861,6 +864,7 @@ static iBool handleWindowEvent_MainWindow_(iMainWindow *d, const SDL_WindowEvent | |||
861 | #if !defined (iPlatformDesktop) | 864 | #if !defined (iPlatformDesktop) |
862 | setFreezeDraw_MainWindow(d, iTrue); | 865 | setFreezeDraw_MainWindow(d, iTrue); |
863 | #endif | 866 | #endif |
867 | closePopups_App(); | ||
864 | return iFalse; | 868 | return iFalse; |
865 | case SDL_WINDOWEVENT_TAKE_FOCUS: | 869 | case SDL_WINDOWEVENT_TAKE_FOCUS: |
866 | SDL_SetWindowInputFocus(d->base.win); | 870 | SDL_SetWindowInputFocus(d->base.win); |
@@ -1124,7 +1128,8 @@ void draw_Window(iWindow *d) { | |||
1124 | drawCount_ = 0; | 1128 | drawCount_ = 0; |
1125 | #endif | 1129 | #endif |
1126 | } | 1130 | } |
1127 | // drawRectThickness_Paint(&p, (iRect){ zero_I2(), sub_I2(d->size, one_I2()) }, gap_UI / 4, uiSeparator_ColorId); | 1131 | drawRectThickness_Paint( |
1132 | &p, (iRect){ zero_I2(), sub_I2(d->size, one_I2()) }, gap_UI / 4, uiSeparator_ColorId); | ||
1128 | setCurrent_Root(NULL); | 1133 | setCurrent_Root(NULL); |
1129 | SDL_RenderPresent(d->render); | 1134 | SDL_RenderPresent(d->render); |
1130 | } | 1135 | } |