Detecting Full screen applications on mac
Asked Answered
R

3

7

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?

Roguish answered 8/4, 2013 at 6:45 Comment(4)
Similar to #7138694Androus
@Androus Thanks for pointing to those links , i have one more query if any application is running in full screen mode and if any other app puts an alert message what happens? and also what happens for OSD like toast message displaying similar to apple's update available feature..can you please help me to find out this answers.Roguish
Hmm you might want to activate your application to have the alert show like in #5269616 ?Androus
ok..but my basic question is how to detect if any of the user application has exited the full screen mode?..here is what i wnat to do...I want to display the user an toast like message but with condition that if the user has any of the full screen apps like it may be any game or any app then i wont have to display it, then as soon as the application quits from full mode i want to display the message ,..so is their way to detect it??Roguish
R
2

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.

Roguish answered 9/4, 2013 at 6:58 Comment(4)
I tried to add observer to the NSWorkspaceActiveSpaceDidChangeNotification notification. But it only works in debug mode. Is there any system restriction in release mode?Designate
This is available from 10.6 and later..do cross check once..ther is not any resrtiction as such straight away it should workRoguish
Weird. I'll dig into it.Designate
Space changes don't only occur when apps enter or exit full-screen mode. Users can have arbitrary many non-full-screen spaces. Which window's -isOnActiveSpace were you planning on testing?Philanthropist
C
3

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.

Canny answered 19/11, 2013 at 4:48 Comment(0)
R
2

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.

Roguish answered 9/4, 2013 at 6:58 Comment(4)
I tried to add observer to the NSWorkspaceActiveSpaceDidChangeNotification notification. But it only works in debug mode. Is there any system restriction in release mode?Designate
This is available from 10.6 and later..do cross check once..ther is not any resrtiction as such straight away it should workRoguish
Weird. I'll dig into it.Designate
Space changes don't only occur when apps enter or exit full-screen mode. Users can have arbitrary many non-full-screen spaces. Which window's -isOnActiveSpace were you planning on testing?Philanthropist
P
1

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

Philanthropist answered 19/11, 2013 at 5:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.