diff options
-rw-r--r-- | Xext/xtest.c | 6 | ||||
-rw-r--r-- | Xi/exevents.c | 31 | ||||
-rw-r--r-- | Xi/getkmap.c | 29 | ||||
-rw-r--r-- | Xi/listdev.c | 6 | ||||
-rw-r--r-- | Xi/queryst.c | 5 | ||||
-rw-r--r-- | Xi/ungrdevk.c | 6 | ||||
-rw-r--r-- | dix/devices.c | 54 | ||||
-rw-r--r-- | dix/events.c | 8 | ||||
-rw-r--r-- | dix/inpututils.c | 28 | ||||
-rw-r--r-- | hw/kdrive/src/kinput.c | 15 | ||||
-rw-r--r-- | hw/xfree86/common/xf86Events.c | 71 | ||||
-rw-r--r-- | include/inputstr.h | 1 | ||||
-rw-r--r-- | include/xkbsrv.h | 11 | ||||
-rw-r--r-- | xkb/xkb.c | 5 | ||||
-rw-r--r-- | xkb/xkbInit.c | 4 | ||||
-rw-r--r-- | xkb/xkbUtils.c | 200 |
16 files changed, 213 insertions, 267 deletions
diff --git a/Xext/xtest.c b/Xext/xtest.c index 2383a8799..7e95c8699 100644 --- a/Xext/xtest.c +++ b/Xext/xtest.c @@ -42,6 +42,8 @@ #include "dixevents.h" #include "sleepuntil.h" #include "mi.h" +#include "xkbsrv.h" +#include "xkbstr.h" #define _XTEST_SERVER_ #include <X11/extensions/XTest.h> #include <X11/extensions/xteststr.h> @@ -321,8 +323,8 @@ ProcXTestFakeInput(ClientPtr client) { case KeyPress: case KeyRelease: - if (ev->u.u.detail < dev->key->curKeySyms.minKeyCode || - ev->u.u.detail > dev->key->curKeySyms.maxKeyCode) + if (ev->u.u.detail < dev->key->xkbInfo->desc->min_key_code || + ev->u.u.detail > dev->key->xkbInfo->desc->max_key_code) { client->errorValue = ev->u.u.detail; return BadValue; diff --git a/Xi/exevents.c b/Xi/exevents.c index 76214b973..011fc7e3c 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -212,8 +212,6 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master) if (device == master) return; - SetKeySymsMap(&mk->curKeySyms, &dk->curKeySyms); - for (i = 0; i < 8; i++) mk->modifierKeyCount[i] = dk->modifierKeyCount[i]; @@ -476,7 +474,6 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to) if (from->key) { - KeySym *oldMap; struct _XkbSrvInfo *oldXkbInfo; if (!to->key) { @@ -492,21 +489,8 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to) classes->key = NULL; } - oldMap = to->key->curKeySyms.map; oldXkbInfo = to->key->xkbInfo; - - if (!oldMap) /* newly created key struct */ - { - int bytes = (to->key->curKeySyms.maxKeyCode - - to->key->curKeySyms.minKeyCode + 1) * - to->key->curKeySyms.mapWidth; - oldMap = (KeySym *)xcalloc(sizeof(KeySym), bytes); - memcpy(oldMap, from->key->curKeySyms.map, bytes); - } - - to->key->curKeySyms.map = oldMap; to->key->xkbInfo = oldXkbInfo; - CopyKeyClass(from, to); } else if (to->key && !from->key) { @@ -1101,7 +1085,8 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k, memcpy((char*)ev->buttons, (char*)b->down, 4); } else if (k) { ev->classes_reported |= (1 << KeyClass); - ev->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode; + ev->num_keys = k->xkbInfo->desc->max_key_code - + k->xkbInfo->desc->min_key_code; memmove((char *)&ev->keys[0], (char *)k->down, 4); } if (v) { @@ -1185,7 +1170,8 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail, evcount++; } if ((k = dev->key) != NULL) { - nkeys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode; + nkeys = k->xkbInfo->desc->max_key_code - + k->xkbInfo->desc->min_key_code; if (nkeys > 32) evcount++; if (nbuttons > 0) { @@ -1355,10 +1341,11 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode, client->errorValue = this_device_mode; return BadValue; } - if (((key > k->curKeySyms.maxKeyCode) || (key < k->curKeySyms.minKeyCode)) + if ((key > k->xkbInfo->desc->max_key_code || + key < k->xkbInfo->desc->min_key_code) && (key != AnyKey)) { client->errorValue = key; - return BadValue; + return BadValue; } if ((modifiers != AnyModifier) && (modifiers & ~AllModifiersMask)) { client->errorValue = modifiers; @@ -1656,8 +1643,8 @@ ChangeKeyMapping(ClientPtr client, if (len != (keyCodes * keySymsPerKeyCode)) return BadLength; - if ((firstKeyCode < k->curKeySyms.minKeyCode) || - (firstKeyCode + keyCodes - 1 > k->curKeySyms.maxKeyCode)) { + if ((firstKeyCode < k->xkbInfo->desc->min_key_code) || + (firstKeyCode + keyCodes - 1 > k->xkbInfo->desc->max_key_code)) { client->errorValue = firstKeyCode; return BadValue; } diff --git a/Xi/getkmap.c b/Xi/getkmap.c index 540184682..78449e212 100644 --- a/Xi/getkmap.c +++ b/Xi/getkmap.c @@ -59,6 +59,8 @@ SOFTWARE. #include <X11/extensions/XIproto.h> #include "exglobals.h" #include "swaprep.h" +#include "xkbsrv.h" +#include "xkbstr.h" #include "getkmap.h" @@ -90,7 +92,8 @@ ProcXGetDeviceKeyMapping(ClientPtr client) { xGetDeviceKeyMappingReply rep; DeviceIntPtr dev; - KeySymsPtr k; + XkbDescPtr xkb; + KeySymsPtr syms; int rc; REQUEST(xGetDeviceKeyMappingReq); @@ -101,31 +104,37 @@ ProcXGetDeviceKeyMapping(ClientPtr client) return rc; if (dev->key == NULL) return BadMatch; - k = &dev->key->curKeySyms; + xkb = dev->key->xkbInfo->desc; - if ((stuff->firstKeyCode < k->minKeyCode) || - (stuff->firstKeyCode > k->maxKeyCode)) { + if (stuff->firstKeyCode < xkb->min_key_code || + stuff->firstKeyCode > xkb->max_key_code) { client->errorValue = stuff->firstKeyCode; return BadValue; } - if (stuff->firstKeyCode + stuff->count > k->maxKeyCode + 1) { + if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) { client->errorValue = stuff->count; return BadValue; } + syms = XkbGetCoreMap(dev); + if (!syms) + return BadAlloc; + rep.repType = X_Reply; rep.RepType = X_GetDeviceKeyMapping; rep.sequenceNumber = client->sequence; - rep.keySymsPerKeyCode = k->mapWidth; - rep.length = (k->mapWidth * stuff->count); /* KeySyms are 4 bytes */ + rep.keySymsPerKeyCode = syms->mapWidth; + rep.length = (syms->mapWidth * stuff->count); /* KeySyms are 4 bytes */ WriteReplyToClient(client, sizeof(xGetDeviceKeyMappingReply), &rep); client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; WriteSwappedDataToClient(client, - k->mapWidth * stuff->count * sizeof(KeySym), - &k->map[(stuff->firstKeyCode - k->minKeyCode) * - k->mapWidth]); + syms->mapWidth * stuff->count * sizeof(KeySym), + &syms->map[syms->mapWidth * (stuff->firstKeyCode - + syms->minKeyCode)]); + xfree(syms->map); + xfree(syms); return Success; } diff --git a/Xi/listdev.c b/Xi/listdev.c index 04550e488..9a5a189de 100644 --- a/Xi/listdev.c +++ b/Xi/listdev.c @@ -64,6 +64,8 @@ SOFTWARE. #include "exglobals.h" /* FIXME */ #include "exevents.h" #include "xace.h" +#include "xkbsrv.h" +#include "xkbstr.h" #include "listdev.h" @@ -211,8 +213,8 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf) k2 = (xKeyInfoPtr) * buf; k2->class = KeyClass; k2->length = sizeof(xKeyInfo); - k2->min_keycode = k->curKeySyms.minKeyCode; - k2->max_keycode = k->curKeySyms.maxKeyCode; + k2->min_keycode = k->xkbInfo->desc->min_key_code; + k2->max_keycode = k->xkbInfo->desc->max_key_code; k2->num_keys = k2->max_keycode - k2->min_keycode + 1; if (client && client->swapped) { swaps(&k2->num_keys, n); diff --git a/Xi/queryst.c b/Xi/queryst.c index 6553aa88e..2b20837d1 100644 --- a/Xi/queryst.c +++ b/Xi/queryst.c @@ -42,6 +42,8 @@ from The Open Group. #include <X11/extensions/XIproto.h> #include "exevents.h" #include "exglobals.h" +#include "xkbsrv.h" +#include "xkbstr.h" #include "queryst.h" @@ -126,7 +128,8 @@ ProcXQueryDeviceState(ClientPtr client) tk = (xKeyState *) buf; tk->class = KeyClass; tk->length = sizeof(xKeyState); - tk->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1; + tk->num_keys = k->xkbInfo->desc->max_key_code - + k->xkbInfo->desc->min_key_code + 1; for (i = 0; i < 32; i++) tk->keys[i] = k->down[i]; buf += sizeof(xKeyState); diff --git a/Xi/ungrdevk.c b/Xi/ungrdevk.c index 8d9cdb17d..7f5e4aab0 100644 --- a/Xi/ungrdevk.c +++ b/Xi/ungrdevk.c @@ -60,6 +60,8 @@ SOFTWARE. #include <X11/extensions/XIproto.h> #include "exglobals.h" #include "dixgrabs.h" +#include "xkbsrv.h" +#include "xkbstr.h" #include "ungrdevk.h" @@ -124,8 +126,8 @@ ProcXUngrabDeviceKey(ClientPtr client) if (rc != Success) return rc; - if (((stuff->key > dev->key->curKeySyms.maxKeyCode) || - (stuff->key < dev->key->curKeySyms.minKeyCode)) + if (((stuff->key > dev->key->xkbInfo->desc->max_key_code) || + (stuff->key < dev->key->xkbInfo->desc->min_key_code)) && (stuff->key != AnyKey)) return BadValue; diff --git a/dix/devices.c b/dix/devices.c index 884256c8d..f3c271711 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -514,13 +514,9 @@ CorePointerProc(DeviceIntPtr pDev, int what) { BYTE map[33]; int i = 0; - ClassesPtr classes; switch (what) { case DEVICE_INIT: - if (!(classes = xcalloc(1, sizeof(ClassesRec)))) - return BadAlloc; - for (i = 1; i <= 32; i++) map[i] = i; InitPointerDeviceStruct((DevicePtr)pDev, map, 32, @@ -619,7 +615,6 @@ FreeDeviceClass(int type, pointer *class) XkbFreeInfo((*k)->xkbInfo); (*k)->xkbInfo = NULL; } - xfree((*k)->curKeySyms.map); xfree((*k)); break; } @@ -1008,8 +1003,8 @@ void QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode) { if (inputInfo.keyboard) { - *minCode = inputInfo.keyboard->key->curKeySyms.minKeyCode; - *maxCode = inputInfo.keyboard->key->curKeySyms.maxKeyCode; + *minCode = inputInfo.keyboard->key->xkbInfo->desc->min_key_code; + *maxCode = inputInfo.keyboard->key->xkbInfo->desc->max_key_code; } } @@ -1482,7 +1477,6 @@ ProcChangeKeyboardMapping(ClientPtr client) REQUEST(xChangeKeyboardMappingReq); unsigned len; KeySymsRec keysyms; - KeySymsPtr curKeySyms = &PickKeyboard(client)->key->curKeySyms; DeviceIntPtr pDev, tmp; int rc; REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq); @@ -1491,14 +1485,17 @@ ProcChangeKeyboardMapping(ClientPtr client) if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode)) return BadLength; - if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || - (stuff->firstKeyCode > curKeySyms->maxKeyCode)) { + pDev = PickKeyboard(client); + + if ((stuff->firstKeyCode < pDev->key->xkbInfo->desc->min_key_code) || + (stuff->firstKeyCode > pDev->key->xkbInfo->desc->max_key_code)) { client->errorValue = stuff->firstKeyCode; return BadValue; } if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) > - curKeySyms->maxKeyCode) || (stuff->keySymsPerKeyCode == 0)) { + pDev->key->xkbInfo->desc->max_key_code) || + (stuff->keySymsPerKeyCode == 0)) { client->errorValue = stuff->keySymsPerKeyCode; return BadValue; } @@ -1589,7 +1586,8 @@ ProcGetKeyboardMapping(ClientPtr client) { xGetKeyboardMappingReply rep; DeviceIntPtr kbd = PickKeyboard(client); - KeySymsPtr curKeySyms = &kbd->key->curKeySyms; + XkbDescPtr xkb; + KeySymsPtr syms; int rc; REQUEST(xGetKeyboardMappingReq); REQUEST_SIZE_MATCH(xGetKeyboardMappingReq); @@ -1598,29 +1596,35 @@ ProcGetKeyboardMapping(ClientPtr client) if (rc != Success) return rc; - if ((stuff->firstKeyCode < curKeySyms->minKeyCode) || - (stuff->firstKeyCode > curKeySyms->maxKeyCode)) { + xkb = kbd->key->xkbInfo->desc; + + if ((stuff->firstKeyCode < xkb->min_key_code) || + (stuff->firstKeyCode > xkb->max_key_code)) { client->errorValue = stuff->firstKeyCode; return BadValue; } - if (stuff->firstKeyCode + stuff->count > - (unsigned)(curKeySyms->maxKeyCode + 1)) { + if (stuff->firstKeyCode + stuff->count > xkb->max_key_code + 1) { client->errorValue = stuff->count; return BadValue; } + syms = XkbGetCoreMap(kbd); + if (!syms) + return BadAlloc; + rep.type = X_Reply; rep.sequenceNumber = client->sequence; - rep.keySymsPerKeyCode = curKeySyms->mapWidth; + rep.keySymsPerKeyCode = syms->mapWidth; /* length is a count of 4 byte quantities and KeySyms are 4 bytes */ - rep.length = (curKeySyms->mapWidth * stuff->count); + rep.length = syms->mapWidth * stuff->count; WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep); client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write; - WriteSwappedDataToClient( - client, - curKeySyms->mapWidth * stuff->count * sizeof(KeySym), - &curKeySyms->map[(stuff->firstKeyCode - curKeySyms->minKeyCode) * - curKeySyms->mapWidth]); + WriteSwappedDataToClient(client, + syms->mapWidth * stuff->count * sizeof(KeySym), + &syms->map[syms->mapWidth * (stuff->firstKeyCode - + syms->minKeyCode)]); + xfree(syms->map); + xfree(syms); return client->noClientException; } @@ -1773,8 +1777,8 @@ DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist, case KBKey: key = (KeyCode)*vlist; vlist++; - if ((KeyCode)key < keybd->key->curKeySyms.minKeyCode || - (KeyCode)key > keybd->key->curKeySyms.maxKeyCode) { + if ((KeyCode)key < keybd->key->xkbInfo->desc->min_key_code || + (KeyCode)key > keybd->key->xkbInfo->desc->max_key_code) { client->errorValue = key; return BadValue; } diff --git a/dix/events.c b/dix/events.c index 5e8fc9b26..0a702967a 100644 --- a/dix/events.c +++ b/dix/events.c @@ -5018,8 +5018,8 @@ ProcUngrabKey(ClientPtr client) if (rc != Success) return rc; - if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) || - (stuff->key < keybd->key->curKeySyms.minKeyCode)) + if (((stuff->key > keybd->key->xkbInfo->desc->max_key_code) || + (stuff->key < keybd->key->xkbInfo->desc->min_key_code)) && (stuff->key != AnyKey)) { client->errorValue = stuff->key; @@ -5080,8 +5080,8 @@ ProcGrabKey(ClientPtr client) client->errorValue = stuff->keyboardMode; return BadValue; } - if (((stuff->key > keybd->key->curKeySyms.maxKeyCode) || - (stuff->key < keybd->key->curKeySyms.minKeyCode)) + if (((stuff->key > keybd->key->xkbInfo->desc->max_key_code) || + (stuff->key < keybd->key->xkbInfo->desc->min_key_code)) && (stuff->key != AnyKey)) { client->errorValue = stuff->key; diff --git a/dix/inpututils.c b/dix/inpututils.c index 4763382c7..366a89799 100644 --- a/dix/inpututils.c +++ b/dix/inpututils.c @@ -148,7 +148,7 @@ static int check_modmap_change(ClientPtr client, DeviceIntPtr dev, KeyCode *modmap) { int ret, i; - KeySymsPtr syms; + XkbDescPtr xkb; ret = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess); if (ret != Success) @@ -156,7 +156,7 @@ check_modmap_change(ClientPtr client, DeviceIntPtr dev, KeyCode *modmap) if (!dev->key) return BadMatch; - syms = &dev->key->curKeySyms; + xkb = dev->key->xkbInfo->desc; for (i = 0; i < MAP_LENGTH; i++) { if (!modmap[i]) @@ -164,7 +164,7 @@ check_modmap_change(ClientPtr client, DeviceIntPtr dev, KeyCode *modmap) /* Check that all the new modifiers fall within the advertised * keycode range. */ - if (i < syms->minKeyCode || i > syms->maxKeyCode) { + if (i < xkb->min_key_code || i > xkb->max_key_code) { client->errorValue = i; return -1; } @@ -185,8 +185,8 @@ check_modmap_change(ClientPtr client, DeviceIntPtr dev, KeyCode *modmap) /* None of the old modifiers may be down while we change the map, * either. */ - for (i = syms->minKeyCode; i < syms->maxKeyCode; i++) { - if (!dev->key->xkbInfo->desc->map->modmap[i]) + for (i = xkb->min_key_code; i < xkb->max_key_code; i++) { + if (!xkb->map->modmap[i]) continue; if (key_is_down(dev, i, KEY_POSTED | KEY_PROCESSED)) { client->errorValue = i; @@ -201,18 +201,18 @@ static int check_modmap_change_slave(ClientPtr client, DeviceIntPtr master, DeviceIntPtr slave, CARD8 *modmap) { - KeySymsPtr master_syms, slave_syms; + XkbDescPtr master_xkb, slave_xkb; int i, j; if (!slave->key || !master->key) return 0; - master_syms = &master->key->curKeySyms; - slave_syms = &slave->key->curKeySyms; + master_xkb = master->key->xkbInfo->desc; + slave_xkb = slave->key->xkbInfo->desc; /* Ignore devices with a clearly different keymap. */ - if (slave_syms->minKeyCode != master_syms->minKeyCode || - slave_syms->maxKeyCode != master_syms->maxKeyCode) + if (slave_xkb->min_key_code != master_xkb->min_key_code || + slave_xkb->max_key_code != master_xkb->max_key_code) return 0; for (i = 0; i < MAP_LENGTH; i++) { @@ -221,9 +221,11 @@ check_modmap_change_slave(ClientPtr client, DeviceIntPtr master, /* If we have different symbols for any modifier on an * extended keyboard, ignore the whole remap request. */ - for (j = 0; j < slave_syms->mapWidth && j < master_syms->mapWidth; j++) - if (slave_syms->map[modmap[i] * slave_syms->mapWidth + j] != - master_syms->map[modmap[i] * master_syms->mapWidth + j]) + for (j = 0; + j < XkbKeyNumSyms(slave_xkb, i) && + j < XkbKeyNumSyms(master_xkb, i); + j++) + if (XkbKeySymsPtr(slave_xkb, i)[j] != XkbKeySymsPtr(master_xkb, i)[j]) return 0; } diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c index 9b34a7a00..2875920ab 100644 --- a/hw/kdrive/src/kinput.c +++ b/hw/kdrive/src/kinput.c @@ -75,12 +75,6 @@ static KdPointerMatrix kdPointerMatrix = { void KdResetInputMachine (void); -#define IsKeyDown(ki, key) ((ki->keyState[(key) >> 3] >> ((key) & 7)) & 1) -#define KEYMAP(ki) (ki->dixdev->key->curKeySyms) -#define KEYMAPDDX(ki) (ki->keySyms) -#define KEYCOL1(ki, k) (KEYMAP(ki).map[((k)-(KEYMAP(ki).minKeyCode))*KEYMAP(ki).mapWidth]) -#define KEYCOL1DDX(ki, k) (KEYMAPDDX(ki).map[((k)-(KEYMAPDDX(ki).minKeyCode))*KEYMAPDDX(ki).mapWidth]) - #define KD_MAX_INPUT_FDS 8 typedef struct _kdInputFd { @@ -1756,13 +1750,6 @@ KdReceiveTimeout (KdPointerInfo *pi) KdRunMouseMachine (pi, timeout, 0, 0, 0, 0, 0, 0); } -#define KILL_SEQUENCE ((1L << KK_CONTROL)|(1L << KK_ALT)|(1L << KK_F8)|(1L << KK_F10)) -#define SPECIAL_SEQUENCE ((1L << KK_CONTROL) | (1L << KK_ALT)) -#define SETKILLKEY(b) (KdSpecialKeys |= (1L << (b))) -#define CLEARKILLKEY(b) (KdSpecialKeys &= ~(1L << (b))) - -CARD32 KdSpecialKeys = 0; - /* * kdCheckTermination * @@ -1819,7 +1806,7 @@ KdReleaseAllKeys (void) for (ki = kdKeyboards; ki; ki = ki->next) { for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode; key++) { - if (IsKeyDown(ki, key)) { + if (key_is_down(ki->dixdev, key, KEY_POSTED | KEY_PROCESSED)) { KdHandleKeyboardEvent(ki, KeyRelease, key); GetEventList(&kdEvents); nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key); diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c index a1beea050..50a5bf6d6 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c @@ -76,6 +76,9 @@ #include "mi.h" #include "mipointer.h" +#include "xkbsrv.h" +#include "xkbstr.h" + #ifdef XF86BIGFONT #define _XF86BIGFONT_SERVER_ #include <X11/extensions/xf86bigfont.h> @@ -402,16 +405,14 @@ xf86PrintBacktrace(void) static void xf86ReleaseKeys(DeviceIntPtr pDev) { - KeyClassPtr keyc = NULL; - KeySym *map = NULL; + KeyClassPtr keyc; xEvent ke; - int i = 0, j = 0, nevents = 0; + int i, j, nevents, sigstate; if (!pDev || !pDev->key) return; keyc = pDev->key; - map = keyc->curKeySyms.map; /* * Hmm... here is the biggest hack of every time ! @@ -424,36 +425,15 @@ xf86ReleaseKeys(DeviceIntPtr pDev) * are reenabled. */ - for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map; - i < keyc->curKeySyms.maxKeyCode; - i++, map += keyc->curKeySyms.mapWidth) { + for (i = keyc->xkbInfo->desc->min_key_code; + i < keyc->xkbInfo->desc->max_key_code; + i++) { if (KeyPressed(i)) { - switch (*map) { - /* Don't release the lock keys */ - case XK_Caps_Lock: - case XK_Shift_Lock: - case XK_Num_Lock: - case XK_Scroll_Lock: - case XK_Kana_Lock: - break; - default: - if (pDev == inputInfo.keyboard) { - ke.u.keyButtonPointer.time = GetTimeInMillis(); - ke.u.keyButtonPointer.rootX = 0; - ke.u.keyButtonPointer.rootY = 0; - ke.u.u.type = KeyRelease; - ke.u.u.detail = i; - (*pDev->public.processInputProc) (&ke, pDev, 1); - } - else { - int sigstate = xf86BlockSIGIO (); - nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i); - for (j = 0; j < nevents; j++) - mieqEnqueue(pDev, (xf86Events + j)->event); - xf86UnblockSIGIO(sigstate); - } - break; - } + sigstate = xf86BlockSIGIO (); + nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i); + for (j = 0; j < nevents; j++) + mieqEnqueue(pDev, (xf86Events + j)->event); + xf86UnblockSIGIO(sigstate); } } } @@ -502,18 +482,19 @@ xf86VTSwitch(void) * Keep the order: Disable Device > LeaveVT * EnterVT > EnableDevice */ - pInfo = xf86InputDevs; - while (pInfo) { - if (pInfo->dev) + for (ih = InputHandlers; ih; ih = ih->next) + xf86DisableInputHandler(ih); + for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) { + if (pInfo->dev) { + xf86ReleaseKeys(pInfo->dev); + ProcessInputEvents(); DisableDevice(pInfo->dev); - pInfo = pInfo->next; + } } xf86EnterServerState(SETUP); for (i = 0; i < xf86NumScreens; i++) xf86Screens[i]->LeaveVT(i, 0); - for (ih = InputHandlers; ih; ih = ih->next) - xf86DisableInputHandler(ih); xf86AccessLeave(); /* We need this here, otherwise */ xf86AccessLeaveState(); /* console won't be restored */ @@ -543,14 +524,10 @@ xf86VTSwitch(void) pInfo = xf86InputDevs; while (pInfo) { - if (pInfo->dev) { - xf86ReleaseKeys(pInfo->dev); + if (pInfo->dev) EnableDevice(pInfo->dev); - } pInfo = pInfo->next; } - /* XXX HACK */ - xf86ReleaseKeys(inputInfo.keyboard); for (ih = InputHandlers; ih; ih = ih->next) xf86EnableInputHandler(ih); @@ -607,14 +584,10 @@ xf86VTSwitch(void) pInfo = xf86InputDevs; while (pInfo) { - if (pInfo->dev) { - xf86ReleaseKeys(pInfo->dev); + if (pInfo->dev) EnableDevice(pInfo->dev); - } pInfo = pInfo->next; } - /* XXX HACK */ - xf86ReleaseKeys(inputInfo.keyboard); for (ih = InputHandlers; ih; ih = ih->next) xf86EnableInputHandler(ih); diff --git a/include/inputstr.h b/include/inputstr.h index 76523aa83..daee7ed32 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -137,7 +137,6 @@ typedef struct _GrabRec { typedef struct _KeyClassRec { CARD8 down[DOWN_LENGTH]; CARD8 postdown[DOWN_LENGTH]; - KeySymsRec curKeySyms; int modifierKeyCount[8]; struct _XkbSrvInfo *xkbInfo; } KeyClassRec, *KeyClassPtr; diff --git a/include/xkbsrv.h b/include/xkbsrv.h index 54010eb0b..768467565 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -322,11 +322,6 @@ extern _X_EXPORT int DeviceEnterNotify,DeviceLeaveNotify; #define _XkbIsPressEvent(t) (((t)==KeyPress)||((t)==DeviceKeyPress)) #define _XkbIsReleaseEvent(t) (((t)==KeyRelease)||((t)==DeviceKeyRelease)) -#define _XkbCoreKeycodeInRange(c,k) (((k)>=(c)->curKeySyms.minKeyCode)&&\ - ((k)<=(c)->curKeySyms.maxKeyCode)) -#define _XkbCoreNumKeys(c) ((c)->curKeySyms.maxKeyCode-\ - (c)->curKeySyms.minKeyCode+1) - #define XConvertCase(s,l,u) XkbConvertCase(s,l,u) #undef IsKeypadKey #define IsKeypadKey(s) XkbKSIsKeypad(s) @@ -510,6 +505,7 @@ extern _X_EXPORT XkbAction *XkbResizeKeyActions( extern _X_EXPORT void XkbUpdateKeyTypesFromCore( DeviceIntPtr /* pXDev */, + KeySymsPtr /* syms */, KeyCode /* first */, CARD8 /* num */, XkbChangesPtr /* pChanges */ @@ -531,9 +527,8 @@ extern _X_EXPORT void XkbUpdateActions( XkbEventCausePtr /* cause */ ); -extern _X_EXPORT void XkbUpdateCoreDescription( - DeviceIntPtr /* keybd */, - Bool /* resize */ +extern _X_EXPORT KeySymsPtr XkbGetCoreMap( + DeviceIntPtr /* keybd */ ); extern _X_EXPORT void XkbApplyMappingChange( @@ -2519,7 +2519,6 @@ _XkbSetMap(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq *req, char *values) if (!sentNKN) XkbSendNotification(dev,&change,&cause); - XkbUpdateCoreDescription(dev,False); return Success; allocFailure: return BadAlloc; @@ -2856,7 +2855,6 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev, &cause); if (check) XkbCheckSecondaryEffects(xkbi,check,&change,&cause); - XkbUpdateCoreDescription(dev,False); XkbSendNotification(dev,&change,&cause); } return Success; @@ -5838,7 +5836,6 @@ ProcXkbGetKbdByName(ClientPtr client) tmpd->coreEvents)) { if (tmpd != dev) XkbCopyDeviceKeymap(tmpd, dev); - XkbUpdateCoreDescription(tmpd, True); if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) { old_sli = tmpd->kbdfeed->xkb_sli; @@ -5854,8 +5851,6 @@ ProcXkbGetKbdByName(ClientPtr client) } } - /* this should be either a MN or an NKN, depending on whether or not - * the keycode range changed? */ nkn.deviceID= nkn.oldDeviceID= dev->id; nkn.minKeyCode= new->min_key_code; nkn.maxKeyCode= new->max_key_code; diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c index bcee26c37..151d9a55a 100644 --- a/xkb/xkbInit.c +++ b/xkb/xkbInit.c @@ -510,12 +510,8 @@ InitKeyboardDeviceStruct(DeviceIntPtr dev, XkbRMLVOSet *rmlvo, XkbDDXInitDevice(dev); - XkbUpdateCoreDescription(dev, True); - XkbUpdateActions(dev, xkb->min_key_code, XkbNumKeys(xkb), &changes, &check, &cause); - dev->key->curKeySyms.minKeyCode = xkb->min_key_code; - dev->key->curKeySyms.maxKeyCode = xkb->max_key_code; InitFocusClassDeviceStruct(dev); diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 89d38251f..3cd35575f 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -213,13 +213,13 @@ register unsigned mask; void XkbUpdateKeyTypesFromCore( DeviceIntPtr pXDev, + KeySymsPtr pCore, KeyCode first, CARD8 num, XkbChangesPtr changes) { XkbDescPtr xkb; unsigned key,nG,explicit; -KeySymsPtr pCore; int types[XkbNumKbdGroups]; KeySym tsyms[XkbMaxSymsPerKey],*syms; XkbMapChangesPtr mc; @@ -232,7 +232,6 @@ XkbMapChangesPtr mc; mc= (changes?(&changes->map):NULL); - pCore= &pXDev->key->curKeySyms; syms= &pCore->map[(first-xkb->min_key_code)*pCore->mapWidth]; for (key=first; key<(first+num); key++,syms+= pCore->mapWidth) { explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask; @@ -355,54 +354,24 @@ CARD8 * repeat; return; } -void -XkbUpdateCoreDescription(DeviceIntPtr keybd,Bool resize) +KeySymsPtr +XkbGetCoreMap(DeviceIntPtr keybd) { register int key,tmp; int maxSymsPerKey,maxKeysPerMod, maxGroup1Width; -int first,last,firstCommon,lastCommon; XkbDescPtr xkb; -KeyClassPtr keyc; +KeySymsPtr syms; int maxNumberOfGroups; if (!keybd || !keybd->key || !keybd->key->xkbInfo) - return; + return NULL; + xkb= keybd->key->xkbInfo->desc; - keyc= keybd->key; maxSymsPerKey= maxGroup1Width= 0; maxNumberOfGroups = 0; - if ((xkb->min_key_code==keyc->curKeySyms.minKeyCode)&& - (xkb->max_key_code==keyc->curKeySyms.maxKeyCode)) { - first= firstCommon= xkb->min_key_code; - last= lastCommon= xkb->max_key_code; - } - else if (resize) { - keyc->curKeySyms.minKeyCode= xkb->min_key_code; - keyc->curKeySyms.maxKeyCode= xkb->max_key_code; - first= firstCommon= xkb->min_key_code; - last= lastCommon= xkb->max_key_code; - } - else { - if (xkb->min_key_code<keyc->curKeySyms.minKeyCode) { - first= xkb->min_key_code; - firstCommon= keyc->curKeySyms.minKeyCode; - } - else { - firstCommon= xkb->min_key_code; - first= keyc->curKeySyms.minKeyCode; - } - if (xkb->max_key_code>keyc->curKeySyms.maxKeyCode) { - lastCommon= keyc->curKeySyms.maxKeyCode; - last= xkb->max_key_code; - } - else { - lastCommon= xkb->max_key_code; - last= keyc->curKeySyms.maxKeyCode; - } - } /* determine sizes */ - for (key=first;key<=last;key++) { + for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) { if (XkbKeycodeInRange(xkb,key)) { int nGroups; int w; @@ -437,53 +406,69 @@ int maxNumberOfGroups; } } - if (maxSymsPerKey>0) { - /* See Section 12.4 of the XKB Protocol spec. Because of the - * single-group distribution for multi-group keyboards, we have to - * have enough symbols for the largest group 1 to replicate across the - * number of groups on the keyboard. e.g. a single-group key with 4 - * symbols on a keyboard that has 3 groups -> 12 syms per key */ - if (maxSymsPerKey < maxNumberOfGroups * maxGroup1Width) - maxSymsPerKey = maxNumberOfGroups * maxGroup1Width; - - tmp= maxSymsPerKey*_XkbCoreNumKeys(keyc); - keyc->curKeySyms.map= _XkbTypedRealloc(keyc->curKeySyms.map,tmp,KeySym); - if (keyc->curKeySyms.map==NULL) - FatalError("Couldn't allocate symbols map in UpdateCore\n"); - } - else if ((keyc->curKeySyms.mapWidth>0)&&(keyc->curKeySyms.map!=NULL)) { - _XkbFree(keyc->curKeySyms.map); - keyc->curKeySyms.map= NULL; - } - keyc->curKeySyms.mapWidth= maxSymsPerKey; + if (maxSymsPerKey <= 0) + return NULL; - for (key=firstCommon;key<=lastCommon;key++) { - if (keyc->curKeySyms.map!=NULL) { - KeySym *pCore,*pXKB; - unsigned nGroups,groupWidth,n,nOut; + syms = xcalloc(1, sizeof(*syms)); + if (!syms) + return NULL; - nGroups= XkbKeyNumGroups(xkb,key); - n= (key-keyc->curKeySyms.minKeyCode)*maxSymsPerKey; - pCore= &keyc->curKeySyms.map[n]; - bzero(pCore,maxSymsPerKey*sizeof(KeySym)); - pXKB= XkbKeySymsPtr(xkb,key); - nOut= 2; - if (nGroups>0) { - groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup1Index); - if (groupWidth>0) pCore[0]= pXKB[0]; - if (groupWidth>1) pCore[1]= pXKB[1]; - for (n=2;n<groupWidth;n++) { - pCore[2+n]= pXKB[n]; - } - if (groupWidth>2) - nOut= groupWidth; - } + /* See Section 12.4 of the XKB Protocol spec. Because of the + * single-group distribution for multi-group keyboards, we have to + * have enough symbols for the largest group 1 to replicate across the + * number of groups on the keyboard. e.g. a single-group key with 4 + * symbols on a keyboard that has 3 groups -> 12 syms per key */ + if (maxSymsPerKey < maxNumberOfGroups * maxGroup1Width) + maxSymsPerKey = maxNumberOfGroups * maxGroup1Width; + + syms->mapWidth = maxSymsPerKey; + + tmp = syms->mapWidth * (xkb->max_key_code - xkb->min_key_code); + syms->map = xcalloc(tmp, sizeof(*syms->map)); + if (!syms->map) { + xfree(syms); + return NULL; + } - /* See XKB Protocol Sec, Section 12.4. - A 1-group key with ABCDE on a 2 group keyboard must be - duplicated across all groups as ABABCDECDE. - */ - if (nGroups == 1) + for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) { + KeySym *pCore,*pXKB; + unsigned nGroups,groupWidth,n,nOut; + + nGroups= XkbKeyNumGroups(xkb,key); + n= (key-xkb->min_key_code)*syms->mapWidth; + pCore= &syms->map[n]; + pXKB= XkbKeySymsPtr(xkb,key); + nOut= 2; + if (nGroups>0) { + groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup1Index); + if (groupWidth>0) pCore[0]= pXKB[0]; + if (groupWidth>1) pCore[1]= pXKB[1]; + for (n=2;n<groupWidth;n++) + pCore[2+n]= pXKB[n]; + if (groupWidth>2) + nOut= groupWidth; + } + + /* See XKB Protocol Sec, Section 12.4. + A 1-group key with ABCDE on a 2 group keyboard must be + duplicated across all groups as ABABCDECDE. + */ + if (nGroups == 1) + { + int idx; + + groupWidth = XkbKeyGroupWidth(xkb, key, XkbGroup1Index); + + /* AB..CDE... -> ABABCDE... */ + if (groupWidth > 0 && syms->mapWidth >= 3) + pCore[2] = pCore[0]; + if (groupWidth > 1 && syms->mapWidth >= 4) + pCore[3] = pCore[1]; + + /* ABABCDE... -> ABABCDECDE */ + idx = 2 + groupWidth; + while (groupWidth > 2 && idx < syms->mapWidth && + idx < groupWidth * 2) { int idx, j; @@ -512,31 +497,38 @@ int maxNumberOfGroups; for (n = 0; n < groupWidth && idx < maxSymsPerKey; n++) pCore[idx++] = pXKB[n]; } + idx = 2 * groupWidth; + if (idx < 4) + idx = 4; + /* 3 or more groups: ABABCDECDEABCDEABCDE */ + for (n = 0; n < groupWidth && idx < syms->mapWidth; n++) + pCore[idx++] = pXKB[n]; + } - pXKB+= XkbKeyGroupsWidth(xkb,key); - nOut+= 2; - if (nGroups>1) { - groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup2Index); - if (groupWidth>0) pCore[2]= pXKB[0]; - if (groupWidth>1) pCore[3]= pXKB[1]; - for (n=2;n<groupWidth;n++) { - pCore[nOut+(n-2)]= pXKB[n]; - } - if (groupWidth>2) - nOut+= (groupWidth-2); + pXKB+= XkbKeyGroupsWidth(xkb,key); + nOut+= 2; + if (nGroups>1) { + groupWidth= XkbKeyGroupWidth(xkb,key,XkbGroup2Index); + if (groupWidth>0) pCore[2]= pXKB[0]; + if (groupWidth>1) pCore[3]= pXKB[1]; + for (n=2;n<groupWidth;n++) { + pCore[nOut+(n-2)]= pXKB[n]; } - pXKB+= XkbKeyGroupsWidth(xkb,key); - for (n=XkbGroup3Index;n<nGroups;n++) { - register int s; - groupWidth= XkbKeyGroupWidth(xkb,key,n); - for (s=0;s<groupWidth;s++) { - pCore[nOut++]= pXKB[s]; - } - pXKB+= XkbKeyGroupsWidth(xkb,key); + if (groupWidth>2) + nOut+= (groupWidth-2); + } + pXKB+= XkbKeyGroupsWidth(xkb,key); + for (n=XkbGroup3Index;n<nGroups;n++) { + register int s; + groupWidth= XkbKeyGroupWidth(xkb,key,n); + for (s=0;s<groupWidth;s++) { + pCore[nOut++]= pXKB[s]; } + pXKB+= XkbKeyGroupsWidth(xkb,key); } } - return; + + return syms; } void @@ -580,9 +572,7 @@ XkbApplyMappingChange(DeviceIntPtr kbd, KeySymsPtr map, KeyCode first_key, check = 0; XkbSetCauseCoreReq(&cause, X_ChangeKeyboardMapping, client); - if (!SetKeySymsMap(&kbd->key->curKeySyms, map)) - FatalError("XkbApplyMappingChange: failed to copy core keymap!\n"); - XkbUpdateKeyTypesFromCore(kbd, first_key, num_keys, &changes); + XkbUpdateKeyTypesFromCore(kbd, map, first_key, num_keys, &changes); XkbUpdateActions(kbd, first_key, num_keys, &changes, &check, &cause); if (check) |