8163583: [macosx] Press "To Back" button on the Dialog,the Dialog moves behind the Frame

Reviewed-by: serb
This commit is contained in:
Dmitry Markov 2016-08-16 11:13:46 +03:00
parent c7429fd2f6
commit 85a2347cb5
5 changed files with 26 additions and 4 deletions
jdk
src/java.desktop/macosx/native/libawt_lwawt/awt
test/java/awt/Modal/ToBack

@ -807,6 +807,18 @@ AWT_ASSERT_APPKIT_THREAD;
- (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 @@ JNF_COCOA_ENTER(env);
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);

@ -26,7 +26,7 @@ import java.awt.Dialog;
/*
* @test
* @key headful
* @bug 8054143
* @bug 8054143 8163583
* @summary Check if toBack method works correctly for a modeless dialog
* having a visible Frame constructor.
*

@ -26,7 +26,7 @@ import java.awt.Dialog;
/*
* @test
* @key headful
* @bug 8054143
* @bug 8054143 8163583
* @summary Check if toBack method works correctly for a modeless dialog
* having a visible Dialog constructor.
*

@ -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.
*

@ -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.
*