aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/quartzKeyboard.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-28 09:11:07 +0200
committermarha <marha@users.sourceforge.net>2012-03-28 09:11:07 +0200
commit9b51c6da8bffdd67353b1e1245698a7eac478481 (patch)
treecde44c263cb1756fae5b4a83facb3c0cdfa474e4 /xorg-server/hw/xquartz/quartzKeyboard.c
parentfb2b04331b6ae2cd11f6132cf16f6fcd848fb6b8 (diff)
parentec617f09d07e32d6f57c0da133f53ad3d43a568a (diff)
downloadvcxsrv-9b51c6da8bffdd67353b1e1245698a7eac478481.tar.gz
vcxsrv-9b51c6da8bffdd67353b1e1245698a7eac478481.tar.bz2
vcxsrv-9b51c6da8bffdd67353b1e1245698a7eac478481.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'xorg-server/hw/xquartz/quartzKeyboard.c')
-rw-r--r--xorg-server/hw/xquartz/quartzKeyboard.c566
1 files changed, 285 insertions, 281 deletions
diff --git a/xorg-server/hw/xquartz/quartzKeyboard.c b/xorg-server/hw/xquartz/quartzKeyboard.c
index e7aadbcf5..84e34d916 100644
--- a/xorg-server/hw/xquartz/quartzKeyboard.c
+++ b/xorg-server/hw/xquartz/quartzKeyboard.c
@@ -1,7 +1,7 @@
/*
quartzKeyboard.c: Keyboard support for Xquartz
- Copyright (c) 2003-2008 Apple Inc.
+ Copyright (c) 2003-2012 Apple Inc.
Copyright (c) 2001-2004 Torrey T. Lyons. All Rights Reserved.
Copyright 2004 Kaleb S. KEITHLEY. All Rights Reserved.
@@ -29,7 +29,7 @@
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
#include "sanitizedCarbon.h"
@@ -37,8 +37,8 @@
#include <dix-config.h>
#endif
-#define HACK_MISSING 1
-#define HACK_KEYPAD 1
+#define HACK_MISSING 1
+#define HACK_KEYPAD 1
#define HACK_BLACKLIST 1
#include <unistd.h>
@@ -65,7 +65,7 @@
#include "keysym2ucs.h"
extern void
- CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
+CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master);
enum {
MOD_COMMAND = 256,
@@ -84,31 +84,33 @@ const static struct {
unsigned short keycode;
KeySym keysym;
} known_keys[] = {
- {
- 55, XK_Meta_L}, {
- 56, XK_Shift_L}, {
- 57, XK_Caps_Lock}, {
- 58, XK_Alt_L}, {
- 59, XK_Control_L}, {
- 60, XK_Shift_R}, {
- 61, XK_Alt_R}, {
- 62, XK_Control_R}, {
- 63, XK_Meta_R}, {
- 122, XK_F1}, {
- 120, XK_F2}, {
- 99, XK_F3}, {
- 118, XK_F4}, {
- 96, XK_F5}, {
- 97, XK_F6}, {
- 98, XK_F7}, {
- 100, XK_F8}, {
- 101, XK_F9}, {
- 109, XK_F10}, {
- 103, XK_F11}, {
- 111, XK_F12}, {
- 105, XK_F13}, {
- 107, XK_F14}, {
-113, XK_F15},};
+ { 55, XK_Meta_L },
+ { 56, XK_Shift_L },
+ { 57, XK_Caps_Lock },
+ { 58, XK_Alt_L },
+ { 59, XK_Control_L },
+
+ { 60, XK_Shift_R },
+ { 61, XK_Alt_R },
+ { 62, XK_Control_R },
+ { 63, XK_Meta_R },
+
+ { 122, XK_F1 },
+ { 120, XK_F2 },
+ { 99, XK_F3 },
+ { 118, XK_F4 },
+ { 96, XK_F5 },
+ { 97, XK_F6 },
+ { 98, XK_F7 },
+ { 100, XK_F8 },
+ { 101, XK_F9 },
+ { 109, XK_F10 },
+ { 103, XK_F11 },
+ { 111, XK_F12 },
+ { 105, XK_F13 },
+ { 107, XK_F14 },
+ { 113, XK_F15 },
+};
#endif
#if HACK_KEYPAD
@@ -119,24 +121,24 @@ const static struct {
unsigned short keycode;
KeySym normal, keypad;
} known_numeric_keys[] = {
- {
- 65, XK_period, XK_KP_Decimal}, {
- 67, XK_asterisk, XK_KP_Multiply}, {
- 69, XK_plus, XK_KP_Add}, {
- 75, XK_slash, XK_KP_Divide}, {
- 76, 0x01000003, XK_KP_Enter}, {
- 78, XK_minus, XK_KP_Subtract}, {
- 81, XK_equal, XK_KP_Equal}, {
- 82, XK_0, XK_KP_0}, {
- 83, XK_1, XK_KP_1}, {
- 84, XK_2, XK_KP_2}, {
- 85, XK_3, XK_KP_3}, {
- 86, XK_4, XK_KP_4}, {
- 87, XK_5, XK_KP_5}, {
- 88, XK_6, XK_KP_6}, {
- 89, XK_7, XK_KP_7}, {
- 91, XK_8, XK_KP_8}, {
-92, XK_9, XK_KP_9},};
+ { 65, XK_period, XK_KP_Decimal },
+ { 67, XK_asterisk, XK_KP_Multiply },
+ { 69, XK_plus, XK_KP_Add },
+ { 75, XK_slash, XK_KP_Divide },
+ { 76, 0x01000003, XK_KP_Enter },
+ { 78, XK_minus, XK_KP_Subtract },
+ { 81, XK_equal, XK_KP_Equal },
+ { 82, XK_0, XK_KP_0 },
+ { 83, XK_1, XK_KP_1 },
+ { 84, XK_2, XK_KP_2 },
+ { 85, XK_3, XK_KP_3 },
+ { 86, XK_4, XK_KP_4 },
+ { 87, XK_5, XK_KP_5 },
+ { 88, XK_6, XK_KP_6 },
+ { 89, XK_7, XK_KP_7 },
+ { 91, XK_8, XK_KP_8 },
+ { 92, XK_9, XK_KP_9 },
+};
#endif
#if HACK_BLACKLIST
@@ -155,40 +157,30 @@ const static unsigned short keycode_blacklist[] = { 66, 70, 72, 77 };
const static struct {
KeySym normal, dead;
} dead_keys[] = {
- {
- XK_grave, XK_dead_grave}, {
- XK_apostrophe, XK_dead_acute}, /* US:"=" on a Czech keyboard */
- {
- XK_acute, XK_dead_acute}, {
- UKEYSYM(0x384), XK_dead_acute}, /* US:";" on a Greek keyboard */
-// {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
- {
- XK_asciicircum, XK_dead_circumflex}, {
- UKEYSYM(0x2c6), XK_dead_circumflex}, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
- {
- XK_asciitilde, XK_dead_tilde}, {
- UKEYSYM(0x2dc), XK_dead_tilde}, /* SMALL TILDE */
- {
- XK_macron, XK_dead_macron}, {
- XK_breve, XK_dead_breve}, {
- XK_abovedot, XK_dead_abovedot}, {
- XK_diaeresis, XK_dead_diaeresis}, {
- UKEYSYM(0x2da), XK_dead_abovering}, /* DOT ABOVE */
- {
- XK_doubleacute, XK_dead_doubleacute}, {
- XK_caron, XK_dead_caron}, {
- XK_cedilla, XK_dead_cedilla}, {
- XK_ogonek, XK_dead_ogonek}, {
- UKEYSYM(0x269), XK_dead_iota}, /* LATIN SMALL LETTER IOTA */
- {
- UKEYSYM(0x2ec), XK_dead_voiced_sound}, /* MODIFIER LETTER VOICING */
-/* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
- {
- UKEYSYM(0x323), XK_dead_belowdot}, /* COMBINING DOT BELOW */
- {
- UKEYSYM(0x309), XK_dead_hook}, /* COMBINING HOOK ABOVE */
- {
- UKEYSYM(0x31b), XK_dead_horn}, /* COMBINING HORN */
+ { XK_grave, XK_dead_grave },
+ { XK_apostrophe, XK_dead_acute }, /* US:"=" on a Czech keyboard */
+ { XK_acute, XK_dead_acute },
+ { UKEYSYM(0x384), XK_dead_acute }, /* US:";" on a Greek keyboard */
+ // {XK_Greek_accentdieresis, XK_dead_diaeresis}, /* US:"opt+;" on a Greek keyboard ... replace with dead_accentdieresis if there is one */
+ { XK_asciicircum, XK_dead_circumflex },
+ { UKEYSYM(0x2c6), XK_dead_circumflex }, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
+ { XK_asciitilde, XK_dead_tilde },
+ { UKEYSYM(0x2dc), XK_dead_tilde }, /* SMALL TILDE */
+ { XK_macron, XK_dead_macron },
+ { XK_breve, XK_dead_breve },
+ { XK_abovedot, XK_dead_abovedot },
+ { XK_diaeresis, XK_dead_diaeresis },
+ { UKEYSYM(0x2da), XK_dead_abovering }, /* DOT ABOVE */
+ { XK_doubleacute, XK_dead_doubleacute },
+ { XK_caron, XK_dead_caron },
+ { XK_cedilla, XK_dead_cedilla },
+ { XK_ogonek, XK_dead_ogonek },
+ { UKEYSYM(0x269), XK_dead_iota }, /* LATIN SMALL LETTER IOTA */
+ { UKEYSYM(0x2ec), XK_dead_voiced_sound }, /* MODIFIER LETTER VOICING */
+ /* {XK_semivoiced_sound, XK_dead_semivoiced_sound}, */
+ { UKEYSYM(0x323), XK_dead_belowdot }, /* COMBINING DOT BELOW */
+ { UKEYSYM(0x309), XK_dead_hook }, /* COMBINING HOOK ABOVE */
+ { UKEYSYM(0x31b), XK_dead_horn }, /* COMBINING HORN */
};
typedef struct darwinKeyboardInfo_struct {
@@ -201,7 +193,7 @@ darwinKeyboardInfo keyInfo;
pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
static void
-DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl * ctrl)
+DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl *ctrl)
{
// FIXME: to be implemented
// keyclick, bell volume / pitch, autorepead, LED's
@@ -217,7 +209,7 @@ DarwinChangeKeyboardControl(DeviceIntPtr device, KeybdCtrl * ctrl)
* the modMap and modifierKeycodes fields.
*/
static void
-DarwinBuildModifierMaps(darwinKeyboardInfo * info)
+DarwinBuildModifierMaps(darwinKeyboardInfo *info)
{
int i;
KeySym *k;
@@ -266,7 +258,7 @@ DarwinBuildModifierMaps(darwinKeyboardInfo * info)
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
info->modMap[MIN_KEYCODE + i] = Mod1Mask;
if (!XQuartzOptionSendsAlt)
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
break;
case XK_Alt_R:
@@ -276,13 +268,13 @@ DarwinBuildModifierMaps(darwinKeyboardInfo * info)
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
#endif
if (!XQuartzOptionSendsAlt)
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
info->modMap[MIN_KEYCODE + i] = Mod1Mask;
break;
case XK_Mode_switch:
- ErrorF
- ("DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
+ ErrorF(
+ "DarwinBuildModifierMaps: XK_Mode_switch encountered, unable to determine side.\n");
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
#ifdef NX_MODIFIERKEY_RALTERNATE
info->modifierKeycodes[NX_MODIFIERKEY_RALTERNATE][0] = i;
@@ -339,7 +331,7 @@ static void
DarwinKeyboardSetRepeat(DeviceIntPtr pDev, int initialKeyRepeatValue,
int keyRepeatValue)
{
- if (initialKeyRepeatValue == 300000) { // off
+ if (initialKeyRepeatValue == 300000) { // off
/* Turn off repeats globally */
XkbSetRepeatKeys(pDev, -1, AutoRepeatModeOff);
}
@@ -405,7 +397,7 @@ DarwinKeyboardReloadHandler(void)
DEBUG_LOG("DarwinKeyboardReloadHandler\n");
/* Get our key repeat settings from GlobalPreferences */
- (void) CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
+ (void)CFPreferencesAppSynchronize(CFSTR(".GlobalPreferences"));
initialKeyRepeatValue =
CFPreferencesGetAppIntegerValue(CFSTR("InitialKeyRepeat"),
@@ -413,13 +405,16 @@ DarwinKeyboardReloadHandler(void)
if (!ok)
initialKeyRepeatValue = 35;
- keyRepeatValue =
- CFPreferencesGetAppIntegerValue(CFSTR("KeyRepeat"),
- CFSTR(".GlobalPreferences"), &ok);
+ keyRepeatValue = CFPreferencesGetAppIntegerValue(CFSTR(
+ "KeyRepeat"),
+ CFSTR(
+ ".GlobalPreferences"),
+ &ok);
if (!ok)
keyRepeatValue = 6;
- pthread_mutex_lock(&keyInfo_mutex); {
+ pthread_mutex_lock(&keyInfo_mutex);
+ {
/* Initialize our keySyms */
keySyms.map = keyInfo.keyMap;
keySyms.mapWidth = GLYPHS_PER_KEY;
@@ -436,43 +431,45 @@ DarwinKeyboardReloadHandler(void)
/* Apply the mappings to the core keyboard */
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
- if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
- XkbApplyMappingChange(pDev, &keySyms, keySyms.minKeyCode,
- keySyms.maxKeyCode - keySyms.minKeyCode +
- 1, keyInfo.modMap, serverClient);
+ if ((pDev->coreEvents ||
+ pDev == inputInfo.keyboard) && pDev->key) {
+ XkbApplyMappingChange(
+ pDev, &keySyms, keySyms.minKeyCode,
+ keySyms.maxKeyCode -
+ keySyms.minKeyCode + 1,
+ keyInfo.modMap, serverClient);
DarwinKeyboardSetRepeat(pDev, initialKeyRepeatValue,
keyRepeatValue);
}
}
- }
- pthread_mutex_unlock(&keyInfo_mutex);
+ } pthread_mutex_unlock(&keyInfo_mutex);
/* Modify with xmodmap */
if (access(xmodmap, F_OK) == 0) {
/* Check for system .Xmodmap */
if (access(sysmodmap, F_OK) == 0) {
- if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap, sysmodmap) <
- sizeof(cmd)) {
+ if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap,
+ sysmodmap) < sizeof(cmd)) {
X11ApplicationLaunchClient(cmd);
}
else {
- ErrorF
- ("X11.app: Unable to create / execute xmodmap command line");
+ ErrorF(
+ "X11.app: Unable to create / execute xmodmap command line");
}
}
/* Check for user's local .Xmodmap */
if ((homedir != NULL) &&
- (snprintf(usermodmap, sizeof(usermodmap), "%s/.Xmodmap", homedir) <
- sizeof(usermodmap))) {
+ (snprintf(usermodmap, sizeof(usermodmap), "%s/.Xmodmap",
+ homedir) < sizeof(usermodmap))) {
if (access(usermodmap, F_OK) == 0) {
- if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap, usermodmap) <
- sizeof(cmd)) {
+ if (snprintf(cmd, sizeof(cmd), "%s %s", xmodmap,
+ usermodmap) < sizeof(cmd)) {
X11ApplicationLaunchClient(cmd);
}
else {
- ErrorF
- ("X11.app: Unable to create / execute xmodmap command line");
+ ErrorF(
+ "X11.app: Unable to create / execute xmodmap command line");
}
}
}
@@ -502,7 +499,6 @@ int
DarwinModifierNXKeyToNXKeycode(int key, int side)
{
int retval;
-
pthread_mutex_lock(&keyInfo_mutex);
retval = keyInfo.modifierKeycodes[key][side];
pthread_mutex_unlock(&keyInfo_mutex);
@@ -526,8 +522,7 @@ DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
pthread_mutex_lock(&keyInfo_mutex);
for (key = 0; key < NX_NUMMODIFIERS; key++) {
for (side = 0; side <= 1; side++) {
- if (keyInfo.modifierKeycodes[key][side] == keycode)
- break;
+ if (keyInfo.modifierKeycodes[key][side] == keycode) break;
}
}
pthread_mutex_unlock(&keyInfo_mutex);
@@ -535,8 +530,7 @@ DarwinModifierNXKeycodeToNXKey(unsigned char keycode, int *outSide)
if (key == NX_NUMMODIFIERS) {
return -1;
}
- if (outSide)
- *outSide = side;
+ if (outSide) *outSide = side;
return key;
}
@@ -551,42 +545,57 @@ DarwinModifierNXMaskToNXKey(int mask)
switch (mask) {
case NX_ALPHASHIFTMASK:
return NX_MODIFIERKEY_ALPHALOCK;
+
case NX_SHIFTMASK:
return NX_MODIFIERKEY_SHIFT;
+
#ifdef NX_DEVICELSHIFTKEYMASK
case NX_DEVICELSHIFTKEYMASK:
return NX_MODIFIERKEY_SHIFT;
+
case NX_DEVICERSHIFTKEYMASK:
return NX_MODIFIERKEY_RSHIFT;
+
#endif
case NX_CONTROLMASK:
return NX_MODIFIERKEY_CONTROL;
+
#ifdef NX_DEVICELCTLKEYMASK
case NX_DEVICELCTLKEYMASK:
return NX_MODIFIERKEY_CONTROL;
+
case NX_DEVICERCTLKEYMASK:
return NX_MODIFIERKEY_RCONTROL;
+
#endif
case NX_ALTERNATEMASK:
return NX_MODIFIERKEY_ALTERNATE;
+
#ifdef NX_DEVICELALTKEYMASK
case NX_DEVICELALTKEYMASK:
return NX_MODIFIERKEY_ALTERNATE;
+
case NX_DEVICERALTKEYMASK:
return NX_MODIFIERKEY_RALTERNATE;
+
#endif
case NX_COMMANDMASK:
return NX_MODIFIERKEY_COMMAND;
+
#ifdef NX_DEVICELCMDKEYMASK
case NX_DEVICELCMDKEYMASK:
return NX_MODIFIERKEY_COMMAND;
+
case NX_DEVICERCMDKEYMASK:
return NX_MODIFIERKEY_RCOMMAND;
+
#endif
case NX_NUMERICPADMASK:
return NX_MODIFIERKEY_NUMERICPAD;
+
case NX_HELPMASK:
return NX_MODIFIERKEY_HELP;
+
case NX_SECONDARYFNMASK:
return NX_MODIFIERKEY_SECONDARYFN;
}
@@ -603,37 +612,52 @@ 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;
+
case NX_MODIFIERKEY_CONTROL:
return NX_CONTROLMASK;
+
case NX_MODIFIERKEY_ALTERNATE:
return NX_ALTERNATEMASK;
+
case NX_MODIFIERKEY_COMMAND:
return NX_COMMANDMASK;
+
#endif
case NX_MODIFIERKEY_NUMERICPAD:
return NX_NUMERICPADMASK;
+
case NX_MODIFIERKEY_HELP:
return NX_HELPMASK;
+
case NX_MODIFIERKEY_SECONDARYFN:
return NX_SECONDARYFNMASK;
}
@@ -649,80 +673,56 @@ DarwinModifierStringToNXMask(const char *str, int separatelr)
{
#ifdef NX_DEVICELSHIFTKEYMASK
if (separatelr) {
- if (!strcasecmp(str, "shift"))
- return NX_DEVICELSHIFTKEYMASK | NX_DEVICERSHIFTKEYMASK;
- if (!strcasecmp(str, "control"))
- return NX_DEVICELCTLKEYMASK | NX_DEVICERCTLKEYMASK;
- if (!strcasecmp(str, "option"))
- return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "alt"))
- return NX_DEVICELALTKEYMASK | NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "command"))
- return NX_DEVICELCMDKEYMASK | NX_DEVICERCMDKEYMASK;
- if (!strcasecmp(str, "lshift"))
- return NX_DEVICELSHIFTKEYMASK;
- if (!strcasecmp(str, "rshift"))
- return NX_DEVICERSHIFTKEYMASK;
- if (!strcasecmp(str, "lcontrol"))
- return NX_DEVICELCTLKEYMASK;
- if (!strcasecmp(str, "rcontrol"))
- return NX_DEVICERCTLKEYMASK;
- if (!strcasecmp(str, "loption"))
- return NX_DEVICELALTKEYMASK;
- if (!strcasecmp(str, "roption"))
- return NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "lalt"))
- return NX_DEVICELALTKEYMASK;
- if (!strcasecmp(str, "ralt"))
- return NX_DEVICERALTKEYMASK;
- if (!strcasecmp(str, "lcommand"))
- return NX_DEVICELCMDKEYMASK;
- if (!strcasecmp(str, "rcommand"))
- return NX_DEVICERCMDKEYMASK;
+ if (!strcasecmp(str,
+ "shift")) return NX_DEVICELSHIFTKEYMASK |
+ NX_DEVICERSHIFTKEYMASK;
+ if (!strcasecmp(str,
+ "control")) return NX_DEVICELCTLKEYMASK |
+ NX_DEVICERCTLKEYMASK;
+ if (!strcasecmp(str,
+ "option")) return NX_DEVICELALTKEYMASK |
+ NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str,
+ "alt")) return NX_DEVICELALTKEYMASK |
+ NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str,
+ "command")) return NX_DEVICELCMDKEYMASK |
+ NX_DEVICERCMDKEYMASK;
+ if (!strcasecmp(str, "lshift")) return NX_DEVICELSHIFTKEYMASK;
+ if (!strcasecmp(str, "rshift")) return NX_DEVICERSHIFTKEYMASK;
+ if (!strcasecmp(str, "lcontrol")) return NX_DEVICELCTLKEYMASK;
+ if (!strcasecmp(str, "rcontrol")) return NX_DEVICERCTLKEYMASK;
+ if (!strcasecmp(str, "loption")) return NX_DEVICELALTKEYMASK;
+ if (!strcasecmp(str, "roption")) return NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "lalt")) return NX_DEVICELALTKEYMASK;
+ if (!strcasecmp(str, "ralt")) return NX_DEVICERALTKEYMASK;
+ if (!strcasecmp(str, "lcommand")) return NX_DEVICELCMDKEYMASK;
+ if (!strcasecmp(str, "rcommand")) return NX_DEVICERCMDKEYMASK;
}
else {
#endif
- if (!strcasecmp(str, "shift"))
- return NX_SHIFTMASK;
- if (!strcasecmp(str, "control"))
- return NX_CONTROLMASK;
- if (!strcasecmp(str, "option"))
- return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "alt"))
- return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "command"))
- return NX_COMMANDMASK;
- if (!strcasecmp(str, "lshift"))
- return NX_SHIFTMASK;
- if (!strcasecmp(str, "rshift"))
- return NX_SHIFTMASK;
- if (!strcasecmp(str, "lcontrol"))
- return NX_CONTROLMASK;
- if (!strcasecmp(str, "rcontrol"))
- return NX_CONTROLMASK;
- if (!strcasecmp(str, "loption"))
- return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "roption"))
- return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "lalt"))
- return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "ralt"))
- return NX_ALTERNATEMASK;
- if (!strcasecmp(str, "lcommand"))
- return NX_COMMANDMASK;
- if (!strcasecmp(str, "rcommand"))
- return NX_COMMANDMASK;
+ if (!strcasecmp(str, "shift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "control")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "option")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "alt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "command")) return NX_COMMANDMASK;
+ if (!strcasecmp(str, "lshift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "rshift")) return NX_SHIFTMASK;
+ if (!strcasecmp(str, "lcontrol")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "rcontrol")) return NX_CONTROLMASK;
+ if (!strcasecmp(str, "loption")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "roption")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "lalt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "ralt")) return NX_ALTERNATEMASK;
+ if (!strcasecmp(str, "lcommand")) return NX_COMMANDMASK;
+ if (!strcasecmp(str, "rcommand")) return NX_COMMANDMASK;
#ifdef NX_DEVICELSHIFTKEYMASK
- }
+}
#endif
- if (!strcasecmp(str, "lock"))
- return NX_ALPHASHIFTMASK;
- if (!strcasecmp(str, "fn"))
- return NX_SECONDARYFNMASK;
- if (!strcasecmp(str, "help"))
- return NX_HELPMASK;
- if (!strcasecmp(str, "numlock"))
- return NX_NUMERICPADMASK;
+ if (!strcasecmp(str, "lock")) return NX_ALPHASHIFTMASK;
+ if (!strcasecmp(str, "fn")) return NX_SECONDARYFNMASK;
+ if (!strcasecmp(str, "help")) return NX_HELPMASK;
+ if (!strcasecmp(str, "numlock")) return NX_NUMERICPADMASK;
return 0;
}
@@ -745,28 +745,42 @@ macroman2ucs(unsigned char c)
first character. */
static const unsigned short table[128] = {
- 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc, 0xe1,
- 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9, 0xe8,
- 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1, 0xf3,
- 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb, 0xfc,
- 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6, 0xdf,
- 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6, 0xd8,
- 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202, 0x2211,
- 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6, 0xf8,
- 0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206, 0xab,
- 0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152, 0x153,
- 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7, 0x25ca,
- 0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01, 0xfb02,
- 0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca, 0xc1,
- 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3, 0xd4,
- 0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6, 0x2dc,
- 0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db, 0x2c7,
+ 0xc4, 0xc5, 0xc7, 0xc9, 0xd1, 0xd6, 0xdc,
+ 0xe1,
+ 0xe0, 0xe2, 0xe4, 0xe3, 0xe5, 0xe7, 0xe9,
+ 0xe8,
+ 0xea, 0xeb, 0xed, 0xec, 0xee, 0xef, 0xf1,
+ 0xf3,
+ 0xf2, 0xf4, 0xf6, 0xf5, 0xfa, 0xf9, 0xfb,
+ 0xfc,
+ 0x2020, 0xb0, 0xa2, 0xa3, 0xa7, 0x2022, 0xb6,
+ 0xdf,
+ 0xae, 0xa9, 0x2122, 0xb4, 0xa8, 0x2260, 0xc6,
+ 0xd8,
+ 0x221e, 0xb1, 0x2264, 0x2265, 0xa5, 0xb5, 0x2202,
+ 0x2211,
+ 0x220f, 0x3c0, 0x222b, 0xaa, 0xba, 0x3a9, 0xe6,
+ 0xf8,
+ 0xbf, 0xa1, 0xac, 0x221a, 0x192, 0x2248, 0x2206,
+ 0xab,
+ 0xbb, 0x2026, 0xa0, 0xc0, 0xc3, 0xd5, 0x152,
+ 0x153,
+ 0x2013, 0x2014, 0x201c, 0x201d, 0x2018, 0x2019, 0xf7,
+ 0x25ca,
+ 0xff, 0x178, 0x2044, 0x20ac, 0x2039, 0x203a, 0xfb01,
+ 0xfb02,
+ 0x2021, 0xb7, 0x201a, 0x201e, 0x2030, 0xc2, 0xca,
+ 0xc1,
+ 0xcb, 0xc8, 0xcd, 0xce, 0xcf, 0xcc, 0xd3,
+ 0xd4,
+ 0xf8ff, 0xd2, 0xda, 0xdb, 0xd9, 0x131, 0x2c6,
+ 0x2dc,
+ 0xaf, 0x2d8, 0x2d9, 0x2da, 0xb8, 0x2dd, 0x2db,
+ 0x2c7,
};
- if (c < 128)
- return c;
- else
- return table[c - 128];
+ if (c < 128) return c;
+ else return table[c - 128];
}
static KeySym
@@ -775,14 +789,13 @@ make_dead_key(KeySym in)
int i;
for (i = 0; i < sizeof(dead_keys) / sizeof(dead_keys[0]); i++)
- if (dead_keys[i].normal == in)
- return dead_keys[i].dead;
+ if (dead_keys[i].normal == in) return dead_keys[i].dead;
return in;
}
static Bool
-QuartzReadSystemKeymap(darwinKeyboardInfo * info)
+QuartzReadSystemKeymap(darwinKeyboardInfo *info)
{
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
KeyboardLayoutRef key_layout;
@@ -801,9 +814,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
TISCopyCurrentKeyboardLayoutInputSource();
if (currentKeyLayoutRef) {
- currentKeyLayoutDataRef =
- (CFDataRef) TISGetInputSourceProperty(currentKeyLayoutRef,
- kTISPropertyUnicodeKeyLayoutData);
+ currentKeyLayoutDataRef = (CFDataRef)TISGetInputSourceProperty(
+ currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
if (currentKeyLayoutDataRef)
chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
}
@@ -811,18 +823,18 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#ifdef __clang__
#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KLGetCurrentKeyboardLayout, KLGetKeyboardLayoutProperty
#endif
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (chr_data == NULL) {
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
- ErrorF
- ("X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
- ErrorF
- ("X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
- (unsigned) keyboard_type, currentKeyLayoutRef,
- currentKeyLayoutDataRef, chr_data);
+ ErrorF(
+ "X11.app: Error detected in determining keyboard layout. If you are using an Apple-provided keyboard layout, please report this error at http://xquartz.macosforge.org and http://bugreport.apple.com\n");
+ ErrorF(
+ "X11.app: Debug Info: keyboard_type=%u, currentKeyLayoutRef=%p, currentKeyLayoutDataRef=%p, chr_data=%p\n",
+ (unsigned)keyboard_type, currentKeyLayoutRef,
+ currentKeyLayoutDataRef, chr_data);
#endif
KLGetCurrentKeyboardLayout(&key_layout);
@@ -830,25 +842,25 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
if (chr_data != NULL) {
- ErrorF
- ("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
+ ErrorF(
+ "X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
}
#endif
}
if (chr_data == NULL) {
- ErrorF
- ("X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
- ErrorF
- ("If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n");
+ ErrorF(
+ "X11.app: Debug Info: kKLuchrData failed, trying kKLKCHRData.\n");
+ ErrorF(
+ "If you are using a 3rd party keyboard layout, please see http://xquartz.macosforge.org/trac/ticket/154\n");
KLGetKeyboardLayoutProperty(key_layout, kKLKCHRData, &chr_data);
is_uchr = 0;
num_keycodes = 128;
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1050
if (chr_data != NULL) {
- ErrorF
- ("X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
+ ErrorF(
+ "X11.app: Fallback succeeded, but this is still a bug. Please report the above information.\n");
}
#endif
}
@@ -877,7 +889,8 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
must be used instead. */
for (i = 0; i < num_keycodes; i++) {
- static const int mods[4] = { 0, MOD_SHIFT, MOD_OPTION,
+ static const int mods[4] = {
+ 0, MOD_SHIFT, MOD_OPTION,
MOD_OPTION | MOD_SHIFT
};
@@ -887,82 +900,74 @@ QuartzReadSystemKeymap(darwinKeyboardInfo * info)
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
if (is_uchr) {
#endif
- UniChar s[8];
- UniCharCount len;
- UInt32 dead_key_state = 0, extra_dead = 0;
-
+ UniChar s[8];
+ UniCharCount len;
+ UInt32 dead_key_state = 0, extra_dead = 0;
+
+ err = UCKeyTranslate(chr_data, i, kUCKeyActionDown,
+ mods[j] >> 8, keyboard_type, 0,
+ &dead_key_state, 8, &len, s);
+ if (err != noErr) continue;
+
+ if (len == 0 && dead_key_state != 0) {
+ /* Found a dead key. Work out which one it is, but
+ remembering that it's dead. */
err = UCKeyTranslate(chr_data, i, kUCKeyActionDown,
- mods[j] >> 8, keyboard_type, 0,
- &dead_key_state, 8, &len, s);
- if (err != noErr)
- continue;
-
- if (len == 0 && dead_key_state != 0) {
- /* Found a dead key. Work out which one it is, but
- remembering that it's dead. */
- err = UCKeyTranslate(chr_data, i, kUCKeyActionDown,
- mods[j] >> 8, keyboard_type,
- kUCKeyTranslateNoDeadKeysMask,
- &extra_dead, 8, &len, s);
- if (err != noErr)
- continue;
- }
+ mods[j] >> 8, keyboard_type,
+ kUCKeyTranslateNoDeadKeysMask,
+ &extra_dead, 8, &len, s);
+ if (err != noErr) continue;
+ }
- /* Not sure why 0x0010 is there.
- * 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ...
- */
- if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
- k[j] = ucs2keysym(s[0]);
- if (dead_key_state != 0)
- k[j] = make_dead_key(k[j]);
- }
-#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ /* Not sure why 0x0010 is there.
+ * 0x0000 - <rdar://problem/7793566> 'Unicode Hex Input' ...
+ */
+ if (len > 0 && s[0] != 0x0010 && s[0] != 0x0000) {
+ k[j] = ucs2keysym(s[0]);
+ if (dead_key_state != 0) k[j] = make_dead_key(k[j]);
}
- else { // kchr
- UInt32 c, state = 0, state2 = 0;
- UInt16 code;
+#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+ }
+ else { // kchr
+ UInt32 c, state = 0, state2 = 0;
+ UInt16 code;
- code = i | mods[j];
+ code = i | mods[j];
#ifdef __clang__
#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" // KeyTranslate
#endif
- c = KeyTranslate(chr_data, code, &state);
+ c = KeyTranslate(chr_data, code, &state);
- /* Dead keys are only processed on key-down, so ask
- to translate those events. When we find a dead key,
- translating the matching key up event will give
- us the actual dead character. */
+ /* Dead keys are only processed on key-down, so ask
+ to translate those events. When we find a dead key,
+ translating the matching key up event will give
+ us the actual dead character. */
- if (state != 0)
- c = KeyTranslate(chr_data, code | 128, &state2);
+ if (state != 0)
+ c = KeyTranslate(chr_data, code | 128, &state2);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
- /* Characters seem to be in MacRoman encoding. */
+ /* Characters seem to be in MacRoman encoding. */
- if (c != 0 && c != 0x0010) {
- k[j] = ucs2keysym(macroman2ucs(c & 255));
+ if (c != 0 && c != 0x0010) {
+ k[j] = ucs2keysym(macroman2ucs(c & 255));
- if (state != 0)
- k[j] = make_dead_key(k[j]);
- }
+ if (state != 0) k[j] = make_dead_key(k[j]);
}
+ }
#endif
}
- if (k[3] == k[2])
- k[3] = NoSymbol;
- if (k[1] == k[0])
- k[1] = NoSymbol;
- if (k[0] == k[2] && k[1] == k[3])
- k[2] = k[3] = NoSymbol;
- if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol)
- k[3] = NoSymbol;
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] = NoSymbol;
}
#if HACK_MISSING
@@ -1006,7 +1011,6 @@ Bool
QuartsResyncKeymap(Bool sendDDXEvent)
{
Bool retval;
-
/* Update keyInfo */
pthread_mutex_lock(&keyInfo_mutex);
memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));