Detecting Full screen applications on mac

I am developing a simple application in Cocoa, and I want to detect whether any application is running in full screen mode. Is this possible?

Through runningApplications API, I can get various informations but there is no specific property related to full screen mode. Does any one know how to detect it? Is there any carbon event or API for this?

Upvotes: 7

Views: 3043

Answers (3)

Ken Thomases
Ken Thomases

Reputation: 90551

You want to key-value observe -[NSApplication currentSystemPresentationOptions]. When the active app is in full-screen mode, that property will include NSApplicationPresentationFullScreen.

Upvotes: 1

user3007353
user3007353

Reputation: 41

I ran into this in the spring and spent forever trying to get it to work. I ended up packaging my code up into a little GitHub project, but I completely forgot to share it here.

https://github.com/shinypb/FullScreenDetector

Hope this is useful for someone.

Upvotes: 3

Anyways after trying out so many options and digging into the NSWorkspace i have found way through which we can achieve this their is notification

"NSWorkspaceActiveSpaceDidChangeNotification"

Apple doc says "Posted when a Spaces change has occurred." so by using we can register for it. along with this we need to use the NSWindow's property "isOnActiveSpace" , so by this we can detect when application enters full screen mode and exits from it.

Upvotes: 2

Related Questions