src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java

Print this page

        

@@ -29,10 +29,12 @@
 import java.awt.Container;
 import java.awt.Event;
 import java.awt.KeyEventPostProcessor;
 import java.awt.Window;
 import java.awt.Toolkit;
+
+import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
 

@@ -131,14 +133,19 @@
                 // with a reasonable delay since it has been generated.
                 // Here we check the last deactivation time of the containing
                 // window. If this time appears to be greater than the altRelease
                 // event time the event is skipped to avoid unexpected menu
                 // activation. See 7121442.
+                // Also we must ensure that original source of key event belongs
+                // to the same window object as winAncestor. See 8001633.
                 boolean skip = false;
                 Toolkit tk = Toolkit.getDefaultToolkit();
                 if (tk instanceof SunToolkit) {
-                    skip = ev.getWhen() <= ((SunToolkit)tk).getWindowDeactivationTime(winAncestor);
+                    Component originalSource = AWTAccessor.getKeyEventAccessor()
+                            .getOriginalSource(ev);
+                    skip = ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor)
+                            || SunToolkit.getContainingWindow(originalSource) != winAncestor;
                 }
 
                 if (menu != null && !skip) {
                     MenuElement[] path = new MenuElement[2];
                     path[0] = mbar;