From 6252d317e208f715054dcf2372ead69e27eeff85 Mon Sep 17 00:00:00 2001 From: Ronald Huveneers <114760413+RonaldH-Parsec@users.noreply.github.com> Date: Fri, 30 Jun 2023 17:09:28 -0400 Subject: [PATCH] Import pull request #108 --- src/unix/apple/macosx/app.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/unix/apple/macosx/app.m b/src/unix/apple/macosx/app.m index 77ae7eb6..aa9f9f69 100644 --- a/src/unix/apple/macosx/app.m +++ b/src/unix/apple/macosx/app.m @@ -797,6 +797,10 @@ static void window_keyboard_event(struct window *ctx, uint16_t key_code, NSEvent mty_app_kb_to_hotkey(ctx->app, &evt, MTY_EVENT_HOTKEY); + // Only use hid keys hotkeys if available. + if (evt.type == MTY_EVENT_HOTKEY && pressed && (ctx->app->flags & MTY_APP_FLAG_HID_KEYBOARD)) + return; + if ((evt.type == MTY_EVENT_HOTKEY && pressed) || (evt.type == MTY_EVENT_KEY && evt.key.key != MTY_KEY_NONE)) ctx->app->event_func(&evt, ctx->app->opaque); } @@ -1290,9 +1294,6 @@ static void app_hid_key(uint32_t usage, bool down, void *opaque) ctx->hid_kb_mod &= ~mod; } - if (!ctx->grab_kb) - return; - struct window *window = app_get_active_window(ctx); if (!window) return; @@ -1310,6 +1311,13 @@ static void app_hid_key(uint32_t usage, bool down, void *opaque) mty_app_kb_to_hotkey(ctx, &evt, MTY_EVENT_HOTKEY); + if (!ctx->grab_kb) { + if (evt.type == MTY_EVENT_HOTKEY && down) + ctx->event_func(&evt, ctx->opaque); + + return; + } + if ((evt.type == MTY_EVENT_HOTKEY && down) || (evt.type == MTY_EVENT_KEY && evt.key.key != MTY_KEY_NONE)) ctx->event_func(&evt, ctx->opaque); }