boolean (final @NotNull AWTEvent e) { LOG.assertTrue(isPopupActive()); if (e.getID() == WindowEvent.WINDOW_LOST_FOCUS || e.getID() == WindowEvent.WINDOW_DEACTIVATED) { if (IdeEventQueueKt.getSkipWindowDeactivationEvents()) { LOG.warn("Skipped " + e); return false; } if (!isPopupActive()) return false; Window sourceWindow = ((WindowEvent)e).getWindow(); if (SystemInfo.isLinux && !sourceWindow.isShowing()) { // Ignore focusLost/deactivated events caused by some window closing on Linux. // Normally, in such cases another IDE window is focused, and 'opposite' event property should point to that window. // On Linux however, due to current JDK implementation, 'opposite' property is null in this case, // and the following code mistakenly assumes focus is transferred to another application. return false; } Window focused = ((WindowEvent)e).getOppositeWindow(); if (focused == null) { focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); if (focused == null) { // Check if any browser is in focus (java focus can be in the process of transfer). JBCefBrowserBase browser = JBCefBrowserBase.getFocusedBrowser(); if (browser != null && browser.getComponent() != null) { focused = SwingUtilities.getWindowAncestor(browser.getComponent()); } } } Component ultimateParentForFocusedComponent = UIUtil.findUltimateParent(focused); Component ultimateParentForEventWindow = UIUtil.findUltimateParent(sourceWindow); boolean shouldCloseAllPopup = false; if (ultimateParentForEventWindow == null || ultimateParentForFocusedComponent == null) { shouldCloseAllPopup = true; } if (!shouldCloseAllPopup && ultimateParentForEventWindow instanceof IdeFrame ultimateParentWindowForEvent) { if (ultimateParentWindowForEvent.isInFullScreen() && !ultimateParentForFocusedComponent.equals(ultimateParentForEventWindow)) { shouldCloseAllPopup = true; } } if (shouldCloseAllPopup) { closeAllPopups(); } } else if (e instanceof KeyEvent keyEvent) { // the following is copied from IdeKeyEventDispatcher Object source = keyEvent.getSource(); if (myIgnoreNextKeyTypedEvent) { if (KeyEvent.KEY_TYPED == e.getID()) return true; myIgnoreNextKeyTypedEvent = false; } else if (SystemInfo.isMac && InputEvent.ALT_DOWN_MASK == keyEvent.getModifiersEx() && Registry.is("ide.mac.alt.mnemonic.without.ctrl") && source instanceof Component) { // the myIgnoreNextKeyTypedEvent changes event processing to support Alt-based mnemonics on Mac only if (KeyEvent.KEY_TYPED == e.getID() && !IdeEventQueue.getInstance().isInputMethodEnabled() || IdeKeyEventDispatcher.hasMnemonicInWindow((Component)source, keyEvent)) { myIgnoreNextKeyTypedEvent = true; return false; } } } if (e instanceof KeyEvent || e instanceof MouseEvent) { for (int i = myDispatchStack.size() - 1; i >= 0 && i < myDispatchStack.size(); i--) { final boolean dispatched = myDispatchStack.get(i).dispatch(e); if (dispatched) return true; } } return false; }