-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
window.toFront()
doesn't make a window active when the app is running in a tray
#4231
Comments
Hello, @yevhenii-nadtochii, thanks for submitting the issue. |
I've tried this: window.addHierarchyListener {
window.toFront()
window.requestFocus()
} But the window remains inactive. I've also tried with |
Is there any way to check if the window is on the front, a boolean function? |
You can use this to cause your window to move to front and become focusable when shown:
|
@m-sasha unfortunately this doesn't help. |
Can you post a new reproducer that uses that workaround? |
Try this:
|
This workaround does better. If the currently active app is But still no changes if the currently active app is another one, which is usually the case for tray apps. |
Ok, I found the magic incantation, it's
|
@m-sasha The magic did the trick! Thank you 🙂 There's interesting detail. I've noticed that sometimes a window still can't get active. One out of 3–7 attempts fails. Turns out that the launched effect is not always executed upon updates of Moving it out of The final snippet
|
Closing this, as it's not an issue with Compose, but with AWT. |
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
A shown window fails to become active and gain focus. The window is created with
alwaysOnTop = true
, so it should gain focus automatically as shown. But direct calls towindow.requestFocus()
andwindow.toFront
also have no effect.Maybe it is because the app is a background application from the start (
Tray
+LSUIElement = true
for MacOS). Tray menu hasShow window
item. And a user usually have another active application at the moment he/she clicks aShow window
item from a tray menu.Code snippet
Affected platforms
Versions
To Reproduce
window-focus-reproducer.zip
When the currently active app is NOT
MainKt
, the window never gets focused on showing up. When the currently active app isMainKt
, the window gets focused half the time.Expected behavior
Top most window is active when it is shown, especially when this is requested explicitly by
window.toFront()
orwindow.requestFocus()
.The text was updated successfully, but these errors were encountered: