Accept Cmd for shortcuts on macOS
For convenience (and to keep the existing behavior), also accept shortcuts using Cmd instead of RCtrl.
This commit is contained in:
parent
a253164237
commit
ded6215362
@ -560,6 +560,9 @@ Also see [issue #14].
|
|||||||
`RCtrl` is the right `Ctrl` key (the left `Ctrl` key is forwarded to the
|
`RCtrl` is the right `Ctrl` key (the left `Ctrl` key is forwarded to the
|
||||||
device).
|
device).
|
||||||
|
|
||||||
|
On macOS, `Cmd` also works (for shortcuts which are not already captured by the
|
||||||
|
system).
|
||||||
|
|
||||||
| Action | Shortcut
|
| Action | Shortcut
|
||||||
| ------------------------------------------- |:-----------------------------
|
| ------------------------------------------- |:-----------------------------
|
||||||
| Switch fullscreen mode | `RCtrl`+`f`
|
| Switch fullscreen mode | `RCtrl`+`f`
|
||||||
|
@ -254,9 +254,18 @@ input_manager_process_key(struct input_manager *im,
|
|||||||
bool meta = event->keysym.mod & (KMOD_LGUI | KMOD_RGUI);
|
bool meta = event->keysym.mod & (KMOD_LGUI | KMOD_RGUI);
|
||||||
bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
|
bool shift = event->keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT);
|
||||||
|
|
||||||
if (alt || meta) {
|
bool shortcut_key = rctrl;
|
||||||
// No shortcuts involve Alt or Meta, and they are not forwarded to the
|
#ifdef __APPLE__
|
||||||
// device
|
shortcut_key |= meta;
|
||||||
|
#else
|
||||||
|
if (meta) {
|
||||||
|
// No shortcut involve Meta, and it is not forwarded to the device
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (alt) {
|
||||||
|
// No shortcuts involve Alt, and it is not forwarded to the device
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +275,7 @@ input_manager_process_key(struct input_manager *im,
|
|||||||
bool down = event->type == SDL_KEYDOWN;
|
bool down = event->type == SDL_KEYDOWN;
|
||||||
|
|
||||||
// Capture all RCtrl events
|
// Capture all RCtrl events
|
||||||
if (rctrl) {
|
if (shortcut_key) {
|
||||||
int action = down ? ACTION_DOWN : ACTION_UP;
|
int action = down ? ACTION_DOWN : ACTION_UP;
|
||||||
bool repeat = event->repeat;
|
bool repeat = event->repeat;
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user