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

Newly opened apps don't get hidden #5

Open
dgfl-gh opened this issue May 18, 2023 · 2 comments
Open

Newly opened apps don't get hidden #5

dgfl-gh opened this issue May 18, 2023 · 2 comments

Comments

@dgfl-gh
Copy link
Contributor

dgfl-gh commented May 18, 2023

Simply put, if I open an app for the first time the focusedAppChanged event gets fired but the app doesn't get hidden as it should, since it looks like the event isn't propagated to focusedWindowChanged.
It works as intended if I switch away from it and then back to it, then focusedAppChanged is fired and focusedWindowChanged follows immediately, hiding the app.

My guess is that this call returns null in this circumstances, but I'm not sure why.

@iloveitaly
Copy link
Owner

Interesting, any ideas of how to fix it?

I've definitely seen this on my machine.

@dgfl-gh
Copy link
Contributor Author

dgfl-gh commented May 30, 2023

I've run some tests and I've found that, indeed, when NSWorkspace.didActivateApplicationNotification is fired for a new app, this happens before any window has been created; this causes focusedWindow to be null, since of course it is.

I haven't found an elegant solution, but I have found a solution: dgfl-gh@05e4a88.
This simply calls focusedAppChanged over and over, until a window is finally found.
On my system (MBP16 M1 Pro, macOS 13.3.1), the call seems to be repeated ~100 times when opening NetNewsWire, but this will most likely depend heavily on the application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants