Closed SABRE1982 closed 2 months ago
It seems that the AX API doesn't return a title for PWAs:
However, the private API _AXUIElementGetWindow
does return window id successfuly (which is also much more accurate than title).
And when I added the following lines inside the loop at the top of findWindow
(Of course, after defining the function signature so that XCode recognizes it):
var cgWindowId: CGWindowID = 0
let windowIDStatus = _AXUIElementGetWindow(axWindow, &cgWindowId)
if windowIDStatus == .success && window.windowID == cgWindowId {
return axWindow
}
The preview works well for PWAs.
I think eventually there will be no choice but to use some private APIs for the critical operations that have no official replacement, such as getting a window ID and taking screenshots of windows in other spaces, etc.
Refs: https://stackoverflow.com/a/74914146 https://stackoverflow.com/a/10134254 https://stackoverflow.com/a/73349397
https://github.com/rxhanson/Rectangle/blob/main/Rectangle/TodoMode/TodoManager.swift#L160-L162 https://github.com/rxhanson/Rectangle/blob/main/Rectangle/Utilities/AXExtension.swift#L87-L92 https://github.com/rxhanson/Rectangle/blob/main/Rectangle/ShortcutManager.swift#L86
https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/Window.swift#L233 https://github.com/lwouis/alt-tab-macos/blob/master/src/api-wrappers/PrivateApis.swift#L171-L174
@ShlomoCode thoughts on making this a PR?
happily. The question is, after we use the window id is it still necessary to guess based on the size and position title, or can this part be removed?
Maybe we can keep it as a fallback method, and just prioritize the private API usage? Though, I'm not sure which scenarios that method could possibly fail under. I'm not sure if a fallback is even needed, thoughts?
It seems pretty stable, I've searched and haven't seen any complaints about it. The apps on my computer work great with it, we can just remove it and see if there are issues from users? 😆
Send in that PR :)
@SABRE1982 @ShlomoCode what PWA was used as a reference for this?
When hovering over icons for Chrome PWA's ("installed" web apps), no preview is shown. Chrome itself works, as well as most native apps.