-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a proper way to activate based on the bundle info on macOS #226
base: master
Are you sure you want to change the base?
Conversation
9b9aeb5
to
d539866
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../darwin/main.m:116:31: warning: incompatible pointer types passing 'NSString *' to parameter of type 'CFStringRef' (aka 'const struct __CFString *') [-Wincompatible-pointer-types]
if (!CFStringHasSuffix(path, @".app")) {
^~~~~~~
/Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFString.h:483:62: note: passing argument to parameter 'suffix' here
Boolean CFStringHasSuffix(CFStringRef theString, CFStringRef suffix);
^
1 warning generated.
Will have to manually build some |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing this issue.
I would be very happy to close this topic as it is highly annoying, even just while debugging.
|
||
// don't check for a NO return; | ||
// something (launch services?) causes running from application bundles to always return NO | ||
// when asking to change activation policy, even if the change is to the same activation policy! | ||
// see https://github.com/andlabs/ui/issues/6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment seems redundant to me, as the context of setActivationPolicy
is now within a non application bundle.
TBH - while maybe a weird API decision - returning NO
on change to the same policy is what is to be expected according to the docs:
true if the policy switch succeded; otherwise, false.
If we really want to check the return code we could check it first via activationPolicy
and only set it if it is !=NSApplicationActivationPolicyRegular
. Then check the return code if it is that important?
activate = YES; | ||
} else if ([uiprivNSApp() activationPolicy] == NSApplicationActivationPolicyAccessory) { | ||
// The app is an agent app that runs in the background and doesn't appear in the Dock. | ||
activate = YES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is my understanding correct, that we need to call activateIgnoringOtherApps
even if we are in an app bundle for NSApplicationActivationPolicyAccessory
? As @cody271 suggested, could we expand that comment?
This PR will make it possible to detect if the program is running as an app bundle or not, and call proper functions for activation.
Closes #225