8205479: OS X: requestFocus() does not work properly for embedded frame
Reviewed-by: serb, aivanov
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Thu Aug 16 19:20:20 2018 +0100
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Fri Aug 17 09:31:13 2018 +0100
@@ -165,8 +165,6 @@
: this;
}
}
- // ignore focus "lost" native request as it may mistakenly
- // deactivate active window (see 8001161)
if (globalFocusedWindow == this) {
responder.handleWindowFocusEvent(parentWindowActive, null);
}
@@ -181,4 +179,19 @@
// another window.
return globalFocusedWindow != null ? !globalFocusedWindow.isParentWindowActive() : true;
}
+
+ @Override
+ public void synthesizeWindowActivation(boolean doActivate) {
+ if (isParentWindowActive() != doActivate) {
+ handleWindowFocusEvent(doActivate);
+ }
+ }
+
+ public static void updateGlobalFocusedWindow(CEmbeddedFrame newGlobalFocusedWindow) {
+ synchronized (classLock) {
+ if (newGlobalFocusedWindow.isParentWindowActive()) {
+ globalFocusedWindow = newGlobalFocusedWindow;
+ }
+ }
+ }
}
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Thu Aug 16 19:20:20 2018 +0100
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java Fri Aug 17 09:31:13 2018 +0100
@@ -147,6 +147,8 @@
@Override
public boolean requestWindowFocus() {
+ CEmbeddedFrame.updateGlobalFocusedWindow(target);
+ target.synthesizeWindowActivation(true);
return true;
}