diff options
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 16 |
1 files changed, 12 insertions, 4 deletions
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 | } |