DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit d6d58b33d199f0680a288b3f0230f445b0a580e0
parent 50aa987a02fd77557e62b70cd4c6ef4e55b437d6
Author: Luciano Iam <oss@lucianoiam.com>
Date:   Thu,  5 Aug 2021 22:54:31 +0200

Fix Mac standalone window focus

Diffstat:
Mdgl/src/ApplicationPrivateData.cpp | 5+++++
Mdgl/src/pugl.cpp | 9+++++++++
Mdgl/src/pugl.hpp | 4++++
3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/dgl/src/ApplicationPrivateData.cpp b/dgl/src/ApplicationPrivateData.cpp @@ -64,6 +64,11 @@ Application::PrivateData::PrivateData(const bool standalone) #ifdef HAVE_X11 sofdFileDialogSetup(world); #endif + +#ifdef DISTRHO_OS_MAC + if (standalone) + puglMacOSActivateApp(); +#endif } Application::PrivateData::~PrivateData() diff --git a/dgl/src/pugl.cpp b/dgl/src/pugl.cpp @@ -391,6 +391,15 @@ bool puglMacOSFilePanelOpen(PuglView* const view, return true; } + +// -------------------------------------------------------------------------------------------------------------------- +// macOS specific, allow standalone window to gain focus + +void puglMacOSActivateApp() +{ + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + [NSApp activateIgnoringOtherApps:YES]; +} #endif #ifdef DISTRHO_OS_WINDOWS diff --git a/dgl/src/pugl.hpp b/dgl/src/pugl.hpp @@ -90,6 +90,10 @@ puglFallbackOnResize(PuglView* view); // macOS specific, setup file browser dialog typedef void (*openPanelCallback)(PuglView* view, const char* path); bool puglMacOSFilePanelOpen(PuglView* view, const char* startDir, const char* title, uint flags, openPanelCallback callback); + +// macOS specific, allow standalone window to gain focus +PUGL_API void +puglMacOSActivateApp(); #endif #ifdef DISTRHO_OS_WINDOWS