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?

Frank Schmitt
  • 30,195
  • 12
  • 73
  • 107
  • 1
    Similar to http://stackoverflow.com/questions/7138194/mac-os-x-lion-detect-if-another-application-is-running-in-full-screen-mode?rq=1 – Jay Apr 08 '13 at 08:54
  • @Jay 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. – sandy Surname or Initialc Apr 08 '13 at 10:07
  • Hmm you might want to activate your application to have the alert show like in http://stackoverflow.com/questions/5269116/make-a-nsalert-the-topmost-window?rq=1 ? – Jay Apr 08 '13 at 11:44
  • 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?? – sandy Surname or Initialc Apr 08 '13 at 13:19

3 Answers3

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.

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.

  • I tried to add observer to the `NSWorkspaceActiveSpaceDidChangeNotification` notification. But it only works in debug mode. Is there any system restriction in release mode? – Gon Oct 31 '13 at 07:39
  • This is available from 10.6 and later..do cross check once..ther is not any resrtiction as such straight away it should work – sandy Surname or Initialc Nov 09 '13 at 09:49
  • Weird. I'll dig into it. – Gon Nov 13 '13 at 07:51
  • 2
    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? – Ken Thomases Nov 19 '13 at 05:12
1

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

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154