aboutsummaryrefslogtreecommitdiff
path: root/ui/cocoa.m
diff options
context:
space:
mode:
Diffstat (limited to 'ui/cocoa.m')
-rw-r--r--ui/cocoa.m49
1 files changed, 39 insertions, 10 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m
index b1250b7..cb6e7c4 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -96,6 +96,7 @@ static DisplayChangeListener dcl = {
static int last_buttons;
static int cursor_hide = 1;
static int left_command_key_enabled = 1;
+static bool swap_opt_cmd;
static int gArgc;
static char **gArgv;
@@ -854,12 +855,22 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
qkbd_state_key_event(kbd, Q_KEY_CODE_CTRL_R, false);
}
if (!(modifiers & NSEventModifierFlagOption)) {
- qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
- qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+ if (swap_opt_cmd) {
+ qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
+ qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+ } else {
+ qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
+ qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+ }
}
if (!(modifiers & NSEventModifierFlagCommand)) {
- qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
- qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+ if (swap_opt_cmd) {
+ qkbd_state_key_event(kbd, Q_KEY_CODE_ALT, false);
+ qkbd_state_key_event(kbd, Q_KEY_CODE_ALT_R, false);
+ } else {
+ qkbd_state_key_event(kbd, Q_KEY_CODE_META_L, false);
+ qkbd_state_key_event(kbd, Q_KEY_CODE_META_R, false);
+ }
}
switch ([event type]) {
@@ -891,29 +902,44 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
case kVK_Option:
if (!!(modifiers & NSEventModifierFlagOption)) {
- [self toggleKey:Q_KEY_CODE_ALT];
+ if (swap_opt_cmd) {
+ [self toggleKey:Q_KEY_CODE_META_L];
+ } else {
+ [self toggleKey:Q_KEY_CODE_ALT];
+ }
}
break;
case kVK_RightOption:
if (!!(modifiers & NSEventModifierFlagOption)) {
- [self toggleKey:Q_KEY_CODE_ALT_R];
+ if (swap_opt_cmd) {
+ [self toggleKey:Q_KEY_CODE_META_R];
+ } else {
+ [self toggleKey:Q_KEY_CODE_ALT_R];
+ }
}
break;
/* Don't pass command key changes to guest unless mouse is grabbed */
case kVK_Command:
if (isMouseGrabbed &&
- !!(modifiers & NSEventModifierFlagCommand) &&
- left_command_key_enabled) {
- [self toggleKey:Q_KEY_CODE_META_L];
+ !!(modifiers & NSEventModifierFlagCommand)) {
+ if (swap_opt_cmd) {
+ [self toggleKey:Q_KEY_CODE_ALT];
+ } else {
+ [self toggleKey:Q_KEY_CODE_META_L];
+ }
}
break;
case kVK_RightCommand:
if (isMouseGrabbed &&
!!(modifiers & NSEventModifierFlagCommand)) {
- [self toggleKey:Q_KEY_CODE_META_R];
+ if (swap_opt_cmd) {
+ [self toggleKey:Q_KEY_CODE_ALT_R];
+ } else {
+ [self toggleKey:Q_KEY_CODE_META_R];
+ }
}
break;
}
@@ -2068,6 +2094,9 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
if (opts->has_show_cursor && opts->show_cursor) {
cursor_hide = 0;
}
+ if (opts->u.cocoa.has_swap_opt_cmd) {
+ swap_opt_cmd = opts->u.cocoa.swap_opt_cmd;
+ }
if (opts->u.cocoa.has_left_command_key && !opts->u.cocoa.left_command_key) {
left_command_key_enabled = 0;