5
votes

I need to monitor for any screen resolution changes in my app, coming with my app in front or not.

I searched a lot on the internet yesterday and tried all these options:

applicationDidChangeScreenParameters;
CGDisplayRegisterReconfigurationCallback;
NSApplicationDidChangeScreenParametersNotification;

I get notifications when I change the resolution manually or plug/unplug a new display.

But I do not get notifications when other applications changes the screen parameters (most games made before 2011).

Is there any way to know if Any mac application changes the screen resolution? Even if my app is in the background? Any notification? Hopefully without Accessibility API...?

Thank you very much


EDIT (June 9)

This answer Events when dock is showing or hiding helped me a little bit. Since I get the notification when another app enters/exits fullscreen, but not when it changes the resolution without changing the fullscreen state =/ And it relies on Carbon APIs which are deprecated on 10.8...

It is not exactly what I want but works for most cases... Is there any other way to achieve on cocoa? Any global notification for this?

1
What are you doing this for? If the user launches a full-screen game, your app probably shouldn't have anything to do in response to this, because the user will not be interacting graphically with your app for the duration of the game, and the screen resolution will be restored when the game quits.user57368
This is for my application: joystickmapper.com It runs on background and I need to know if anything changes the screen resolution to fix a issue that happens in a few games when using a different resolution than the desktop one.Rodrigo

1 Answers

1
votes

You probably already looked at this page:

https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/QuartzDisplayServicesConceptual/Articles/Notification.html%23//apple_ref/doc/uid/TP40004235-SW1

Also it seems you need to account for notifications from other apps hence use NSDistributedNotificationCenter instead of just NSNotificationCenter.