Commit 361f405d authored by Rui Matos's avatar Rui Matos Committed by Peter Hutterer

xkb: Factor out a function to copy a keymap's controls onto another

Reviewed-by: 's avatarKristian Høgsberg <krh@bitplanet.net>
Signed-off-by: 's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 79506647
......@@ -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;
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment