summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-02-27 16:18:27 -0800
committerJeremy Huddleston <jeremyhu@apple.com>2011-02-27 16:19:50 -0800
commit0343aed1f082baf4bfbd730c1c3582f1410b8741 (patch)
tree270e0b427e30526b0e2b19fcf8b1b407c6bb6f6e
parentde32d4dcf57c10fc100c1b33630127947a8c8460 (diff)
XQuartz: Don't use deprecated CoreGraphics API on SL and Lion
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--hw/xquartz/xpr/xprScreen.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 6e6d06e6b..972278b75 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -299,9 +299,34 @@ xprAddScreen(int index, ScreenPtr pScreen)
DEBUG_LOG("index=%d depth=%d\n", index, depth);
if(depth == -1) {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
depth = CGDisplaySamplesPerPixel(kCGDirectMainDisplay) * CGDisplayBitsPerSample(kCGDirectMainDisplay);
+#else
+ CGDisplayModeRef modeRef;
+ CFStringRef encStrRef;
+
+ modeRef = CGDisplayCopyDisplayMode(kCGDirectMainDisplay);
+ if(!modeRef)
+ goto have_depth;
+
+ encStrRef = CGDisplayModeCopyPixelEncoding(modeRef);
+ CFRelease(modeRef);
+ if(!encStrRef)
+ goto have_depth;
+
+ if(CFStringCompare(encStrRef, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ depth = 24;
+ } else if(CFStringCompare(encStrRef, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ depth = 15;
+ } else if(CFStringCompare(encStrRef, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
+ depth = 8;
+ }
+
+ CFRelease(encStrRef);
+#endif
}
+have_depth:
switch(depth) {
case 8: // pseudo-working
dfb->visuals = PseudoColorMask;
@@ -326,7 +351,7 @@ xprAddScreen(int index, ScreenPtr pScreen)
// case 24:
default:
if(depth != 24)
- ErrorF("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d CGDisplaySamplesPerPixel=%d CGDisplayBitsPerSample=%d)\n", darwinDesiredDepth, depth, (int)CGDisplaySamplesPerPixel(kCGDirectMainDisplay), (int)CGDisplayBitsPerSample(kCGDirectMainDisplay));
+ ErrorF("Unsupported color depth requested. Defaulting to 24bit. (depth=%d darwinDesiredDepth=%d)\n", depth, darwinDesiredDepth);
dfb->visuals = TrueColorMask; //LARGE_VISUALS;
dfb->preferredCVC = TrueColor;
dfb->depth = 24;