Merge branch 'fix-macos-text-input-beep' of https://github.com/page-down/kitty

This commit is contained in:
Kovid Goyal 2022-01-13 20:23:23 +05:30
commit 0a89fe2e17
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -727,6 +727,20 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
@end // }}}
// Text input context class for the GLFW content view {{{
@interface GLFWTextInputContext : NSTextInputContext
@end
@implementation GLFWTextInputContext
- (void)doCommandBySelector:(SEL)selector
{
// interpretKeyEvents: May call insertText: or doCommandBySelector:.
// With the default macOS keybindings, pressing certain key combinations
// (e.g. Ctrl+/, Ctrl+Cmd+Down/Left/Right) will produce a beep sound.
debug_key("\n\tTextInputCtx: doCommandBySelector: (%s)\n", [NSStringFromSelector(selector) UTF8String]);
}
@end // }}}
// Content view class for the GLFW window {{{
@ -734,6 +748,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
{
_GLFWwindow* window;
NSTrackingArea* trackingArea;
GLFWTextInputContext* input_context;
NSMutableAttributedString* markedText;
NSRect markedRect;
bool marked_text_cleared_by_insert;
@ -754,6 +769,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
{
window = initWindow;
trackingArea = nil;
input_context = [[GLFWTextInputContext alloc] initWithClient:self];
markedText = [[NSMutableAttributedString alloc] init];
markedRect = NSMakeRect(0.0, 0.0, 0.0, 0.0);
input_source_at_last_key_event = nil;
@ -1009,6 +1025,11 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
[super updateTrackingAreas];
}
- (NSTextInputContext *)inputContext
{
return input_context;
}
static UInt32
convert_cocoa_to_carbon_modifiers(NSUInteger flags) {
UInt32 mods = 0;