Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to know if another application changed the display resolution in Cocoa?

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?

like image 801
Rodrigo Avatar asked Nov 14 '22 04:11

Rodrigo


1 Answers

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.

like image 155
Carelinkz Avatar answered Dec 31 '22 13:12

Carelinkz