macOS: Allow assigning only the left or right :kbd:Option key to work as the :kbd:Alt key. See :opt:macos_option_as_alt for details

Fixes #1022
This commit is contained in:
Kovid Goyal
2019-02-14 20:39:32 +05:30
parent b49b34c4c1
commit 23482e3cf4
10 changed files with 51 additions and 16 deletions

View File

@@ -348,6 +348,15 @@ cocoa_make_window_resizable(void *w, bool resizable) {
return true;
}
#define NSLeftAlternateKeyMask (0x000020 | NSEventModifierFlagOption)
#define NSRightAlternateKeyMask (0x000040 | NSEventModifierFlagOption)
bool
cocoa_alt_option_key_pressed(NSUInteger flags) {
NSUInteger q = (OPT(macos_option_as_alt) == 1) ? NSRightAlternateKeyMask : NSLeftAlternateKeyMask;
return ((q & flags) == q) ? true : false;
}
void
cocoa_focus_window(void *w) {
NSWindow *window = (NSWindow*)w;