Giter Site home page Giter Site logo

vicever / fullscreendetector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shinypb/fullscreendetector

0.0 2.0 0.0 168 KB

Get notifications in your Cocoa apps when switching between full screen apps and regular Spaces on Mac OS X Lion or OS X Mountain Lion.

Objective-C 100.00%

fullscreendetector's Introduction

FullScreenDetector

Determine whether a full screen application is currently active, and get notifications when switching between full screen apps and regular Spaces.

This little library is the result of much banging of foreheads and gnashing of teeth — Mac OS X Lion and OS X Mountain Lion do not expose this information in a particularly direct way.

Usage

Add MDCFullScreenDetector.h and MDCFullScreenDetector.m to your project. Add a new NSWindow to your MainMenu.xib and change its class to MDCFullScreenDetector.

Caveats

Full screen detection does not work if your application has LSUIElement (displayed in Xcode as “Application is agent (UIElement)”) set to YES in its Info.plist.

MDCFullScreenDetector will log a warning message if it detects this condition.

Workaround: call [NSApp setActivationPolicy:NSApplicationActivationPolicyProhibited] in your AppDelegate's applicationDidFinishLaunching: method.

Notifications

MDCFullScreenDetector posts two notifications to [NSNotificationCenter defaultCenter]:

  • kMDCFullScreenDetectorSwitchedToFullScreenApp, when switching to a full screen app
  • kMDCFullScreenDetectorSwitchedToRegularSpace, when switching to a regular Space

When switching between two full screen apps, or two regular Spaces, no notification will be posted. If you need to know this, listen for NSWorkspaceActiveSpaceDidChangeNotification and check fullScreenAppIsActive (see Methods, below).

Methods

- (BOOL)fullScreenAppIsActive — returns YES if a full screen app is currently active, and NO if a regular Space is currently active.

Demo

Although the demo is currently Mountain Lion only, the library itself should work fine on Lion (todo: actually test it).

Open the included Xcode project and run FullScreenDetector. Notifications will pop up in Notification Center when switching between full screen apps and regular Spaces.

License

All of the code here was written by @shinypb. I hereby release it into the public domain, although I'd love to hear what you build with it.

Special thanks to @anathemalie and @siegel for listening to me complain about this for so long, and @skid for his kind but ultimately unsuccessful suggestion. :)

fullscreendetector's People

Contributors

shinypb avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.