mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-09-20 19:19:41 +03:00
macOS: Fix ctrl or cmd with Esc or Function keys not working
Fixes #4109
This commit is contained in:
parent
5e033773dd
commit
2b9408c217
@ -77,6 +77,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
- Fix soft hyphens not being preserved when round tripping text through the
|
||||
terminal
|
||||
|
||||
- macOS: Fix :kbd:`ctrl or cmd` with :kbd:`Esc or Function keys` not working
|
||||
(:iss:`4109`)
|
||||
|
||||
|
||||
0.23.1 [2021-08-17]
|
||||
----------------------
|
||||
|
@ -471,6 +471,22 @@ - (void)render_frame_received:(id)displayIDAsID
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_modified_special_key(NSEvent *event, NSEventModifierFlags modifierFlags) {
|
||||
if ((modifierFlags & (NSEventModifierFlagControl | NSEventModifierFlagCommand)) && [event.charactersIgnoringModifiers length] == 1) {
|
||||
switch ([event.charactersIgnoringModifiers characterAtIndex:0]) {
|
||||
case 0x1b: // Esc
|
||||
case NSF1FunctionKey: case NSF2FunctionKey: case NSF3FunctionKey:
|
||||
case NSF4FunctionKey: case NSF5FunctionKey: case NSF6FunctionKey: case NSF7FunctionKey:
|
||||
case NSF8FunctionKey: case NSF9FunctionKey: case NSF10FunctionKey: case NSF11FunctionKey:
|
||||
case NSF12FunctionKey: case NSF13FunctionKey: case NSF14FunctionKey: case NSF15FunctionKey:
|
||||
case NSF16FunctionKey: case NSF17FunctionKey: case NSF18FunctionKey: case NSF19FunctionKey:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
GLFWAPI GLFWapplicationshouldhandlereopenfun glfwSetApplicationShouldHandleReopen(GLFWapplicationshouldhandlereopenfun callback) {
|
||||
GLFWapplicationshouldhandlereopenfun previous = handle_reopen_callback;
|
||||
handle_reopen_callback = callback;
|
||||
@ -511,9 +527,10 @@ int _glfwPlatformInit(void)
|
||||
NSEvent* (^keydown_block)(NSEvent*) = ^ NSEvent* (NSEvent* event)
|
||||
{
|
||||
NSEventModifierFlags modifierFlags = [event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask;
|
||||
if (is_ctrl_tab(event, modifierFlags) || is_cmd_period(event, modifierFlags)) {
|
||||
// Cocoa swallows Ctrl+Tab to cycle between views
|
||||
if (is_modified_special_key(event, modifierFlags) || is_ctrl_tab(event, modifierFlags) || is_cmd_period(event, modifierFlags)) {
|
||||
// Cocoa swallows various key presses, so route them explicitly
|
||||
[[NSApp keyWindow].contentView keyDown:event];
|
||||
return nil;
|
||||
}
|
||||
|
||||
return event;
|
||||
@ -528,9 +545,10 @@ int _glfwPlatformInit(void)
|
||||
// down the command key don't get sent to the key window.
|
||||
[[NSApp keyWindow] sendEvent:event];
|
||||
}
|
||||
if (is_ctrl_tab(event, modifierFlags) || is_cmd_period(event, modifierFlags)) {
|
||||
// Cocoa swallows Ctrl+Tab to cycle between views
|
||||
if (is_modified_special_key(event, modifierFlags) || is_ctrl_tab(event, modifierFlags) || is_cmd_period(event, modifierFlags)) {
|
||||
// Cocoa swallows various key presses, so route them explicitly
|
||||
[[NSApp keyWindow].contentView keyUp:event];
|
||||
return nil;
|
||||
}
|
||||
|
||||
return event;
|
||||
|
Loading…
Reference in New Issue
Block a user