mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
macOS: Fix the new OS window keyboard shortcut not working if no kitty window currently has focus.
Fixes #524
This commit is contained in:
@@ -2088,3 +2088,96 @@ GLFWAPI GLFWcocoatextinputfilterfun glfwSetCocoaTextInputFilter(GLFWwindow *hand
|
||||
window->ns.textInputFilterCallback = callback;
|
||||
return previous;
|
||||
}
|
||||
|
||||
GLFWAPI void glfwGetCocoaKeyEquivalent(int glfw_key, int glfw_mods, unsigned short *cocoa_key, int *cocoa_mods) {
|
||||
*cocoa_key = 0;
|
||||
*cocoa_mods = 0;
|
||||
|
||||
if (glfw_mods & GLFW_MOD_SHIFT)
|
||||
*cocoa_mods |= NSEventModifierFlagShift;
|
||||
if (glfw_mods & GLFW_MOD_CONTROL)
|
||||
*cocoa_mods |= NSEventModifierFlagControl;
|
||||
if (glfw_mods & GLFW_MOD_ALT)
|
||||
*cocoa_mods |= NSEventModifierFlagOption;
|
||||
if (glfw_mods & GLFW_MOD_SUPER)
|
||||
*cocoa_mods |= NSEventModifierFlagCommand;
|
||||
if (glfw_mods & GLFW_MOD_CAPS_LOCK)
|
||||
*cocoa_mods |= NSEventModifierFlagCapsLock;
|
||||
|
||||
switch(glfw_key) {
|
||||
#define K(ch, name) case GLFW_KEY_##name: *cocoa_key = ch; break;
|
||||
K('a', A);
|
||||
K('b', B);
|
||||
K('c', C);
|
||||
K('d', D);
|
||||
K('e', E);
|
||||
K('f', F);
|
||||
K('g', G);
|
||||
K('h', H);
|
||||
K('i', I);
|
||||
K('j', J);
|
||||
K('k', K);
|
||||
K('l', L);
|
||||
K('m', M);
|
||||
K('n', N);
|
||||
K('o', O);
|
||||
K('p', P);
|
||||
K('q', Q);
|
||||
K('r', R);
|
||||
K('s', S);
|
||||
K('t', T);
|
||||
K('u', U);
|
||||
K('v', V);
|
||||
K('w', W);
|
||||
K('x', X);
|
||||
K('y', Y);
|
||||
K('z', Z);
|
||||
K('0', 0);
|
||||
K('1', 1);
|
||||
K('2', 2);
|
||||
K('3', 3);
|
||||
K('5', 5);
|
||||
K('6', 6);
|
||||
K('7', 7);
|
||||
K('8', 8);
|
||||
K('9', 9);
|
||||
K('\'', APOSTROPHE);
|
||||
K(',', COMMA);
|
||||
K('.', PERIOD);
|
||||
K('/', SLASH);
|
||||
K('-', MINUS);
|
||||
K('=', EQUAL);
|
||||
K(';', SEMICOLON);
|
||||
K('[', LEFT_BRACKET);
|
||||
K(']', RIGHT_BRACKET);
|
||||
K('`', GRAVE_ACCENT);
|
||||
K('\\', BACKSLASH);
|
||||
|
||||
K(0x35, ESCAPE);
|
||||
K('\r', ENTER);
|
||||
K('\t', TAB);
|
||||
K(NSBackspaceCharacter, BACKSPACE);
|
||||
K(NSInsertFunctionKey, INSERT);
|
||||
K(NSDeleteCharacter, DELETE);
|
||||
K(NSLeftArrowFunctionKey, LEFT);
|
||||
K(NSRightArrowFunctionKey, RIGHT);
|
||||
K(NSUpArrowFunctionKey, UP);
|
||||
K(NSDownArrowFunctionKey, DOWN);
|
||||
K(NSPageUpFunctionKey, PAGE_UP);
|
||||
K(NSPageDownFunctionKey, PAGE_DOWN);
|
||||
K(NSHomeFunctionKey, HOME);
|
||||
K(NSEndFunctionKey, END);
|
||||
K(NSPrintFunctionKey, PRINT_SCREEN);
|
||||
case GLFW_KEY_F1 ... GLFW_KEY_F24:
|
||||
*cocoa_key = NSF1FunctionKey + (glfw_key - GLFW_KEY_F1); break;
|
||||
case GLFW_KEY_KP_0 ... GLFW_KEY_KP_9:
|
||||
*cocoa_key = NSEventModifierFlagNumericPad | (0x52 + (glfw_key - GLFW_KEY_KP_0)); break;
|
||||
K((unichar)(0x41|NSEventModifierFlagNumericPad), KP_DECIMAL);
|
||||
K((unichar)(0x43|NSEventModifierFlagNumericPad), KP_MULTIPLY);
|
||||
K((unichar)(0x45|NSEventModifierFlagNumericPad), KP_ADD);
|
||||
K((unichar)(0x4B|NSEventModifierFlagNumericPad), KP_DIVIDE);
|
||||
K((unichar)(0x4E|NSEventModifierFlagNumericPad), KP_SUBTRACT);
|
||||
K((unichar)(0x51|NSEventModifierFlagNumericPad), KP_EQUAL);
|
||||
#undef K
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user