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

feat: add app activated event for macos #911

Closed

Conversation

thewh1teagle
Copy link

This PR adds Activated event for macOS, resolving #218.

Useful in two cases:

  1. When the app is open but no windows are visible, clicking its icon in the dock will emit the Activated event.
  2. When the app is running in the background with no windows, and you try to open it again, macOS usually brings the already open instance to the front (without activating windows, so nothing happens). With this change, the Activated event will be emitted in such cases.

@thewh1teagle thewh1teagle requested a review from a team as a code owner April 28, 2024 23:02
@FabianLars
Copy link
Member

Thanks for contributing! I am not one of the main maintainers so take this with a grain of salt, but i've worked with events a while back and i think that this feature should use the NSApplicationDelegate's shouldHandleReopen method instead. The problem with that is that we'd need to figure out how to return a bool dynamically (or always false since the default behavior doesn't seem to apply to tauri apps anyway).

@FabianLars
Copy link
Member

Ahh, i forgot. We already have a PR for what i just said: #517

@thewh1teagle
Copy link
Author

Oh I didn't knew about this event, that looks better because we can control the default behavior too.
Does tao / tauri already use winit? (Like mentioned there) So we can merge it?

@FabianLars
Copy link
Member

No, and winit still doesn't support this. But we've changed the approach since then and started merging PRs that use platform specific apis even if winit doesn't support them yet.

@pronebird
Copy link

pronebird commented May 1, 2024

applicationShouldHandleReopen sounds like a thing used for document based apps.

I found it simpler to rely on applicationDidBecomeActive which fires every time the app activates.

@BillGoldenWater
Copy link
Contributor

I think this event isn't a solution for #218, it's not emitted for the click on dock icon, and it's emitted every time the app gains focus

I think it's usage would be pair with applicationDidResignActive and their "will" variant for handle lose/gain focus of entire app

@FabianLars FabianLars closed this May 1, 2024
@pronebird
Copy link

@BillGoldenWater I think you're right, it doesn't trigger if the app is in focus but doesn't have any windows open.

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

Successfully merging this pull request may close these issues.

4 participants