ejbills / DockDoor

Window peeking for macOS
https://dockdoor.net
GNU General Public License v3.0
1.55k stars 39 forks source link

[BUG] no preview of minimized/hidden window if not initially previewed at least once #238

Open david-leeb opened 4 months ago

david-leeb commented 4 months ago

To get a preview of a minimized/hidden window I have to hover over the app at least once while the app is open before minimizing to get the preview. If I minimize the window without ever invoking the dock preview window, no preview of the window is shown in its minimized state.

illavoluntas commented 4 months ago

For now the method used needs to capture at least once the preview of the window in order to display it. The captures are only made when you trigger DockDoor Dock peek feature, and I don't think the team has figured yet how to capture the preview when minimized. They can correct me if I am wrong.

hasansultan92 commented 4 months ago

We could potentially do it, but that would involve heavy use of private APIs and an overhaul of the logic. We also discussed some of this in #9 and stuck with option 3: Concept of Discovery

ejbills commented 4 months ago

This is being looked into in https://github.com/ejbills/DockDoor/pull/214

ShlomoCode commented 3 months ago

We could potentially do it, but that would involve heavy use of private APIs and an overhaul of the logic

@hasansultan92 I don't think it should be a big deal, it's probably just one private API (CGSHWCaptureWindowList)

0n0mat0p03ia commented 3 months ago

Just adding that I've experienced this same issue as well. Wasn't sure what was causing it, but after some testing what I'm observing aligns with @dannymaybach's description.

ShlomoCode commented 3 months ago

@hasansultan92 You are using macOS 15 beta, right? Can you try https://github.com/ShlomoCode/DockDoor/tree/capture-minimize-windows and let me know if an error appears every time you open the app about using an deprecated API or something similar? It uses the private screenshot API (doesn't handle minimized windows yet, it's just a POC)

hasansultan92 commented 3 months ago

Yes, I'm running the 15.1 Beta. Cannot build and compile the program. Is there something that was supposed to be included in the files that wasn't committed perhaps?

image
ShlomoCode commented 3 months ago

@hasansultan92 Sorry, try again now

ShlomoCode commented 3 months ago

@hasansultan92 @ejbills Can you please check this on macOS 15?

ejbills commented 3 months ago

@hasansultan92 @ejbills Can you please check this on macOS 15?

Only happened once.

ShlomoCode commented 3 months ago

@ejbills I'm a bit confused, does ScreenCaptureKit allow us to take a picture of minimized windows (not in another space\full screen) or not? After all, these windows can be obtained using the API using the getExcludingDesktopWindows API located under ScreenCaptureKit:

getExcludingDesktopWindows(true, onScreenWindowsOnly: false)

as well as by calling kAXWindowsAttribute on the App ax element

What are the limitations of ScreenCaptureKit?

ejbills commented 3 months ago

ScreenCaptureKit is unable to get previews of minimized, hidden, and other-space windows. The CoreGraphics API you mentioned is what Apple said in their release notes will "warn users" - but this happens with SCKit too, so...

We won't know what Apple is doing with the warning message till the first major release of Sequoia, but it seems like it'll be a weekly (per-app?) warning: https://9to5mac.com/2024/08/06/macos-sequoia-screen-recording-privacy-prompt/

ShlomoCode commented 3 months ago

ScreenCaptureKit is unable to get previews of minimized windows

Please try this POC (based on #main): https://github.com/ShlomoCode/DockDoor/commit/27af2456a099e0618c229a32dce9dba9295d2c6a As far as I understand it uses ScreenCaptureKit only, not CG methods, and it can capture an image for a minimized VSCode window.

hasansultan92 commented 3 months ago

@ShlomoCode just tried the capture-minimize-window branch. Seems to be working fine with no warnings, though, occasionally I am running into Failed to bring window to front with fallback attempts. in the logs when I want to use the window switcher. Seems that the only cure for that is to go to another space and then try the window switcher again, then go to the space with the window and try the window switcher again.

Please beware, my computer has not once shown me the pink/purple/lavender notification for ScreenCapture since I have used DockDoor, not in the past, and not this time.

I also tried the 27af245 commit and I cannot see my minimized windows without first unminimizing them and discovering them, similar to what DockDoor is doing right now. If I open a window, use the window switcher and see the window there, then go and minimize the window, the window disappears from the window switcher as well

hasansultan92 commented 3 months ago

@ShlomoCode To add to @ejbills's argument about the weekly allowance, I thought this was an Xcode thing, Ive had to allow DockDoor - your POCs - a couple of times already for screencapture - most likely cause it's a new build each time ive tried it. I did not realize that the warning is the OS and not Xcode.

ShlomoCode commented 3 months ago

@hasansultan92 The capture-minimize-windows branch is just #master + using CGSHWCaptureWindowList to capture the images instead of using ScreenCaptureKit. It does not include minimized windows as its purpose is only to test the macos purple warning issue.