xenocara/xserver/xkb/xkbSwap.c

540 lines
14 KiB
C
Raw Normal View History

2006-11-26 11:13:41 -07:00
/************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution
2006-11-26 11:13:41 -07:00
of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability
2006-11-26 11:13:41 -07:00
of this software for any purpose. It is provided "as is"
without any express or implied warranty.
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2006-11-26 11:13:41 -07:00
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
2006-11-26 11:13:41 -07:00
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "stdio.h"
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "inputstr.h"
2007-11-24 10:55:21 -07:00
#include <xkbsrv.h>
#include "xkbstr.h"
2006-11-26 11:13:41 -07:00
#include "extnsionst.h"
#include "xkb.h"
/*
* REQUEST SWAPPING
*/
2006-11-26 11:13:41 -07:00
static int
SProcXkbUseExtension(ClientPtr client)
{
REQUEST(xkbUseExtensionReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbUseExtensionReq);
swaps(&stuff->wantedMajor);
swaps(&stuff->wantedMinor);
2006-11-26 11:13:41 -07:00
return ProcXkbUseExtension(client);
}
static int
SProcXkbSelectEvents(ClientPtr client)
{
REQUEST(xkbSelectEventsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSelectEventsReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->affectWhich);
swaps(&stuff->clear);
swaps(&stuff->selectAll);
swaps(&stuff->affectMap);
swaps(&stuff->map);
if ((stuff->affectWhich & (~XkbMapNotifyMask)) != 0) {
union {
BOOL *b;
CARD8 *c8;
CARD16 *c16;
CARD32 *c32;
} from;
register unsigned bit, ndx, maskLeft, dataLeft, size;
from.c8 = (CARD8 *) &stuff[1];
dataLeft = (stuff->length * 4) - SIZEOF(xkbSelectEventsReq);
maskLeft = (stuff->affectWhich & (~XkbMapNotifyMask));
for (ndx = 0, bit = 1; (maskLeft != 0); ndx++, bit <<= 1) {
if (((bit & maskLeft) == 0) || (ndx == XkbMapNotify))
continue;
maskLeft &= ~bit;
if ((stuff->selectAll & bit) || (stuff->clear & bit))
continue;
switch (ndx) {
case XkbNewKeyboardNotify:
case XkbStateNotify:
case XkbNamesNotify:
case XkbAccessXNotify:
case XkbExtensionDeviceNotify:
size = 2;
break;
case XkbControlsNotify:
case XkbIndicatorStateNotify:
case XkbIndicatorMapNotify:
size = 4;
break;
case XkbBellNotify:
case XkbActionMessage:
case XkbCompatMapNotify:
size = 1;
break;
default:
client->errorValue = _XkbErrCode2(0x1, bit);
return BadValue;
}
if (dataLeft < (size * 2))
return BadLength;
if (size == 2) {
swaps(&from.c16[0]);
swaps(&from.c16[1]);
}
else if (size == 4) {
swapl(&from.c32[0]);
swapl(&from.c32[1]);
}
else {
size = 2;
}
from.c8 += (size * 2);
dataLeft -= (size * 2);
}
if (dataLeft > 2) {
ErrorF("[xkb] Extra data (%d bytes) after SelectEvents\n",
dataLeft);
return BadLength;
}
2006-11-26 11:13:41 -07:00
}
return ProcXkbSelectEvents(client);
}
static int
SProcXkbBell(ClientPtr client)
{
REQUEST(xkbBellReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbBellReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->bellClass);
swaps(&stuff->bellID);
swapl(&stuff->name);
swapl(&stuff->window);
swaps(&stuff->pitch);
swaps(&stuff->duration);
2006-11-26 11:13:41 -07:00
return ProcXkbBell(client);
}
static int
SProcXkbGetState(ClientPtr client)
{
REQUEST(xkbGetStateReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetStateReq);
swaps(&stuff->deviceSpec);
2006-11-26 11:13:41 -07:00
return ProcXkbGetState(client);
}
static int
SProcXkbLatchLockState(ClientPtr client)
{
REQUEST(xkbLatchLockStateReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbLatchLockStateReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->groupLatch);
2006-11-26 11:13:41 -07:00
return ProcXkbLatchLockState(client);
}
static int
SProcXkbGetControls(ClientPtr client)
{
REQUEST(xkbGetControlsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetControlsReq);
swaps(&stuff->deviceSpec);
2006-11-26 11:13:41 -07:00
return ProcXkbGetControls(client);
}
static int
SProcXkbSetControls(ClientPtr client)
{
REQUEST(xkbSetControlsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbSetControlsReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->affectInternalVMods);
swaps(&stuff->internalVMods);
swaps(&stuff->affectIgnoreLockVMods);
swaps(&stuff->ignoreLockVMods);
swaps(&stuff->axOptions);
swapl(&stuff->affectEnabledCtrls);
swapl(&stuff->enabledCtrls);
swapl(&stuff->changeCtrls);
swaps(&stuff->repeatDelay);
swaps(&stuff->repeatInterval);
swaps(&stuff->slowKeysDelay);
swaps(&stuff->debounceDelay);
swaps(&stuff->mkDelay);
swaps(&stuff->mkInterval);
swaps(&stuff->mkTimeToMax);
swaps(&stuff->mkMaxSpeed);
swaps(&stuff->mkCurve);
swaps(&stuff->axTimeout);
swapl(&stuff->axtCtrlsMask);
swapl(&stuff->axtCtrlsValues);
swaps(&stuff->axtOptsMask);
swaps(&stuff->axtOptsValues);
2006-11-26 11:13:41 -07:00
return ProcXkbSetControls(client);
}
static int
SProcXkbGetMap(ClientPtr client)
{
REQUEST(xkbGetMapReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetMapReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->full);
swaps(&stuff->partial);
swaps(&stuff->virtualMods);
2006-11-26 11:13:41 -07:00
return ProcXkbGetMap(client);
}
static int
SProcXkbSetMap(ClientPtr client)
{
REQUEST(xkbSetMapReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSetMapReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->present);
swaps(&stuff->flags);
swaps(&stuff->totalSyms);
swaps(&stuff->totalActs);
swaps(&stuff->virtualMods);
2006-11-26 11:13:41 -07:00
return ProcXkbSetMap(client);
}
static int
SProcXkbGetCompatMap(ClientPtr client)
{
REQUEST(xkbGetCompatMapReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetCompatMapReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->firstSI);
swaps(&stuff->nSI);
2006-11-26 11:13:41 -07:00
return ProcXkbGetCompatMap(client);
}
static int
SProcXkbSetCompatMap(ClientPtr client)
{
REQUEST(xkbSetCompatMapReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSetCompatMapReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->firstSI);
swaps(&stuff->nSI);
2006-11-26 11:13:41 -07:00
return ProcXkbSetCompatMap(client);
}
static int
SProcXkbGetIndicatorState(ClientPtr client)
{
REQUEST(xkbGetIndicatorStateReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq);
swaps(&stuff->deviceSpec);
2006-11-26 11:13:41 -07:00
return ProcXkbGetIndicatorState(client);
}
static int
SProcXkbGetIndicatorMap(ClientPtr client)
{
REQUEST(xkbGetIndicatorMapReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetIndicatorMapReq);
swaps(&stuff->deviceSpec);
swapl(&stuff->which);
2006-11-26 11:13:41 -07:00
return ProcXkbGetIndicatorMap(client);
}
static int
SProcXkbSetIndicatorMap(ClientPtr client)
{
REQUEST(xkbSetIndicatorMapReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSetIndicatorMapReq);
swaps(&stuff->deviceSpec);
swapl(&stuff->which);
2006-11-26 11:13:41 -07:00
return ProcXkbSetIndicatorMap(client);
}
static int
SProcXkbGetNamedIndicator(ClientPtr client)
{
REQUEST(xkbGetNamedIndicatorReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetNamedIndicatorReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->ledClass);
swaps(&stuff->ledID);
swapl(&stuff->indicator);
2006-11-26 11:13:41 -07:00
return ProcXkbGetNamedIndicator(client);
}
static int
SProcXkbSetNamedIndicator(ClientPtr client)
{
REQUEST(xkbSetNamedIndicatorReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbSetNamedIndicatorReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->ledClass);
swaps(&stuff->ledID);
swapl(&stuff->indicator);
swaps(&stuff->virtualMods);
swapl(&stuff->ctrls);
2006-11-26 11:13:41 -07:00
return ProcXkbSetNamedIndicator(client);
}
static int
SProcXkbGetNames(ClientPtr client)
{
REQUEST(xkbGetNamesReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetNamesReq);
swaps(&stuff->deviceSpec);
swapl(&stuff->which);
2006-11-26 11:13:41 -07:00
return ProcXkbGetNames(client);
}
static int
SProcXkbSetNames(ClientPtr client)
{
REQUEST(xkbSetNamesReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSetNamesReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->virtualMods);
swapl(&stuff->which);
swapl(&stuff->indicators);
swaps(&stuff->totalKTLevelNames);
2006-11-26 11:13:41 -07:00
return ProcXkbSetNames(client);
}
static int
SProcXkbGetGeometry(ClientPtr client)
{
REQUEST(xkbGetGeometryReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetGeometryReq);
swaps(&stuff->deviceSpec);
swapl(&stuff->name);
2006-11-26 11:13:41 -07:00
return ProcXkbGetGeometry(client);
}
static int
SProcXkbSetGeometry(ClientPtr client)
{
REQUEST(xkbSetGeometryReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSetGeometryReq);
swaps(&stuff->deviceSpec);
swapl(&stuff->name);
swaps(&stuff->widthMM);
swaps(&stuff->heightMM);
swaps(&stuff->nProperties);
swaps(&stuff->nColors);
swaps(&stuff->nDoodads);
swaps(&stuff->nKeyAliases);
2006-11-26 11:13:41 -07:00
return ProcXkbSetGeometry(client);
}
static int
SProcXkbPerClientFlags(ClientPtr client)
{
REQUEST(xkbPerClientFlagsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbPerClientFlagsReq);
swaps(&stuff->deviceSpec);
swapl(&stuff->change);
swapl(&stuff->value);
swapl(&stuff->ctrlsToChange);
swapl(&stuff->autoCtrls);
swapl(&stuff->autoCtrlValues);
2006-11-26 11:13:41 -07:00
return ProcXkbPerClientFlags(client);
}
static int
SProcXkbListComponents(ClientPtr client)
{
REQUEST(xkbListComponentsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbListComponentsReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->maxNames);
2006-11-26 11:13:41 -07:00
return ProcXkbListComponents(client);
}
static int
SProcXkbGetKbdByName(ClientPtr client)
{
REQUEST(xkbGetKbdByNameReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->want);
swaps(&stuff->need);
2006-11-26 11:13:41 -07:00
return ProcXkbGetKbdByName(client);
}
static int
SProcXkbGetDeviceInfo(ClientPtr client)
{
REQUEST(xkbGetDeviceInfoReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_SIZE_MATCH(xkbGetDeviceInfoReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->wanted);
swaps(&stuff->ledClass);
swaps(&stuff->ledID);
2006-11-26 11:13:41 -07:00
return ProcXkbGetDeviceInfo(client);
}
static int
SProcXkbSetDeviceInfo(ClientPtr client)
{
REQUEST(xkbSetDeviceInfoReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSetDeviceInfoReq);
swaps(&stuff->deviceSpec);
swaps(&stuff->change);
swaps(&stuff->nDeviceLedFBs);
2006-11-26 11:13:41 -07:00
return ProcXkbSetDeviceInfo(client);
}
static int
SProcXkbSetDebuggingFlags(ClientPtr client)
{
REQUEST(xkbSetDebuggingFlagsReq);
swaps(&stuff->length);
2006-11-26 11:13:41 -07:00
REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq);
swapl(&stuff->affectFlags);
swapl(&stuff->flags);
swapl(&stuff->affectCtrls);
swapl(&stuff->ctrls);
swaps(&stuff->msgLength);
2006-11-26 11:13:41 -07:00
return ProcXkbSetDebuggingFlags(client);
}
int
SProcXkbDispatch(ClientPtr client)
2006-11-26 11:13:41 -07:00
{
REQUEST(xReq);
switch (stuff->data) {
2006-11-26 11:13:41 -07:00
case X_kbUseExtension:
return SProcXkbUseExtension(client);
2006-11-26 11:13:41 -07:00
case X_kbSelectEvents:
return SProcXkbSelectEvents(client);
2006-11-26 11:13:41 -07:00
case X_kbBell:
return SProcXkbBell(client);
2006-11-26 11:13:41 -07:00
case X_kbGetState:
return SProcXkbGetState(client);
2006-11-26 11:13:41 -07:00
case X_kbLatchLockState:
return SProcXkbLatchLockState(client);
2006-11-26 11:13:41 -07:00
case X_kbGetControls:
return SProcXkbGetControls(client);
2006-11-26 11:13:41 -07:00
case X_kbSetControls:
return SProcXkbSetControls(client);
2006-11-26 11:13:41 -07:00
case X_kbGetMap:
return SProcXkbGetMap(client);
2006-11-26 11:13:41 -07:00
case X_kbSetMap:
return SProcXkbSetMap(client);
2006-11-26 11:13:41 -07:00
case X_kbGetCompatMap:
return SProcXkbGetCompatMap(client);
2006-11-26 11:13:41 -07:00
case X_kbSetCompatMap:
return SProcXkbSetCompatMap(client);
2006-11-26 11:13:41 -07:00
case X_kbGetIndicatorState:
return SProcXkbGetIndicatorState(client);
2006-11-26 11:13:41 -07:00
case X_kbGetIndicatorMap:
return SProcXkbGetIndicatorMap(client);
2006-11-26 11:13:41 -07:00
case X_kbSetIndicatorMap:
return SProcXkbSetIndicatorMap(client);
2006-11-26 11:13:41 -07:00
case X_kbGetNamedIndicator:
return SProcXkbGetNamedIndicator(client);
2006-11-26 11:13:41 -07:00
case X_kbSetNamedIndicator:
return SProcXkbSetNamedIndicator(client);
2006-11-26 11:13:41 -07:00
case X_kbGetNames:
return SProcXkbGetNames(client);
2006-11-26 11:13:41 -07:00
case X_kbSetNames:
return SProcXkbSetNames(client);
2006-11-26 11:13:41 -07:00
case X_kbGetGeometry:
return SProcXkbGetGeometry(client);
2006-11-26 11:13:41 -07:00
case X_kbSetGeometry:
return SProcXkbSetGeometry(client);
2006-11-26 11:13:41 -07:00
case X_kbPerClientFlags:
return SProcXkbPerClientFlags(client);
2006-11-26 11:13:41 -07:00
case X_kbListComponents:
return SProcXkbListComponents(client);
2006-11-26 11:13:41 -07:00
case X_kbGetKbdByName:
return SProcXkbGetKbdByName(client);
2006-11-26 11:13:41 -07:00
case X_kbGetDeviceInfo:
return SProcXkbGetDeviceInfo(client);
2006-11-26 11:13:41 -07:00
case X_kbSetDeviceInfo:
return SProcXkbSetDeviceInfo(client);
2006-11-26 11:13:41 -07:00
case X_kbSetDebuggingFlags:
return SProcXkbSetDebuggingFlags(client);
2006-11-26 11:13:41 -07:00
default:
return BadRequest;
2006-11-26 11:13:41 -07:00
}
}