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

fix(windows): Use SetForegroundWindow before focus hack #719

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

FabianLars
Copy link
Member

This fixes an issue we had with interactive notifications and "deep links", see FabianLars/tauri-plugin-deep-link#26 (comment) / FabianLars/tauri-plugin-deep-link#27 (comment)

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

Checklist

  • This PR will resolve #___
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary
  • It can be built on all targets and pass CI/CD.

Other information

Small discord conversation: https://discord.com/channels/616186924390023171/807549941936816148/1092384046912380978

@FabianLars FabianLars requested a review from a team as a code owner April 3, 2023 12:23
@wusyong wusyong merged commit 62db431 into dev Apr 3, 2023
@wusyong wusyong deleted the fix/windows-focus branch April 3, 2023 23:30
@github-actions github-actions bot mentioned this pull request Apr 3, 2023
@RandomEngy
Copy link
Contributor

Thanks for getting the fix in here!

I think that original focus hack should probably go away. It seems like Windows has already patched it. Trying to steal foreground focus is always going to be a dangerous and brittle game. Windows is going to always be fighting against apps that try to take focus without permission, so we should push devs to go with the AllowSetForegroundWindow approach instead in single-instance scenarios.

https://devblogs.microsoft.com/oldnewthing/20090220-00/?p=19083

@FabianLars
Copy link
Member Author

I agree we should keep an eye on it, but removing it prematurely may be the wrong call right now. The hack was not added with single instance applications in mind so it likely has use-cases we're not thinking about right now.

FabianLars added a commit that referenced this pull request Apr 4, 2023
wusyong pushed a commit that referenced this pull request Apr 4, 2023
@RandomEngy
Copy link
Contributor

Fair enough, though maybe we should pay attention to the output of the first SetForegroundWindow and skip the hack code if it succeeds.

@github-actions github-actions bot mentioned this pull request May 6, 2023
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