RAM2118 commited on
Commit
9423d64
·
verified ·
1 Parent(s): 0632681

fix: set NSApplicationActivationPolicyAccessory at launch to prevent separate app appearance

Browse files

The helper was appearing as a separate app in Dock/Cmd+Tab because
the activation policy was never being set. The showAsFloatingPanel()
only handled window level, not the application-level policy.

Now sets policy=1 (Accessory) as the FIRST thing in initialise(),
before any windows are created. This means:
- No Dock icon
- No Cmd+Tab entry
- No focus steal when helper launches
- GUI window floats over Ableton as a panel

Files changed (1) hide show
  1. Source/Helper/main.cpp +15 -0
Source/Helper/main.cpp CHANGED
@@ -3,6 +3,11 @@
3
  #include <juce_gui_basics/juce_gui_basics.h>
4
  #include <juce_events/juce_events.h>
5
 
 
 
 
 
 
6
  #include "SharedAudioBuffer.h"
7
  #include "IPCProtocol.h"
8
  #include "Constants.h"
@@ -17,6 +22,16 @@ public:
17
 
18
  void initialise(const juce::String& commandLine) override
19
  {
 
 
 
 
 
 
 
 
 
 
20
  auto args = juce::StringArray::fromTokens(commandLine, " ", "\"");
21
 
22
  int parentPid = 0;
 
3
  #include <juce_gui_basics/juce_gui_basics.h>
4
  #include <juce_events/juce_events.h>
5
 
6
+ #if JUCE_MAC
7
+ #include <objc/objc.h>
8
+ #include <objc/message.h>
9
+ #endif
10
+
11
  #include "SharedAudioBuffer.h"
12
  #include "IPCProtocol.h"
13
  #include "Constants.h"
 
22
 
23
  void initialise(const juce::String& commandLine) override
24
  {
25
+ #if JUCE_MAC
26
+ // SET ACTIVATION POLICY BEFORE ANYTHING ELSE
27
+ // Policy 1 = NSApplicationActivationPolicyAccessory
28
+ // This prevents: Dock icon, Cmd+Tab entry, focus stealing on launch
29
+ id nsApp = ((id(*)(id, SEL))objc_msgSend)((id)objc_getClass("NSApplication"),
30
+ sel_registerName("sharedApplication"));
31
+ ((void(*)(id, SEL, long))objc_msgSend)(nsApp,
32
+ sel_registerName("setActivationPolicy:"), 1);
33
+ #endif
34
+
35
  auto args = juce::StringArray::fromTokens(commandLine, " ", "\"");
36
 
37
  int parentPid = 0;