void () { myKeyStroke2SysShortcut.clear(); if (!SystemInfo.isMac || !SystemInfo.isJetBrainsJvm || !Registry.is("read.system.shortcuts")) { return; } try { if (ourShkClass == null) { ourShkClass = ReflectionUtil.forName("java.awt.desktop.SystemHotkey"); } if (ourMethodReadSystemHotkeys == null) { ourMethodReadSystemHotkeys = ReflectionUtil.getMethod(ourShkClass, "readSystemHotkeys"); } if (ourMethodReadSystemHotkeys == null) { return; } @SuppressWarnings("unchecked") List<AWTKeyStroke> all = (List<AWTKeyStroke>)ourMethodReadSystemHotkeys.invoke(ourShkClass); if (all == null || all.isEmpty()) { return; } StringBuilder debugInfo = new StringBuilder(); for (AWTKeyStroke shk : all) { if (shk.getModifiers() == 0) { //System.out.println("Skip system shortcut [without modifiers]: " + shk); continue; } if (shk.getKeyChar() == KeyEvent.CHAR_UNDEFINED && shk.getKeyCode() == KeyEvent.VK_UNDEFINED) { //System.out.println("Skip system shortcut [undefined key]: " + shk); continue; } if ("Move focus to the next window in application".equals(getDescription(shk))) { // Skip this shortcut because it handled in IDE-side // see: JBR-1515 Regression test jb/sun/awt/macos/MoveFocusShortcutTest.java fails on macOS (Now we prevent Mac OS from handling the shortcut. We can enumerate windows on IDE level.) continue; } KeyStroke sysKS; if (shk.getKeyChar() != KeyEvent.CHAR_UNDEFINED) { final int keyCode = KeyEvent.getExtendedKeyCodeForChar(shk.getKeyChar()); if (keyCode == KeyEvent.VK_UNDEFINED) { //System.out.println("Skip system shortcut [undefined key]: " + shk); continue; } sysKS = KeyStroke.getKeyStroke(keyCode, shk.getModifiers()); } else { sysKS = KeyStroke.getKeyStroke(shk.getKeyCode(), shk.getModifiers()); } myKeyStroke2SysShortcut.put(sysKS, shk); if (DEBUG_SYSTEM_SHORTCUTS) { debugInfo.append(shk).append(";\n"); } } if (DEBUG_SYSTEM_SHORTCUTS) { Logger.getInstance(SystemShortcuts.class).info("system shortcuts:\n" + debugInfo); } } catch (Throwable e) { Logger.getInstance(SystemShortcuts.class).debug(e); } finally { if (SystemInfo.isMacOSBigSur) { addCustomShortcut(KeyEvent.VK_OPEN_BRACKET, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, "Select Next Tab Window"); addCustomShortcut(KeyEvent.VK_CLOSE_BRACKET, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK, "Select Previous Tab Window"); } } }