5

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?

Community
  • 1
  • 1
Rodrigo
  • 674
  • 8
  • 19
  • 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 Jun 16 '12 at 03:39
  • 1
    This is for my application: http://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 Jun 16 '12 at 04:10

1 Answers1

1

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.

Carelinkz
  • 936
  • 8
  • 27
  • Yeah, I read this. Maybe I misread something. I will double check just to be sure. – Rodrigo Jun 16 '12 at 04:26
  • How did you fare? It seems strange that the system does not provide these notifications so I'm curious if you got it to work! – Carelinkz Jun 17 '12 at 19:15
  • For some reason, NSDistributedNotificationCenter is not working for me. when using NSNotificationCenter, I got the notifications. however, when some app changes the screen resolution temporarily (and goes back to previous resolution on exit), my app simply does not receive any notification. Not sure if this is a bug or a feature. – Rodrigo Jun 18 '12 at 17:55