XQuartz: More input fixes

stuck-modifier fixes (capslock)
3button-emulation now doesn't send the modifier key with the click
Added other options to fake_button2 and fake_button3 defaults options:
	({l,r}{control,alt,command,shift})
(cherry picked from commit 8fb6a1cf44c35a20dfb0c05c9824f94898f88da7)
(cherry picked from commit ae9c1b3cfb3874b4d1251681c24bda91c398bcab)
This commit is contained in:
Jeremy Huddleston 2008-08-20 09:56:06 -07:00
parent 436b659091
commit be06961312
5 changed files with 139 additions and 149 deletions

View File

@ -833,6 +833,8 @@ convert_flags (unsigned int nsflags) {
return xflags; return xflags;
} }
extern int darwin_modifier_flags; // darwinEvents.c
static void send_nsevent (NSEventType type, NSEvent *e) { static void send_nsevent (NSEventType type, NSEvent *e) {
NSRect screen; NSRect screen;
NSPoint location; NSPoint location;
@ -859,26 +861,34 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
tilt_x = 0; tilt_x = 0;
tilt_y = 0; tilt_y = 0;
/* We don't receive modifier key events while out of focus, and 3button
* emulation mucks this up, so we need to check our modifier flag state
* on every event... ugg
*/
if(darwin_modifier_flags != [e modifierFlags])
DarwinUpdateModKeys([e modifierFlags]);
switch (type) { switch (type) {
case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto check_subtype; case NSMouseMoved: ev_button=0; ev_type=MotionNotify; goto check_subtype;
case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto check_subtype; case NSLeftMouseDown: ev_button=1; ev_type=ButtonPress; goto check_subtype;
case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto check_subtype; case NSOtherMouseDown: ev_button=2; ev_type=ButtonPress; goto check_subtype;
case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto check_subtype; case NSRightMouseDown: ev_button=3; ev_type=ButtonPress; goto check_subtype;
case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto check_subtype; case NSLeftMouseUp: ev_button=1; ev_type=ButtonRelease; goto check_subtype;
case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto check_subtype; case NSOtherMouseUp: ev_button=2; ev_type=ButtonRelease; goto check_subtype;
case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto check_subtype; case NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; goto check_subtype;
case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto check_subtype; case NSLeftMouseDragged: ev_button=1; ev_type=MotionNotify; goto check_subtype;
case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto check_subtype; case NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto check_subtype;
case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto check_subtype; case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto check_subtype;
check_subtype: check_subtype:
if ([e subtype] != NSTabletPointEventSubtype) if ([e subtype] != NSTabletPointEventSubtype)
goto handle_mouse; goto handle_mouse;
// fall through to get tablet data // fall through to get tablet data
case NSTabletPoint: case NSTabletPoint:
pressure = [e pressure]; pressure = [e pressure];
tilt_x = [e tilt].x; tilt_x = [e tilt].x;
tilt_y = [e tilt].y; tilt_y = [e tilt].y;
goto handle_mouse; goto handle_mouse;
// fall through to normal mouse handling // fall through to normal mouse handling
@ -901,9 +911,6 @@ handle_mouse:
DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]); DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
break; break;
case NSFlagsChanged: default: break; /* for gcc */
DarwinUpdateModKeys([e modifierFlags]);
break;
default: break; /* for gcc */
} }
} }

View File

@ -104,8 +104,13 @@ char *darwinKeymapFile = "USA.keymapping";
int darwinSyncKeymap = FALSE; int darwinSyncKeymap = FALSE;
// modifier masks for faking mouse buttons // modifier masks for faking mouse buttons
#ifdef NX_DEVICELCMDKEYMASK
int darwinFakeMouse2Mask = NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
int darwinFakeMouse3Mask = NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
#else
int darwinFakeMouse2Mask = NX_ALTERNATEMASK; int darwinFakeMouse2Mask = NX_ALTERNATEMASK;
int darwinFakeMouse3Mask = NX_COMMANDMASK; int darwinFakeMouse3Mask = NX_COMMANDMASK;
#endif
// devices // devices
DeviceIntPtr darwinPointer = NULL; DeviceIntPtr darwinPointer = NULL;
@ -140,7 +145,7 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
#define XORG_RELEASE "?" #define XORG_RELEASE "?"
#endif #endif
const char *__crashreporter_info__ = "X.Org X Server " XSERVER_VERSION "Build Date: " BUILD_DATE; const char *__crashreporter_info__ = "X.Org X Server " XSERVER_VERSION " Build Date: " BUILD_DATE;
void DDXRingBell(int volume, int pitch, int duration) { void DDXRingBell(int volume, int pitch, int duration) {
// FIXME -- make some noise, yo // FIXME -- make some noise, yo
@ -496,9 +501,9 @@ int DarwinParseModifierList(
while (p) { while (p) {
modifier = strsep(&p, " ,+&|/"); // allow lots of separators modifier = strsep(&p, " ,+&|/"); // allow lots of separators
nxkey = DarwinModifierStringToNXKey(modifier); nxkey = DarwinModifierStringToNXMask(modifier);
if (nxkey != -1) if(nxkey)
result |= DarwinModifierNXKeyToNXMask(nxkey); result |= nxkey;
else else
ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier); ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier);
} }

View File

@ -30,6 +30,8 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group. in this Software without prior written authorization from The Open Group.
*/ */
#include "sanitizedCarbon.h"
#ifdef HAVE_DIX_CONFIG_H #ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h> #include <dix-config.h>
#endif #endif
@ -77,7 +79,7 @@ in this Software without prior written authorization from The Open Group.
/* FIXME: Abstract this better */ /* FIXME: Abstract this better */
void QuartzModeEQInit(void); void QuartzModeEQInit(void);
static int modifier_flags = 0; // last known modifier state int darwin_modifier_flags = 0; // last known modifier state
#define FD_ADD_MAX 128 #define FD_ADD_MAX 128
static int fd_add[FD_ADD_MAX]; static int fd_add[FD_ADD_MAX];
@ -139,89 +141,55 @@ static inline void darwinEvents_unlock(void) {
} }
/* /*
* DarwinPressModifierMask * DarwinPressModifierKey
* Press or release the given modifier key, specified by its mask (one of NX_*MASK constants) * Press or release the given modifier key (one of NX_MODIFIERKEY_* constants)
*/ */
static void DarwinPressModifierMask(int pressed, int mask) { static void DarwinPressModifierKey(int pressed, int key) {
int keycode; int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
int key = DarwinModifierNXMaskToNXKey(mask);
if (key != -1) { if (keycode == 0) {
keycode = DarwinModifierNXKeyToNXKeycode(key, 0); ErrorF("DarwinPressModifierKey bad keycode: key=%d\n", pressed == KeyPress ? "press" : "release", key, keycode);
if (keycode != 0) return;
DarwinSendKeyboardEvents(pressed, keycode);
} }
DarwinSendKeyboardEvents(pressed, keycode);
} }
#ifdef NX_DEVICELCTLKEYMASK
#define CONTROL_MASK(flags) (flags & (NX_DEVICELCTLKEYMASK|NX_DEVICERCTLKEYMASK))
#define NX_CONTROLMASK_FULL (NX_CONTROLMASK | NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK)
#else
#define CONTROL_MASK(flags) (NX_CONTROLMASK)
#define NX_CONTROLMASK_FULL NX_CONTROLMASK
#endif /* NX_DEVICELCTLKEYMASK */
#ifdef NX_DEVICELSHIFTKEYMASK
#define SHIFT_MASK(flags) (flags & (NX_DEVICELSHIFTKEYMASK|NX_DEVICERSHIFTKEYMASK))
#define NX_SHIFTMASK_FULL (NX_SHIFTMASK | NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK)
#else
#define SHIFT_MASK(flags) (NX_SHIFTMASK)
#define NX_SHIFTMASK_FULL NX_SHIFTMASK
#endif /* NX_DEVICELSHIFTKEYMASK */
#ifdef NX_DEVICELCMDKEYMASK
#define COMMAND_MASK(flags) (flags & (NX_DEVICELCMDKEYMASK|NX_DEVICERCMDKEYMASK))
#define NX_COMMANDMASK_FULL (NX_COMMANDMASK | NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK)
#else
#define COMMAND_MASK(flags) (NX_COMMANDMASK)
#define NX_COMMANDMASK_FULL NX_COMMANDMASK
#endif /* NX_DEVICELCMDKEYMASK */
#ifdef NX_DEVICELALTKEYMASK
#define ALTERNATE_MASK(flags) (flags & (NX_DEVICELALTKEYMASK|NX_DEVICERALTKEYMASK))
#define NX_ALTERNATEMASK_FULL (NX_ALTERNATEMASK | NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK)
#else
#define ALTERNATE_MASK(flags) (NX_ALTERNATEMASK)
#define NX_ALTERNATEMASK_FULL NX_ALTERNATEMASK
#endif /* NX_DEVICELALTKEYMASK */
/* /*
* DarwinUpdateModifiers * DarwinUpdateModifiers
* Send events to update the modifier state. * Send events to update the modifier state.
*/ */
static int modifier_mask_list[] = {
NX_SECONDARYFNMASK, NX_NUMERICPADMASK, NX_HELPMASK,
#ifdef NX_DEVICELCMDKEYMASK
NX_DEVICELCTLKEYMASK, NX_DEVICERCTLKEYMASK,
NX_DEVICELSHIFTKEYMASK, NX_DEVICERSHIFTKEYMASK,
NX_DEVICELCMDKEYMASK, NX_DEVICERCMDKEYMASK,
NX_DEVICELALTKEYMASK, NX_DEVICERALTKEYMASK,
#else
NX_CONTROLMASK, NX_SHIFTMASK, NX_COMMANDMASK, NX_ALTERNATEMASK,
#endif
0
};
static void DarwinUpdateModifiers( static void DarwinUpdateModifiers(
int pressed, // KeyPress or KeyRelease int pressed, // KeyPress or KeyRelease
int flags ) // modifier flags that have changed int flags ) // modifier flags that have changed
{ {
if (flags & NX_ALPHASHIFTMASK) { int *f;
DarwinPressModifierMask(pressed, NX_ALPHASHIFTMASK);
}
if (flags & NX_COMMANDMASK_FULL) {
DarwinPressModifierMask(pressed, COMMAND_MASK(flags));
}
if (flags & NX_CONTROLMASK_FULL) {
DarwinPressModifierMask(pressed, CONTROL_MASK(flags));
}
if (flags & NX_ALTERNATEMASK_FULL) {
DarwinPressModifierMask(pressed, ALTERNATE_MASK(flags));
}
if (flags & NX_SHIFTMASK_FULL) {
DarwinPressModifierMask(pressed, SHIFT_MASK(flags));
}
if (flags & NX_SECONDARYFNMASK) {
DarwinPressModifierMask(pressed, NX_SECONDARYFNMASK);
}
}
/* /* Capslock is special. This mask is the state of capslock (on/off),
* DarwinReleaseModifiers * not the state of the button. Hopefully we can find a better solution.
* This hacky function releases all modifier keys. It should be called when X11.app */
* is deactivated (kXquartzDeactivate) to prevent modifiers from getting stuck if they if(NX_ALPHASHIFTMASK & flags) {
* are held down during a "context" switch -- otherwise, we would miss the KeyUp. DarwinPressModifierKey(KeyPress, NX_MODIFIERKEY_ALPHALOCK);
*/ DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK);
static void DarwinReleaseModifiers(void) { }
ErrorF("DarwinReleaseModifiers\n");
DarwinUpdateModifiers(KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1)); for(f=modifier_mask_list; *f; f++)
if(*f & flags)
DarwinPressModifierKey(pressed, DarwinModifierNXMaskToNXKey(*f));
} }
/* Generic handler for Xquartz-specifc events. When possible, these should /* Generic handler for Xquartz-specifc events. When possible, these should
@ -263,7 +231,6 @@ static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, in
case kXquartzDeactivate: case kXquartzDeactivate:
DEBUG_LOG("kXquartzDeactivate\n"); DEBUG_LOG("kXquartzDeactivate\n");
DarwinReleaseModifiers();
AppleWMSendEvent(AppleWMActivationNotify, AppleWMSendEvent(AppleWMActivationNotify,
AppleWMActivationNotifyMask, AppleWMActivationNotifyMask,
AppleWMIsInactive, 0); AppleWMIsInactive, 0);
@ -476,20 +443,29 @@ void DarwinSendPointerEvents(int ev_type, int ev_button, int pointer_x, int poin
DarwinSendPointerEvents(ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y); DarwinSendPointerEvents(ButtonRelease, darwinFakeMouseButtonDown, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
darwinFakeMouseButtonDown=0; darwinFakeMouseButtonDown=0;
} }
if ((modifier_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) { if (darwin_modifier_flags & darwinFakeMouse2Mask) {
ev_button = 2; ev_button = 2;
darwinFakeMouseButtonDown = 2; darwinFakeMouseButtonDown = 2;
} else if ((modifier_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) { DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse2Mask);
} else if (darwin_modifier_flags & darwinFakeMouse3Mask) {
ev_button = 3; ev_button = 3;
darwinFakeMouseButtonDown = 3; darwinFakeMouseButtonDown = 3;
DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse3Mask);
} }
} }
if (ev_type == ButtonRelease && ev_button == 1) { if (ev_type == ButtonRelease && ev_button == 1) {
if(darwinFakeMouseButtonDown) { if(darwinFakeMouseButtonDown) {
ev_button = darwinFakeMouseButtonDown; ev_button = darwinFakeMouseButtonDown;
darwinFakeMouseButtonDown = 0;
} }
if(darwinFakeMouseButtonDown == 2) {
DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse2Mask);
} else if(darwinFakeMouseButtonDown == 3) {
DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse3Mask);
}
darwinFakeMouseButtonDown = 0;
} }
DarwinPrepareValuators(valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y); DarwinPrepareValuators(valuators, screen, pointer_x, pointer_y, pressure, tilt_x, tilt_y);
@ -509,7 +485,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
return; return;
} }
if (modifier_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) { if (darwinSyncKeymap && darwinKeymapFile == NULL) {
/* See if keymap has changed. */ /* See if keymap has changed. */
static unsigned int last_seed; static unsigned int last_seed;
@ -589,9 +565,9 @@ void DarwinSendScrollEvents(float count_x, float count_y,
/* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to /* Send the appropriate KeyPress/KeyRelease events to GetKeyboardEvents to
reflect changing modifier flags (alt, control, meta, etc) */ reflect changing modifier flags (alt, control, meta, etc) */
void DarwinUpdateModKeys(int flags) { void DarwinUpdateModKeys(int flags) {
DarwinUpdateModifiers(KeyRelease, modifier_flags & ~flags); DarwinUpdateModifiers(KeyRelease, darwin_modifier_flags & ~flags);
DarwinUpdateModifiers(KeyPress, ~modifier_flags & flags); DarwinUpdateModifiers(KeyPress, ~darwin_modifier_flags & flags);
modifier_flags = flags; darwin_modifier_flags = flags;
} }
/* /*

View File

@ -71,8 +71,6 @@
#include "X11/keysym.h" #include "X11/keysym.h"
#include "keysym2ucs.h" #include "keysym2ucs.h"
#include <Availability.h>
void QuartzXkbUpdate(DeviceIntPtr pDev); void QuartzXkbUpdate(DeviceIntPtr pDev);
enum { enum {
@ -1014,28 +1012,6 @@ int DarwinModifierNXMaskToNXKey(int mask) {
return -1; return -1;
} }
static const char *DarwinModifierNXMaskTostring(int mask) {
switch (mask) {
case NX_ALPHASHIFTMASK: return "NX_ALPHASHIFTMASK";
case NX_SHIFTMASK: return "NX_SHIFTMASK";
case NX_DEVICELSHIFTKEYMASK: return "NX_DEVICELSHIFTKEYMASK";
case NX_DEVICERSHIFTKEYMASK: return "NX_DEVICERSHIFTKEYMASK";
case NX_CONTROLMASK: return "NX_CONTROLMASK";
case NX_DEVICELCTLKEYMASK: return "NX_DEVICELCTLKEYMASK";
case NX_DEVICERCTLKEYMASK: return "NX_DEVICERCTLKEYMASK";
case NX_ALTERNATEMASK: return "NX_ALTERNATEMASK";
case NX_DEVICELALTKEYMASK: return "NX_DEVICELALTKEYMASK";
case NX_DEVICERALTKEYMASK: return "NX_DEVICERALTKEYMASK";
case NX_COMMANDMASK: return "NX_COMMANDMASK";
case NX_DEVICELCMDKEYMASK: return "NX_DEVICELCMDKEYMASK";
case NX_DEVICERCMDKEYMASK: return "NX_DEVICERCMDKEYMASK";
case NX_NUMERICPADMASK: return "NX_NUMERICPADMASK";
case NX_HELPMASK: return "NX_HELPMASK";
case NX_SECONDARYFNMASK: return "NX_SECONDARYFNMASK";
}
return "unknown mask";
}
/* /*
* DarwinModifierNXKeyToNXMask * DarwinModifierNXKeyToNXMask
* Returns 0 if key is not a known modifier key. * Returns 0 if key is not a known modifier key.
@ -1043,21 +1019,20 @@ static const char *DarwinModifierNXMaskTostring(int mask) {
int DarwinModifierNXKeyToNXMask(int key) { int DarwinModifierNXKeyToNXMask(int key) {
switch (key) { switch (key) {
case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK; case NX_MODIFIERKEY_ALPHALOCK: return NX_ALPHASHIFTMASK;
#ifdef NX_DEVICELSHIFTKEYMASK
case NX_MODIFIERKEY_SHIFT: return NX_DEVICELSHIFTKEYMASK;
case NX_MODIFIERKEY_RSHIFT: return NX_DEVICERSHIFTKEYMASK;
case NX_MODIFIERKEY_CONTROL: return NX_DEVICELCTLKEYMASK;
case NX_MODIFIERKEY_RCONTROL: return NX_DEVICERCTLKEYMASK;
case NX_MODIFIERKEY_ALTERNATE: return NX_DEVICELALTKEYMASK;
case NX_MODIFIERKEY_RALTERNATE: return NX_DEVICERALTKEYMASK;
case NX_MODIFIERKEY_COMMAND: return NX_DEVICELCMDKEYMASK;
case NX_MODIFIERKEY_RCOMMAND: return NX_DEVICERCMDKEYMASK;
#else
case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK; case NX_MODIFIERKEY_SHIFT: return NX_SHIFTMASK;
#ifdef NX_MODIFIERKEY_RSHIFT
case NX_MODIFIERKEY_RSHIFT: return NX_SHIFTMASK;
#endif
case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK; case NX_MODIFIERKEY_CONTROL: return NX_CONTROLMASK;
#ifdef NX_MODIFIERKEY_RCONTROL
case NX_MODIFIERKEY_RCONTROL: return NX_CONTROLMASK;
#endif
case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK; case NX_MODIFIERKEY_ALTERNATE: return NX_ALTERNATEMASK;
#ifdef NX_MODIFIERKEY_RALTERNATE
case NX_MODIFIERKEY_RALTERNATE: return NX_ALTERNATEMASK;
#endif
case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK; case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
#ifdef NX_MODIFIERKEY_RCOMMAND
case NX_MODIFIERKEY_RCOMMAND: return NX_COMMANDMASK;
#endif #endif
case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK; case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
case NX_MODIFIERKEY_HELP: return NX_HELPMASK; case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
@ -1067,16 +1042,42 @@ int DarwinModifierNXKeyToNXMask(int key) {
} }
/* /*
* DarwinModifierStringToNXKey * DarwinModifierStringToNXMask
* Returns -1 if string is not a known modifier. * Returns 0 if string is not a known modifier.
*/ */
int DarwinModifierStringToNXKey(const char *str) { int DarwinModifierStringToNXMask(const char *str) {
if (!strcasecmp(str, "shift")) return NX_MODIFIERKEY_SHIFT; #ifdef NX_DEVICELSHIFTKEYMASK
else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL; if (!strcasecmp(str, "shift")) return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK;
else if (!strcasecmp(str, "option")) return NX_MODIFIERKEY_ALTERNATE; else if (!strcasecmp(str, "control")) return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK;
else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND; else if (!strcasecmp(str, "option")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
else if (!strcasecmp(str, "fn")) return NX_MODIFIERKEY_SECONDARYFN; else if (!strcasecmp(str, "command")) return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
else return -1; else if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK;
else if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK;
else if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK;
else if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK;
else if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK;
else if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK;
else if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK;
else if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK;
#else
if (!strcasecmp(str, "shift")) return NX_SHIFTMASK;
else if (!strcasecmp(str, "control")) return NX_CONTROLMASK;
else if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK;
else if (!strcasecmp(str, "command")) return NX_COMMANDMASK;
else if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK;
else if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK;
else if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK;
else if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK;
else if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK;
else if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK;
else if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK;
else if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK;
#endif
else if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK;
else if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK;
else if (!strcasecmp(str, "help")) return NX_HELPMASK;
else if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK;
else return 0;
} }
/* /*
@ -1092,7 +1093,7 @@ Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
/* TODO: Not thread safe */ /* TODO: Not thread safe */
unsigned int QuartzSystemKeymapSeed(void) { unsigned int QuartzSystemKeymapSeed(void) {
static unsigned int seed = 0; static unsigned int seed = 0;
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 #if defined(__x86_64__) || defined(__ppc64__)
static TISInputSourceRef last_key_layout = NULL; static TISInputSourceRef last_key_layout = NULL;
TISInputSourceRef key_layout; TISInputSourceRef key_layout;
@ -1159,7 +1160,7 @@ static KeySym make_dead_key(KeySym in) {
} }
Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) { Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #if !defined(__x86_64__) && !defined(__ppc64__)
KeyboardLayoutRef key_layout; KeyboardLayoutRef key_layout;
#endif #endif
const void *chr_data = NULL; const void *chr_data = NULL;
@ -1178,10 +1179,11 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef); chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
} }
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060 #if !defined(__x86_64__) && !defined(__ppc64__)
if (chr_data == NULL) { if (chr_data == NULL) {
ErrorF("X11.app: Error detected in determining keyboard layout. Please report this error at http://xquartz.macosforge.org\n"); ErrorF("X11.app: Error detected in determining keyboard layout. Please report this error at http://xquartz.macosforge.org\n");
ErrorF("X11.app: Debug Info: currentKeyLayoutRef=%p, chr_data=%p\n", currentKeyLayoutRef, chr_data); ErrorF("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
(unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data);
KLGetCurrentKeyboardLayout (&key_layout); KLGetCurrentKeyboardLayout (&key_layout);
KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data); KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
@ -1192,7 +1194,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
} }
if (chr_data == NULL) { if (chr_data == NULL) {
ErrorF("X11.app: Debug Info: kKLuchrData fallback failed, trying kKLKCHRData.\n", currentKeyLayoutRef, chr_data); ErrorF("X11.app: Debug Info: kKLuchrData fallback failed, trying kKLKCHRData.\n");
KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data); KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
is_uchr = 0; is_uchr = 0;
num_keycodes = 128; num_keycodes = 128;

View File

@ -57,7 +57,7 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
int DarwinModifierNXKeyToNXKeycode(int key, int side); int DarwinModifierNXKeyToNXKeycode(int key, int side);
int DarwinModifierNXKeyToNXMask(int key); int DarwinModifierNXKeyToNXMask(int key);
int DarwinModifierNXMaskToNXKey(int mask); int DarwinModifierNXMaskToNXKey(int mask);
int DarwinModifierStringToNXKey(const char *string); int DarwinModifierStringToNXMask(const char *string);
/* Provided for darwin.c */ /* Provided for darwin.c */
void DarwinKeyboardInit(DeviceIntPtr pDev); void DarwinKeyboardInit(DeviceIntPtr pDev);