Commit d35a02a7 authored by Rui Tiago Matos's avatar Rui Tiago Matos Committed by Peter Hutterer

xkb: Repurpose XkbCopyDeviceKeymap to apply a given keymap to a device

This will also make it useful for cases when we have a new keymap to
apply to a device but don't have a source device.
Reviewed-by: Kristian H. Kristensen's avatarKristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 361f405d
...@@ -230,7 +230,7 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master) ...@@ -230,7 +230,7 @@ CopyKeyClass(DeviceIntPtr device, DeviceIntPtr master)
mk->sourceid = device->id; mk->sourceid = device->id;
if (!XkbCopyDeviceKeymap(master, device)) if (!XkbDeviceApplyKeymap(master, device->key->xkbInfo->desc))
FatalError("Couldn't pivot keymap from device to core!\n"); FatalError("Couldn't pivot keymap from device to core!\n");
} }
......
...@@ -824,8 +824,8 @@ extern _X_EXPORT void XkbSendNewKeyboardNotify(DeviceIntPtr /* kbd */ , ...@@ -824,8 +824,8 @@ extern _X_EXPORT void XkbSendNewKeyboardNotify(DeviceIntPtr /* kbd */ ,
extern Bool XkbCopyKeymap(XkbDescPtr /* dst */ , extern Bool XkbCopyKeymap(XkbDescPtr /* dst */ ,
XkbDescPtr /* src */ ); XkbDescPtr /* src */ );
extern _X_EXPORT Bool XkbCopyDeviceKeymap(DeviceIntPtr /* dst */ , extern _X_EXPORT Bool XkbDeviceApplyKeymap(DeviceIntPtr /* dst */ ,
DeviceIntPtr /* src */ ); XkbDescPtr /* src */ );
extern void XkbFilterEvents(ClientPtr /* pClient */ , extern void XkbFilterEvents(ClientPtr /* pClient */ ,
int /* nEvents */ , int /* nEvents */ ,
......
...@@ -5979,7 +5979,7 @@ ProcXkbGetKbdByName(ClientPtr client) ...@@ -5979,7 +5979,7 @@ ProcXkbGetKbdByName(ClientPtr client)
continue; continue;
if (tmpd != dev) if (tmpd != dev)
XkbCopyDeviceKeymap(tmpd, dev); XkbDeviceApplyKeymap(tmpd, xkb);
if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) { if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
old_sli = tmpd->kbdfeed->xkb_sli; old_sli = tmpd->kbdfeed->xkb_sli;
......
...@@ -1999,28 +1999,28 @@ XkbCopyKeymap(XkbDescPtr dst, XkbDescPtr src) ...@@ -1999,28 +1999,28 @@ XkbCopyKeymap(XkbDescPtr dst, XkbDescPtr src)
} }
Bool Bool
XkbCopyDeviceKeymap(DeviceIntPtr dst, DeviceIntPtr src) XkbDeviceApplyKeymap(DeviceIntPtr dst, XkbDescPtr desc)
{ {
xkbNewKeyboardNotify nkn; xkbNewKeyboardNotify nkn;
Bool ret; Bool ret;
if (!dst->key || !src->key) if (!dst->key || !desc)
return FALSE; return FALSE;
memset(&nkn, 0, sizeof(xkbNewKeyboardNotify)); memset(&nkn, 0, sizeof(xkbNewKeyboardNotify));
nkn.oldMinKeyCode = dst->key->xkbInfo->desc->min_key_code; nkn.oldMinKeyCode = dst->key->xkbInfo->desc->min_key_code;
nkn.oldMaxKeyCode = dst->key->xkbInfo->desc->max_key_code; nkn.oldMaxKeyCode = dst->key->xkbInfo->desc->max_key_code;
nkn.deviceID = dst->id; nkn.deviceID = dst->id;
nkn.oldDeviceID = dst->id; /* maybe src->id? */ nkn.oldDeviceID = dst->id;
nkn.minKeyCode = src->key->xkbInfo->desc->min_key_code; nkn.minKeyCode = desc->min_key_code;
nkn.maxKeyCode = src->key->xkbInfo->desc->max_key_code; nkn.maxKeyCode = desc->max_key_code;
nkn.requestMajor = XkbReqCode; nkn.requestMajor = XkbReqCode;
nkn.requestMinor = X_kbSetMap; /* Near enough's good enough. */ nkn.requestMinor = X_kbSetMap; /* Near enough's good enough. */
nkn.changed = XkbNKN_KeycodesMask; nkn.changed = XkbNKN_KeycodesMask;
if (src->key->xkbInfo->desc->geom) if (desc->geom)
nkn.changed |= XkbNKN_GeometryMask; nkn.changed |= XkbNKN_GeometryMask;
ret = XkbCopyKeymap(dst->key->xkbInfo->desc, src->key->xkbInfo->desc); ret = XkbCopyKeymap(dst->key->xkbInfo->desc, desc);
if (ret) if (ret)
XkbSendNewKeyboardNotify(dst, &nkn); XkbSendNewKeyboardNotify(dst, &nkn);
......
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