From 3f91c8782b786eb942276d4210dd389f54fabc2b Mon Sep 17 00:00:00 2001 From: Anthony Nicholls Date: Mon, 17 Apr 2023 12:45:17 +0100 Subject: [PATCH] macOS: Move set dock icon to juce_core --- modules/juce_core/juce_core.cpp | 1 + modules/juce_core/native/juce_Process_mac.mm | 36 +++++++++++++++++++ modules/juce_core/threads/juce_Process.h | 2 +- .../native/juce_Windowing_mac.mm | 9 ----- 4 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 modules/juce_core/native/juce_Process_mac.mm diff --git a/modules/juce_core/juce_core.cpp b/modules/juce_core/juce_core.cpp index 7bbe6ba697..8a7fa37100 100644 --- a/modules/juce_core/juce_core.cpp +++ b/modules/juce_core/juce_core.cpp @@ -209,6 +209,7 @@ #include "native/juce_SystemStats_mac.mm" #include "native/juce_Threads_mac.mm" #include "native/juce_PlatformTimer_generic.cpp" + #include "native/juce_Process_mac.mm" //============================================================================== #elif JUCE_WINDOWS diff --git a/modules/juce_core/native/juce_Process_mac.mm b/modules/juce_core/native/juce_Process_mac.mm new file mode 100644 index 0000000000..c4825539d1 --- /dev/null +++ b/modules/juce_core/native/juce_Process_mac.mm @@ -0,0 +1,36 @@ +/* + ============================================================================== + + 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. + + The code included in this file is provided under the terms of the ISC license + http://www.isc.org/downloads/software-support-policy/isc-license. Permission + To use, copy, modify, and/or distribute this software for any purpose with or + without fee is hereby granted provided that the above copyright notice and + this permission notice appear in all copies. + + 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 +{ + +#if JUCE_MAC +void Process::setDockIconVisible (bool isVisible) +{ + ProcessSerialNumber psn { 0, kCurrentProcess }; + + [[maybe_unused]] OSStatus err = TransformProcessType (&psn, isVisible ? kProcessTransformToForegroundApplication + : kProcessTransformToUIElementApplication); + jassert (err == 0); +} +#endif + +} // namespace juce diff --git a/modules/juce_core/threads/juce_Process.h b/modules/juce_core/threads/juce_Process.h index 61f2157b11..b44e9d6d12 100644 --- a/modules/juce_core/threads/juce_Process.h +++ b/modules/juce_core/threads/juce_Process.h @@ -134,7 +134,7 @@ public: #endif //============================================================================== - #if (JUCE_MAC && JUCE_MODULE_AVAILABLE_juce_gui_basics) || DOXYGEN + #if JUCE_MAC || DOXYGEN /** OSX ONLY - Shows or hides the OSX dock icon for this app. */ static void setDockIconVisible (bool isVisible); #endif diff --git a/modules/juce_gui_basics/native/juce_Windowing_mac.mm b/modules/juce_gui_basics/native/juce_Windowing_mac.mm index 7fefb2936f..ad459d483e 100644 --- a/modules/juce_gui_basics/native/juce_Windowing_mac.mm +++ b/modules/juce_gui_basics/native/juce_Windowing_mac.mm @@ -585,13 +585,4 @@ String SystemClipboard::getTextFromClipboard() return nsStringToJuce ([[NSPasteboard generalPasteboard] stringForType: NSPasteboardTypeString]); } -void Process::setDockIconVisible (bool isVisible) -{ - ProcessSerialNumber psn { 0, kCurrentProcess }; - - [[maybe_unused]] OSStatus err = TransformProcessType (&psn, isVisible ? kProcessTransformToForegroundApplication - : kProcessTransformToUIElementApplication); - jassert (err == 0); -} - } // namespace juce