From ea757cf1eaf0c1a54c151f7c5a7c0dec2f9d86c4 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 26 Aug 2021 12:07:05 +0100 Subject: [PATCH] PopupMenu: Only show menus within safe areas of the screen This change stops menus from displaying under notches/cutouts on mobile platforms. --- modules/juce_gui_basics/menus/juce_PopupMenu.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp index 2bbf62615b..45aba4bb5e 100644 --- a/modules/juce_gui_basics/menus/juce_PopupMenu.cpp +++ b/modules/juce_gui_basics/menus/juce_PopupMenu.cpp @@ -781,12 +781,8 @@ struct MenuWindow : public Component if (relativeTo != nullptr) targetPoint = relativeTo->localPointToGlobal (targetPoint); - auto parentArea = Desktop::getInstance().getDisplays().getDisplayForPoint (targetPoint * scaleFactor) - #if JUCE_MAC || JUCE_ANDROID - ->userArea; - #else - ->totalArea; // on windows, don't stop the menu overlapping the taskbar - #endif + auto* display = Desktop::getInstance().getDisplays().getDisplayForPoint (targetPoint * scaleFactor); + auto parentArea = display->safeAreaInsets.subtractedFrom (display->totalArea); if (parentComponent == nullptr) return parentArea;