diff options
Diffstat (limited to 'src/ui/util.c')
-rw-r--r-- | src/ui/util.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index 4ab086fe..72a973a6 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1034,11 +1034,18 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) { | |||
1034 | } | 1034 | } |
1035 | iRect winRect; | 1035 | iRect winRect; |
1036 | SDL_Window *sdlWin = get_Window()->win; | 1036 | SDL_Window *sdlWin = get_Window()->win; |
1037 | SDL_GetWindowPosition(sdlWin, &winRect.pos.x, &winRect.pos.y); | 1037 | const float pixelRatio = get_Window()->pixelRatio; |
1038 | SDL_GetWindowSize(sdlWin, &winRect.size.x, &winRect.size.y); | 1038 | iInt2 winPos; |
1039 | SDL_GetWindowPosition(sdlWin, &winPos.x, &winPos.y); | ||
1040 | winRect = rootRect; | ||
1041 | winRect.pos.x /= pixelRatio; | ||
1042 | winRect.pos.y /= pixelRatio; | ||
1043 | winRect.size.x /= pixelRatio; | ||
1044 | winRect.size.y /= pixelRatio; | ||
1045 | addv_I2(&winRect.pos, winPos); | ||
1039 | iRect visibleWinRect = intersect_Rect(winRect, displayRect); | 1046 | iRect visibleWinRect = intersect_Rect(winRect, displayRect); |
1040 | /* Only use a popup window if the menu can't fit inside the main window. */ | 1047 | /* Only use a popup window if the menu can't fit inside the main window. */ |
1041 | if (height_Widget(d) > visibleWinRect.size.y && isUsingMenuPopupWindows_()) { | 1048 | if (height_Widget(d) * pixelRatio > visibleWinRect.size.y && isUsingMenuPopupWindows_()) { |
1042 | if (postCommands) { | 1049 | if (postCommands) { |
1043 | postCommand_Widget(d, "menu.opened"); | 1050 | postCommand_Widget(d, "menu.opened"); |
1044 | } | 1051 | } |
@@ -1050,7 +1057,6 @@ void openMenuFlags_Widget(iWidget *d, iInt2 windowCoord, int menuOpenFlags) { | |||
1050 | removeChild_Widget(parent_Widget(d), d); /* we'll borrow the widget for a while */ | 1057 | removeChild_Widget(parent_Widget(d), d); /* we'll borrow the widget for a while */ |
1051 | iInt2 winPos; | 1058 | iInt2 winPos; |
1052 | SDL_GetWindowPosition(sdlWin, &winPos.x, &winPos.y); | 1059 | SDL_GetWindowPosition(sdlWin, &winPos.x, &winPos.y); |
1053 | const float pixelRatio = get_Window()->pixelRatio; | ||
1054 | iInt2 menuPos = add_I2(winPos, | 1060 | iInt2 menuPos = add_I2(winPos, |
1055 | divf_I2(sub_I2(windowCoord, divi_I2(gap2_UI, 2)), pixelRatio)); | 1061 | divf_I2(sub_I2(windowCoord, divi_I2(gap2_UI, 2)), pixelRatio)); |
1056 | /* Check display bounds. */ { | 1062 | /* Check display bounds. */ { |