changeset 51910:4b492ccc0b71

8205479: OS X: requestFocus() does not work properly for embedded frame Reviewed-by: serb, aivanov
author dmarkov
date Fri, 17 Aug 2018 09:31:13 +0100
parents 8f12ff1c0555
children 57fa2c1c98d4
files src/java.desktop/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformEmbeddedFrame.java
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;
     }