xkb: ProcXkbSetIndicatorMap should work on all attached SDs.

If called with XkbUseCoreKbd, run through all attached SDs and replicate the
call. This way, we keep the SDs in sync with the MD as long as core clients
control the MDs.
This commit is contained in:
Peter Hutterer 2008-08-01 16:38:59 +09:30
parent e8c2a3d7c9
commit a609dbed7c

View File

@ -3071,17 +3071,59 @@ XkbIndicatorPtr leds;
return XkbSendIndicatorMap(client,leds,&rep); return XkbSendIndicatorMap(client,leds,&rep);
} }
/* FIXME: Needs to set indicator map on all core-sending devices. */ /**
* Apply the given map to the given device. Which specifies which components
* to apply.
*/
static int
_XkbSetIndicatorMap(ClientPtr client, DeviceIntPtr dev,
int which, xkbIndicatorMapWireDesc *desc)
{
XkbSrvInfoPtr xkbi;
XkbSrvLedInfoPtr sli;
XkbEventCauseRec cause;
int i, bit;
xkbi = dev->key->xkbInfo;
sli= XkbFindSrvLedInfo(dev, XkbDfltXIClass, XkbDfltXIId,
XkbXI_IndicatorMapsMask);
if (!sli)
return BadAlloc;
for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
if (which & bit) {
sli->maps[i].flags = desc->flags;
sli->maps[i].which_groups = desc->whichGroups;
sli->maps[i].groups = desc->groups;
sli->maps[i].which_mods = desc->whichMods;
sli->maps[i].mods.mask = desc->mods;
sli->maps[i].mods.real_mods = desc->mods;
sli->maps[i].mods.vmods= desc->virtualMods;
sli->maps[i].ctrls = desc->ctrls;
if (desc->virtualMods!=0) {
unsigned tmp;
tmp= XkbMaskForVMask(xkbi->desc,desc->virtualMods);
sli->maps[i].mods.mask= desc->mods|tmp;
}
desc++;
}
}
XkbSetCauseXkbReq(&cause,X_kbSetIndicatorMap,client);
XkbApplyLedMapChanges(dev,sli,which,NULL,NULL,&cause);
return Success;
}
int int
ProcXkbSetIndicatorMap(ClientPtr client) ProcXkbSetIndicatorMap(ClientPtr client)
{ {
register int i,bit; int i, bit;
int nIndicators; int nIndicators;
DeviceIntPtr dev; DeviceIntPtr dev;
XkbSrvInfoPtr xkbi;
xkbIndicatorMapWireDesc *from; xkbIndicatorMapWireDesc *from;
XkbSrvLedInfoPtr sli; int rc;
XkbEventCauseRec cause;
REQUEST(xkbSetIndicatorMapReq); REQUEST(xkbSetIndicatorMapReq);
REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq); REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq);
@ -3091,8 +3133,6 @@ ProcXkbSetIndicatorMap(ClientPtr client)
CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess); CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixSetAttrAccess);
xkbi= dev->key->xkbInfo;
if (stuff->which==0) if (stuff->which==0)
return client->noClientException; return client->noClientException;
@ -3105,16 +3145,11 @@ ProcXkbSetIndicatorMap(ClientPtr client)
return BadLength; return BadLength;
} }
sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,
XkbXI_IndicatorMapsMask);
if (!sli)
return BadAlloc;
from = (xkbIndicatorMapWireDesc *)&stuff[1]; from = (xkbIndicatorMapWireDesc *)&stuff[1];
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) { for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
if (stuff->which&bit) { if (stuff->which&bit) {
if (client->swapped) { if (client->swapped) {
register int n; int n;
swaps(&from->virtualMods,n); swaps(&from->virtualMods,n);
swapl(&from->ctrls,n); swapl(&from->ctrls,n);
} }
@ -3125,28 +3160,25 @@ ProcXkbSetIndicatorMap(ClientPtr client)
} }
from = (xkbIndicatorMapWireDesc *)&stuff[1]; from = (xkbIndicatorMapWireDesc *)&stuff[1];
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) { rc = _XkbSetIndicatorMap(client, dev, stuff->which, from);
if (stuff->which&bit) { if (rc != Success)
sli->maps[i].flags = from->flags; return rc;
sli->maps[i].which_groups = from->whichGroups;
sli->maps[i].groups = from->groups; if (stuff->deviceSpec == XkbUseCoreKbd)
sli->maps[i].which_mods = from->whichMods; {
sli->maps[i].mods.mask = from->mods; DeviceIntPtr other;
sli->maps[i].mods.real_mods = from->mods; for (other = inputInfo.devices; other; other = other->next)
sli->maps[i].mods.vmods= from->virtualMods; {
sli->maps[i].ctrls = from->ctrls; if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
if (from->virtualMods!=0) { {
unsigned tmp; rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess);
tmp= XkbMaskForVMask(xkbi->desc,from->virtualMods); if (rc == Success)
sli->maps[i].mods.mask= from->mods|tmp; _XkbSetIndicatorMap(client, other, stuff->which, from);
} }
from++;
} }
} }
XkbSetCauseXkbReq(&cause,X_kbSetIndicatorMap,client); return Success;
XkbApplyLedMapChanges(dev,sli,stuff->which,NULL,NULL,&cause);
return client->noClientException;
} }
/***====================================================================***/ /***====================================================================***/