diff options
author | Daniel Stone <daniel@fooishbar.org> | 2006-08-23 18:53:04 +0300 |
---|---|---|
committer | Daniel Stone <daniels@endtroducing.fooishbar.org> | 2006-08-23 18:53:04 +0300 |
commit | 6323a11d0db4d3cf0317af83f0362730142f5325 (patch) | |
tree | 968b9375935b3374b88f7477aaa39cc827d9590b /xkb/xkbUtils.c | |
parent | 728fbadd16a748b45c80bc2c65c46f82cf803578 (diff) |
XkbCopyKeymap: optionally send NewKeyboardNotify/MapNotify events
Optionally send a NewKeyboardNotify or MapNotify event when copying the
keymap; modify GetKeyboardValuatorEvents to make use of this.
Diffstat (limited to 'xkb/xkbUtils.c')
-rw-r--r-- | xkb/xkbUtils.c | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 4fa536968..da790f933 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -985,13 +985,16 @@ XkbConvertCase(register KeySym sym, KeySym *lower, KeySym *upper) * to remain valid, but part of the map may be from src and part from dst. */ Bool -XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst) +XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies) { int i = 0, j = 0; void *tmp = NULL; XkbKeyTypePtr stype = NULL, dtype = NULL; + DeviceIntPtr pDev = NULL, tmpDev = NULL; + xkbMapNotify mn; + xkbNewKeyboardNotify nkn; - if (!src || !dst) + if (!src || !dst || src == dst) return FALSE; /* client map */ @@ -1368,6 +1371,74 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst) } } + if (inputInfo.keyboard->key->xkbInfo && + inputInfo.keyboard->key->xkbInfo->desc == dst) { + pDev = inputInfo.keyboard; + } + else { + for (tmpDev = inputInfo.devices; tmpDev && !pDev; + tmpDev = tmpDev->next) { + if (tmpDev->key && tmpDev->key->xkbInfo && + tmpDev->key->xkbInfo->desc == dst) { + pDev = tmpDev; + break; + } + } + for (tmpDev = inputInfo.off_devices; tmpDev && !pDev; + tmpDev = tmpDev->next) { + if (tmpDev->key && tmpDev->key->xkbInfo && + tmpDev->key->xkbInfo->desc == dst) { + pDev = tmpDev; + break; + } + } + } + + if (sendNotifies) { + if (!pDev) { + ErrorF("XkbCopyKeymap: asked for notifies, but can't find device!\n"); + } + else { + /* send NewKeyboardNotify if the keycode range changed, else + * just MapNotify. */ + if (src->min_key_code != dst->min_key_code || + src->max_key_code != dst->max_key_code && sendNotifies) { + nkn.oldMinKeyCode = dst->min_key_code; + nkn.oldMaxKeyCode = dst->max_key_code; + nkn.deviceID = nkn.oldDeviceID = pDev->id; + nkn.minKeyCode = src->min_key_code; + nkn.maxKeyCode = src->max_key_code; + nkn.requestMajor = XkbReqCode; + nkn.requestMinor = X_kbSetMap; /* XXX bare-faced lie */ + nkn.changed = XkbAllNewKeyboardEventsMask; + XkbSendNewKeyboardNotify(pDev, &nkn); + } + else if (sendNotifies) { + mn.deviceID = pDev->id; + mn.minKeyCode = src->min_key_code; + mn.maxKeyCode = src->max_key_code; + mn.firstType = 0; + mn.nTypes = dst->map->num_types; + mn.firstKeySym = dst->min_key_code; + mn.nKeySyms = XkbNumKeys(dst); + mn.firstKeyAct = dst->min_key_code; + mn.nKeyActs = XkbNumKeys(dst); + /* Cargo-culted from ProcXkbGetMap. */ + mn.firstKeyBehavior = dst->min_key_code; + mn.nKeyBehaviors = XkbNumKeys(dst); + mn.firstKeyExplicit = dst->min_key_code; + mn.nKeyExplicit = XkbNumKeys(dst); + mn.firstModMapKey = dst->min_key_code; + mn.nModMapKeys = XkbNumKeys(dst); + mn.firstVModMapKey = dst->min_key_code; + mn.nVModMapKeys = XkbNumKeys(dst); + mn.virtualMods = ~0; /* ??? */ + mn.changed = XkbAllMapComponentsMask; + XkbSendMapNotify(pDev, &mn); + } + } + } + dst->min_key_code = src->min_key_code; dst->max_key_code = src->max_key_code; |