1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

WindowUtils: Make areThereAnyAlwaysOnTopWindows() public

This commit is contained in:
reuk 2023-05-03 13:19:35 +01:00
parent ad59f71b99
commit 53bfd5b16d
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
22 changed files with 257 additions and 69 deletions

View file

@ -97,7 +97,7 @@ struct AlertWindowHelpers
alert->setCentrePosition (parent->getLocalBounds().getCentre());
}
alert->setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows());
alert->setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());
return alert;
}

View file

@ -32,8 +32,6 @@ struct WindowingHelpers
static Image createIconForFile (const File& file);
static bool areThereAnyAlwaysOnTopWindows();
#if JUCE_WINDOWS
static bool isEmbeddedInForegroundProcess (Component* c);
static bool isWindowOnCurrentVirtualDesktop (void*);

View file

@ -115,7 +115,7 @@ FileChooserDialogBox::FileChooserDialogBox (const String& name,
if (parentComp != nullptr)
parentComp->addAndMakeVisible (this);
else
setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows());
setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());
}
FileChooserDialogBox::~FileChooserDialogBox()

View file

@ -143,6 +143,7 @@
#if JUCE_IOS
#include "native/juce_UIViewComponentPeer_ios.mm"
#include "native/accessibility/juce_Accessibility_ios.mm"
#include "native/juce_WindowUtils_ios.mm"
#include "native/juce_Windowing_ios.mm"
#include "native/juce_NativeMessageBox_ios.mm"
#include "native/juce_NativeModalWrapperComponent_ios.h"
@ -156,6 +157,7 @@
#include "native/accessibility/juce_Accessibility_mac.mm"
#include "native/juce_PerScreenDisplayLinks_mac.h"
#include "native/juce_NSViewComponentPeer_mac.mm"
#include "native/juce_WindowUtils_mac.mm"
#include "native/juce_Windowing_mac.mm"
#include "native/juce_NativeMessageBox_mac.mm"
#include "native/juce_MainMenu_mac.mm"
@ -172,6 +174,7 @@
#include "native/accessibility/juce_UIAProviders_windows.h"
#include "native/accessibility/juce_AccessibilityElement_windows.cpp"
#include "native/accessibility/juce_Accessibility_windows.cpp"
#include "native/juce_WindowUtils_windows.cpp"
#include "native/juce_Windowing_windows.cpp"
#include "native/juce_NativeMessageBox_windows.cpp"
#include "native/juce_DragAndDrop_windows.cpp"
@ -184,6 +187,7 @@
JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wzero-as-null-pointer-constant")
#include "native/juce_ScopedWindowAssociation_linux.h"
#include "native/juce_WindowUtils_linux.cpp"
#include "native/juce_Windowing_linux.cpp"
#include "native/juce_NativeMessageBox_linux.cpp"
#include "native/juce_XWindowSystem_linux.cpp"
@ -196,6 +200,7 @@
#include "juce_core/files/juce_common_MimeTypes.h"
#include "native/accessibility/juce_Accessibility_android.cpp"
#include "native/juce_WindowUtils_android.cpp"
#include "native/juce_Windowing_android.cpp"
#include "native/juce_NativeMessageBox_android.cpp"
#include "native/juce_FileChooser_android.cpp"

View file

@ -290,6 +290,7 @@ namespace juce
#include "windows/juce_ThreadWithProgressWindow.h"
#include "windows/juce_TooltipWindow.h"
#include "windows/juce_VBlankAttachement.h"
#include "windows/juce_WindowUtils.h"
#include "layout/juce_MultiDocumentPanel.h"
#include "layout/juce_SidePanel.h"
#include "filebrowser/juce_FileBrowserListener.h"

View file

@ -179,7 +179,7 @@ public:
{
if (panel != nil)
{
setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows());
setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());
addToDesktop (0);
enterModalState (true);

View file

@ -828,7 +828,7 @@ public:
0, 0);
setOpaque (true);
setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows());
setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());
addToDesktop (0);
}

View file

@ -175,7 +175,7 @@ std::unique_ptr<ScopedMessageBoxInterface> ScopedMessageBoxInterface::create (co
{
// this window can get lost behind JUCE windows which are set to be alwaysOnTop
// so if there are any set it to be topmost
const auto topmostFlag = detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() ? MB_TOPMOST : 0;
const auto topmostFlag = WindowUtils::areThereAnyAlwaysOnTopWindows() ? MB_TOPMOST : 0;
const auto iconFlags = [&]() -> decltype (topmostFlag)
{

View file

@ -0,0 +1,34 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
bool WindowUtils::areThereAnyAlwaysOnTopWindows()
{
return false;
}
} // namespace juce

View file

@ -0,0 +1,34 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
bool WindowUtils::areThereAnyAlwaysOnTopWindows()
{
return false;
}
} // namespace juce

View file

@ -0,0 +1,39 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
struct WindowUtilsInternal
{
inline static int numAlwaysOnTopPeers = 0;
};
bool WindowUtils::areThereAnyAlwaysOnTopWindows()
{
return WindowUtilsInternal::numAlwaysOnTopPeers > 0;
}
} // namespace juce

View file

@ -0,0 +1,38 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
bool WindowUtils::areThereAnyAlwaysOnTopWindows()
{
for (NSWindow* window in [NSApp windows])
if ([window level] > NSNormalWindowLevel)
return true;
return false;
}
} // namespace juce

View file

@ -0,0 +1,59 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
static BOOL CALLBACK enumAlwaysOnTopWindows (HWND hwnd, LPARAM lParam)
{
if (IsWindowVisible (hwnd))
{
DWORD processID = 0;
GetWindowThreadProcessId (hwnd, &processID);
if (processID == GetCurrentProcessId())
{
WINDOWINFO info{};
if (GetWindowInfo (hwnd, &info)
&& (info.dwExStyle & WS_EX_TOPMOST) != 0)
{
*reinterpret_cast<bool*> (lParam) = true;
return FALSE;
}
}
}
return TRUE;
}
bool WindowUtils::areThereAnyAlwaysOnTopWindows()
{
bool anyAlwaysOnTopFound = false;
EnumWindows (&enumAlwaysOnTopWindows, (LPARAM) &anyAlwaysOnTopFound);
return anyAlwaysOnTopFound;
}
} // namespace juce

View file

@ -2443,12 +2443,6 @@ void Desktop::allowedOrientationsChanged()
getEnv()->CallVoidMethod (activity.get(), AndroidActivity.setRequestedOrientation, getAndroidOrientationFlag (allowedOrientations));
}
//==============================================================================
bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()
{
return false;
}
//==============================================================================
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
METHOD (create, "<init>", "()V") \

View file

@ -498,12 +498,6 @@ bool Desktop::isScreenSaverEnabled()
return ! [[UIApplication sharedApplication] isIdleTimerDisabled];
}
//==============================================================================
bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()
{
return false;
}
//==============================================================================
Image detail::WindowingHelpers::createIconForFile (const File&)
{

View file

@ -26,10 +26,6 @@
namespace juce
{
//==============================================================================
static int numAlwaysOnTopPeers = 0;
bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows() { return numAlwaysOnTopPeers > 0; }
//==============================================================================
class LinuxComponentPeer : public ComponentPeer,
private XWindowSystemUtilities::XSettings::Listener
@ -48,7 +44,7 @@ public:
return;
if (isAlwaysOnTop)
++numAlwaysOnTopPeers;
++WindowUtilsInternal::numAlwaysOnTopPeers;
repainter = std::make_unique<LinuxRepaintManager> (*this);
@ -79,7 +75,7 @@ public:
xSettings->removeListener (this);
if (isAlwaysOnTop)
--numAlwaysOnTopPeers;
--WindowUtilsInternal::numAlwaysOnTopPeers;
}
::Window getWindowHandle() const noexcept

View file

@ -464,16 +464,6 @@ void Displays::findDisplays (const float masterScale)
}
}
//==============================================================================
bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()
{
for (NSWindow* window in [NSApp windows])
if ([window level] > NSNormalWindowLevel)
return true;
return false;
}
//==============================================================================
static void selectImageForDrawing (const Image& image)
{

View file

@ -4775,37 +4775,6 @@ bool JUCE_CALLTYPE Process::isForegroundProcess()
void JUCE_CALLTYPE Process::makeForegroundProcess() {}
void JUCE_CALLTYPE Process::hide() {}
//==============================================================================
static BOOL CALLBACK enumAlwaysOnTopWindows (HWND hwnd, LPARAM lParam)
{
if (IsWindowVisible (hwnd))
{
DWORD processID = 0;
GetWindowThreadProcessId (hwnd, &processID);
if (processID == GetCurrentProcessId())
{
WINDOWINFO info{};
if (GetWindowInfo (hwnd, &info)
&& (info.dwExStyle & WS_EX_TOPMOST) != 0)
{
*reinterpret_cast<bool*> (lParam) = true;
return FALSE;
}
}
}
return TRUE;
}
bool detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows()
{
bool anyAlwaysOnTopFound = false;
EnumWindows (&enumAlwaysOnTopWindows, (LPARAM) &anyAlwaysOnTopFound);
return anyAlwaysOnTopFound;
}
//==============================================================================
bool detail::MouseInputSourceList::addSource()
{

View file

@ -50,7 +50,7 @@ AlertWindow::AlertWindow (const String& title,
associatedComponent (comp),
desktopScale (comp != nullptr ? Component::getApproximateScaleFactorForComponent (comp) : 1.0f)
{
setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows());
setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());
accessibleMessageLabel.setColour (Label::textColourId, Colours::transparentBlack);
accessibleMessageLabel.setColour (Label::backgroundColourId, Colours::transparentBlack);

View file

@ -39,7 +39,7 @@ CallOutBox::CallOutBox (Component& c, Rectangle<int> area, Component* const pare
}
else
{
setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows());
setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());
updatePosition (area, Desktop::getInstance().getDisplays().getDisplayForRect (area)->userArea);
addToDesktop (ComponentPeer::windowIsTemporary);

View file

@ -92,7 +92,7 @@ public:
setResizable (options.resizable, options.useBottomRightCornerResizer);
setUsingNativeTitleBar (options.useNativeTitleBar);
setAlwaysOnTop (detail::WindowingHelpers::areThereAnyAlwaysOnTopWindows());
setAlwaysOnTop (WindowUtils::areThereAnyAlwaysOnTopWindows());
}
void closeButtonPressed() override

View file

@ -0,0 +1,37 @@
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce
{
struct WindowUtils
{
WindowUtils() = delete;
/** Returns true if any windows have a z order that is higher than normal. */
static bool areThereAnyAlwaysOnTopWindows();
};
} // namespace juce