Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS - Prevent double hotkeys. #108

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/unix/apple/macosx/app.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down