aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorleonidr <none@none>2013-10-30 20:54:42 +0400
committerleonidr <none@none>2013-10-30 20:54:42 +0400
commitdc3798e8cb61a2773c736de6985169418625d391 (patch)
tree6e20200e8255985dae52e0cb7ca1bb896d41fc35 /src
parent70926f2401cd397162483644fd2f4365a4eb61d9 (diff)
8013581: [macosx] Key Bindings break with awt GraphicsEnvironment setFullScreenWindow
Reviewed-by: anthony, serb
Diffstat (limited to 'src')
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java8
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CPlatformView.java8
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java25
-rw-r--r--src/macosx/classes/sun/lwawt/macosx/CWrapper.java3
-rw-r--r--src/macosx/native/sun/awt/AWTWindow.h4
-rw-r--r--src/macosx/native/sun/awt/AWTWindow.m56
-rw-r--r--src/macosx/native/sun/awt/CWrapper.m40
7 files changed, 64 insertions, 80 deletions
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java
index e5d99678b..d09f1571d 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformLWView.java
@@ -54,14 +54,6 @@ public class CPlatformLWView extends CPlatformView {
}
@Override
- public void enterFullScreenMode() {
- }
-
- @Override
- public void exitFullScreenMode() {
- }
-
- @Override
public SurfaceData replaceSurfaceData() {
return null;
}
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java
index b287e7745..ba05ab0b6 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformView.java
@@ -96,14 +96,6 @@ public class CPlatformView extends CFRetainedResource {
return peer;
}
- public void enterFullScreenMode() {
- CWrapper.NSView.enterFullScreenMode(ptr);
- }
-
- public void exitFullScreenMode() {
- CWrapper.NSView.exitFullScreenMode(ptr);
- }
-
public void setToolTip(String msg) {
CWrapper.NSView.setToolTip(ptr, msg);
}
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
index e099bd210..f0eebfcdc 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
@@ -63,6 +63,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
private static native void nativeSynthesizeMouseEnteredExitedEvents();
private static native void nativeDispose(long nsWindowPtr);
private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
+ private static native void nativeEnterFullScreenMode(long nsWindowPtr);
+ private static native void nativeExitFullScreenMode(long nsWindowPtr);
// Loger to report issues happened during execution but that do not affect functionality
private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
@@ -440,10 +442,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
@Override // PlatformWindow
public Insets getInsets() {
- if (!isFullScreenMode) {
- return nativeGetNSWindowInsets(getNSWindowPtr());
- }
- return new Insets(0, 0, 0, 0);
+ return nativeGetNSWindowInsets(getNSWindowPtr());
}
@Override // PlatformWindow
@@ -764,18 +763,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
@Override
public void enterFullScreenMode() {
isFullScreenMode = true;
- contentView.enterFullScreenMode();
- // the move/size notification from the underlying system comes
- // but it contains a bounds smaller than the whole screen
- // and therefore we need to create the synthetic notifications
- Rectangle screenBounds = getPeer().getGraphicsConfiguration().getBounds();
- peer.notifyReshape(screenBounds.x, screenBounds.y, screenBounds.width,
- screenBounds.height);
+ nativeEnterFullScreenMode(getNSWindowPtr());
}
@Override
public void exitFullScreenMode() {
- contentView.exitFullScreenMode();
+ nativeExitFullScreenMode(getNSWindowPtr());
isFullScreenMode = false;
}
@@ -933,14 +926,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
protected void deliverMoveResizeEvent(int x, int y, int width, int height,
boolean byUser) {
- // when the content view enters the full-screen mode, the native
- // move/resize notifications contain a bounds smaller than
- // the whole screen and therefore we ignore the native notifications
- // and the content view itself creates correct synthetic notifications
- if (isFullScreenMode) {
- return;
- }
-
checkZoom();
final Rectangle oldB = nativeBounds;
diff --git a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java
index 879118cf2..a9c55237e 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CWrapper.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CWrapper.java
@@ -82,9 +82,6 @@ public final class CWrapper {
public static native Rectangle2D frame(long view);
public static native long window(long view);
- public static native void enterFullScreenMode(long view);
- public static native void exitFullScreenMode(long view);
-
public static native void setHidden(long view, boolean hidden);
public static native void setToolTip(long view, String msg);
diff --git a/src/macosx/native/sun/awt/AWTWindow.h b/src/macosx/native/sun/awt/AWTWindow.h
index 698820ade..7f7bac777 100644
--- a/src/macosx/native/sun/awt/AWTWindow.h
+++ b/src/macosx/native/sun/awt/AWTWindow.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,6 +45,7 @@
BOOL isEnabled;
NSWindow *nsWindow;
AWTWindow *ownerWindow;
+ jint preFullScreenLevel;
}
// An instance of either AWTWindow_Normal or AWTWindow_Panel
@@ -57,6 +58,7 @@
@property (nonatomic) NSSize javaMaxSize;
@property (nonatomic) jint styleBits;
@property (nonatomic) BOOL isEnabled;
+@property (nonatomic) jint preFullScreenLevel;
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)javaPlatformWindow
diff --git a/src/macosx/native/sun/awt/AWTWindow.m b/src/macosx/native/sun/awt/AWTWindow.m
index 59acc9fd8..687fa6b4d 100644
--- a/src/macosx/native/sun/awt/AWTWindow.m
+++ b/src/macosx/native/sun/awt/AWTWindow.m
@@ -122,6 +122,7 @@ AWT_NS_WINDOW_IMPLEMENTATION
@synthesize styleBits;
@synthesize isEnabled;
@synthesize ownerWindow;
+@synthesize preFullScreenLevel;
- (void) updateMinMaxSize:(BOOL)resizable {
if (resizable) {
@@ -1212,3 +1213,58 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env);
}
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeEnterFullScreenMode
+(JNIEnv *env, jclass clazz, jlong windowPtr)
+{
+JNF_COCOA_ENTER(env);
+
+ NSWindow *nsWindow = OBJC(windowPtr);
+ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+ AWTWindow *window = (AWTWindow*)[nsWindow delegate];
+ NSNumber* screenID = [AWTWindow getNSWindowDisplayID_AppKitThread: nsWindow];
+ CGDirectDisplayID aID = [screenID intValue];
+
+ if (CGDisplayCapture(aID) == kCGErrorSuccess) {
+ // remove window decoration
+ NSUInteger styleMask = [AWTWindow styleMaskForStyleBits:window.styleBits];
+ [nsWindow setStyleMask:(styleMask & ~NSTitledWindowMask) | NSBorderlessWindowMask];
+
+ int shieldLevel = CGShieldingWindowLevel();
+ window.preFullScreenLevel = [nsWindow level];
+ [nsWindow setLevel: shieldLevel];
+
+ NSRect screenRect = [[nsWindow screen] frame];
+ [nsWindow setFrame:screenRect display:YES];
+ } else {
+ [JNFException raise:env as:kRuntimeException reason:"Failed to enter full screen."];
+ }
+ }];
+
+JNF_COCOA_EXIT(env);
+}
+
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeExitFullScreenMode
+(JNIEnv *env, jclass clazz, jlong windowPtr)
+{
+JNF_COCOA_ENTER(env);
+
+ NSWindow *nsWindow = OBJC(windowPtr);
+ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+ AWTWindow *window = (AWTWindow*)[nsWindow delegate];
+ NSNumber* screenID = [AWTWindow getNSWindowDisplayID_AppKitThread: nsWindow];
+ CGDirectDisplayID aID = [screenID intValue];
+
+ if (CGDisplayRelease(aID) == kCGErrorSuccess) {
+ NSUInteger styleMask = [AWTWindow styleMaskForStyleBits:window.styleBits];
+ [nsWindow setStyleMask:styleMask];
+ [nsWindow setLevel: window.preFullScreenLevel];
+
+ // GraphicsDevice takes care of restoring pre full screen bounds
+ } else {
+ [JNFException raise:env as:kRuntimeException reason:"Failed to exit full screen."];
+ }
+ }];
+
+JNF_COCOA_EXIT(env);
+}
+
diff --git a/src/macosx/native/sun/awt/CWrapper.m b/src/macosx/native/sun/awt/CWrapper.m
index a658a5df6..e5847bea9 100644
--- a/src/macosx/native/sun/awt/CWrapper.m
+++ b/src/macosx/native/sun/awt/CWrapper.m
@@ -587,46 +587,6 @@ JNF_COCOA_EXIT(env);
/*
* Class: sun_lwawt_macosx_CWrapper$NSView
- * Method: enterFullScreenMode
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL
-Java_sun_lwawt_macosx_CWrapper_00024NSView_enterFullScreenMode
-(JNIEnv *env, jclass cls, jlong viewPtr)
-{
-JNF_COCOA_ENTER(env);
-
- NSView *view = (NSView *)jlong_to_ptr(viewPtr);
- [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
- NSScreen *screen = [[view window] screen];
- NSDictionary *opts = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, nil];
- [view enterFullScreenMode:screen withOptions:opts];
- }];
-
-JNF_COCOA_EXIT(env);
-}
-
-/*
- * Class: sun_lwawt_macosx_CWrapper$NSView
- * Method: exitFullScreenMode
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL
-Java_sun_lwawt_macosx_CWrapper_00024NSView_exitFullScreenMode
-(JNIEnv *env, jclass cls, jlong viewPtr)
-{
-JNF_COCOA_ENTER(env);
-
- NSView *view = (NSView *)jlong_to_ptr(viewPtr);
- [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
- [view exitFullScreenModeWithOptions:nil];
- }];
-
-JNF_COCOA_EXIT(env);
-}
-
-/*
- * Class: sun_lwawt_macosx_CWrapper$NSView
* Method: window
* Signature: (J)J
*/