8163583: [macosx] Press "To Back" button on the Dialog,the Dialog moves behind the Frame
Reviewed-by: serb
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Mon Aug 15 10:23:39 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m Tue Aug 16 11:13:46 2016 +0300
@@ -807,6 +807,18 @@
- (void)sendEvent:(NSEvent *)event {
if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
+ // Move parent windows to front and make sure that a child window is displayed
+ // in front of its nearest parent.
+ if (self.ownerWindow != nil) {
+ JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
+ jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
+ if (platformWindow != NULL) {
+ static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V");
+ JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings);
+ (*env)->DeleteLocalRef(env, platformWindow);
+ }
+ }
+ [self orderChildWindows:YES];
NSPoint p = [NSEvent mouseLocation];
NSRect frame = [self.nsWindow frame];
@@ -1159,6 +1171,16 @@
NSWindow *nsWindow = OBJC(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[nsWindow orderBack:nil];
+ // Order parent windows
+ AWTWindow *awtWindow = (AWTWindow*)[nsWindow delegate];
+ while (awtWindow.ownerWindow != nil) {
+ awtWindow = awtWindow.ownerWindow;
+ if ([AWTWindow isJavaPlatformWindowVisible:awtWindow.nsWindow]) {
+ [awtWindow.nsWindow orderBack:nil];
+ }
+ }
+ // Order child windows
+ [(AWTWindow*)[nsWindow delegate] orderChildWindows:NO];
}];
JNF_COCOA_EXIT(env);
--- a/jdk/test/java/awt/Modal/ToBack/ToBackModeless5Test.java Mon Aug 15 10:23:39 2016 -0700
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless5Test.java Tue Aug 16 11:13:46 2016 +0300
@@ -26,7 +26,7 @@
/*
* @test
* @key headful
- * @bug 8054143
+ * @bug 8054143 8163583
* @summary Check if toBack method works correctly for a modeless dialog
* having a visible Frame constructor.
*
--- a/jdk/test/java/awt/Modal/ToBack/ToBackModeless6Test.java Mon Aug 15 10:23:39 2016 -0700
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackModeless6Test.java Tue Aug 16 11:13:46 2016 +0300
@@ -26,7 +26,7 @@
/*
* @test
* @key headful
- * @bug 8054143
+ * @bug 8054143 8163583
* @summary Check if toBack method works correctly for a modeless dialog
* having a visible Dialog constructor.
*
--- a/jdk/test/java/awt/Modal/ToBack/ToBackNonModal5Test.java Mon Aug 15 10:23:39 2016 -0700
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal5Test.java Tue Aug 16 11:13:46 2016 +0300
@@ -25,7 +25,7 @@
/*
* @test
* @key headful
- * @bug 8054143
+ * @bug 8054143 8163583
* @summary Check if toBack method works correctly for a non-modal dialog
* having a visible Frame constructor.
*
--- a/jdk/test/java/awt/Modal/ToBack/ToBackNonModal6Test.java Mon Aug 15 10:23:39 2016 -0700
+++ b/jdk/test/java/awt/Modal/ToBack/ToBackNonModal6Test.java Tue Aug 16 11:13:46 2016 +0300
@@ -25,7 +25,7 @@
/*
* @test
* @key headful
- * @bug 8054143
+ * @bug 8054143 8163583
* @summary Check if toBack method works correctly for a non-modal dialog
* having a visible Dialog constructor.
*