# HG changeset patch # User alexsch # Date 1342778332 -14400 # Node ID bf5bf37108c14d1d01b8a1043f9e3ff0e3727869 # Parent 1318ba62cd1e66c4f5372cc10fe1fa4ccd1f2773 7182902: [macosx] Test api/java_awt/GraphicsDevice/indexTGF.html#SetDisplayMode fails on Mac OS X 10.7 Reviewed-by: bae, kizune diff -r 1318ba62cd1e -r bf5bf37108c1 src/macosx/classes/sun/awt/CGraphicsDevice.java --- a/src/macosx/classes/sun/awt/CGraphicsDevice.java Thu Jul 19 20:19:35 2012 -0700 +++ b/src/macosx/classes/sun/awt/CGraphicsDevice.java Fri Jul 20 13:58:52 2012 +0400 @@ -48,6 +48,9 @@ private static AWTPermission fullScreenExclusivePermission; + // Save/restore DisplayMode for the Full Screen mode + private DisplayMode originalMode; + public CGraphicsDevice(int displayID) { this.displayID = displayID; configs = new GraphicsConfiguration[] { @@ -124,18 +127,22 @@ } boolean fsSupported = isFullScreenSupported(); + if (fsSupported && old != null) { // enter windowed mode (and restore original display mode) exitFullScreenExclusive(old); - - // TODO: restore display mode + if (originalMode != null) { + setDisplayMode(originalMode); + originalMode = null; + } } super.setFullScreenWindow(w); if (fsSupported && w != null) { - // TODO: save current display mode - + if (isDisplayChangeSupported()) { + originalMode = getDisplayMode(); + } // enter fullscreen mode enterFullScreenExclusive(w); } diff -r 1318ba62cd1e -r bf5bf37108c1 src/macosx/native/sun/awt/CGraphicsDevice.m --- a/src/macosx/native/sun/awt/CGraphicsDevice.m Thu Jul 19 20:19:35 2012 -0700 +++ b/src/macosx/native/sun/awt/CGraphicsDevice.m Fri Jul 20 13:58:52 2012 +0400 @@ -28,7 +28,7 @@ /* * Convert the mode string to the more convinient bits per pixel value */ -static int getBPPFromModeString(CFStringRef mode) +static int getBPPFromModeString(CFStringRef mode) { if ((CFStringCompare(mode, CFSTR(kIO30BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)) { // This is a strange mode, where we using 10 bits per RGB component and pack it into 32 bits @@ -44,7 +44,7 @@ else if (CFStringCompare(mode, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) { return 8; } - + return 0; } @@ -68,6 +68,11 @@ // One of the key parameters does not match continue; } + + if (refrate == 0) { // REFRESH_RATE_UNKNOWN + return cRef; + } + // Refresh rate might be 0 in display mode and we ask for specific display rate // but if we do not find exact match then 0 refresh rate might be just Ok if (CGDisplayModeGetRefreshRate(cRef) == refrate) { @@ -165,7 +170,10 @@ } } }]; + } else { + [JNFException raise:env as:kIllegalArgumentException reason:"Invalid display mode"]; } + CFRelease(allModes); JNF_COCOA_EXIT(env); }