changeset 10761:3371dde31d76

8038919: Requesting focus to a modeless dialog doesn't work on Safari Reviewed-by: ant, serb
author mcherkas
date Fri, 10 Oct 2014 20:14:42 +0400
parents 60acda0a0886
children 1b0d9518c251
files src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m
diffstat 3 files changed, 29 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Oct 10 09:09:06 2014 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java	Fri Oct 10 20:14:42 2014 +0400
@@ -676,6 +676,13 @@
     @Override  // PlatformWindow
     public void toFront() {
         final long nsWindowPtr = getNSWindowPtr();
+        LWCToolkit lwcToolkit = (LWCToolkit) Toolkit.getDefaultToolkit();
+        Window w = DefaultKeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
+        if( w != null
+                && ((LWWindowPeer)w.getPeer()).getPeerType() == LWWindowPeer.PeerType.EMBEDDED_FRAME
+                && !lwcToolkit.isApplicationActive()) {
+            lwcToolkit.activateApplicationIgnoringOtherApps();
+        }
         updateFocusabilityForAutoRequestFocus(false);
         nativePushNSWindowToFront(nsWindowPtr);
         updateFocusabilityForAutoRequestFocus(true);
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Fri Oct 10 09:09:06 2014 -0700
+++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java	Fri Oct 10 20:14:42 2014 +0400
@@ -811,6 +811,11 @@
      */
     public static native boolean isEmbedded();
 
+    /*
+     * Activates application ignoring other apps.
+     */
+    public native void activateApplicationIgnoringOtherApps();
+
     /************************
      * Native methods section
      ************************/
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Fri Oct 10 09:09:06 2014 -0700
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/LWCToolkit.m	Fri Oct 10 20:14:42 2014 +0400
@@ -606,6 +606,23 @@
     return active;
 }
 
+/*
+ * Class:     sun_lwawt_macosx_LWCToolkit
+ * Method:    activateApplicationIgnoringOtherApps
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_lwawt_macosx_LWCToolkit_activateApplicationIgnoringOtherApps
+(JNIEnv *env, jclass clazz)
+{
+    JNF_COCOA_ENTER(env);
+    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
+        if(![NSApp isActive]){
+            [NSApp activateIgnoringOtherApps:YES];
+        }
+    }];
+    JNF_COCOA_EXIT(env);
+}
+
 
 /*
  * Class:     sun_awt_SunToolkit