void (InputEvent e) { final int usedKeyMask = InputEvent.ALT_DOWN_MASK | InputEvent.META_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK | InputEvent.ALT_GRAPH_DOWN_MASK; final int oldLastModifiersEx = lastModifiersEx; lastModifiersEx = e.getModifiersEx() & usedKeyMask; final boolean areModifiersChanged = lastModifiersEx != oldLastModifiersEx; if (e instanceof MouseEvent && !areModifiersChanged) { // NOTE: to increase the stability of switching normal/alt layouts, we process changes of modifier mask even from mouse events return; } // check esc button if (Helpers.isPhisycalEsc() && e instanceof KeyEvent && e.getID() == KeyEvent.KEY_RELEASED && ((KeyEvent)e).getKeyCode() == KeyEvent.VK_ESCAPE && lastModifiersEx == 0 ) { // find current (showing) component corresponding to an event window final Window windowOfEvent = getWindow(e.getComponent()); if (windowOfEvent == null) { if (LOG_INPUT_PROCESSING) LOG.debug("INPUT: can't find window of component %s (during isPhisycalEsc processing)", e.getComponent()); return; } final Stack s = ourStacks.get(windowOfEvent); if (s != null) { final @Nullable ComponentActions ca = s.getTopActions(); if (ca != null && ca.getCurrent() != null && ca.getCurrent().isCrossEsc()) { s.pop(); } } } if (LOG_INPUT_PROCESSING) { final Window windowOfEvent = getWindow(e.getComponent()); final @Nullable ComponentActions componentActions = getShownActions(windowOfEvent); if (componentActions == null) { LOG.debug("INPUT: no touchbar actions are shown for window '%s', component '%s'", windowOfEvent, e.getComponent()); } else { LOG.debug("INPUT: show actions of component %s, keymask=%d", componentActions.component.get(), lastModifiersEx); } } if (areModifiersChanged) { // change to alt for all registered components for (ComponentActions ca : ourComp2Actions.values()) { if (ca != null) { ca.setCurrent(lastModifiersEx); } } // NOTE: mask-change can be received from popup window, but we must update stack for popup and also at least for main-frame. // So update for all windows. for (Stack s : ourStacks.values()) { s.updateIfNecessary(); } } }