Skip to content
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

Fixes Mac Console / Delegate Glitch #149

Merged
merged 4 commits into from
Apr 25, 2020
Merged

Fixes Mac Console / Delegate Glitch #149

merged 4 commits into from
Apr 25, 2020

Conversation

josegomez
Copy link
Collaborator

@josegomez josegomez commented Apr 25, 2020

So Avalonia registers their own App Delegate on MacOSX
See: https://github.com/AvaloniaUI/Avalonia/blob/5a2ef35dacbce0438b66d9f012e5f629045beb3d/native/Avalonia.Native/src/OSX/app.mm#L7-L23

In our application we register our own which cases Avalonia's to get removed

NSApplication.SharedApplication.Delegate = new Platform.OSX.AppDelegate();

This causes the Avalonia registered events

- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
    if([[NSApplication sharedApplication] activationPolicy] != AvnDesiredActivationPolicy)
    {
        for (NSRunningApplication * app in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) {
            [app activateWithOptions:NSApplicationActivateIgnoringOtherApps];
            break;
        }
        
        [[NSApplication sharedApplication] setActivationPolicy: AvnDesiredActivationPolicy];
    }
}


- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
    [[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
}

To no be executed which causes our application to not be activated with the right options.

This fix basically re-implements the Avalonia events in our own AppDelegate (I just re-wrote their code in C# inside our app delegate)

This appears to fix the issue and may prevent other issues we aren't yet aware of.

I also opened this Issue with Avalonia: AvaloniaUI/Avalonia#3822 as an enhancement request.

It would be nice to be able to subscribe to all these events directly without having to re-implement the AppDelegate completely seeing as if they (Avalonia) changes or updates their delegate code our app won't benefit from that with this solution.

Either way it appears to work fine now
ConsoleFix

Also change the mac and linux installers to tar.gz #143

@josegomez josegomez added the bug Something isn't working label Apr 25, 2020
@josegomez josegomez added this to the v0.1.2.0-beta milestone Apr 25, 2020
@josegomez josegomez linked an issue Apr 25, 2020 that may be closed by this pull request
@josegomez josegomez mentioned this pull request Apr 25, 2020
Copy link
Member

@alexhauser alexhauser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, @josegomez!

@josegomez josegomez merged commit 0bada86 into master Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Mac Console Issue
2 participants