fix: set fullscreen-compatible behavior BEFORE making window visible
Browse filesPrevious fix set collection behavior after setVisible(true) which is
too late — macOS has already assigned the window to a Space.
Now sets canJoinAllSpaces + fullScreenAuxiliary + stationary (1<<4)
BEFORE the window becomes visible. Also uses NSPanel-level behavior
and moves window to active Space explicitly via orderWindow:relativeTo:.
If this still fails in fullscreen, the only remaining option is to
render the plugin GUI in-process (framebuffer sharing).
8 unmodified lines9101112131415161718192021222324252627282930313233343536373839404142434445239 unmodified lines2852862872882892902912924 unmodified lines2972982993003013023033043053068 unmodified lines#include <objc/message.h>#endif// Show window as floating panel without activating this app or stealing focus// Works in BOTH windowed and fullscreen modestatic void showAsFloatingPanel(juce::Component* window){#if JUCE_MACif (auto* peer = window->getPeer()){auto* nsWindow = (id)peer->getNativeHandle();// --- COLLECTION BEHAVIOR (critical for fullscreen) ---// canJoinAllSpaces = 1 << 0 (window appears on ALL Spaces/desktops)// fullScreenAuxiliary = 1 << 8 (window can float over fullscreen apps)// Combined = 257long behavior = (1 << 0) | (1 << 8);((void(*)(id, SEL, long))objc_msgSend)(nsWindow, sel_registerName("setCollectionBehavior:"), behavior);// --- WINDOW LEVEL ---// NSStatusWindowLevel = 25 (above fullscreen apps)// NSFloatingWindowLevel = 3 is NOT enough — fullscreen apps are higher((void(*)(id, SEL, long))objc_msgSend)(nsWindow, sel_registerName("setLevel:"), 25);// Don't hide on deactivate (stay visible when helper loses focus)((void(*)(id, SEL, int))objc_msgSend)(nsWindow, sel_registerName("setHidesOnDeactivate:"), 0);// Show without activating this app((void(*)(id, SEL))objc_msgSend)(nsWindow, sel_registerName("orderFrontRegardless"));}#endif}// Custom windowclass PluginGuiWindow : public juce::DocumentWindow{public:239 unmodified lines// If window exists but hidden, just show itif (guiWindow){guiWindow->setVisible(true);showAsFloatingPanel(guiWindow.get());return;}4 unmodified linesguiWindow->setContentOwned(editor, true);guiWindow->setResizable(true, true);guiWindow->centreWithSize(editor->getWidth(), editor->getHeight());guiWindow->setVisible(true);// Make it float without stealing focus — works in windowed AND fullscreenshowAsFloatingPanel(guiWindow.get());});}8 unmodified lines9101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354239 unmodified lines2942952962972982993003013023034 unmodified lines3083093103113123133143153163173183193203213228 unmodified lines#include <objc/message.h>#endif// Configure window for floating-panel behavior that works in fullscreen// MUST be called BEFORE the window is made visiblestatic void configureAsOverlayPanel(juce::Component* window){#if JUCE_MACif (auto* peer = window->getPeer()){auto* nsWindow = (id)peer->getNativeHandle();// --- COLLECTION BEHAVIOR (MUST be set before visible) ---// canJoinAllSpaces = 1 << 0 (appear on all desktops/spaces)// fullScreenAuxiliary = 1 << 8 (can appear over fullscreen apps)// stationary = 1 << 4 (don't move with space switches)// ignoresCycle = 1 << 6 (skip in Cmd+` cycling)long behavior = (1 << 0) | (1 << 8) | (1 << 4) | (1 << 6);((void(*)(id, SEL, long))objc_msgSend)(nsWindow, sel_registerName("setCollectionBehavior:"), behavior);// --- WINDOW LEVEL ---// Level 25 = NSStatusWindowLevel (above fullscreen apps)((void(*)(id, SEL, long))objc_msgSend)(nsWindow, sel_registerName("setLevel:"), 25);// Don't hide when the helper app loses focus((void(*)(id, SEL, int))objc_msgSend)(nsWindow, sel_registerName("setHidesOnDeactivate:"), 0);}#endif}// Make the window appear without stealing focus (call AFTER visible)static void showWithoutFocusSteal(juce::Component* window){#if JUCE_MACif (auto* peer = window->getPeer()){auto* nsWindow = (id)peer->getNativeHandle();((void(*)(id, SEL))objc_msgSend)(nsWindow, sel_registerName("orderFrontRegardless"));}#endif}// Custom window — no native title bar close issues with accessory policyclass PluginGuiWindow : public juce::DocumentWindow{public:239 unmodified lines// If window exists but hidden, just show itif (guiWindow){// Re-apply overlay config before showing (in case Space changed)configureAsOverlayPanel(guiWindow.get());guiWindow->setVisible(true);showWithoutFocusSteal(guiWindow.get());return;}4 unmodified linesguiWindow->setContentOwned(editor, true);guiWindow->setResizable(true, true);guiWindow->centreWithSize(editor->getWidth(), editor->getHeight());// CRITICAL: configure overlay behavior BEFORE making visibleconfigureAsOverlayPanel(guiWindow.get());// NOW make visibleguiWindow->setVisible(true);// Show without stealing focus from AbletonshowWithoutFocusSteal(guiWindow.get());});}
Source/Helper/HelperPluginHost.cpp+32-16