winemac: Add registry settings to make Option keys send Alt rather than accessing additional characters from the keyboard layout.

This commit is contained in:
Ken Thomases 2013-10-09 16:30:59 -05:00 committed by Alexandre Julliard
parent 05e3d0e5cc
commit 79d45585bc
3 changed files with 29 additions and 2 deletions

View File

@ -117,6 +117,24 @@ static inline void fix_generic_modifiers_by_device(NSUInteger* modifiers)
*modifiers &= ~NX_ALTERNATEMASK;
}
static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modifiers)
{
fix_device_modifiers_by_generic(&modifiers);
if (left_option_is_alt && (modifiers & NX_DEVICELALTKEYMASK))
{
modifiers |= NX_DEVICELCMDKEYMASK;
modifiers &= ~NX_DEVICELALTKEYMASK;
}
if (right_option_is_alt && (modifiers & NX_DEVICERALTKEYMASK))
{
modifiers |= NX_DEVICERCMDKEYMASK;
modifiers &= ~NX_DEVICERALTKEYMASK;
}
fix_generic_modifiers_by_device(&modifiers);
return modifiers;
}
@interface WineContentView : NSView <NSTextInputClient>
{
@ -1253,7 +1271,7 @@ - (void) postKeyEvent:(NSEvent *)theEvent
[self flagsChanged:theEvent];
[self postKey:[theEvent keyCode]
pressed:[theEvent type] == NSKeyDown
modifiers:[theEvent modifierFlags]
modifiers:adjusted_modifiers_for_option_behavior([theEvent modifierFlags])
event:theEvent];
}
@ -1416,7 +1434,7 @@ - (void) flagsChanged:(NSEvent *)theEvent
{ NX_DEVICERCMDKEYMASK, kVK_RightCommand },
};
NSUInteger modifierFlags = [theEvent modifierFlags];
NSUInteger modifierFlags = adjusted_modifiers_for_option_behavior([theEvent modifierFlags]);
NSUInteger changed;
int i, last_changed;

View File

@ -143,6 +143,8 @@
extern int macdrv_err_on;
extern int topmost_float_inactive DECLSPEC_HIDDEN;
extern int capture_displays_for_fullscreen DECLSPEC_HIDDEN;
extern int left_option_is_alt DECLSPEC_HIDDEN;
extern int right_option_is_alt DECLSPEC_HIDDEN;
extern int macdrv_start_cocoa_app(unsigned long long tickcount) DECLSPEC_HIDDEN;
extern void macdrv_window_rejected_focus(const struct macdrv_event *event) DECLSPEC_HIDDEN;

View File

@ -50,6 +50,8 @@ int capture_displays_for_fullscreen = 0;
BOOL skip_single_buffer_flushes = FALSE;
BOOL allow_vsync = TRUE;
BOOL allow_set_gamma = TRUE;
int left_option_is_alt = 0;
int right_option_is_alt = 0;
/**************************************************************************
@ -168,6 +170,11 @@ static void setup_options(void)
if (!get_config_key(hkey, appkey, "AllowSetGamma", buffer, sizeof(buffer)))
allow_set_gamma = IS_OPTION_TRUE(buffer[0]);
if (!get_config_key(hkey, appkey, "LeftOptionIsAlt", buffer, sizeof(buffer)))
left_option_is_alt = IS_OPTION_TRUE(buffer[0]);
if (!get_config_key(hkey, appkey, "RightOptionIsAlt", buffer, sizeof(buffer)))
right_option_is_alt = IS_OPTION_TRUE(buffer[0]);
if (appkey) RegCloseKey(appkey);
if (hkey) RegCloseKey(hkey);
}