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
This commit is contained in:
UnknownShadow200 2020-07-24 12:10:16 +10:00
parent 3b1b13eb22
commit 586e7c4830
2 changed files with 11 additions and 1 deletions

View File

@ -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);

View File

@ -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;
@ -2231,6 +2232,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,
typeUnicodeText, NULL, 16 * sizeof(UniChar), NULL, chars);