src/macosx/classes/sun/lwawt/LWWindowPeer.java

Print this page

        

@@ -99,12 +99,10 @@
     // A bitmask that indicates what mouse buttons produce MOUSE_CLICKED events
     // on MOUSE_RELEASE. Click events are only generated if there were no drag
     // events between MOUSE_PRESSED and MOUSE_RELEASED for particular button
     private static int mouseClickButtons = 0;
 
-    private volatile boolean cachedFocusableWindow;
-
     private volatile boolean isOpaque = true;
 
     private static final Font DEFAULT_FONT = new Font("Lucida Grande", Font.PLAIN, 13);
 
     private static LWWindowPeer grabbingWindow;

@@ -174,12 +172,10 @@
         }
 
         setAlwaysOnTop(getTarget().isAlwaysOnTop());
         updateMinimumSize();
 
-        cachedFocusableWindow = getTarget().isFocusableWindow();
-
         setOpacity(getTarget().getOpacity());
         setOpaque(getTarget().isOpaque());
 
         // Create surface data and back buffer
         replaceSurfaceData(1, null);

@@ -246,11 +242,10 @@
                 if (isSimpleWindow()) {
                     LWKeyboardFocusManagerPeer manager = LWKeyboardFocusManagerPeer.
                         getInstance(getAppContext());
 
                     if (visible) {
-                        updateFocusableWindowState();
                         changeFocusedWindow(true, true);
 
                     // Focus the owner in case this window is focused.
                     } else if (manager.getCurrentFocusedWindow() == getTarget()) {
                         LWWindowPeer owner = getOwnerFrameDialog(LWWindowPeer.this);

@@ -401,11 +396,10 @@
         platformWindow.setAlwaysOnTop(value);
     }
 
     @Override
     public void updateFocusableWindowState() {
-        cachedFocusableWindow = getTarget().isFocusableWindow();
         platformWindow.updateFocusableWindowState();
     }
 
     @Override
     public void setModalBlocked(Dialog blocker, boolean blocked) {

@@ -1118,11 +1112,23 @@
     }
 
     private boolean focusAllowedFor() {
         Window window = getTarget();
         // TODO: check if modal blocked
-        return window.isVisible() && window.isEnabled() && window.isFocusableWindow();
+        return window.isVisible() && window.isEnabled() && isFocusableWindow();
+    }
+    
+    private boolean isFocusableWindow() {
+        boolean focusable = getTarget().isFocusableWindow();
+        if (isSimpleWindow()) {
+            LWWindowPeer ownerPeer = getOwnerFrameDialog(this);
+            if (ownerPeer == null) {
+                return false;
+            }
+            return focusable && ownerPeer.getTarget().isFocusableWindow();
+        }
+        return focusable;
     }
 
     public boolean isSimpleWindow() {
         Window window = getTarget();
         return !(window instanceof Dialog || window instanceof Frame);

@@ -1138,12 +1144,12 @@
         if (isShowing && !getTarget().isAutoRequestFocus() || skipNextFocusChange) {
             focusLog.fine("skipping focus change");
             skipNextFocusChange = false;
             return;
         }
-
-        if (!cachedFocusableWindow) {
+        if (!isFocusableWindow() && becomesFocused) {
+            focusLog.fine("the window is not focusable");            
             return;
         }
         if (becomesFocused) {
             synchronized (getPeerTreeLock()) {
                 if (blocker != null) {