Closed kettle11 closed 3 years ago
I also experience the same but nothing found on the internet. Please update if you can find a solution for this. Thanks.
@kainjinez Thanks for letting me know that I'm not the only one! I'll update this issue if I find a fix.
Actually, I just found your issue not by using your app. My app is running in the background & users have to click an icon on taskbar. I'm using below code and it works for Catalina and older, not this Big Sur.
NSApp.windows.last?.makeKeyAndOrderFront(nil)
NSApp.activate(ignoringOtherApps: true)
I'll update here also if i find out any.
Fixed in 1f7a9b32e22ecf4bf7919beab5b3a43d047f635f
The key line was let () = msg_send![ns_application, activateIgnoringOtherApps:YES];
I believe this will make it so if the app takes a while to launch it will always steal focus at the end, even if the user has started using another app. This is acceptable for now, but isn't perfect.
Any solution for Swift?
I also found an acceptable solution for my single screen app.
I get all windows in NSApp and check if any is NSWindow
then call makeKeyAndOrderFront()
function.
Launched windows remain behind all windows. Investigation is needed to figure out why.
Does this impact other windowing libraries?