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})
This commit is contained in:
parent
eedecba0b8
commit
8fb6a1cf44
|
@ -836,6 +836,8 @@ convert_flags (unsigned int nsflags) {
|
|||
return xflags;
|
||||
}
|
||||
|
||||
extern int darwin_modifier_flags; // darwinEvents.c
|
||||
|
||||
static void send_nsevent (NSEventType type, NSEvent *e) {
|
||||
NSRect screen;
|
||||
NSPoint location;
|
||||
|
@ -862,26 +864,34 @@ static void send_nsevent (NSEventType type, NSEvent *e) {
|
|||
tilt_x = 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) {
|
||||
case NSMouseMoved: ev_button=0; ev_type=MotionNotify; 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 NSRightMouseDown: ev_button=3; ev_type=ButtonPress; 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 NSRightMouseUp: ev_button=3; ev_type=ButtonRelease; 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 NSRightMouseDragged: ev_button=3; 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 NSOtherMouseDown: ev_button=2; 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 NSOtherMouseUp: ev_button=2; 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 NSOtherMouseDragged: ev_button=2; ev_type=MotionNotify; goto check_subtype;
|
||||
case NSRightMouseDragged: ev_button=3; ev_type=MotionNotify; goto check_subtype;
|
||||
|
||||
check_subtype:
|
||||
if ([e subtype] != NSTabletPointEventSubtype)
|
||||
goto handle_mouse;
|
||||
// fall through to get tablet data
|
||||
|
||||
case NSTabletPoint:
|
||||
pressure = [e pressure];
|
||||
tilt_x = [e tilt].x;
|
||||
tilt_y = [e tilt].y;
|
||||
pressure = [e pressure];
|
||||
tilt_x = [e tilt].x;
|
||||
tilt_y = [e tilt].y;
|
||||
goto handle_mouse;
|
||||
// fall through to normal mouse handling
|
||||
|
||||
|
@ -904,9 +914,6 @@ handle_mouse:
|
|||
DarwinSendKeyboardEvents((type == NSKeyDown)?KeyPress:KeyRelease, [e keyCode]);
|
||||
break;
|
||||
|
||||
case NSFlagsChanged:
|
||||
DarwinUpdateModKeys([e modifierFlags]);
|
||||
break;
|
||||
default: break; /* for gcc */
|
||||
default: break; /* for gcc */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,8 +106,13 @@ char *darwinKeymapFile = "USA.keymapping";
|
|||
int darwinSyncKeymap = FALSE;
|
||||
|
||||
// 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 darwinFakeMouse3Mask = NX_COMMANDMASK;
|
||||
#endif
|
||||
|
||||
// devices
|
||||
DeviceIntPtr darwinPointer = NULL;
|
||||
|
@ -142,7 +147,7 @@ const int NUMFORMATS = sizeof(formats)/sizeof(formats[0]);
|
|||
#define XSERVER_VERSION "?"
|
||||
#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) {
|
||||
// FIXME -- make some noise, yo
|
||||
|
@ -498,9 +503,9 @@ int DarwinParseModifierList(
|
|||
|
||||
while (p) {
|
||||
modifier = strsep(&p, " ,+&|/"); // allow lots of separators
|
||||
nxkey = DarwinModifierStringToNXKey(modifier);
|
||||
if (nxkey != -1)
|
||||
result |= DarwinModifierNXKeyToNXMask(nxkey);
|
||||
nxkey = DarwinModifierStringToNXMask(modifier);
|
||||
if(nxkey)
|
||||
result |= nxkey;
|
||||
else
|
||||
ErrorF("fakebuttons: Unknown modifier \"%s\"\n", modifier);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
||||
#include "sanitizedCarbon.h"
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
@ -77,7 +79,7 @@ in this Software without prior written authorization from The Open Group.
|
|||
/* FIXME: Abstract this better */
|
||||
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
|
||||
static int fd_add[FD_ADD_MAX];
|
||||
|
@ -139,89 +141,55 @@ static inline void darwinEvents_unlock(void) {
|
|||
}
|
||||
|
||||
/*
|
||||
* DarwinPressModifierMask
|
||||
* Press or release the given modifier key, specified by its mask (one of NX_*MASK constants)
|
||||
* DarwinPressModifierKey
|
||||
* Press or release the given modifier key (one of NX_MODIFIERKEY_* constants)
|
||||
*/
|
||||
static void DarwinPressModifierMask(int pressed, int mask) {
|
||||
int keycode;
|
||||
int key = DarwinModifierNXMaskToNXKey(mask);
|
||||
static void DarwinPressModifierKey(int pressed, int key) {
|
||||
int keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
|
||||
|
||||
if (key != -1) {
|
||||
keycode = DarwinModifierNXKeyToNXKeycode(key, 0);
|
||||
if (keycode != 0)
|
||||
DarwinSendKeyboardEvents(pressed, keycode);
|
||||
if (keycode == 0) {
|
||||
ErrorF("DarwinPressModifierKey bad keycode: key=%d\n", pressed == KeyPress ? "press" : "release", key, keycode);
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
* 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(
|
||||
int pressed, // KeyPress or KeyRelease
|
||||
int flags ) // modifier flags that have changed
|
||||
{
|
||||
if (flags & NX_ALPHASHIFTMASK) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
int *f;
|
||||
|
||||
/*
|
||||
* DarwinReleaseModifiers
|
||||
* 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
|
||||
* are held down during a "context" switch -- otherwise, we would miss the KeyUp.
|
||||
*/
|
||||
static void DarwinReleaseModifiers(void) {
|
||||
ErrorF("DarwinReleaseModifiers\n");
|
||||
DarwinUpdateModifiers(KeyRelease, COMMAND_MASK(-1) | CONTROL_MASK(-1) | ALTERNATE_MASK(-1) | SHIFT_MASK(-1));
|
||||
/* Capslock is special. This mask is the state of capslock (on/off),
|
||||
* not the state of the button. Hopefully we can find a better solution.
|
||||
*/
|
||||
if(NX_ALPHASHIFTMASK & flags) {
|
||||
DarwinPressModifierKey(KeyPress, NX_MODIFIERKEY_ALPHALOCK);
|
||||
DarwinPressModifierKey(KeyRelease, NX_MODIFIERKEY_ALPHALOCK);
|
||||
}
|
||||
|
||||
for(f=modifier_mask_list; *f; f++)
|
||||
if(*f & flags)
|
||||
DarwinPressModifierKey(pressed, DarwinModifierNXMaskToNXKey(*f));
|
||||
}
|
||||
|
||||
/* 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:
|
||||
DEBUG_LOG("kXquartzDeactivate\n");
|
||||
DarwinReleaseModifiers();
|
||||
AppleWMSendEvent(AppleWMActivationNotify,
|
||||
AppleWMActivationNotifyMask,
|
||||
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);
|
||||
darwinFakeMouseButtonDown=0;
|
||||
}
|
||||
if ((modifier_flags & darwinFakeMouse2Mask) == darwinFakeMouse2Mask) {
|
||||
if (darwin_modifier_flags & darwinFakeMouse2Mask) {
|
||||
ev_button = 2;
|
||||
darwinFakeMouseButtonDown = 2;
|
||||
} else if ((modifier_flags & darwinFakeMouse3Mask) == darwinFakeMouse3Mask) {
|
||||
DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse2Mask);
|
||||
} else if (darwin_modifier_flags & darwinFakeMouse3Mask) {
|
||||
ev_button = 3;
|
||||
darwinFakeMouseButtonDown = 3;
|
||||
DarwinUpdateModKeys(darwin_modifier_flags & ~darwinFakeMouse3Mask);
|
||||
}
|
||||
}
|
||||
|
||||
if (ev_type == ButtonRelease && ev_button == 1) {
|
||||
if(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);
|
||||
|
@ -509,7 +485,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (modifier_flags == 0 && darwinSyncKeymap && darwinKeymapFile == NULL) {
|
||||
if (darwinSyncKeymap && darwinKeymapFile == NULL) {
|
||||
/* See if keymap has changed. */
|
||||
|
||||
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
|
||||
reflect changing modifier flags (alt, control, meta, etc) */
|
||||
void DarwinUpdateModKeys(int flags) {
|
||||
DarwinUpdateModifiers(KeyRelease, modifier_flags & ~flags);
|
||||
DarwinUpdateModifiers(KeyPress, ~modifier_flags & flags);
|
||||
modifier_flags = flags;
|
||||
DarwinUpdateModifiers(KeyRelease, darwin_modifier_flags & ~flags);
|
||||
DarwinUpdateModifiers(KeyPress, ~darwin_modifier_flags & flags);
|
||||
darwin_modifier_flags = flags;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -71,8 +71,6 @@
|
|||
#include "X11/keysym.h"
|
||||
#include "keysym2ucs.h"
|
||||
|
||||
#include <Availability.h>
|
||||
|
||||
void QuartzXkbUpdate(DeviceIntPtr pDev);
|
||||
|
||||
enum {
|
||||
|
@ -1014,28 +1012,6 @@ int DarwinModifierNXMaskToNXKey(int mask) {
|
|||
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
|
||||
* Returns 0 if key is not a known modifier key.
|
||||
|
@ -1043,21 +1019,20 @@ static const char *DarwinModifierNXMaskTostring(int mask) {
|
|||
int DarwinModifierNXKeyToNXMask(int key) {
|
||||
switch (key) {
|
||||
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;
|
||||
#ifdef NX_MODIFIERKEY_RSHIFT
|
||||
case NX_MODIFIERKEY_RSHIFT: return NX_SHIFTMASK;
|
||||
#endif
|
||||
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;
|
||||
#ifdef NX_MODIFIERKEY_RALTERNATE
|
||||
case NX_MODIFIERKEY_RALTERNATE: return NX_ALTERNATEMASK;
|
||||
#endif
|
||||
case NX_MODIFIERKEY_COMMAND: return NX_COMMANDMASK;
|
||||
#ifdef NX_MODIFIERKEY_RCOMMAND
|
||||
case NX_MODIFIERKEY_RCOMMAND: return NX_COMMANDMASK;
|
||||
#endif
|
||||
case NX_MODIFIERKEY_NUMERICPAD: return NX_NUMERICPADMASK;
|
||||
case NX_MODIFIERKEY_HELP: return NX_HELPMASK;
|
||||
|
@ -1067,16 +1042,42 @@ int DarwinModifierNXKeyToNXMask(int key) {
|
|||
}
|
||||
|
||||
/*
|
||||
* DarwinModifierStringToNXKey
|
||||
* Returns -1 if string is not a known modifier.
|
||||
* DarwinModifierStringToNXMask
|
||||
* Returns 0 if string is not a known modifier.
|
||||
*/
|
||||
int DarwinModifierStringToNXKey(const char *str) {
|
||||
if (!strcasecmp(str, "shift")) return NX_MODIFIERKEY_SHIFT;
|
||||
else if (!strcasecmp(str, "control")) return NX_MODIFIERKEY_CONTROL;
|
||||
else if (!strcasecmp(str, "option")) return NX_MODIFIERKEY_ALTERNATE;
|
||||
else if (!strcasecmp(str, "command")) return NX_MODIFIERKEY_COMMAND;
|
||||
else if (!strcasecmp(str, "fn")) return NX_MODIFIERKEY_SECONDARYFN;
|
||||
else return -1;
|
||||
int DarwinModifierStringToNXMask(const char *str) {
|
||||
#ifdef NX_DEVICELSHIFTKEYMASK
|
||||
if (!strcasecmp(str, "shift")) return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK;
|
||||
else if (!strcasecmp(str, "control")) return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK;
|
||||
else if (!strcasecmp(str, "option")) return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
|
||||
else if (!strcasecmp(str, "command")) return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
|
||||
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 */
|
||||
unsigned int QuartzSystemKeymapSeed(void) {
|
||||
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;
|
||||
TISInputSourceRef key_layout;
|
||||
|
||||
|
@ -1159,7 +1160,7 @@ static KeySym make_dead_key(KeySym in) {
|
|||
}
|
||||
|
||||
Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
#if !defined(__x86_64__) && !defined(__ppc64__)
|
||||
KeyboardLayoutRef key_layout;
|
||||
#endif
|
||||
const void *chr_data = NULL;
|
||||
|
@ -1179,11 +1180,11 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
|
|||
chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
|
||||
}
|
||||
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||
#if !defined(__x86_64__) && !defined(__ppc64__)
|
||||
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: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
|
||||
keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data);
|
||||
(unsigned)keyboard_type, currentKeyLayoutRef, currentKeyLayoutDataRef, chr_data);
|
||||
|
||||
KLGetCurrentKeyboardLayout (&key_layout);
|
||||
KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
|
||||
|
@ -1194,7 +1195,7 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
|
|||
}
|
||||
|
||||
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);
|
||||
is_uchr = 0;
|
||||
num_keycodes = 128;
|
||||
|
|
|
@ -57,7 +57,7 @@ int DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide);
|
|||
int DarwinModifierNXKeyToNXKeycode(int key, int side);
|
||||
int DarwinModifierNXKeyToNXMask(int key);
|
||||
int DarwinModifierNXMaskToNXKey(int mask);
|
||||
int DarwinModifierStringToNXKey(const char *string);
|
||||
int DarwinModifierStringToNXMask(const char *string);
|
||||
|
||||
/* Provided for darwin.c */
|
||||
void DarwinKeyboardInit(DeviceIntPtr pDev);
|
||||
|
|
Loading…
Reference in New Issue
Block a user