aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/xkb/xkb.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/xkb/xkb.c')
-rw-r--r--xorg-server/xkb/xkb.c160
1 files changed, 70 insertions, 90 deletions
diff --git a/xorg-server/xkb/xkb.c b/xorg-server/xkb/xkb.c
index 4ff2d5fef..0b54a2ec9 100644
--- a/xorg-server/xkb/xkb.c
+++ b/xorg-server/xkb/xkb.c
@@ -30,8 +30,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <stdio.h>
#include <X11/X.h>
-#define NEED_EVENTS
-#define NEED_REPLIES
#include <X11/Xproto.h>
#include "misc.h"
#include "inputstr.h"
@@ -42,12 +40,13 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "xkb.h"
#include <X11/extensions/XI.h>
+#include <X11/extensions/XKMformat.h>
- int XkbEventBase;
+int XkbEventBase;
static int XkbErrorBase;
- int XkbReqCode;
- int XkbKeyboardErrorCode;
-CARD32 xkbDebugFlags = 0;
+int XkbReqCode;
+int XkbKeyboardErrorCode;
+CARD32 xkbDebugFlags = 0;
static CARD32 xkbDebugCtrls = 0;
static RESTYPE RT_XKBCLIENT;
@@ -181,6 +180,7 @@ ProcXkbUseExtension(ClientPtr client)
stuff->wantedMajor,stuff->wantedMinor,
XkbMajorVersion,XkbMinorVersion);
}
+ memset(&rep, 0, sizeof(xkbUseExtensionReply));
rep.type = X_Reply;
rep.supported = supported;
rep.length = 0;
@@ -522,7 +522,7 @@ ProcXkbBell(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixBellAccess);
if (rc == Success)
@@ -561,7 +561,7 @@ ProcXkbGetState(ClientPtr client)
rep.sequenceNumber= client->sequence;
rep.length = 0;
rep.deviceID = dev->id;
- rep.mods = dev->key->state&0xff;
+ rep.mods = XkbStateFieldFromRec(xkb) & 0xff;
rep.baseMods = xkb->base_mods;
rep.lockedMods = xkb->locked_mods;
rep.latchedMods = xkb->latched_mods;
@@ -605,9 +605,8 @@ ProcXkbLatchLockState(ClientPtr client)
status = Success;
for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
- if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
- tmpd == dev) {
- if (!tmpd->key->xkbInfo)
+ if ((tmpd == dev) || (!IsMaster(tmpd) && tmpd->u.master == dev)) {
+ if (!tmpd->key || !tmpd->key->xkbInfo)
continue;
oldState = tmpd->key->xkbInfo->state;
@@ -628,7 +627,6 @@ ProcXkbLatchLockState(ClientPtr client)
return status;
XkbComputeDerivedState(tmpd->key->xkbInfo);
- tmpd->key->state = XkbStateFieldFromRec(newState);
changed = XkbStateChangedFlags(&oldState, newState);
if (changed) {
@@ -670,8 +668,8 @@ ProcXkbGetControls(ClientPtr client)
xkb = dev->key->xkbInfo->desc->ctrls;
rep.type = X_Reply;
- rep.length = (SIZEOF(xkbGetControlsReply)-
- SIZEOF(xGenericReply)) >> 2;
+ rep.length = bytes_to_int32(SIZEOF(xkbGetControlsReply)-
+ SIZEOF(xGenericReply));
rep.sequenceNumber = client->sequence;
rep.deviceID = ((DeviceIntPtr)dev)->id;
rep.numGroups = xkb->num_groups;
@@ -746,10 +744,10 @@ ProcXkbSetControls(ClientPtr client)
CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixManageAccess);
CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask);
- for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) {
- if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
- tmpd == dev) {
-
+ for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
+ if (!tmpd->key || !tmpd->key->xkbInfo)
+ continue;
+ if ((tmpd == dev) || (!IsMaster(tmpd) && tmpd->u.master == dev)) {
xkbi = tmpd->key->xkbInfo;
ctrl = xkbi->desc->ctrls;
new = *ctrl;
@@ -1366,7 +1364,7 @@ unsigned i,len;
char *desc,*start;
len= (rep->length*4)-(SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
- start= desc= (char *)xalloc(len);
+ start= desc= xcalloc(1, len);
if (!start)
return BadAlloc;
if ( rep->nTypes>0 )
@@ -2187,8 +2185,8 @@ unsigned first,last;
if (maxRG>(int)xkbi->nRadioGroups) {
int sz = maxRG*sizeof(XkbRadioGroupRec);
if (xkbi->radioGroups)
- xkbi->radioGroups=(XkbRadioGroupPtr)_XkbRealloc(xkbi->radioGroups,sz);
- else xkbi->radioGroups= (XkbRadioGroupPtr)_XkbCalloc(1, sz);
+ xkbi->radioGroups= xrealloc(xkbi->radioGroups,sz);
+ else xkbi->radioGroups= xcalloc(1, sz);
if (xkbi->radioGroups) {
if (xkbi->nRadioGroups)
bzero(&xkbi->radioGroups[xkbi->nRadioGroups],
@@ -2522,7 +2520,6 @@ _XkbSetMap(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq *req, char *values)
if (!sentNKN)
XkbSendNotification(dev,&change,&cause);
- XkbUpdateCoreDescription(dev,False);
return Success;
allocFailure:
return BadAlloc;
@@ -2560,7 +2557,7 @@ ProcXkbSetMap(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);
if (rc == Success)
@@ -2583,7 +2580,7 @@ ProcXkbSetMap(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);
if (rc == Success)
@@ -2631,7 +2628,7 @@ int size;
size= rep->length*4;
if (size>0) {
- data = (char *)xalloc(size);
+ data = xalloc(size);
if (data) {
register unsigned i,bit;
xkbModsWireDesc * grp;
@@ -2859,7 +2856,6 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev,
&cause);
if (check)
XkbCheckSecondaryEffects(xkbi,check,&change,&cause);
- XkbUpdateCoreDescription(dev,False);
XkbSendNotification(dev,&change,&cause);
}
return Success;
@@ -2891,7 +2887,7 @@ ProcXkbSetCompatMap(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);
if (rc == Success)
@@ -2914,7 +2910,7 @@ ProcXkbSetCompatMap(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);
if (rc == Success)
@@ -2999,7 +2995,7 @@ register unsigned bit;
length = rep->length*4;
if (length>0) {
CARD8 *to;
- to= map= (CARD8 *)xalloc(length);
+ to= map= xalloc(length);
if (map) {
xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to;
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
@@ -3169,7 +3165,7 @@ ProcXkbSetIndicatorMap(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess);
if (rc == Success)
@@ -3437,7 +3433,7 @@ ProcXkbSetNamedIndicator(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && !other->isMaster && (other->u.master == dev) &&
+ if ((other != dev) && !IsMaster(other) && (other->u.master == dev) &&
(other->kbdfeed || other->leds) &&
(XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess) == Success))
{
@@ -3461,7 +3457,7 @@ ProcXkbSetNamedIndicator(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && !other->isMaster && (other->u.master == dev) &&
+ if ((other != dev) && !IsMaster(other) && (other->u.master == dev) &&
(other->kbdfeed || other->leds) &&
(XaceHook(XACE_DEVICE_ACCESS, client, other, DixSetAttrAccess) == Success))
{
@@ -3635,7 +3631,7 @@ register int n;
swapl(&rep->indicators,n);
}
- start = desc = (char *)xalloc(length);
+ start = desc = xalloc(length);
if ( !start )
return BadAlloc;
if (xkb->names) {
@@ -3780,6 +3776,7 @@ ProcXkbGetNames(ClientPtr client)
CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask);
xkb = dev->key->xkbInfo->desc;
+ memset(&rep, 0, sizeof(xkbGetNamesReply));
rep.type= X_Reply;
rep.sequenceNumber= client->sequence;
rep.length = 0;
@@ -3860,7 +3857,7 @@ register int i,bit;
static Bool
_XkbCheckTypeName(Atom name,int typeNdx)
{
-char * str;
+const char * str;
str= NameForAtom(name);
if ((strcmp(str,"ONE_LEVEL")==0)||(strcmp(str,"TWO_LEVEL")==0)||
@@ -4120,7 +4117,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff)
tmp+= stuff->nKeyAliases*2;
}
else if (names->key_aliases!=NULL) {
- _XkbFree(names->key_aliases);
+ xfree(names->key_aliases);
names->key_aliases= NULL;
names->num_key_aliases= 0;
}
@@ -4139,7 +4136,7 @@ _XkbSetNames(ClientPtr client, DeviceIntPtr dev, xkbSetNamesReq *stuff)
tmp+= stuff->nRadioGroups;
}
else if (names->radio_groups) {
- _XkbFree(names->radio_groups);
+ xfree(names->radio_groups);
names->radio_groups= NULL;
names->num_rg= 0;
}
@@ -4251,7 +4248,7 @@ ProcXkbSetNames(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);
@@ -4276,7 +4273,7 @@ ProcXkbSetNames(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);
@@ -4739,7 +4736,7 @@ XkbSendGeometry( ClientPtr client,
if (geom!=NULL) {
len= rep->length*4;
- start= desc= (char *)xalloc(len);
+ start= desc= xalloc(len);
if (!start)
return BadAlloc;
desc= XkbWriteCountedString(desc,geom->label_font,client->swapped);
@@ -4833,7 +4830,7 @@ CARD16 len,*plen;
swaps(plen,n);
}
len= *plen;
- str= (char *)_XkbAlloc(len+1);
+ str= xalloc(len+1);
if (str) {
memcpy(str,&wire[2],len);
str[len]= '\0';
@@ -5327,7 +5324,7 @@ ProcXkbSetGeometry(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if ((other != dev) && other->key && !other->isMaster && (other->u.master == dev))
+ if ((other != dev) && other->key && !IsMaster(other) && (other->u.master == dev))
{
rc = XaceHook(XACE_DEVICE_ACCESS, client, other, DixManageAccess);
if (rc == Success)
@@ -5360,6 +5357,7 @@ ProcXkbPerClientFlags(ClientPtr client)
CHK_MASK_MATCH(0x02,stuff->change,stuff->value);
interest = XkbFindClientResource((DevicePtr)dev,client);
+ memset(&rep, 0, sizeof(xkbPerClientFlagsReply));
rep.type= X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@@ -5447,7 +5445,7 @@ unsigned char *wire,*str,*tmp,*legal;
wire= *pWire;
len= (*(unsigned char *)wire++);
if (len>0) {
- str= (unsigned char *)_XkbCalloc(1, len+1);
+ str= xcalloc(1, len+1);
if (str) {
tmp= str;
for (i=0;i<len;i++) {
@@ -5458,7 +5456,7 @@ unsigned char *wire,*str,*tmp,*legal;
if (tmp!=str)
*tmp++= '\0';
else {
- _XkbFree(str);
+ xfree(str);
str= NULL;
}
}
@@ -5497,7 +5495,6 @@ ProcXkbListComponents(ClientPtr client)
str= (unsigned char *)&stuff[1];
bzero(&list,sizeof(XkbSrvListInfoRec));
list.maxRtrn= stuff->maxNames;
- list.pattern[_XkbListKeymaps]= GetComponentSpec(&str,False,&status);
list.pattern[_XkbListKeycodes]= GetComponentSpec(&str,False,&status);
list.pattern[_XkbListTypes]= GetComponentSpec(&str,False,&status);
list.pattern[_XkbListCompat]= GetComponentSpec(&str,False,&status);
@@ -5510,7 +5507,7 @@ ProcXkbListComponents(ClientPtr client)
return BadLength;
if ((status=XkbDDXList(dev,&list,client))!=Success) {
if (list.pool) {
- _XkbFree(list.pool);
+ xfree(list.pool);
list.pool= NULL;
}
return status;
@@ -5520,7 +5517,7 @@ ProcXkbListComponents(ClientPtr client)
rep.deviceID = dev->id;
rep.sequenceNumber = client->sequence;
rep.length = XkbPaddedSize(list.nPool)/4;
- rep.nKeymaps = list.nFound[_XkbListKeymaps];
+ rep.nKeymaps = 0;
rep.nKeycodes = list.nFound[_XkbListKeycodes];
rep.nTypes = list.nFound[_XkbListTypes];
rep.nCompatMaps = list.nFound[_XkbListCompat];
@@ -5544,7 +5541,7 @@ ProcXkbListComponents(ClientPtr client)
WriteToClient(client,SIZEOF(xkbListComponentsReply),(char *)&rep);
if (list.nPool && list.pool) {
WriteToClient(client,XkbPaddedSize(list.nPool), (char *)list.pool);
- _XkbFree(list.pool);
+ xfree(list.pool);
list.pool= NULL;
}
return client->noClientException;
@@ -5586,7 +5583,8 @@ ProcXkbGetKbdByName(ClientPtr client)
xkb = dev->key->xkbInfo->desc;
status= Success;
str= (unsigned char *)&stuff[1];
- names.keymap= GetComponentSpec(&str,True,&status);
+ if (GetComponentSpec(&str,True,&status)) /* keymap, unsupported */
+ return BadMatch;
names.keycodes= GetComponentSpec(&str,True,&status);
names.types= GetComponentSpec(&str,True,&status);
names.compat= GetComponentSpec(&str,True,&status);
@@ -5840,16 +5838,9 @@ ProcXkbGetKbdByName(ClientPtr client)
xkb->ctrls->num_groups= nTG;
for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
- if (tmpd == dev ||
- (dev->id == inputInfo.keyboard->id && tmpd->key &&
- tmpd->coreEvents)) {
-
- memcpy(tmpd->key->modifierMap, xkb->map->modmap,
- xkb->max_key_code + 1);
+ if ((tmpd == dev) || (!IsMaster(tmpd) && tmpd->u.master == dev)) {
if (tmpd != dev)
- XkbCopyKeymap(dev->key->xkbInfo->desc,
- tmpd->key->xkbInfo->desc, True);
- XkbUpdateCoreDescription(tmpd, True);
+ XkbCopyDeviceKeymap(tmpd, dev);
if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
old_sli = tmpd->kbdfeed->xkb_sli;
@@ -5865,8 +5856,6 @@ ProcXkbGetKbdByName(ClientPtr client)
}
}
- /* this should be either a MN or an NKN, depending on whether or not
- * the keycode range changed? */
nkn.deviceID= nkn.oldDeviceID= dev->id;
nkn.minKeyCode= new->min_key_code;
nkn.maxKeyCode= new->max_key_code;
@@ -5878,17 +5867,26 @@ ProcXkbGetKbdByName(ClientPtr client)
if (geom_changed)
nkn.changed|= XkbNKN_GeometryMask;
XkbSendNewKeyboardNotify(dev,&nkn);
+
+ if (!IsMaster(dev) && dev->u.master)
+ {
+ DeviceIntPtr master = dev->u.master;
+ if (master->u.lastSlave == dev)
+ {
+ XkbCopyDeviceKeymap(dev->u.master, dev);
+ XkbSendNewKeyboardNotify(dev,&nkn);
+ }
+ }
}
if ((new!=NULL)&&(new!=xkb)) {
XkbFreeKeyboard(new,XkbAllComponentsMask,True);
new= NULL;
}
- if (names.keymap) { _XkbFree(names.keymap); names.keymap= NULL; }
- if (names.keycodes) { _XkbFree(names.keycodes); names.keycodes= NULL; }
- if (names.types) { _XkbFree(names.types); names.types= NULL; }
- if (names.compat) { _XkbFree(names.compat); names.compat= NULL; }
- if (names.symbols) { _XkbFree(names.symbols); names.symbols= NULL; }
- if (names.geometry) { _XkbFree(names.geometry); names.geometry= NULL; }
+ if (names.keycodes) { xfree(names.keycodes); names.keycodes= NULL; }
+ if (names.types) { xfree(names.types); names.types= NULL; }
+ if (names.compat) { xfree(names.compat); names.compat= NULL; }
+ if (names.symbols) { xfree(names.symbols); names.symbols= NULL; }
+ if (names.geometry) { xfree(names.geometry); names.geometry= NULL; }
return client->noClientException;
}
@@ -5974,10 +5972,8 @@ Bool classOk;
}
}
if (nFBs>0) {
- if (rep->supported&XkbXI_IndicatorsMask) {
- rep->nDeviceLedFBs= nFBs;
- rep->length+= (length/4);
- }
+ rep->nDeviceLedFBs= nFBs;
+ rep->length+= (length/4);
return Success;
}
if (classOk) client->errorValue= _XkbErrCode2(XkbErr_BadId,id);
@@ -6101,7 +6097,7 @@ xkbGetDeviceInfoReply rep;
int status,nDeviceLedFBs;
unsigned length,nameLen;
CARD16 ledClass,ledID;
-unsigned wanted,supported;
+unsigned wanted;
char * str;
REQUEST(xkbGetDeviceInfoReq);
@@ -6134,7 +6130,7 @@ char * str;
if (dev->button)
rep.totalBtns= dev->button->numButtons;
else rep.totalBtns= 0;
- rep.devType= dev->type;
+ rep.devType= dev->xinput_type;
rep.hasOwnState= (dev->key && dev->key->xkbInfo);
rep.nDeviceLedFBs = 0;
if (dev->kbdfeed) rep.dfltKbdFB= dev->kbdfeed->ctrl.id;
@@ -6192,7 +6188,6 @@ char * str;
return status;
}
length= rep.length*4;
- supported= rep.supported;
nDeviceLedFBs = rep.nDeviceLedFBs;
if (client->swapped) {
register int n;
@@ -6206,7 +6201,7 @@ char * str;
}
WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep);
- str= (char*) xalloc(nameLen);
+ str= xalloc(nameLen);
if (!str)
return BadAlloc;
XkbWriteCountedString(str,dev->name,client->swapped);
@@ -6232,19 +6227,6 @@ char * str;
ErrorF("[xkb] Wrote %d fewer bytes than expected\n",length);
return BadLength;
}
- if (stuff->wanted&(~supported)) {
- xkbExtensionDeviceNotify ed;
- bzero((char *)&ed,SIZEOF(xkbExtensionDeviceNotify));
- ed.ledClass= ledClass;
- ed.ledID= ledID;
- ed.ledsDefined= 0;
- ed.ledState= 0;
- ed.firstBtn= ed.nBtns= 0;
- ed.reason= XkbXI_UnsupportedFeatureMask;
- ed.supported= supported;
- ed.unsupported= stuff->wanted&(~supported);
- XkbSendExtensionDeviceNotify(dev,client,&ed);
- }
return client->noClientException;
}
@@ -6530,7 +6512,7 @@ ProcXkbSetDeviceInfo(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if (((other != dev) && !other->isMaster && (other->u.master == dev)) &&
+ if (((other != dev) && !IsMaster(other) && (other->u.master == dev)) &&
((stuff->deviceSpec == XkbUseCoreKbd && other->key) ||
(stuff->deviceSpec == XkbUseCorePtr && other->button)))
{
@@ -6555,7 +6537,7 @@ ProcXkbSetDeviceInfo(ClientPtr client)
DeviceIntPtr other;
for (other = inputInfo.devices; other; other = other->next)
{
- if (((other != dev) && !other->isMaster && (other->u.master == dev)) &&
+ if (((other != dev) && !IsMaster(other) && (other->u.master == dev)) &&
((stuff->deviceSpec == XkbUseCoreKbd && other->key) ||
(stuff->deviceSpec == XkbUseCorePtr && other->button)))
{
@@ -6617,8 +6599,6 @@ int rc;
xkbDebugFlags = newFlags;
xkbDebugCtrls = newCtrls;
- XkbDisableLockActions= (xkbDebugCtrls&XkbDF_DisableLocks);
-
rep.type= X_Reply;
rep.length = 0;
rep.sequenceNumber = client->sequence;