diff options
author | Rui Matos <tiagomatos@gmail.com> | 2014-03-07 14:32:28 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-03-12 15:45:38 +1000 |
commit | 361f405d3c866bc4d22ef84975fe771691156336 (patch) | |
tree | 865bb5e91d308d917a017d6b8e0ae7b36876c256 | |
parent | 795066477ee81b5b82e490eac8bed6b656d01f17 (diff) |
xkb: Factor out a function to copy a keymap's controls onto another
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | include/xkbsrv.h | 3 | ||||
-rw-r--r-- | xkb/xkb.c | 14 | ||||
-rw-r--r-- | xkb/xkbUtils.c | 23 |
3 files changed, 27 insertions, 13 deletions
diff --git a/include/xkbsrv.h b/include/xkbsrv.h index f857b2280..06f12003b 100644 --- a/include/xkbsrv.h +++ b/include/xkbsrv.h @@ -841,6 +841,9 @@ extern void XkbFakeDeviceButton(DeviceIntPtr /* dev */ , int /* press */ , int /* button */ ); +extern _X_EXPORT void XkbCopyControls(XkbDescPtr /* dst */ , + XkbDescPtr /* src */ ); + #include "xkbfile.h" #include "xkbrules.h" @@ -5950,25 +5950,13 @@ ProcXkbGetKbdByName(ClientPtr client) if (rep.loaded) { XkbDescPtr old_xkb; xkbNewKeyboardNotify nkn; - int i, nG, nTG; old_xkb = xkb; xkb = new; dev->key->xkbInfo->desc = xkb; new = old_xkb; /* so it'll get freed automatically */ - *xkb->ctrls = *old_xkb->ctrls; - for (nG = nTG = 0, i = xkb->min_key_code; i <= xkb->max_key_code; i++) { - nG = XkbKeyNumGroups(xkb, i); - if (nG >= XkbNumKbdGroups) { - nTG = XkbNumKbdGroups; - break; - } - if (nG > nTG) { - nTG = nG; - } - } - xkb->ctrls->num_groups = nTG; + XkbCopyControls(xkb, old_xkb); nkn.deviceID = nkn.oldDeviceID = dev->id; nkn.minKeyCode = new->min_key_code; diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c index 6c6af60f0..b59d92550 100644 --- a/xkb/xkbUtils.c +++ b/xkb/xkbUtils.c @@ -2090,3 +2090,26 @@ XkbMergeLockedPtrBtns(DeviceIntPtr master) xkbi->lockedPtrButtons |= d->key->xkbInfo->lockedPtrButtons; } } + +void +XkbCopyControls(XkbDescPtr dst, XkbDescPtr src) +{ + int i, nG, nTG; + + if (!dst || !src) + return; + + *dst->ctrls = *src->ctrls; + + for (nG = nTG = 0, i = dst->min_key_code; i <= dst->max_key_code; i++) { + nG = XkbKeyNumGroups(dst, i); + if (nG >= XkbNumKbdGroups) { + nTG = XkbNumKbdGroups; + break; + } + if (nG > nTG) { + nTG = nG; + } + } + dst->ctrls->num_groups = nTG; +} |