home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SuperFlyAppleEventHandler.cp
-
- Contains: Routines to install and handle the Display Manager's Apple Event
-
- Written by: Kent Miller
-
- Copyright: © 1996 Apple Computer
-
- Change History (most recent first):
-
- */
-
- //From the Sprocket Lib
- #include "AppleEventHandling.h"
-
- //SuperFly includes
- #include "GDeviceUtilities.h"
- #include "SuperFlyAppleEventHandler.h"
- #include "SuperFly.h"
-
- OSErr
- InstallDisplayManagerEventHandler(void)
- {
- return AEInstallEventHandler(kCoreEventClass,kAESystemConfigNotice,NewAEEventHandlerProc(HandleDisplayManagerEvent),0,false);
- }
-
-
- pascal OSErr
- HandleDisplayManagerEvent(AppleEvent *theAppleEvent,AppleEvent * /* reply */,long /* refCon */)
- {
- AEDescList DisplayList, DisplayID;
- long displayCount;
- AERecord OldConfig, NewConfig;
- AEKeyword tempWord;
- AEDesc returnType;
- OSErr myErr;
- Rect oldRect, newRect;
- SInt16 oldDepth, newDepth;
- Boolean graphicsWorldChanged = false;
-
- if ((myErr = AEGetParamDesc(theAppleEvent,kAEDisplayNotice, typeWildCard, &DisplayList)) != noErr)
- return myErr;
-
- if ((myErr = CheckAppleEventForMissingParams(theAppleEvent)) != noErr)
- return myErr;
-
- if ((myErr = AECountItems(&DisplayList,&displayCount)) != noErr)
- return myErr;
-
- if ( CountUniqueDeviceRects() != gMyWindowList->CountListItems())
- graphicsWorldChanged = true;
- else
- {
- while (displayCount > 0)
- {
- //From Display Manager developer note, September 1995 developer CD
-
- AEGetNthDesc(&DisplayList, displayCount, typeWildCard, &tempWord, &DisplayID);
- AEGetNthDesc(&DisplayID, 1, typeWildCard, &tempWord, &OldConfig);
- AEGetNthDesc(&DisplayID, 2, typeWildCard, &tempWord, &NewConfig);
-
- //Did the bitdepth change?
- AEGetKeyPtr(&OldConfig, keyPixMapCmpSize, typeWildCard, (UInt32 *) &returnType, &oldDepth, 2, nil);
- AEGetKeyPtr(&NewConfig, keyPixMapCmpSize, typeWildCard, (UInt32 *) &returnType, &newDepth, 2, nil);
- if (oldDepth != newDepth)
- {
- //maybe do something here if you're interested in bit depth changes
- }
-
- //Did the devices move or something like that?
- AEGetKeyPtr(&OldConfig, keyDeviceRect, typeWildCard, (UInt32 *) &returnType, &oldRect, sizeof(Rect), nil);
- AEGetKeyPtr(&NewConfig, keyDeviceRect, typeWildCard, (UInt32 *) &returnType, &newRect, sizeof(Rect), nil);
- if (! EqualRect(&oldRect, &newRect) )
- {
- SuperFlyHandleGDevicesMoved();
- }
- displayCount--;
-
- (void) AEDisposeDesc(&DisplayID);
- (void) AEDisposeDesc(&OldConfig);
- (void) AEDisposeDesc(&NewConfig);
- }
- }
-
- (void) AEDisposeDesc(&DisplayList);
-
- if (graphicsWorldChanged)
- {
- SuperFlySetUpWindows();
- if (gMyToolWindow)
- gMyToolWindow->MoveToRelativePosition();
- }
-
- return noErr; // we really don’t handle this yet...
- }
-