Added XKB support for Xquartz
(cherry picked from commit 56dc1215202746590dbe8758411f47e8876e1317)
This commit is contained in:
parent
652479dba3
commit
22bb7608a0
|
@ -41,7 +41,7 @@
|
||||||
// Define this to get a diagnostic output to stderr which is helpful
|
// Define this to get a diagnostic output to stderr which is helpful
|
||||||
// in determining how the X server is interpreting the Darwin keymap.
|
// in determining how the X server is interpreting the Darwin keymap.
|
||||||
#define DUMP_DARWIN_KEYMAP
|
#define DUMP_DARWIN_KEYMAP
|
||||||
|
#define XQUARTZ_USE_XKB
|
||||||
#define HACK_MISSING 1
|
#define HACK_MISSING 1
|
||||||
#define HACK_KEYPAD 1
|
#define HACK_KEYPAD 1
|
||||||
|
|
||||||
|
@ -70,12 +70,12 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "xkbsrv.h"
|
||||||
|
#include "exevents.h"
|
||||||
|
|
||||||
#include "X11/keysym.h"
|
#include "X11/keysym.h"
|
||||||
#include "keysym2ucs.h"
|
#include "keysym2ucs.h"
|
||||||
|
|
||||||
|
void QuartzXkbUpdate(DeviceIntPtr pDev);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MOD_COMMAND = 256,
|
MOD_COMMAND = 256,
|
||||||
|
@ -863,6 +863,15 @@ static void DarwinLoadKeyboardMapping(KeySymsRec *keySyms) {
|
||||||
keySyms->maxKeyCode = MAX_KEYCODE;
|
keySyms->maxKeyCode = MAX_KEYCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QuartzXkbUpdate(DeviceIntPtr pDev) {
|
||||||
|
#ifdef XQUARTZ_USE_XKB
|
||||||
|
SendDeviceMappingNotify(serverClient, MappingKeyboard,
|
||||||
|
pDev->key->curKeySyms.minKeyCode,
|
||||||
|
pDev->key->curKeySyms.maxKeyCode - pDev->key->curKeySyms.minKeyCode, pDev);
|
||||||
|
SendDeviceMappingNotify(serverClient, MappingModifier, 0, 0, pDev);
|
||||||
|
SwitchCoreKeyboard(pDev);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DarwinKeyboardInit
|
* DarwinKeyboardInit
|
||||||
|
@ -879,38 +888,56 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
|
||||||
assert( darwinParamConnect = NXOpenEventStatus() );
|
assert( darwinParamConnect = NXOpenEventStatus() );
|
||||||
|
|
||||||
DarwinLoadKeyboardMapping(&keySyms);
|
DarwinLoadKeyboardMapping(&keySyms);
|
||||||
// DarwinKeyboardReload(pDev);
|
|
||||||
/* Initialize the seed, so we don't reload the keymap unnecessarily
|
/* Initialize the seed, so we don't reload the keymap unnecessarily
|
||||||
(and possibly overwrite xinitrc changes) */
|
(and possibly overwrite xinitrc changes) */
|
||||||
QuartzSystemKeymapSeed();
|
QuartzSystemKeymapSeed();
|
||||||
|
|
||||||
|
#ifdef XQUARTZ_USE_XKB
|
||||||
|
XkbComponentNamesRec names;
|
||||||
|
bzero(&names, sizeof(names));
|
||||||
|
XkbSetRulesDflts("base", "pc105", "us", NULL, NULL);
|
||||||
|
assert(XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, keyInfo.modMap,
|
||||||
|
QuartzBell, DarwinChangeKeyboardControl));
|
||||||
|
assert(SetKeySymsMap(&pDev->key->curKeySyms, &keySyms));
|
||||||
|
assert(keyInfo.modMap!=NULL);
|
||||||
|
assert(pDev->key->modifierMap!=NULL);
|
||||||
|
memcpy(pDev->key->modifierMap, keyInfo.modMap, sizeof(keyInfo.modMap));
|
||||||
|
|
||||||
|
QuartzXkbUpdate(pDev);
|
||||||
|
#else
|
||||||
|
#error FAIL
|
||||||
assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
|
assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
|
||||||
keyInfo.modMap, QuartzBell,
|
keyInfo.modMap, QuartzBell,
|
||||||
DarwinChangeKeyboardControl ));
|
DarwinChangeKeyboardControl ));
|
||||||
SwitchCoreKeyboard(pDev);
|
SwitchCoreKeyboard(pDev);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
|
void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr pDev, int nevents) {
|
||||||
KeySymsRec keySyms;
|
if (pDev == NULL) pDev = darwinKeyboard;
|
||||||
if (dev == NULL) dev = darwinKeyboard;
|
|
||||||
|
|
||||||
DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", dev);
|
DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", pDev);
|
||||||
DarwinLoadKeyboardMapping(&keySyms);
|
|
||||||
|
|
||||||
if (dev->key) {
|
#ifdef XQUARTZ_USE_XKB
|
||||||
if (dev->key->curKeySyms.map) xfree(dev->key->curKeySyms.map);
|
QuartzXkbUpdate(pDev);
|
||||||
if (dev->key->modifierKeyMap) xfree(dev->key->modifierKeyMap);
|
#else
|
||||||
xfree(dev->key);
|
#error FAIL
|
||||||
|
if (pDev->key) {
|
||||||
|
if (pDev->key->curKeySyms.map) xfree(pDev->key->curKeySyms.map);
|
||||||
|
if (pDev->key->modifierKeyMap) xfree(pDev->key->modifierKeyMap);
|
||||||
|
xfree(pDev->key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!InitKeyClassDeviceStruct(dev, &keySyms, keyInfo.modMap)) {
|
KeySymsRec keySyms;
|
||||||
|
if (!InitKeyClassDeviceStruct(pDev, &keySyms, keyInfo.modMap)) {
|
||||||
DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
|
DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
|
SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
|
||||||
SendMappingNotify(MappingModifier, 0, 0, 0);
|
SendMappingNotify(MappingModifier, 0, 0, 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue