phoenix icon indicating copy to clipboard operation
phoenix copied to clipboard

Event for when window moves to a new space

Open Braden1996 opened this issue 6 years ago • 6 comments

  • Version: 2.6 (62)
  • macOS: 10.13.2

I am trying to build a configuration which allows a space to manage the windows it contains. However, I'm unable to find an elegant way to detect when a window has been moved to a different space. The events windowDidMove and windowDidResize do not fire, as I suppose the moved window doesn't actually change size.

Is this possible without continuously polling which windows belong inside which spaces?

Cheers :)

Braden1996 avatar Jan 08 '18 21:01 Braden1996

Hi! Unfortunately the only viable option currently is to poll. Apple doesn’t provide really any public APIs for Spaces and if I remember correctly there’s no private one for this either. I’ll be sure to check this again.

kasper avatar Jan 19 '18 21:01 kasper

Hmm. I wonder if you could use NSAccessibilityFocusedWindowChangedNotification to detect this, i.e. presumably if you move the window, another window will become the focused one for the current space.

kasper avatar Jun 08 '18 13:06 kasper

Wonder if NSAccessibilityFocusedWindowChangedNotification would allow for detecting loss of window focus. Would love to be able to hide a window when the user clicks away.

lukesmurray avatar Feb 19 '21 21:02 lukesmurray

@lukesmurray It should, you can try using the windowDidFocus event which is exactly the event mentioned above.

kasper avatar Feb 20 '21 10:02 kasper

yup! it works 🥳 Love this library

lukesmurray avatar Feb 20 '21 15:02 lukesmurray

@lukesmurray Thanks! I appreciate the kind words!

kasper avatar Feb 20 '21 16:02 kasper