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

Doesn't work for Chrome PWA's #75

Closed
SABRE1982 opened this issue Jul 6, 2024 · 7 comments · Fixed by #126
Closed

Doesn't work for Chrome PWA's #75

SABRE1982 opened this issue Jul 6, 2024 · 7 comments · Fixed by #126

Comments

@SABRE1982
Copy link

When hovering over icons for Chrome PWA's ("installed" web apps), no preview is shown. Chrome itself works, as well as most native apps.

@ShlomoCode
Copy link
Contributor

ShlomoCode commented Jul 7, 2024

It seems that the AX API doesn't return a title for PWAs:
CleanShot 2024-07-07 at 02 40 56@2x

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
}

CleanShot 2024-07-07 at 03 26 44@2x

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 added a commit to ShlomoCode/DockDoor that referenced this issue Jul 7, 2024
@ejbills
Copy link
Owner

ejbills commented Jul 8, 2024

@ShlomoCode thoughts on making this a PR?

ShlomoCode added a commit to ShlomoCode/DockDoor that referenced this issue Jul 8, 2024
@ShlomoCode
Copy link
Contributor

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?

@ejbills
Copy link
Owner

ejbills commented Jul 8, 2024

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?

@ShlomoCode
Copy link
Contributor

ShlomoCode commented Jul 9, 2024

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? 😆

@ejbills
Copy link
Owner

ejbills commented Jul 9, 2024

Send in that PR :)

ShlomoCode added a commit to ShlomoCode/DockDoor that referenced this issue Jul 9, 2024
ShlomoCode added a commit to ShlomoCode/DockDoor that referenced this issue Jul 10, 2024
findWindow using AXWindow Id (_AXUIElementGetWindow)
closes ejbills#75
ShlomoCode added a commit to ShlomoCode/DockDoor that referenced this issue Jul 10, 2024
findWindow using AXWindow Id (_AXUIElementGetWindow)
closes ejbills#75
ShlomoCode added a commit to ShlomoCode/DockDoor that referenced this issue Jul 10, 2024
findWindow (find windowRef (AX Window) by `SCWindow`) using `_AXUIElementGetWindow`
closes ejbills#75
ShlomoCode added a commit to ShlomoCode/DockDoor that referenced this issue Jul 10, 2024
findWindow (find windowRef (AX Window) by `SCWindow`) using `_AXUIElementGetWindow`
closes ejbills#75
@hasansultan92
Copy link
Contributor

@SABRE1982 @ShlomoCode what PWA was used as a reference for this?

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 a pull request may close this issue.

4 participants