aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xquartz/quartzKeyboard.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-04-16 09:32:42 +0000
committermarha <marha@users.sourceforge.net>2010-04-16 09:32:42 +0000
commit0afd2d366de6470b72f0d305643be9afd8cc461d (patch)
tree9363104b0080ddd001256d1b3a0eceae078f13a0 /xorg-server/hw/xquartz/quartzKeyboard.c
parent6412df1b3df28c6213b43821c4a98cc3857d9a3f (diff)
downloadvcxsrv-0afd2d366de6470b72f0d305643be9afd8cc461d.tar.gz
vcxsrv-0afd2d366de6470b72f0d305643be9afd8cc461d.tar.bz2
vcxsrv-0afd2d366de6470b72f0d305643be9afd8cc461d.zip
git update 16/4/2010
Diffstat (limited to 'xorg-server/hw/xquartz/quartzKeyboard.c')
-rw-r--r--xorg-server/hw/xquartz/quartzKeyboard.c91
1 files changed, 68 insertions, 23 deletions
diff --git a/xorg-server/hw/xquartz/quartzKeyboard.c b/xorg-server/hw/xquartz/quartzKeyboard.c
index a4a0b08bd..745333f03 100644
--- a/xorg-server/hw/xquartz/quartzKeyboard.c
+++ b/xorg-server/hw/xquartz/quartzKeyboard.c
@@ -39,6 +39,7 @@
#define HACK_MISSING 1
#define HACK_KEYPAD 1
+#define HACK_BLACKLIST 1
#include <unistd.h>
#include <stdio.h>
@@ -49,6 +50,7 @@
#include "quartzCommon.h"
#include "darwin.h"
+#include "darwinEvents.h"
#include "quartzKeyboard.h"
#include "quartzAudio.h"
@@ -83,6 +85,7 @@ enum {
#define UKEYSYM(u) ((u) | 0x01000000)
+#if HACK_MISSING
/* Table of keycode->keysym mappings we use to fallback on for important
keys that are often not in the Unicode mapping. */
@@ -117,7 +120,9 @@ const static struct {
{107, XK_F14},
{113, XK_F15},
};
+#endif
+#if HACK_KEYPAD
/* Table of keycode->old,new-keysym mappings we use to fixup the numeric
keypad entries. */
@@ -143,6 +148,17 @@ const static struct {
{91, XK_8, XK_KP_8},
{92, XK_9, XK_KP_9},
};
+#endif
+
+#if HACK_BLACKLIST
+/* <rdar://problem/7824370> wine notepad produces wrong characters on shift+arrow
+ * http://xquartz.macosforge.org/trac/ticket/295
+ * http://developer.apple.com/legacy/mac/library/documentation/mac/Text/Text-579.html
+ *
+ * legacy Mac keycodes for arrow keys that shift-modify to math symbols
+ */
+const static unsigned short keycode_blacklist[] = {66, 70, 72, 77};
+#endif
/* Table mapping normal keysyms to their dead equivalents.
FIXME: all the unicode keysyms (apart from circumflex) were guessed. */
@@ -176,6 +192,12 @@ const static struct {
{UKEYSYM (0x31b), XK_dead_horn}, /* COMBINING HORN */
};
+typedef struct darwinKeyboardInfo_struct {
+ CARD8 modMap[MAP_LENGTH];
+ KeySym keyMap[MAP_LENGTH * GLYPHS_PER_KEY];
+ unsigned char modifierKeycodes[32][2];
+} darwinKeyboardInfo;
+
darwinKeyboardInfo keyInfo;
pthread_mutex_t keyInfo_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -240,7 +262,8 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
case XK_Alt_L:
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
info->modMap[MIN_KEYCODE + i] = Mod1Mask;
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ if(!quartzOptionSendsAlt)
+ *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:
@@ -249,7 +272,8 @@ static void DarwinBuildModifierMaps(darwinKeyboardInfo *info) {
#else
info->modifierKeycodes[NX_MODIFIERKEY_ALTERNATE][0] = i;
#endif
- *k = XK_Mode_switch; // Yes, this is ugly. This needs to be cleaned up when we integrate quartzKeyboard with this code and refactor.
+ if(!quartzOptionSendsAlt)
+ *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;
@@ -632,7 +656,7 @@ static KeySym make_dead_key(KeySym in) {
return in;
}
-Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
+static Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
#if !defined(__LP64__) || MAC_OS_X_VERSION_MIN_REQUIRED < 1050
KeyboardLayoutRef key_layout;
int is_uchr = 1;
@@ -772,34 +796,55 @@ Bool QuartzReadSystemKeymap(darwinKeyboardInfo *info) {
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
/* Fix up some things that are normally missing.. */
-
- if (HACK_MISSING) {
- for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
- k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
-
- if (k[0] == NoSymbol && k[1] == NoSymbol
- && k[2] == NoSymbol && k[3] == NoSymbol)
- k[0] = known_keys[i].keysym;
- }
+
+ for (i = 0; i < sizeof (known_keys) / sizeof (known_keys[0]); i++) {
+ k = info->keyMap + known_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if ( k[0] == NoSymbol && k[1] == NoSymbol
+ && k[2] == NoSymbol && k[3] == NoSymbol)
+ k[0] = known_keys[i].keysym;
}
-
+#endif
+
+#if HACK_KEYPAD
/* And some more things. We find the right symbols for the numeric
- keypad, but not the KP_ keysyms. So try to convert known keycodes. */
-
- if (HACK_KEYPAD) {
- for (i = 0; i < sizeof (known_numeric_keys)
- / sizeof (known_numeric_keys[0]); i++) {
- k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
-
- if (k[0] == known_numeric_keys[i].normal)
- k[0] = known_numeric_keys[i].keypad;
- }
+ keypad, but not the KP_ keysyms. So try to convert known keycodes. */
+ for (i = 0; i < sizeof (known_numeric_keys) / sizeof (known_numeric_keys[0]); i++) {
+ k = info->keyMap + known_numeric_keys[i].keycode * GLYPHS_PER_KEY;
+
+ if (k[0] == known_numeric_keys[i].normal)
+ k[0] = known_numeric_keys[i].keypad;
}
+#endif
+
+#if HACK_BLACKLIST
+ for (i = 0; i < sizeof (keycode_blacklist) / sizeof (keycode_blacklist[0]); i++) {
+ k = info->keyMap + keycode_blacklist[i] * GLYPHS_PER_KEY;
+ k[0] = k[1] = k[2] = k[3] = NoSymbol;
+ }
+#endif
DarwinBuildModifierMaps(info);
return TRUE;
}
+
+Bool QuartsResyncKeymap(Bool sendDDXEvent) {
+ Bool retval;
+ /* Update keyInfo */
+ pthread_mutex_lock(&keyInfo_mutex);
+ memset(keyInfo.keyMap, 0, sizeof(keyInfo.keyMap));
+ retval = QuartzReadSystemKeymap(&keyInfo);
+ pthread_mutex_unlock(&keyInfo_mutex);
+
+ /* Tell server thread to deal with new keyInfo */
+ if(sendDDXEvent)
+ DarwinSendDDXEvent(kXquartzReloadKeymap, 0);
+
+ return retval;
+}