From 586e7c4830617e01ccf8140d82dbf65c9a8f33c1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 24 Jul 2020 12:10:16 +1000 Subject: [PATCH] Fix when using cmd+c/cmd+v on 32 bit mac, 'c' and 'v' characters are still appended to text input This commit makes all key character input ignored while command key is pressed --- src/Launcher.c | 1 - src/Window.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Launcher.c b/src/Launcher.c index c21f3cf37..ac8b16e0e 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -30,7 +30,6 @@ static struct FontDesc logoFont; cc_bool Launcher_ShouldExit, Launcher_ShouldUpdate; static char hashBuffer[STRING_SIZE]; String Launcher_AutoHash = String_FromArray(hashBuffer); -static void Launcher_ApplyUpdate(void); void Launcher_SetScreen(struct LScreen* screen) { if (Launcher_Screen) Launcher_Screen->Free(Launcher_Screen); diff --git a/src/Window.c b/src/Window.c index 8dc80889a..5442e13ed 100644 --- a/src/Window.c +++ b/src/Window.c @@ -2223,6 +2223,7 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) { static OSStatus Window_ProcessTextEvent(EventRef inEvent) { UInt32 kind; + EventRef keyEvent = NULL; UniChar chars[17] = { 0 }; char keyChar; int i; @@ -2230,6 +2231,16 @@ static OSStatus Window_ProcessTextEvent(EventRef inEvent) { kind = GetEventKind(inEvent); if (kind != kEventTextInputUnicodeForKeyEvent) return eventNotHandledErr; + + /* When command key is pressed, text input should be ignored */ + res = GetEventParameter(inEvent, kEventParamTextInputSendKeyboardEvent, + typeEventRef, NULL, sizeof(keyEvent), NULL, &keyEvent); + if (!res && keyEvent) { + UInt32 modifiers = 0; + GetEventParameter(keyEvent, kEventParamKeyModifiers, + typeUInt32, NULL, sizeof(modifiers), NULL, &modifiers); + if (modifiers & 0x0100) return eventNotHandledErr; + } /* TODO: is the assumption we only get 1-4 characters always valid */ res = GetEventParameter(inEvent, kEventParamTextInputSendText,