< Previous PageNext Page > Hide TOC

Notification of Configuration Changes

Quartz Display Services provides a general notification mechanism for applications that need to know about display configuration changes. Any application can register a display reconfiguration callback function. At several points during reconfiguration, Quartz passes to your callback function the display ID, status flags, and optional private data. During a display mode change, for example, you could use a callback to print a log message that describes the new mode.

Quartz invokes your callback function when:

Before display reconfiguration, Quartz invokes your callback function once for each online display to indicate a pending configuration change. The kCGDisplayBeginConfigurationFlag flag is always set. After display reconfiguration, Quartz invokes your callback function once for each added, removed, and online display. At this time, all display state reported by Quartz Display Services, QuickDraw, and the Carbon Display Manager will be up to date. The flags indicate how the display configuration has changed.

Carbon and Cocoa already use this notification mechanism to respond to display reconfigurations. As a result, when a user or application changes a display mode, turns on mirroring, or disconnects a display, Carbon or Cocoa applications don't need to be concerned with repositioning or resizing their windows. The application frameworks handle this task automatically.

If you want to receive notifications of configuration changes, here is a brief description of the steps:

  1. Register your notification callback function:

    CGDisplayRegisterReconfigurationCallback (MyDisplayReconfigurationCallBack, &userInfo);
  2. When your function is called, check the parameters to see if action is required. For example:

    void MyDisplayReconfigurationCallBack (
       CGDirectDisplayID display,
       CGDisplayChangeSummaryFlags flags,
       void *userInfo)
    {
        if (flags & kCGDisplaySetModeFlag) {
            /* handle mode change for this display */
        }
    }
  3. When you no longer require notification, remove the callback registration:

    CGDisplayRemoveReconfigurationCallback (MyDisplayReconfigurationCallBack, &userInfo);


< Previous PageNext Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-06-28)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.