ejbills / DockDoor

Window peeking for macOS
MIT License
294 stars 8 forks source link

No preview for Visual Studio Code, Calendar, Finder #21

Closed ShlomoCode closed 1 week ago

ShlomoCode commented 1 week ago

When I hover over the Dock icon of these applications nothing happens. Version 1.0.5, macOS 14.5

ejbills commented 1 week ago

Lets focus on finder - if you right click the finder icon and hit "new finder window" and then hover over it again, it doesnt show up?

ShlomoCode commented 1 week ago

It's weird - it does work now for Finder (for VSCode and Calendar not yet). Probably for Finder this is some edge case, I will try to understand how to exactly reproduce the problem.

ejbills commented 1 week ago

Are you positive vscode and calendar have active windows open? Apps can be "active" without any windows being open - hence the confusion. Or its possible their windows are in another desktop space, which isnt supported yet.

ShlomoCode commented 1 week ago

Are you positive vscode and calendar have active windows open?

Yes of course. I made a screen recording for a demonstration where you can see that a preview does not appear for an open VSCode window, while for other applications (for example iTerm) it does:

https://github.com/ejbills/DockDoor/assets/78599753/b7f78c50-0a24-401b-85c0-c9593ca55c51

For you it shows for VSCode?

ejbills commented 1 week ago

It wasn't showing vscode for me either, I fixed it. Will be in next release.

ShlomoCode commented 1 week ago

Great. This should also fix Apple Calendar?

ejbills commented 1 week ago

Yes, my calendar previews are working on my laptop. If the issue is still there once the update is released, just ping me here and we can repoen this ticket.

ShlomoCode commented 1 week ago

If you'd like to push the fix commit I can confirm if it does fix the problem (I'm actually currently running a local DockDoor build I built using XCode, with Ctrl + Tab functionality disabled).

ejbills commented 1 week ago

Just pushed to main, give it a try and let me know!

ShlomoCode commented 1 week ago

Now works for open VSCode window, but not for minimized VSCode. For Calendar does not work at all, not even if it is open

https://github.com/ejbills/DockDoor/assets/78599753/02e45934-368b-4c92-9bc8-8b928c844d3f

ejbills commented 1 week ago

OK, I think I know the issue. I think it's the app name matching, it looks like your system applications are using a different language so the window can't find the match.

Can you please add this to line 257 of WindowUtil.swift print("Owning application: (app.applicationName)") print("Searching for: (applicationName)")

and hover over calendar, let me know what it says?

ShlomoCode commented 1 week ago

Looks like you're right! And when I change back the language of Calendar (in System Settings > Language & Region > Applications) to "System Default - English" the preview works. CleanShot 2024-06-25 at 21 31 41@2x

ShlomoCode commented 1 week ago

This happens because macOS does not apply the localization to the title in the Dock and Launchpad when the language is changed only for the application and not for the entire system, but it does change the window title...

ejbills commented 1 week ago

Can you print out the applicationName.localizedLowercase var? I'm hoping that will match the window name.

ejbills commented 1 week ago

I switched my locale to hebrew, and calendar previews appear to be working for me...

ShlomoCode commented 1 week ago

Yes, when the application and the system are the same, there is no problem, because both the window title and the name in the Dock are translated and identical. The problem is caused when the system is in one language, and a specific language is selected for the application (this is a built-in option of macOS). For example, an English system, and the Hebrew language was selected for the calendar app. In this case, the name in the Dock remains in its English version but the window title is the translated version, thus creating a mismatch: CleanShot 2024-06-25 at 22 53 43@2x

CleanShot 2024-06-25 at 22 55 25@2x

ShlomoCode commented 1 week ago

Can you print out the applicationName.localizedLowercase var? I'm hoping that will match the window name.

CleanShot 2024-06-25 at 23 21 34@2x

ejbills commented 1 week ago

I think I fixed it, please try the latest commit on main.

ShlomoCode commented 1 week ago

Yes, it works!

ejbills commented 1 week ago

Thank you for your help!

ShlomoCode commented 1 week ago

About this, we can get the bundle url directly using NSWorkspace.shared.urlForApplication:

func getNonLocalizedAppName(forBundleIdentifier bundleIdentifier: String) -> String? {
      guard let bundleURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: bundleIdentifier) else {
          return nil
      }

      let bundle = Bundle(url: bundleURL)

// ....

let nonLocalName = getNonLocalizedAppName(forBundleIdentifier: app.bundleIdentifier)

This seems to me more clean than going through NSRunningApplication.runningApplications > tempApp > tempApp.bundleURL. If you want I can also make a PR.

ejbills commented 1 week ago

Yes, that would be great!

ShlomoCode commented 1 week ago

https://github.com/ejbills/DockDoor/pull/28