diff options
author | marha <marha@users.sourceforge.net> | 2012-03-26 14:23:28 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-26 14:23:28 +0200 |
commit | 76bcc36ed305418a3ddc5752d287ede894243e1b (patch) | |
tree | bacb320c825768471ce56f058f17ce863d592376 /xorg-server/hw/xquartz/quartzRandR.c | |
parent | 7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff) | |
parent | 0f834b91a4768673833ab4917e87d86c237bb1a6 (diff) | |
download | vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2 vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
pixman/pixman/pixman-mmx.c
xorg-server/Xext/shm.c
xorg-server/Xext/syncsrv.h
xorg-server/Xext/xvmain.c
xorg-server/Xi/exevents.c
xorg-server/Xi/opendev.c
xorg-server/composite/compalloc.c
xorg-server/composite/compoverlay.c
xorg-server/dix/colormap.c
xorg-server/dix/devices.c
xorg-server/dix/dispatch.c
xorg-server/dix/dixfonts.c
xorg-server/dix/eventconvert.c
xorg-server/dix/events.c
xorg-server/dix/gc.c
xorg-server/dix/getevents.c
xorg-server/dix/main.c
xorg-server/dix/privates.c
xorg-server/dix/registry.c
xorg-server/dix/resource.c
xorg-server/exa/exa_accel.c
xorg-server/exa/exa_migration_classic.c
xorg-server/exa/exa_unaccel.c
xorg-server/fb/fb.h
xorg-server/fb/fbcopy.c
xorg-server/fb/fbpixmap.c
xorg-server/glx/dispatch.h
xorg-server/glx/glapi.h
xorg-server/glx/glapi_gentable.c
xorg-server/glx/glapitable.h
xorg-server/glx/glprocs.h
xorg-server/glx/glxcmds.c
xorg-server/glx/glxcmdsswap.c
xorg-server/glx/glxdricommon.c
xorg-server/glx/glxdriswrast.c
xorg-server/glx/glxext.c
xorg-server/glx/indirect_dispatch.c
xorg-server/glx/indirect_dispatch.h
xorg-server/glx/indirect_dispatch_swap.c
xorg-server/glx/indirect_size.h
xorg-server/glx/indirect_size_get.h
xorg-server/glx/indirect_table.c
xorg-server/glx/indirect_util.c
xorg-server/glx/rensize.c
xorg-server/glx/single2swap.c
xorg-server/glx/singlepix.c
xorg-server/glx/singlepixswap.c
xorg-server/glx/singlesize.c
xorg-server/hw/dmx/dmxinit.c
xorg-server/hw/kdrive/ephyr/ephyr.c
xorg-server/hw/kdrive/ephyr/hostx.c
xorg-server/hw/kdrive/ephyr/hostx.h
xorg-server/hw/kdrive/src/kinput.c
xorg-server/hw/xfree86/common/compiler.h
xorg-server/hw/xwin/InitInput.c
xorg-server/hw/xwin/InitOutput.c
xorg-server/hw/xwin/ddraw.h
xorg-server/hw/xwin/glx/glwrap.c
xorg-server/hw/xwin/glx/indirect.c
xorg-server/hw/xwin/glx/wgl_ext_api.h
xorg-server/hw/xwin/glx/winpriv.c
xorg-server/hw/xwin/win.h
xorg-server/hw/xwin/winallpriv.c
xorg-server/hw/xwin/winauth.c
xorg-server/hw/xwin/winclipboard.h
xorg-server/hw/xwin/winclipboardinit.c
xorg-server/hw/xwin/winclipboardthread.c
xorg-server/hw/xwin/winclipboardunicode.c
xorg-server/hw/xwin/winclipboardwndproc.c
xorg-server/hw/xwin/winclipboardwrappers.c
xorg-server/hw/xwin/winclipboardxevents.c
xorg-server/hw/xwin/wincmap.c
xorg-server/hw/xwin/winconfig.c
xorg-server/hw/xwin/wincreatewnd.c
xorg-server/hw/xwin/wincursor.c
xorg-server/hw/xwin/windialogs.c
xorg-server/hw/xwin/winengine.c
xorg-server/hw/xwin/winerror.c
xorg-server/hw/xwin/wingc.c
xorg-server/hw/xwin/wingetsp.c
xorg-server/hw/xwin/winkeybd.c
xorg-server/hw/xwin/winkeybd.h
xorg-server/hw/xwin/winlayouts.h
xorg-server/hw/xwin/winmisc.c
xorg-server/hw/xwin/winmonitors.c
xorg-server/hw/xwin/winmouse.c
xorg-server/hw/xwin/winmsg.c
xorg-server/hw/xwin/winmsg.h
xorg-server/hw/xwin/winmultiwindowclass.c
xorg-server/hw/xwin/winmultiwindowicons.c
xorg-server/hw/xwin/winmultiwindowshape.c
xorg-server/hw/xwin/winmultiwindowwindow.c
xorg-server/hw/xwin/winmultiwindowwm.c
xorg-server/hw/xwin/winmultiwindowwndproc.c
xorg-server/hw/xwin/winnativegdi.c
xorg-server/hw/xwin/winpfbdd.c
xorg-server/hw/xwin/winpixmap.c
xorg-server/hw/xwin/winpolyline.c
xorg-server/hw/xwin/winprefs.c
xorg-server/hw/xwin/winprocarg.c
xorg-server/hw/xwin/winregistry.c
xorg-server/hw/xwin/winscrinit.c
xorg-server/hw/xwin/winsetsp.c
xorg-server/hw/xwin/winshaddd.c
xorg-server/hw/xwin/winshadddnl.c
xorg-server/hw/xwin/winshadgdi.c
xorg-server/hw/xwin/wintrayicon.c
xorg-server/hw/xwin/winwin32rootless.c
xorg-server/hw/xwin/winwin32rootlesswindow.c
xorg-server/hw/xwin/winwin32rootlesswndproc.c
xorg-server/hw/xwin/winwindow.c
xorg-server/hw/xwin/winwindow.h
xorg-server/hw/xwin/winwindowswm.c
xorg-server/hw/xwin/winwndproc.c
xorg-server/include/callback.h
xorg-server/include/dixstruct.h
xorg-server/include/misc.h
xorg-server/include/os.h
xorg-server/include/scrnintstr.h
xorg-server/mi/micmap.c
xorg-server/mi/miinitext.c
xorg-server/mi/mioverlay.c
xorg-server/mi/misprite.c
xorg-server/mi/mivaltree.c
xorg-server/mi/miwindow.c
xorg-server/miext/damage/damage.c
xorg-server/miext/rootless/rootlessGC.c
xorg-server/miext/rootless/rootlessWindow.c
xorg-server/os/WaitFor.c
xorg-server/os/access.c
xorg-server/os/connection.c
xorg-server/os/io.c
xorg-server/os/log.c
xorg-server/os/osinit.c
xorg-server/os/utils.c
xorg-server/os/xdmcp.c
xorg-server/os/xprintf.c
xorg-server/os/xstrans.c
xorg-server/render/mipict.c
xorg-server/xkb/xkbActions.c
xorg-server/xkb/xkbInit.c
xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'xorg-server/hw/xquartz/quartzRandR.c')
-rw-r--r-- | xorg-server/hw/xquartz/quartzRandR.c | 393 |
1 files changed, 234 insertions, 159 deletions
diff --git a/xorg-server/hw/xquartz/quartzRandR.c b/xorg-server/hw/xquartz/quartzRandR.c index 98b382d65..b7c424f50 100644 --- a/xorg-server/hw/xquartz/quartzRandR.c +++ b/xorg-server/hw/xquartz/quartzRandR.c @@ -64,14 +64,17 @@ static Bool ignore_next_fake_mode_update = FALSE; #define CALLBACK_ERROR -1 typedef int (*QuartzModeCallback) - (ScreenPtr, QuartzModeInfoPtr, void *); + (ScreenPtr, QuartzModeInfoPtr, void *); #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 -static long getDictLong (CFDictionaryRef dictRef, CFStringRef key) { +static long +getDictLong(CFDictionaryRef dictRef, CFStringRef key) +{ long value; CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key); + if (!numRef) return 0; @@ -80,10 +83,13 @@ static long getDictLong (CFDictionaryRef dictRef, CFStringRef key) { return value; } -static double getDictDouble (CFDictionaryRef dictRef, CFStringRef key) { +static double +getDictDouble(CFDictionaryRef dictRef, CFStringRef key) +{ double value; CFNumberRef numRef = (CFNumberRef) CFDictionaryGetValue(dictRef, key); + if (!numRef) return 0.0; @@ -92,43 +98,51 @@ static double getDictDouble (CFDictionaryRef dictRef, CFStringRef key) { return value; } -static void QuartzRandRGetModeInfo (CFDictionaryRef modeRef, - QuartzModeInfoPtr pMode) { +static void +QuartzRandRGetModeInfo(CFDictionaryRef modeRef, QuartzModeInfoPtr pMode) +{ pMode->width = (size_t) getDictLong(modeRef, kCGDisplayWidth); pMode->height = (size_t) getDictLong(modeRef, kCGDisplayHeight); - pMode->refresh = (int)(getDictDouble(modeRef, kCGDisplayRefreshRate) + 0.5); + pMode->refresh = + (int) (getDictDouble(modeRef, kCGDisplayRefreshRate) + 0.5); if (pMode->refresh == 0) pMode->refresh = DEFAULT_REFRESH; pMode->ref = NULL; pMode->pSize = NULL; } -static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId, - QuartzModeInfoPtr pMode) { +static Bool +QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId, + QuartzModeInfoPtr pMode) +{ CFDictionaryRef curModeRef = CGDisplayCurrentMode(screenId); + if (!curModeRef) return FALSE; QuartzRandRGetModeInfo(curModeRef, pMode); - pMode->ref = (void *)curModeRef; + pMode->ref = (void *) curModeRef; CFRetain(pMode->ref); return TRUE; } -static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId, - QuartzModeInfoPtr pMode) { +static Bool +QuartzRandRSetCGMode(CGDirectDisplayID screenId, QuartzModeInfoPtr pMode) +{ CFDictionaryRef modeRef = (CFDictionaryRef) pMode->ref; + return (CGDisplaySwitchToMode(screenId, modeRef) == kCGErrorSuccess); } -static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, - QuartzModeCallback callback, - void *data) { +static Bool +QuartzRandREnumerateModes(ScreenPtr pScreen, + QuartzModeCallback callback, void *data) +{ Bool retval = FALSE; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); /* Just an 800x600 fallback if we have no attached heads */ - if(pQuartzScreen->displayIDs) { + if (pQuartzScreen->displayIDs) { CFDictionaryRef curModeRef, modeRef; long curBpp; CFArrayRef modes; @@ -146,6 +160,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, return FALSE; for (i = 0; i < CFArrayGetCount(modes); i++) { int cb; + modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i); /* Skip modes that are not usable on the current display or have a @@ -157,7 +172,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, continue; QuartzRandRGetModeInfo(modeRef, &modeInfo); - modeInfo.ref = (void *)modeRef; + modeInfo.ref = (void *) modeRef; cb = callback(pScreen, &modeInfo, data); if (cb == CALLBACK_CONTINUE) retval = TRUE; @@ -168,35 +183,36 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, } } - switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) { - case CALLBACK_SUCCESS: - return TRUE; - case CALLBACK_ERROR: - return FALSE; - case CALLBACK_CONTINUE: - retval = TRUE; - default: - break; + switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) { + case CALLBACK_SUCCESS: + return TRUE; + case CALLBACK_ERROR: + return FALSE; + case CALLBACK_CONTINUE: + retval = TRUE; + default: + break; } - switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { - case CALLBACK_SUCCESS: - return TRUE; - case CALLBACK_ERROR: - return FALSE; - case CALLBACK_CONTINUE: - retval = TRUE; - default: - break; + switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { + case CALLBACK_SUCCESS: + return TRUE; + case CALLBACK_ERROR: + return FALSE; + case CALLBACK_CONTINUE: + retval = TRUE; + default: + break; } return retval; } -#else /* we have the new CG APIs from Snow Leopard */ +#else /* we have the new CG APIs from Snow Leopard */ -static void QuartzRandRGetModeInfo (CGDisplayModeRef modeRef, - QuartzModeInfoPtr pMode) { +static void +QuartzRandRGetModeInfo(CGDisplayModeRef modeRef, QuartzModeInfoPtr pMode) +{ pMode->width = CGDisplayModeGetWidth(modeRef); pMode->height = CGDisplayModeGetHeight(modeRef); pMode->refresh = (int) (CGDisplayModeGetRefreshRate(modeRef) + 0.5); @@ -206,9 +222,12 @@ static void QuartzRandRGetModeInfo (CGDisplayModeRef modeRef, pMode->pSize = NULL; } -static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId, - QuartzModeInfoPtr pMode) { +static Bool +QuartzRandRCopyCurrentModeInfo(CGDirectDisplayID screenId, + QuartzModeInfoPtr pMode) +{ CGDisplayModeRef curModeRef = CGDisplayCopyDisplayMode(screenId); + if (!curModeRef) return FALSE; @@ -217,23 +236,27 @@ static Bool QuartzRandRCopyCurrentModeInfo (CGDirectDisplayID screenId, return TRUE; } -static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId, - QuartzModeInfoPtr pMode) { +static Bool +QuartzRandRSetCGMode(CGDirectDisplayID screenId, QuartzModeInfoPtr pMode) +{ CGDisplayModeRef modeRef = (CGDisplayModeRef) pMode->ref; + if (!modeRef) return FALSE; - return (CGDisplaySetDisplayMode(screenId, modeRef, NULL) == kCGErrorSuccess); + return (CGDisplaySetDisplayMode(screenId, modeRef, NULL) == + kCGErrorSuccess); } -static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, - QuartzModeCallback callback, - void *data) { +static Bool +QuartzRandREnumerateModes(ScreenPtr pScreen, + QuartzModeCallback callback, void *data) +{ Bool retval = FALSE; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); /* Just an 800x600 fallback if we have no attached heads */ - if(pQuartzScreen->displayIDs) { + if (pQuartzScreen->displayIDs) { CGDisplayModeRef curModeRef, modeRef; CFStringRef curPixelEnc, pixelEnc; CFComparisonResult pixelEncEqual; @@ -255,6 +278,7 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, } for (i = 0; i < CFArrayGetCount(modes); i++) { int cb; + modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); /* Skip modes that are not usable on the current display or have a @@ -273,11 +297,13 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, cb = callback(pScreen, &modeInfo, data); if (cb == CALLBACK_CONTINUE) { retval = TRUE; - } else if (cb == CALLBACK_SUCCESS) { + } + else if (cb == CALLBACK_SUCCESS) { CFRelease(modes); CFRelease(curPixelEnc); return TRUE; - } else if (cb == CALLBACK_ERROR) { + } + else if (cb == CALLBACK_ERROR) { CFRelease(modes); CFRelease(curPixelEnc); return FALSE; @@ -288,81 +314,91 @@ static Bool QuartzRandREnumerateModes (ScreenPtr pScreen, CFRelease(curPixelEnc); } - switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) { - case CALLBACK_SUCCESS: - return TRUE; - case CALLBACK_ERROR: - return FALSE; - case CALLBACK_CONTINUE: - retval = TRUE; - default: - break; + switch (callback(pScreen, &pQuartzScreen->rootlessMode, data)) { + case CALLBACK_SUCCESS: + return TRUE; + case CALLBACK_ERROR: + return FALSE; + case CALLBACK_CONTINUE: + retval = TRUE; + default: + break; } - switch(callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { - case CALLBACK_SUCCESS: - return TRUE; - case CALLBACK_ERROR: - return FALSE; - case CALLBACK_CONTINUE: - retval = TRUE; - default: - break; + switch (callback(pScreen, &pQuartzScreen->fullscreenMode, data)) { + case CALLBACK_SUCCESS: + return TRUE; + case CALLBACK_ERROR: + return FALSE; + case CALLBACK_CONTINUE: + retval = TRUE; + default: + break; } return retval; } -#endif /* Snow Leopard CoreGraphics APIs */ +#endif /* Snow Leopard CoreGraphics APIs */ - -static Bool QuartzRandRModesEqual (QuartzModeInfoPtr pMode1, - QuartzModeInfoPtr pMode2) { +static Bool +QuartzRandRModesEqual(QuartzModeInfoPtr pMode1, QuartzModeInfoPtr pMode2) +{ return (pMode1->width == pMode2->width) && - (pMode1->height == pMode2->height) && - (pMode1->refresh == pMode2->refresh); + (pMode1->height == pMode2->height) && + (pMode1->refresh == pMode2->refresh); } -static Bool QuartzRandRRegisterMode (ScreenPtr pScreen, - QuartzModeInfoPtr pMode) { +static Bool +QuartzRandRRegisterMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode) +{ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - Bool isCurrentMode = QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode); + Bool isCurrentMode = + QuartzRandRModesEqual(&pQuartzScreen->currentMode, pMode); /* TODO: DPI */ - pMode->pSize = RRRegisterSize(pScreen, pMode->width, pMode->height, pScreen->mmWidth, pScreen->mmHeight); + pMode->pSize = + RRRegisterSize(pScreen, pMode->width, pMode->height, pScreen->mmWidth, + pScreen->mmHeight); if (pMode->pSize) { //DEBUG_LOG("registering: %d x %d @ %d %s\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh, isCurrentMode ? "*" : ""); RRRegisterRate(pScreen, pMode->pSize, pMode->refresh); if (isCurrentMode) - RRSetCurrentConfig(pScreen, RR_Rotate_0, pMode->refresh, pMode->pSize); + RRSetCurrentConfig(pScreen, RR_Rotate_0, pMode->refresh, + pMode->pSize); return TRUE; } return FALSE; } -static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen, - QuartzModeInfoPtr pMode, - void *data __unused) { - if(QuartzRandRRegisterMode(pScreen, pMode)) { +static int +QuartzRandRRegisterModeCallback(ScreenPtr pScreen, + QuartzModeInfoPtr pMode, void *data __unused) +{ + if (QuartzRandRRegisterMode(pScreen, pMode)) { return CALLBACK_CONTINUE; - } else { + } + else { return CALLBACK_ERROR; } } -static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) { +static Bool +QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) +{ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); - Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS); + Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && + pMode->refresh != FAKE_REFRESH_ROOTLESS); CGDirectDisplayID screenId; - if(pQuartzScreen->displayIDs == NULL) + if (pQuartzScreen->displayIDs == NULL) return FALSE; screenId = pQuartzScreen->displayIDs[0]; - if(XQuartzShieldingWindowLevel == 0 && captureDisplay) { - if(!X11ApplicationCanEnterRandR()) + if (XQuartzShieldingWindowLevel == 0 && captureDisplay) { + if (!X11ApplicationCanEnterRandR()) return FALSE; CGCaptureAllDisplays(); XQuartzShieldingWindowLevel = CGShieldingWindowLevel(); // 2147483630 @@ -370,11 +406,14 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL CGShieldingWindowID(screenId), XQuartzShieldingWindowLevel); } - if (pQuartzScreen->currentMode.ref && CFEqual(pMode->ref, pQuartzScreen->currentMode.ref)) { + if (pQuartzScreen->currentMode.ref && + CFEqual(pMode->ref, pQuartzScreen->currentMode.ref)) { DEBUG_LOG("Requested RandR resolution matches current CG mode\n"); - } if (QuartzRandRSetCGMode(screenId, pMode)) { + } + if (QuartzRandRSetCGMode(screenId, pMode)) { ignore_next_fake_mode_update = TRUE; - } else { + } + else { DEBUG_LOG("Error while requesting CG resolution change.\n"); return FALSE; } @@ -387,13 +426,13 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL QuartzShowFullscreen(TRUE); } - if(pQuartzScreen->currentMode.ref) + if (pQuartzScreen->currentMode.ref) CFRelease(pQuartzScreen->currentMode.ref); pQuartzScreen->currentMode = *pMode; - if(pQuartzScreen->currentMode.ref) + if (pQuartzScreen->currentMode.ref) CFRetain(pQuartzScreen->currentMode.ref); - - if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) { + + if (XQuartzShieldingWindowLevel != 0 && !captureDisplay) { CGReleaseAllDisplays(); XQuartzShieldingWindowLevel = 0; } @@ -401,32 +440,37 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL return TRUE; } -static int QuartzRandRSetModeCallback (ScreenPtr pScreen, - QuartzModeInfoPtr pMode, - void *data) { +static int +QuartzRandRSetModeCallback(ScreenPtr pScreen, + QuartzModeInfoPtr pMode, void *data) +{ QuartzModeInfoPtr pReqMode = (QuartzModeInfoPtr) data; - + if (!QuartzRandRModesEqual(pMode, pReqMode)) - return CALLBACK_CONTINUE; /* continue enumeration */ + return CALLBACK_CONTINUE; /* continue enumeration */ - DEBUG_LOG("Found a match for requested RandR resolution (%dx%d@%d).\n", (int)pMode->width, (int)pMode->height, (int)pMode->refresh); + DEBUG_LOG("Found a match for requested RandR resolution (%dx%d@%d).\n", + (int) pMode->width, (int) pMode->height, (int) pMode->refresh); - if(QuartzRandRSetMode(pScreen, pMode, FALSE)) + if (QuartzRandRSetMode(pScreen, pMode, FALSE)) return CALLBACK_SUCCESS; else return CALLBACK_ERROR; } -static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) { - *rotations = RR_Rotate_0; /* TODO: support rotation */ +static Bool +QuartzRandRGetInfo(ScreenPtr pScreen, Rotation * rotations) +{ + *rotations = RR_Rotate_0; /* TODO: support rotation */ - return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL); + return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, + NULL); } -static Bool QuartzRandRSetConfig (ScreenPtr pScreen, - Rotation randr, - int rate, - RRScreenSizePtr pSize) { +static Bool +QuartzRandRSetConfig(ScreenPtr pScreen, + Rotation randr, int rate, RRScreenSizePtr pSize) +{ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzModeInfo reqMode; @@ -437,92 +481,111 @@ static Bool QuartzRandRSetConfig (ScreenPtr pScreen, /* Do not switch modes if requested mode is equal to current mode. */ if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode)) return TRUE; - - if (QuartzRandREnumerateModes(pScreen, QuartzRandRSetModeCallback, &reqMode)) { + + if (QuartzRandREnumerateModes + (pScreen, QuartzRandRSetModeCallback, &reqMode)) { return TRUE; } - - DEBUG_LOG("Unable to find a matching config: %d x %d @ %d\n", (int)reqMode.width, (int)reqMode.height, (int)reqMode.refresh); + + DEBUG_LOG("Unable to find a matching config: %d x %d @ %d\n", + (int) reqMode.width, (int) reqMode.height, (int) reqMode.refresh); return FALSE; } -static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) { +static Bool +_QuartzRandRUpdateFakeModes(ScreenPtr pScreen) +{ QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzModeInfo activeMode; - if(pQuartzScreen->displayCount > 0) { - if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) { + if (pQuartzScreen->displayCount > 0) { + if (!QuartzRandRCopyCurrentModeInfo + (pQuartzScreen->displayIDs[0], &activeMode)) { ErrorF("Unable to determine current display mode.\n"); return FALSE; } - } else { + } + else { memset(&activeMode, 0, sizeof(activeMode)); activeMode.width = 800; activeMode.height = 600; activeMode.refresh = 60; } - if(pQuartzScreen->fullscreenMode.ref) + if (pQuartzScreen->fullscreenMode.ref) CFRelease(pQuartzScreen->fullscreenMode.ref); - if(pQuartzScreen->currentMode.ref) + if (pQuartzScreen->currentMode.ref) CFRelease(pQuartzScreen->currentMode.ref); - if(pQuartzScreen->displayCount > 1) { + if (pQuartzScreen->displayCount > 1) { activeMode.width = pScreen->width; activeMode.height = pScreen->height; - if(XQuartzIsRootless) + if (XQuartzIsRootless) activeMode.height += aquaMenuBarHeight; } - pQuartzScreen->fullscreenMode = activeMode; + pQuartzScreen->fullscreenMode = activeMode; pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN; pQuartzScreen->rootlessMode = activeMode; pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS; pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight; - if(XQuartzIsRootless) { + if (XQuartzIsRootless) { pQuartzScreen->currentMode = pQuartzScreen->rootlessMode; - } else { + } + else { pQuartzScreen->currentMode = pQuartzScreen->fullscreenMode; } /* This extra retain is for currentMode's copy. * fullscreen and rootless share a retain. */ - if(pQuartzScreen->currentMode.ref) + if (pQuartzScreen->currentMode.ref) CFRetain(pQuartzScreen->currentMode.ref); - - DEBUG_LOG("rootlessMode: %d x %d\n", (int)pQuartzScreen->rootlessMode.width, (int)pQuartzScreen->rootlessMode.height); - DEBUG_LOG("fullscreenMode: %d x %d\n", (int)pQuartzScreen->fullscreenMode.width, (int)pQuartzScreen->fullscreenMode.height); - DEBUG_LOG("currentMode: %d x %d\n", (int)pQuartzScreen->currentMode.width, (int)pQuartzScreen->currentMode.height); - + + DEBUG_LOG("rootlessMode: %d x %d\n", + (int) pQuartzScreen->rootlessMode.width, + (int) pQuartzScreen->rootlessMode.height); + DEBUG_LOG("fullscreenMode: %d x %d\n", + (int) pQuartzScreen->fullscreenMode.width, + (int) pQuartzScreen->fullscreenMode.height); + DEBUG_LOG("currentMode: %d x %d\n", (int) pQuartzScreen->currentMode.width, + (int) pQuartzScreen->currentMode.height); + return TRUE; } -Bool QuartzRandRUpdateFakeModes (BOOL force_update) { +Bool +QuartzRandRUpdateFakeModes(BOOL force_update) +{ ScreenPtr pScreen = screenInfo.screens[0]; - - if(ignore_next_fake_mode_update) { - DEBUG_LOG("Ignoring update request caused by RandR resolution change.\n"); + + if (ignore_next_fake_mode_update) { + DEBUG_LOG + ("Ignoring update request caused by RandR resolution change.\n"); ignore_next_fake_mode_update = FALSE; return TRUE; } - - if(!_QuartzRandRUpdateFakeModes(pScreen)) + + if (!_QuartzRandRUpdateFakeModes(pScreen)) return FALSE; - - if(force_update) + + if (force_update) RRGetInfo(pScreen, TRUE); return TRUE; } -Bool QuartzRandRInit (ScreenPtr pScreen) { - rrScrPrivPtr pScrPriv; - - if (!RRScreenInit (pScreen)) return FALSE; - if (!_QuartzRandRUpdateFakeModes (pScreen)) return FALSE; +Bool +QuartzRandRInit(ScreenPtr pScreen) +{ + rrScrPrivPtr pScrPriv; + + if (!RRScreenInit(pScreen)) + return FALSE; + if (!_QuartzRandRUpdateFakeModes(pScreen)) + return FALSE; pScrPriv = rrGetScrPriv(pScreen); pScrPriv->rrGetInfo = QuartzRandRGetInfo; @@ -530,12 +593,14 @@ Bool QuartzRandRInit (ScreenPtr pScreen) { return TRUE; } -void QuartzRandRSetFakeRootless (void) { +void +QuartzRandRSetFakeRootless(void) +{ int i; - + DEBUG_LOG("QuartzRandRSetFakeRootless called.\n"); - - for (i=0; i < screenInfo.numScreens; i++) { + + for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); @@ -543,18 +608,20 @@ void QuartzRandRSetFakeRootless (void) { } } -void QuartzRandRSetFakeFullscreen (BOOL state) { +void +QuartzRandRSetFakeFullscreen(BOOL state) +{ int i; DEBUG_LOG("QuartzRandRSetFakeFullscreen called.\n"); - - for (i=0; i < screenInfo.numScreens; i++) { + + for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); QuartzRandRSetMode(pScreen, &pQuartzScreen->fullscreenMode, TRUE); } - + QuartzShowFullscreen(state); } @@ -563,23 +630,31 @@ void QuartzRandRSetFakeFullscreen (BOOL state) { * mode, this will toggles us to the default fake mode and hide windows if * it is fullscreen */ -void QuartzRandRToggleFullscreen (void) { +void +QuartzRandRToggleFullscreen(void) +{ ScreenPtr pScreen = screenInfo.screens[0]; QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen); if (pQuartzScreen->currentMode.ref == NULL) { - ErrorF("Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n"); - } else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) { - ErrorF("Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n"); - } else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_FULLSCREEN) { + ErrorF + ("Ignoring QuartzRandRToggleFullscreen because don't have a current mode set.\n"); + } + else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_ROOTLESS) { + ErrorF + ("Ignoring QuartzRandRToggleFullscreen because we are in rootless mode.\n"); + } + else if (pQuartzScreen->currentMode.refresh == FAKE_REFRESH_FULLSCREEN) { /* Legacy fullscreen mode. Hide/Show */ QuartzShowFullscreen(!XQuartzFullscreenVisible); - } else { + } + else { /* RandR fullscreen mode. Return to default mode and hide if it is fullscreen. */ - if(XQuartzRootlessDefault) { + if (XQuartzRootlessDefault) { QuartzRandRSetFakeRootless(); - } else { + } + else { QuartzRandRSetFakeFullscreen(FALSE); } - } + } } |