AlexPerathoner / SlimHUD

Replacement for MacOS' volume, brightness and keyboard backlight HUDs.
https://alexperathoner.github.io/SlimHUD
GNU General Public License v3.0
394 stars 9 forks source link

Respect padding for Stage Manager #126

Open towerofnix opened 1 year ago

towerofnix commented 1 year ago

Before opening the issue, have you...?

Is your feature request related to a problem? Please describe

When using Stage Manager, window previews/thumbnails are shown along the left screen edge (or right if the Dock is on the left). SlimHUD doesn't acknowledge this and just shows up over window previews.

Describe the solution you'd like

Respect the area allocated for Stage Manager (when active) just like for the Dock!

Describe alternatives you've considered

No real alternatives here.

Anything else?

Compare SlimHUD with Stage Manager and with Dock:

SlimHUD covering Stage Manager preview windows SlimHUD elegantly moving over past the Dock

BTW, thanks for your work on this app! It looks great and is super easy to use and configure!

AlexPerathoner commented 1 year ago

Looked into this, but unfortunately couldn't find a way to detect if Stage Manager is currently active in macOS

towerofnix commented 1 year ago

It's pretty trivial with defaults:

# check stage manager: 0 or 1
defaults read com.apple.WindowManager GloballyEnabled

# enable stage manager
defaults write com.apple.WindowManager GloballyEnabled -bool true

# disable stage manager
defaults write com.apple.WindowManager GloballyEnabled -bool false

I'm not sure if there's a direct analogy for Swift, but the read command reacts to changes in Stage Manager right away, so forking a shell process should work anyway. (There's no poll/watch command for defaults unfortunately, so you might have to do some thinking outside the box to react to changes effectively. The terminal command takes about 0.1s to execute.)

AlexPerathoner commented 1 year ago

That allows to check if it's enabled in the settings only, not if it's currently being shown in the UI (which is what I'd need to know before showing the HUD). What I couldn't find out is how to check if the stage manager UI is visible or not (which depends on the size and position of the frontmost window). Figuring that out would be too time consuming (and almost certainly way too resource intensive, too)

and imo quite confusing, too (what should happen in such a situation?): image

towerofnix commented 1 year ago

Gotcha, that makes sense. Or in this case where the window preview are even more covered:

Screenshot 2023-03-25 at 3 07 01 PM

Figuring that out would be too time consuming (and almost certainly way too resource intensive, too)

Agreed on time-consuming, not sure if it'd really be resource-intensive though. You only need to perform window checks when deciding where to position SlimHUD, and it's not computationally challenging math, and querying window positions shouldn't be a power draw.

My main concern is that you just might not be able to access that window info in the first place, i.e. the list of windows which are in the current set. After all, a window behind the focused one, within the same set, can also obscure the window thumbnails:

Screenshot 2023-03-25 at 3 11 43 PM

The same windows don't obscure Stage Manager window previews if they aren't part of the current set, i.e. some other app/set is brought to the front:

Screenshot 2023-03-25 at 3 12 53 PM

I don't think it would be too complicated to compute whether or not any given windows would cause thumbnails to hide, but I don't know if we can access the list of windows for the current set. And while I doubt it would be a significant power draw, I don't know that for sure.