2003-11-14 16:54:54 +01:00
|
|
|
/************************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
2007-11-13 07:28:23 +01:00
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
2003-11-14 16:54:54 +01:00
|
|
|
provided that the above copyright notice appear in all copies and that
|
2007-11-13 07:28:23 +01:00
|
|
|
both that copyright notice and this permission notice appear in
|
2003-11-14 16:54:54 +01:00
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
2007-11-13 07:28:23 +01:00
|
|
|
software without specific, written prior permission.
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL 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 OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
********************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "resource.h"
|
|
|
|
#define NEED_EVENTS
|
|
|
|
#define NEED_REPLIES
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/Xproto.h>
|
2008-07-13 11:10:53 +02:00
|
|
|
#include <X11/Xatom.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "windowstr.h"
|
|
|
|
#include "inputstr.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "cursorstr.h"
|
|
|
|
#include "dixstruct.h"
|
2008-07-10 15:03:39 +02:00
|
|
|
#include "ptrveloc.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "site.h"
|
2006-06-07 21:33:44 +02:00
|
|
|
#ifndef XKB_IN_SERVER
|
2003-11-14 16:54:54 +01:00
|
|
|
#define XKB_IN_SERVER
|
2006-06-07 21:33:44 +02:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef XKB
|
2007-03-18 21:31:19 +01:00
|
|
|
#include <xkbsrv.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2007-04-04 21:59:51 +02:00
|
|
|
#include "privates.h"
|
2004-05-05 22:04:52 +02:00
|
|
|
#include "xace.h"
|
2008-05-20 03:37:39 +02:00
|
|
|
#include "mi.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "dispatch.h"
|
|
|
|
#include "swaprep.h"
|
|
|
|
#include "dixevents.h"
|
2008-06-14 03:01:50 +02:00
|
|
|
#include "mipointer.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2007-04-24 14:04:47 +02:00
|
|
|
#include <X11/extensions/XI.h>
|
2006-07-20 22:39:54 +02:00
|
|
|
#include <X11/extensions/XIproto.h>
|
|
|
|
#include "exglobals.h"
|
2006-10-08 19:32:16 +02:00
|
|
|
#include "exevents.h"
|
2007-11-12 02:05:18 +01:00
|
|
|
#include "listdev.h" /* for CopySwapXXXClass */
|
2008-07-07 14:40:17 +02:00
|
|
|
#include "xiproperty.h"
|
2008-11-14 06:44:29 +01:00
|
|
|
#include "enterleave.h" /* for EnterWindow() */
|
2008-09-23 09:25:04 +02:00
|
|
|
#include "xserver-properties.h"
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2007-06-19 08:01:56 +02:00
|
|
|
/** @file
|
|
|
|
* This file handles input device-related stuff.
|
|
|
|
*/
|
|
|
|
|
2008-08-29 00:05:40 +02:00
|
|
|
static int CoreDevicePrivateKeyIndex;
|
|
|
|
DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKeyIndex;
|
2008-04-13 12:18:28 +02:00
|
|
|
/* Used to sture classes currently not in use by an MD */
|
2008-08-29 00:05:40 +02:00
|
|
|
static int UnusedClassesPrivateKeyIndex;
|
|
|
|
DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKeyIndex;
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2008-07-13 11:10:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DIX property handler.
|
|
|
|
*/
|
2008-09-18 08:42:02 +02:00
|
|
|
static int
|
2008-10-08 05:42:21 +02:00
|
|
|
DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
|
|
|
|
BOOL checkonly)
|
2008-07-13 11:10:53 +02:00
|
|
|
{
|
|
|
|
if (property == XIGetKnownProperty(XI_PROP_ENABLED))
|
|
|
|
{
|
|
|
|
if (prop->format != 8 || prop->type != XA_INTEGER || prop->size != 1)
|
2008-09-18 08:42:02 +02:00
|
|
|
return BadValue;
|
2008-07-13 11:10:53 +02:00
|
|
|
|
2008-10-23 00:49:41 +02:00
|
|
|
/* Don't allow disabling of VCP/VCK */
|
|
|
|
if ((dev == inputInfo.pointer || dev == inputInfo.keyboard) &&
|
|
|
|
!(*(CARD8*)prop->data))
|
|
|
|
return BadAccess;
|
|
|
|
|
2008-10-08 05:42:21 +02:00
|
|
|
if (!checkonly)
|
|
|
|
{
|
|
|
|
if ((*((CARD8*)prop->data)) && !dev->enabled)
|
|
|
|
EnableDevice(dev);
|
|
|
|
else if (!(*((CARD8*)prop->data)) && dev->enabled)
|
|
|
|
DisableDevice(dev);
|
|
|
|
}
|
2008-07-13 11:10:53 +02:00
|
|
|
}
|
|
|
|
|
2008-09-18 08:42:02 +02:00
|
|
|
return Success;
|
2008-07-13 11:10:53 +02:00
|
|
|
}
|
|
|
|
|
2008-10-31 06:57:58 +01:00
|
|
|
/* Pair the keyboard to the pointer device. Keyboard events will follow the
|
|
|
|
* pointer sprite. Only applicable for master devices.
|
|
|
|
* If the client is set, the request to pair comes from some client. In this
|
|
|
|
* case, we need to check for access. If the client is NULL, it's from an
|
|
|
|
* internal automatic pairing, we must always permit this.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
PairDevices(ClientPtr client, DeviceIntPtr ptr, DeviceIntPtr kbd)
|
|
|
|
{
|
|
|
|
if (!ptr)
|
|
|
|
return BadDevice;
|
|
|
|
|
|
|
|
/* Don't allow pairing for slave devices */
|
|
|
|
if (!ptr->isMaster || !kbd->isMaster)
|
|
|
|
return BadDevice;
|
|
|
|
|
|
|
|
if (ptr->spriteInfo->paired)
|
|
|
|
return BadDevice;
|
|
|
|
|
|
|
|
if (kbd->spriteInfo->spriteOwner)
|
|
|
|
{
|
|
|
|
xfree(kbd->spriteInfo->sprite);
|
|
|
|
kbd->spriteInfo->sprite = NULL;
|
|
|
|
kbd->spriteInfo->spriteOwner = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
kbd->spriteInfo->sprite = ptr->spriteInfo->sprite;
|
|
|
|
kbd->spriteInfo->paired = ptr;
|
|
|
|
ptr->spriteInfo->paired = kbd;
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2008-07-13 11:10:53 +02:00
|
|
|
|
2008-10-31 07:20:28 +01:00
|
|
|
/**
|
|
|
|
* Find and return the next unpaired MD pointer device.
|
|
|
|
*/
|
|
|
|
static DeviceIntPtr
|
|
|
|
NextFreePointerDevice(void)
|
|
|
|
{
|
|
|
|
DeviceIntPtr dev;
|
|
|
|
for (dev = inputInfo.devices; dev; dev = dev->next)
|
|
|
|
if (dev->isMaster &&
|
|
|
|
dev->spriteInfo->spriteOwner &&
|
|
|
|
!dev->spriteInfo->paired)
|
|
|
|
return dev;
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-13 11:10:53 +02:00
|
|
|
|
2007-06-19 08:01:56 +02:00
|
|
|
/**
|
|
|
|
* Create a new input device and init it to sane values. The device is added
|
|
|
|
* to the server's off_devices list.
|
|
|
|
*
|
|
|
|
* @param deviceProc Callback for device control function (switch dev on/off).
|
|
|
|
* @return The newly created device.
|
|
|
|
*/
|
2003-11-14 17:49:22 +01:00
|
|
|
DeviceIntPtr
|
2008-01-21 14:13:53 +01:00
|
|
|
AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
DeviceIntPtr dev, *prev; /* not a typo */
|
2007-04-10 22:57:48 +02:00
|
|
|
DeviceIntPtr devtmp;
|
|
|
|
int devid;
|
2008-10-31 06:46:18 +01:00
|
|
|
char devind[MAXDEVICES];
|
2008-10-23 00:43:41 +02:00
|
|
|
BOOL enabled;
|
2007-04-10 22:57:48 +02:00
|
|
|
|
|
|
|
/* Find next available id */
|
2008-10-31 06:46:18 +01:00
|
|
|
memset(devind, 0, sizeof(char)*MAXDEVICES);
|
2007-04-10 22:57:48 +02:00
|
|
|
for (devtmp = inputInfo.devices; devtmp; devtmp = devtmp->next)
|
|
|
|
devind[devtmp->id]++;
|
|
|
|
for (devtmp = inputInfo.off_devices; devtmp; devtmp = devtmp->next)
|
|
|
|
devind[devtmp->id]++;
|
2008-10-31 06:46:18 +01:00
|
|
|
for (devid = 0; devid < MAXDEVICES && devind[devid]; devid++)
|
2007-04-10 22:57:48 +02:00
|
|
|
;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2008-10-31 06:46:18 +01:00
|
|
|
if (devid >= MAXDEVICES)
|
2003-11-14 17:49:22 +01:00
|
|
|
return (DeviceIntPtr)NULL;
|
2008-10-06 21:36:51 +02:00
|
|
|
dev = xcalloc(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), 1);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!dev)
|
2003-11-14 17:49:22 +01:00
|
|
|
return (DeviceIntPtr)NULL;
|
2007-04-10 22:57:48 +02:00
|
|
|
dev->id = devid;
|
2003-11-14 16:54:54 +01:00
|
|
|
dev->public.processInputProc = (ProcessInputProc)NoopDDA;
|
|
|
|
dev->public.realInputProc = (ProcessInputProc)NoopDDA;
|
|
|
|
dev->public.enqueueInputProc = EnqueueEvent;
|
|
|
|
dev->deviceProc = deviceProc;
|
|
|
|
dev->startup = autoStart;
|
2007-03-08 07:47:23 +01:00
|
|
|
|
|
|
|
/* device grab defaults */
|
|
|
|
dev->deviceGrab.grabTime = currentTime;
|
2008-10-06 21:36:51 +02:00
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
dev->coreEvents = TRUE;
|
2006-10-15 19:01:01 +02:00
|
|
|
|
2007-03-25 07:30:03 +02:00
|
|
|
/* sprite defaults */
|
2007-11-13 07:20:18 +01:00
|
|
|
dev->spriteInfo = (SpriteInfoPtr)&dev[1];
|
2008-07-07 14:40:17 +02:00
|
|
|
|
2007-10-02 19:39:25 +02:00
|
|
|
/* security creation/labeling check
|
|
|
|
*/
|
2008-05-14 07:47:05 +02:00
|
|
|
if (XaceHook(XACE_DEVICE_ACCESS, client, dev, DixCreateAccess)) {
|
2007-10-02 19:39:25 +02:00
|
|
|
xfree(dev);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
inputInfo.numDevices++;
|
|
|
|
|
2006-10-15 19:01:01 +02:00
|
|
|
for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next)
|
|
|
|
;
|
|
|
|
*prev = dev;
|
|
|
|
dev->next = NULL;
|
|
|
|
|
2008-10-23 13:37:37 +02:00
|
|
|
enabled = FALSE;
|
2008-07-13 11:10:53 +02:00
|
|
|
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
|
2008-10-23 00:43:41 +02:00
|
|
|
XA_INTEGER, 8, PropModeReplace, 1, &enabled,
|
2008-09-18 08:28:46 +02:00
|
|
|
FALSE);
|
2008-09-18 10:51:03 +02:00
|
|
|
XISetDevicePropertyDeletable(dev, XIGetKnownProperty(XI_PROP_ENABLED), FALSE);
|
|
|
|
XIRegisterPropertyHandler(dev, DeviceSetProperty, NULL, NULL);
|
2008-07-13 11:10:53 +02:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
return dev;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2007-04-09 11:02:00 +02:00
|
|
|
/**
|
2007-08-12 08:01:10 +02:00
|
|
|
* Enable the device through the driver, add the device to the device list.
|
2007-06-19 08:01:56 +02:00
|
|
|
* Switch device ON through the driver and push it onto the global device
|
2007-08-12 08:01:10 +02:00
|
|
|
* list. Initialize the DIX sprite or pair the device. All clients are
|
|
|
|
* notified about the device being enabled.
|
2007-06-19 08:01:56 +02:00
|
|
|
*
|
2007-10-16 04:00:32 +02:00
|
|
|
* A master pointer device needs to be enabled before a master keyboard
|
|
|
|
* device.
|
2007-11-13 07:28:23 +01:00
|
|
|
*
|
2007-06-19 08:01:56 +02:00
|
|
|
* @param The device to be enabled.
|
|
|
|
* @return TRUE on success or FALSE otherwise.
|
2007-04-09 11:02:00 +02:00
|
|
|
*/
|
2003-11-14 16:54:54 +01:00
|
|
|
Bool
|
2007-03-08 08:20:19 +01:00
|
|
|
EnableDevice(DeviceIntPtr dev)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
DeviceIntPtr *prev;
|
2006-07-20 22:39:54 +02:00
|
|
|
int ret;
|
2007-04-24 14:04:47 +02:00
|
|
|
DeviceIntRec dummyDev;
|
2007-10-16 04:00:32 +02:00
|
|
|
DeviceIntPtr other;
|
2007-04-24 14:04:47 +02:00
|
|
|
devicePresenceNotify ev;
|
2008-02-03 00:55:15 +01:00
|
|
|
int namelen = 0; /* dummy */
|
|
|
|
int evsize = sizeof(xEvent);
|
|
|
|
int listlen;
|
|
|
|
EventListPtr evlist;
|
2008-10-23 13:37:37 +02:00
|
|
|
BOOL enabled;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (prev = &inputInfo.off_devices;
|
|
|
|
*prev && (*prev != dev);
|
|
|
|
prev = &(*prev)->next)
|
|
|
|
;
|
2007-04-26 08:28:50 +02:00
|
|
|
|
2007-09-07 07:01:19 +02:00
|
|
|
if (!dev->spriteInfo->sprite)
|
|
|
|
{
|
2007-10-16 04:00:32 +02:00
|
|
|
if (dev->isMaster)
|
|
|
|
{
|
|
|
|
/* Sprites appear on first root window, so we can hardcode it */
|
|
|
|
if (dev->spriteInfo->spriteOwner)
|
2007-10-16 04:04:29 +02:00
|
|
|
{
|
2007-10-16 04:00:32 +02:00
|
|
|
InitializeSprite(dev, WindowTable[0]);
|
2008-11-14 06:44:29 +01:00
|
|
|
/* mode doesn't matter */
|
|
|
|
EnterWindow(dev, WindowTable[0], NotifyAncestor);
|
2007-10-16 04:04:29 +02:00
|
|
|
}
|
2007-10-16 04:00:32 +02:00
|
|
|
else if ((other = NextFreePointerDevice()) == NULL)
|
|
|
|
{
|
|
|
|
ErrorF("[dix] cannot find pointer to pair with. "
|
|
|
|
"This is a bug.\n");
|
|
|
|
return FALSE;
|
|
|
|
} else
|
|
|
|
PairDevices(NULL, other, dev);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
other = (IsPointerDevice(dev)) ? inputInfo.pointer :
|
|
|
|
inputInfo.keyboard;
|
|
|
|
AttachDevice(NULL, dev, other);
|
|
|
|
}
|
2007-09-07 07:01:19 +02:00
|
|
|
}
|
2007-04-26 08:28:50 +02:00
|
|
|
|
2008-02-03 00:55:15 +01:00
|
|
|
/* Before actually enabling the device, we need to make sure the event
|
|
|
|
* list's events have enough memory for a ClassesChangedEvent from the
|
|
|
|
* device
|
|
|
|
*/
|
|
|
|
|
|
|
|
SizeDeviceInfo(dev, &namelen, &evsize);
|
|
|
|
|
|
|
|
listlen = GetEventList(&evlist);
|
|
|
|
OsBlockSignals();
|
|
|
|
SetMinimumEventSize(evlist, listlen, evsize);
|
2008-04-30 10:27:48 +02:00
|
|
|
mieqResizeEvents(evsize);
|
2008-02-03 00:55:15 +01:00
|
|
|
OsReleaseSignals();
|
|
|
|
|
2008-07-13 11:10:53 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((*prev != dev) || !dev->inited ||
|
2006-07-20 22:39:54 +02:00
|
|
|
((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
|
2007-09-26 07:49:53 +02:00
|
|
|
ErrorF("[dix] couldn't enable device %d\n", dev->id);
|
2003-11-14 16:54:54 +01:00
|
|
|
return FALSE;
|
2006-07-20 22:39:54 +02:00
|
|
|
}
|
2006-10-19 23:28:40 +02:00
|
|
|
dev->enabled = TRUE;
|
2003-11-14 16:54:54 +01:00
|
|
|
*prev = dev->next;
|
2006-10-15 19:01:01 +02:00
|
|
|
|
|
|
|
for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next)
|
|
|
|
;
|
|
|
|
*prev = dev;
|
|
|
|
dev->next = NULL;
|
|
|
|
|
2008-10-23 13:37:37 +02:00
|
|
|
enabled = TRUE;
|
2008-07-13 11:10:53 +02:00
|
|
|
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
|
2008-10-23 13:37:37 +02:00
|
|
|
XA_INTEGER, 8, PropModeReplace, 1, &enabled,
|
2008-09-18 08:28:46 +02:00
|
|
|
TRUE);
|
2008-07-13 11:10:53 +02:00
|
|
|
|
2007-04-24 14:04:47 +02:00
|
|
|
ev.type = DevicePresenceNotify;
|
|
|
|
ev.time = currentTime.milliseconds;
|
|
|
|
ev.devchange = DeviceEnabled;
|
|
|
|
ev.deviceid = dev->id;
|
2008-10-31 06:46:18 +01:00
|
|
|
dummyDev.id = MAXDEVICES;
|
2007-04-24 14:04:47 +02:00
|
|
|
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
|
|
|
(xEvent *) &ev, 1);
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-04-09 11:02:00 +02:00
|
|
|
/**
|
2007-06-19 08:01:56 +02:00
|
|
|
* Switch a device off through the driver and push it onto the off_devices
|
|
|
|
* list. A device will not send events while disabled. All clients are
|
|
|
|
* notified about the device being disabled.
|
|
|
|
*
|
2007-10-16 04:00:32 +02:00
|
|
|
* Master keyboard devices have to be disabled before master pointer devices
|
|
|
|
* otherwise things turn bad.
|
|
|
|
*
|
2007-06-19 08:01:56 +02:00
|
|
|
* @return TRUE on success or FALSE otherwise.
|
|
|
|
*/
|
2003-11-14 16:54:54 +01:00
|
|
|
Bool
|
2007-03-08 08:20:19 +01:00
|
|
|
DisableDevice(DeviceIntPtr dev)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-10-16 04:00:32 +02:00
|
|
|
DeviceIntPtr *prev, other;
|
2007-04-24 14:04:47 +02:00
|
|
|
DeviceIntRec dummyDev;
|
|
|
|
devicePresenceNotify ev;
|
2008-10-23 13:37:37 +02:00
|
|
|
BOOL enabled;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (prev = &inputInfo.devices;
|
|
|
|
*prev && (*prev != dev);
|
|
|
|
prev = &(*prev)->next)
|
|
|
|
;
|
|
|
|
if (*prev != dev)
|
|
|
|
return FALSE;
|
2007-10-16 04:00:32 +02:00
|
|
|
|
2008-04-15 06:59:53 +02:00
|
|
|
/* float attached devices */
|
|
|
|
if (dev->isMaster)
|
|
|
|
{
|
|
|
|
for (other = inputInfo.devices; other; other = other->next)
|
|
|
|
{
|
|
|
|
if (other->u.master == dev)
|
|
|
|
AttachDevice(NULL, other, NULL);
|
|
|
|
}
|
|
|
|
}
|
2008-07-21 20:48:24 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
for (other = inputInfo.devices; other; other = other->next)
|
|
|
|
{
|
|
|
|
if (other->isMaster && other->u.lastSlave == dev)
|
|
|
|
other->u.lastSlave = NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-04-15 06:59:53 +02:00
|
|
|
|
2007-10-16 04:00:32 +02:00
|
|
|
if (dev->isMaster && dev->spriteInfo->sprite)
|
|
|
|
{
|
|
|
|
for (other = inputInfo.devices; other; other = other->next)
|
|
|
|
{
|
|
|
|
if (other->spriteInfo->paired == dev)
|
|
|
|
{
|
2007-11-13 07:28:23 +01:00
|
|
|
ErrorF("[dix] cannot disable device, still paired. "
|
2007-10-16 04:00:32 +02:00
|
|
|
"This is a bug. \n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
(void)(*dev->deviceProc)(dev, DEVICE_OFF);
|
2006-10-19 23:28:40 +02:00
|
|
|
dev->enabled = FALSE;
|
2003-11-14 16:54:54 +01:00
|
|
|
*prev = dev->next;
|
|
|
|
dev->next = inputInfo.off_devices;
|
|
|
|
inputInfo.off_devices = dev;
|
2007-04-24 14:04:47 +02:00
|
|
|
|
2008-10-23 13:37:37 +02:00
|
|
|
enabled = FALSE;
|
2008-07-13 11:10:53 +02:00
|
|
|
XIChangeDeviceProperty(dev, XIGetKnownProperty(XI_PROP_ENABLED),
|
2008-10-23 13:37:37 +02:00
|
|
|
XA_INTEGER, 8, PropModeReplace, 1, &enabled,
|
2008-09-18 08:28:46 +02:00
|
|
|
TRUE);
|
2008-07-13 11:10:53 +02:00
|
|
|
|
2007-04-24 14:04:47 +02:00
|
|
|
ev.type = DevicePresenceNotify;
|
|
|
|
ev.time = currentTime.milliseconds;
|
|
|
|
ev.devchange = DeviceDisabled;
|
|
|
|
ev.deviceid = dev->id;
|
2008-10-31 06:46:18 +01:00
|
|
|
dummyDev.id = MAXDEVICES;
|
2007-04-24 14:04:47 +02:00
|
|
|
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
|
|
|
(xEvent *) &ev, 1);
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-04-09 12:01:59 +02:00
|
|
|
/**
|
2007-06-19 08:01:56 +02:00
|
|
|
* Initialise a new device through the driver and tell all clients about the
|
|
|
|
* new device.
|
2007-11-13 07:28:23 +01:00
|
|
|
*
|
2007-04-09 12:01:59 +02:00
|
|
|
* Must be called before EnableDevice.
|
2007-06-19 08:01:56 +02:00
|
|
|
* The device will NOT send events until it is enabled!
|
|
|
|
*
|
|
|
|
* @return Success or an error code on failure.
|
2007-04-09 12:01:59 +02:00
|
|
|
*/
|
2006-07-20 22:39:54 +02:00
|
|
|
int
|
|
|
|
ActivateDevice(DeviceIntPtr dev)
|
|
|
|
{
|
|
|
|
int ret = Success;
|
|
|
|
devicePresenceNotify ev;
|
|
|
|
DeviceIntRec dummyDev;
|
2007-04-09 12:01:59 +02:00
|
|
|
ScreenPtr pScreen = screenInfo.screens[0];
|
2006-07-20 22:39:54 +02:00
|
|
|
|
|
|
|
if (!dev || !dev->deviceProc)
|
|
|
|
return BadImplementation;
|
|
|
|
|
|
|
|
ret = (*dev->deviceProc) (dev, DEVICE_INIT);
|
|
|
|
dev->inited = (ret == Success);
|
2008-12-23 00:59:28 +01:00
|
|
|
if (!dev->inited)
|
|
|
|
return ret;
|
2007-04-09 12:01:59 +02:00
|
|
|
|
|
|
|
/* Initialize memory for sprites. */
|
2007-10-16 04:00:32 +02:00
|
|
|
if (dev->isMaster && dev->spriteInfo->spriteOwner)
|
2007-04-09 12:01:59 +02:00
|
|
|
pScreen->DeviceCursorInitialize(dev, pScreen);
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
ev.type = DevicePresenceNotify;
|
|
|
|
ev.time = currentTime.milliseconds;
|
2007-04-24 14:04:47 +02:00
|
|
|
ev.devchange = DeviceAdded;
|
|
|
|
ev.deviceid = dev->id;
|
2008-05-31 02:54:37 +02:00
|
|
|
|
|
|
|
memset(&dummyDev, 0, sizeof(DeviceIntRec));
|
2008-10-31 06:46:18 +01:00
|
|
|
dummyDev.id = MAXDEVICES;
|
2006-07-20 22:39:54 +02:00
|
|
|
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
2006-10-08 19:32:16 +02:00
|
|
|
(xEvent *) &ev, 1);
|
2006-07-20 22:39:54 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-06-19 08:01:56 +02:00
|
|
|
/**
|
|
|
|
* Ring the bell.
|
|
|
|
* The actual task of ringing the bell is the job of the DDX.
|
|
|
|
*/
|
2006-07-20 22:39:54 +02:00
|
|
|
static void
|
2006-11-01 22:10:26 +01:00
|
|
|
CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer arg, int something)
|
2006-07-20 22:39:54 +02:00
|
|
|
{
|
2006-11-01 22:10:26 +01:00
|
|
|
KeybdCtrl *ctrl = arg;
|
|
|
|
|
|
|
|
DDXRingBell(volume, ctrl->bell_pitch, ctrl->bell_duration);
|
2006-07-20 22:39:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-06-19 08:01:56 +02:00
|
|
|
/**
|
2007-11-13 07:28:23 +01:00
|
|
|
* Device control function for the Virtual Core Keyboard.
|
2007-06-19 08:01:56 +02:00
|
|
|
*/
|
2006-07-20 22:39:54 +02:00
|
|
|
static int
|
|
|
|
CoreKeyboardProc(DeviceIntPtr pDev, int what)
|
|
|
|
{
|
|
|
|
CARD8 *modMap;
|
|
|
|
KeySymsRec keySyms;
|
|
|
|
#ifdef XKB
|
|
|
|
XkbComponentNamesRec names;
|
|
|
|
#endif
|
2007-11-09 13:40:24 +01:00
|
|
|
ClassesPtr classes;
|
2006-07-20 22:39:54 +02:00
|
|
|
|
|
|
|
switch (what) {
|
|
|
|
case DEVICE_INIT:
|
2008-01-03 07:34:54 +01:00
|
|
|
if (!(classes = xcalloc(1, sizeof(ClassesRec))))
|
|
|
|
{
|
|
|
|
ErrorF("[dix] Could not allocate device classes.\n");
|
|
|
|
return BadAlloc;
|
|
|
|
}
|
2007-11-09 13:40:24 +01:00
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
keySyms.minKeyCode = 8;
|
|
|
|
keySyms.maxKeyCode = 255;
|
|
|
|
keySyms.mapWidth = 4;
|
|
|
|
keySyms.map = (KeySym *)xcalloc(sizeof(KeySym),
|
|
|
|
(keySyms.maxKeyCode -
|
2007-03-25 01:11:33 +01:00
|
|
|
keySyms.minKeyCode + 1) *
|
2006-07-20 22:39:54 +02:00
|
|
|
keySyms.mapWidth);
|
|
|
|
if (!keySyms.map) {
|
2007-09-26 07:49:53 +02:00
|
|
|
ErrorF("[dix] Couldn't allocate core keymap\n");
|
2008-01-03 08:39:56 +01:00
|
|
|
xfree(classes);
|
2006-07-20 22:39:54 +02:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
2008-10-06 20:19:30 +02:00
|
|
|
modMap = xcalloc(1, MAP_LENGTH);
|
2006-07-20 22:39:54 +02:00
|
|
|
if (!modMap) {
|
2007-09-26 07:49:53 +02:00
|
|
|
ErrorF("[dix] Couldn't allocate core modifier map\n");
|
2008-01-03 08:39:56 +01:00
|
|
|
xfree(classes);
|
2006-07-20 22:39:54 +02:00
|
|
|
return BadAlloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XKB
|
|
|
|
if (!noXkbExtension) {
|
|
|
|
bzero(&names, sizeof(names));
|
|
|
|
XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, modMap,
|
|
|
|
CoreKeyboardBell, CoreKeyboardCtl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
2006-10-27 00:27:31 +02:00
|
|
|
{
|
|
|
|
/* FIXME Our keymap here isn't exactly useful. */
|
|
|
|
InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
|
|
|
|
CoreKeyboardBell, CoreKeyboardCtl);
|
|
|
|
}
|
2006-10-27 00:25:39 +02:00
|
|
|
|
|
|
|
xfree(keySyms.map);
|
|
|
|
xfree(modMap);
|
2006-07-20 22:39:54 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DEVICE_CLOSE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2007-06-19 08:01:56 +02:00
|
|
|
/**
|
|
|
|
* Device control function for the Virtual Core Pointer.
|
2007-11-13 07:28:23 +01:00
|
|
|
*
|
2007-11-09 13:40:24 +01:00
|
|
|
* Aside from initialisation, it backs up the original device classes into the
|
|
|
|
* devicePrivates. This only needs to be done for master devices.
|
2007-06-19 08:01:56 +02:00
|
|
|
*/
|
2006-07-20 22:39:54 +02:00
|
|
|
static int
|
|
|
|
CorePointerProc(DeviceIntPtr pDev, int what)
|
|
|
|
{
|
|
|
|
BYTE map[33];
|
|
|
|
int i = 0;
|
2007-11-09 13:40:24 +01:00
|
|
|
ClassesPtr classes;
|
2006-07-20 22:39:54 +02:00
|
|
|
|
|
|
|
switch (what) {
|
|
|
|
case DEVICE_INIT:
|
2008-01-03 07:34:54 +01:00
|
|
|
if (!(classes = xcalloc(1, sizeof(ClassesRec))))
|
2007-11-09 13:40:24 +01:00
|
|
|
return BadAlloc;
|
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
for (i = 1; i <= 32; i++)
|
|
|
|
map[i] = i;
|
|
|
|
InitPointerDeviceStruct((DevicePtr)pDev, map, 32,
|
2008-05-25 15:19:54 +02:00
|
|
|
(PtrCtrlProcPtr)NoopDDA,
|
2006-10-25 00:09:19 +02:00
|
|
|
GetMotionHistorySize(), 2);
|
2006-07-20 22:39:54 +02:00
|
|
|
pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
|
2008-05-23 04:21:53 +02:00
|
|
|
pDev->last.valuators[0] = pDev->valuator->axisVal[0];
|
2006-07-20 22:39:54 +02:00
|
|
|
pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
|
2008-05-23 04:21:53 +02:00
|
|
|
pDev->last.valuators[1] = pDev->valuator->axisVal[1];
|
2006-07-20 22:39:54 +02:00
|
|
|
break;
|
|
|
|
|
2006-08-10 13:00:34 +02:00
|
|
|
case DEVICE_CLOSE:
|
|
|
|
break;
|
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2007-04-09 11:02:00 +02:00
|
|
|
/**
|
2007-06-19 08:01:56 +02:00
|
|
|
* Initialise the two core devices, VCP and VCK (see events.c).
|
2007-04-09 11:02:00 +02:00
|
|
|
* Both devices are not tied to physical devices, but guarantee that there is
|
|
|
|
* always a keyboard and a pointer present and keep the protocol semantics.
|
2007-08-12 08:01:10 +02:00
|
|
|
*
|
2007-06-19 08:01:56 +02:00
|
|
|
* Note that the server MUST have two core devices at all times, even if there
|
|
|
|
* is no physical device connected.
|
2007-04-09 11:02:00 +02:00
|
|
|
*/
|
2006-07-20 22:39:54 +02:00
|
|
|
void
|
2007-04-09 23:33:15 +02:00
|
|
|
InitCoreDevices(void)
|
2006-07-20 22:39:54 +02:00
|
|
|
{
|
2008-01-21 14:13:53 +01:00
|
|
|
if (AllocMasterDevice(serverClient, "Virtual core",
|
2007-11-13 07:28:23 +01:00
|
|
|
&inputInfo.pointer,
|
2008-01-21 14:13:53 +01:00
|
|
|
&inputInfo.keyboard) != Success)
|
2007-10-16 11:16:12 +02:00
|
|
|
FatalError("Failed to allocate core devices");
|
2008-11-21 06:13:00 +01:00
|
|
|
|
|
|
|
ActivateDevice(inputInfo.pointer);
|
|
|
|
ActivateDevice(inputInfo.keyboard);
|
|
|
|
EnableDevice(inputInfo.pointer);
|
|
|
|
EnableDevice(inputInfo.keyboard);
|
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
}
|
|
|
|
|
2007-04-09 11:02:00 +02:00
|
|
|
/**
|
2007-06-19 08:01:56 +02:00
|
|
|
* Activate all switched-off devices and then enable all those devices.
|
2007-11-13 07:28:23 +01:00
|
|
|
*
|
2007-06-19 08:01:56 +02:00
|
|
|
* Will return an error if no core keyboard or core pointer is present.
|
|
|
|
* In theory this should never happen if you call InitCoreDevices() first.
|
2007-04-09 11:02:00 +02:00
|
|
|
*
|
2007-05-01 08:19:41 +02:00
|
|
|
* InitAndStartDevices needs to be called AFTER the windows are initialized.
|
|
|
|
* Devices will start sending events after InitAndStartDevices() has
|
|
|
|
* completed.
|
2007-11-13 07:28:23 +01:00
|
|
|
*
|
2007-06-19 08:01:56 +02:00
|
|
|
* @return Success or error code on failure.
|
2007-04-09 11:02:00 +02:00
|
|
|
*/
|
2008-11-26 01:42:52 +01:00
|
|
|
int
|
2008-05-14 07:59:28 +02:00
|
|
|
InitAndStartDevices()
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-07 08:49:20 +01:00
|
|
|
DeviceIntPtr dev, next;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
for (dev = inputInfo.off_devices; dev; dev = dev->next) {
|
2006-10-08 17:26:26 +02:00
|
|
|
DebugF("(dix) initialising device %d\n", dev->id);
|
2007-12-28 14:49:50 +01:00
|
|
|
if (!dev->inited)
|
|
|
|
ActivateDevice(dev);
|
2006-07-20 22:39:54 +02:00
|
|
|
}
|
2007-03-07 08:49:20 +01:00
|
|
|
|
2007-05-01 08:19:41 +02:00
|
|
|
/* enable real devices */
|
|
|
|
for (dev = inputInfo.off_devices; dev; dev = next)
|
|
|
|
{
|
|
|
|
DebugF("(dix) enabling device %d\n", dev->id);
|
|
|
|
next = dev->next;
|
|
|
|
if (dev->inited && dev->startup)
|
2008-11-26 01:42:52 +01:00
|
|
|
(void)EnableDevice(dev);
|
2007-05-01 08:19:41 +02:00
|
|
|
}
|
2008-11-26 01:42:52 +01:00
|
|
|
|
|
|
|
return Success;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2007-11-15 06:13:44 +01:00
|
|
|
/**
|
|
|
|
* Free the given device class and reset the pointer to NULL.
|
|
|
|
*/
|
2008-10-31 07:35:40 +01:00
|
|
|
static void
|
2007-11-15 06:13:44 +01:00
|
|
|
FreeDeviceClass(int type, pointer *class)
|
|
|
|
{
|
|
|
|
if (!(*class))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case KeyClass:
|
|
|
|
{
|
|
|
|
KeyClassPtr* k = (KeyClassPtr*)class;
|
|
|
|
#ifdef XKB
|
|
|
|
if ((*k)->xkbInfo)
|
2008-01-03 07:34:54 +01:00
|
|
|
{
|
2007-11-15 06:13:44 +01:00
|
|
|
XkbFreeInfo((*k)->xkbInfo);
|
2008-01-03 07:34:54 +01:00
|
|
|
(*k)->xkbInfo = NULL;
|
|
|
|
}
|
2007-11-15 06:13:44 +01:00
|
|
|
#endif
|
|
|
|
xfree((*k)->curKeySyms.map);
|
|
|
|
xfree((*k)->modifierKeyMap);
|
|
|
|
xfree((*k));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ButtonClass:
|
|
|
|
{
|
|
|
|
ButtonClassPtr *b = (ButtonClassPtr*)class;
|
|
|
|
#ifdef XKB
|
|
|
|
if ((*b)->xkb_acts)
|
|
|
|
xfree((*b)->xkb_acts);
|
|
|
|
#endif
|
|
|
|
xfree((*b));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ValuatorClass:
|
|
|
|
{
|
|
|
|
ValuatorClassPtr *v = (ValuatorClassPtr*)class;
|
|
|
|
|
|
|
|
/* Counterpart to 'biggest hack ever' in init. */
|
2008-05-25 15:19:54 +02:00
|
|
|
if ((*v)->motion)
|
2007-11-15 06:13:44 +01:00
|
|
|
xfree((*v)->motion);
|
|
|
|
xfree((*v));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FocusClass:
|
|
|
|
{
|
|
|
|
FocusClassPtr *f = (FocusClassPtr*)class;
|
|
|
|
xfree((*f)->trace);
|
|
|
|
xfree((*f));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ProximityClass:
|
|
|
|
{
|
|
|
|
ProximityClassPtr *p = (ProximityClassPtr*)class;
|
|
|
|
xfree((*p));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*class = NULL;
|
|
|
|
}
|
2008-10-31 07:35:40 +01:00
|
|
|
|
|
|
|
static void
|
2007-11-15 06:13:44 +01:00
|
|
|
FreeFeedbackClass(int type, pointer *class)
|
|
|
|
{
|
|
|
|
if (!(*class))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case KbdFeedbackClass:
|
|
|
|
{
|
|
|
|
KbdFeedbackPtr *kbdfeed = (KbdFeedbackPtr*)class;
|
|
|
|
KbdFeedbackPtr k, knext;
|
|
|
|
for (k = (*kbdfeed); k; k = knext) {
|
|
|
|
knext = k->next;
|
|
|
|
#ifdef XKB
|
|
|
|
if (k->xkb_sli)
|
|
|
|
XkbFreeSrvLedInfo(k->xkb_sli);
|
|
|
|
#endif
|
|
|
|
xfree(k);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PtrFeedbackClass:
|
|
|
|
{
|
|
|
|
PtrFeedbackPtr *ptrfeed = (PtrFeedbackPtr*)class;
|
|
|
|
PtrFeedbackPtr p, pnext;
|
|
|
|
|
|
|
|
for (p = (*ptrfeed); p; p = pnext) {
|
|
|
|
pnext = p->next;
|
|
|
|
xfree(p);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IntegerFeedbackClass:
|
|
|
|
{
|
|
|
|
IntegerFeedbackPtr *intfeed = (IntegerFeedbackPtr*)class;
|
|
|
|
IntegerFeedbackPtr i, inext;
|
|
|
|
|
|
|
|
for (i = (*intfeed); i; i = inext) {
|
|
|
|
inext = i->next;
|
|
|
|
xfree(i);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case StringFeedbackClass:
|
|
|
|
{
|
|
|
|
StringFeedbackPtr *stringfeed = (StringFeedbackPtr*)class;
|
|
|
|
StringFeedbackPtr s, snext;
|
|
|
|
|
|
|
|
for (s = (*stringfeed); s; s = snext) {
|
|
|
|
snext = s->next;
|
|
|
|
xfree(s->ctrl.symbols_supported);
|
|
|
|
xfree(s->ctrl.symbols_displayed);
|
|
|
|
xfree(s);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case BellFeedbackClass:
|
|
|
|
{
|
|
|
|
BellFeedbackPtr *bell = (BellFeedbackPtr*)class;
|
|
|
|
BellFeedbackPtr b, bnext;
|
|
|
|
|
|
|
|
for (b = (*bell); b; b = bnext) {
|
|
|
|
bnext = b->next;
|
|
|
|
xfree(b);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LedFeedbackClass:
|
|
|
|
{
|
|
|
|
LedFeedbackPtr *leds = (LedFeedbackPtr*)class;
|
|
|
|
LedFeedbackPtr l, lnext;
|
|
|
|
|
|
|
|
for (l = (*leds); l; l = lnext) {
|
|
|
|
lnext = l->next;
|
|
|
|
#ifdef XKB
|
|
|
|
if (l->xkb_sli)
|
|
|
|
XkbFreeSrvLedInfo(l->xkb_sli);
|
|
|
|
#endif
|
|
|
|
xfree(l);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*class = NULL;
|
|
|
|
}
|
2008-10-31 07:35:40 +01:00
|
|
|
|
|
|
|
static void
|
|
|
|
FreeAllDeviceClasses(ClassesPtr classes)
|
|
|
|
{
|
|
|
|
if (!classes)
|
|
|
|
return;
|
|
|
|
|
|
|
|
FreeDeviceClass(KeyClass, (pointer)&classes->key);
|
|
|
|
FreeDeviceClass(ValuatorClass, (pointer)&classes->valuator);
|
|
|
|
FreeDeviceClass(ButtonClass, (pointer)&classes->button);
|
|
|
|
FreeDeviceClass(FocusClass, (pointer)&classes->focus);
|
|
|
|
FreeDeviceClass(ProximityClass, (pointer)&classes->proximity);
|
|
|
|
|
|
|
|
FreeFeedbackClass(KbdFeedbackClass, (pointer)&classes->kbdfeed);
|
|
|
|
FreeFeedbackClass(PtrFeedbackClass, (pointer)&classes->ptrfeed);
|
|
|
|
FreeFeedbackClass(IntegerFeedbackClass, (pointer)&classes->intfeed);
|
|
|
|
FreeFeedbackClass(StringFeedbackClass, (pointer)&classes->stringfeed);
|
|
|
|
FreeFeedbackClass(BellFeedbackClass, (pointer)&classes->bell);
|
|
|
|
FreeFeedbackClass(LedFeedbackClass, (pointer)&classes->leds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-04-09 11:02:00 +02:00
|
|
|
/**
|
2007-11-13 07:28:23 +01:00
|
|
|
* Close down a device and free all resources.
|
2007-06-19 08:01:56 +02:00
|
|
|
* Once closed down, the driver will probably not expect you that you'll ever
|
|
|
|
* enable it again and free associated structs. If you want the device to just
|
|
|
|
* be disabled, DisableDevice().
|
|
|
|
* Don't call this function directly, use RemoveDevice() instead.
|
2007-04-09 11:02:00 +02:00
|
|
|
*/
|
2003-11-14 16:54:54 +01:00
|
|
|
static void
|
2007-03-08 08:20:19 +01:00
|
|
|
CloseDevice(DeviceIntPtr dev)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-04-09 12:01:59 +02:00
|
|
|
ScreenPtr screen = screenInfo.screens[0];
|
2007-11-09 13:40:24 +01:00
|
|
|
ClassesPtr classes;
|
2007-03-02 05:51:46 +01:00
|
|
|
int j;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2007-04-19 10:38:55 +02:00
|
|
|
if (!dev)
|
|
|
|
return;
|
|
|
|
|
2008-07-07 14:40:17 +02:00
|
|
|
XIDeleteAllDeviceProperties(dev);
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (dev->inited)
|
|
|
|
(void)(*dev->deviceProc)(dev, DEVICE_CLOSE);
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2007-04-09 12:01:59 +02:00
|
|
|
/* free sprite memory */
|
2007-10-14 00:22:11 +02:00
|
|
|
if (dev->isMaster && dev->spriteInfo->sprite)
|
2007-04-09 12:01:59 +02:00
|
|
|
screen->DeviceCursorCleanup(dev, screen);
|
|
|
|
|
2008-07-10 15:03:39 +02:00
|
|
|
/* free acceleration info */
|
|
|
|
if(dev->valuator && dev->valuator->accelScheme.AccelCleanupProc)
|
|
|
|
dev->valuator->accelScheme.AccelCleanupProc(dev);
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
xfree(dev->name);
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2007-11-16 02:42:41 +01:00
|
|
|
classes = (ClassesPtr)&dev->key;
|
2007-11-15 06:13:44 +01:00
|
|
|
FreeAllDeviceClasses(classes);
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2008-04-15 07:39:40 +02:00
|
|
|
if (dev->isMaster)
|
|
|
|
{
|
|
|
|
classes = dixLookupPrivate(&dev->devPrivates, UnusedClassesPrivateKey);
|
|
|
|
FreeAllDeviceClasses(classes);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef XKB
|
2006-07-20 22:39:54 +02:00
|
|
|
while (dev->xkb_interest)
|
2003-11-14 16:54:54 +01:00
|
|
|
XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
|
|
|
|
#endif
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2008-04-06 01:32:57 +02:00
|
|
|
if (DevHasCursor(dev) && dev->spriteInfo->sprite) {
|
2007-04-26 08:28:50 +02:00
|
|
|
xfree(dev->spriteInfo->sprite->spriteTrace);
|
|
|
|
xfree(dev->spriteInfo->sprite);
|
|
|
|
}
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2007-03-02 05:51:46 +01:00
|
|
|
/* a client may have the device set as client pointer */
|
|
|
|
for (j = 0; j < currentMaxClients; j++)
|
|
|
|
{
|
2007-05-14 03:12:03 +02:00
|
|
|
if (clients[j] && clients[j]->clientPtr == dev)
|
2007-04-09 10:57:22 +02:00
|
|
|
{
|
|
|
|
clients[j]->clientPtr = NULL;
|
|
|
|
clients[j]->clientPtr = PickPointer(clients[j]);
|
|
|
|
}
|
2007-03-02 05:51:46 +01:00
|
|
|
}
|
|
|
|
|
2007-03-08 07:47:23 +01:00
|
|
|
xfree(dev->deviceGrab.sync.event);
|
2007-08-28 15:28:25 +02:00
|
|
|
dixFreePrivates(dev->devPrivates);
|
2003-11-14 16:54:54 +01:00
|
|
|
xfree(dev);
|
|
|
|
}
|
|
|
|
|
2007-06-19 08:01:56 +02:00
|
|
|
/**
|
2007-11-13 07:28:23 +01:00
|
|
|
* Shut down all devices, free all resources, etc.
|
2007-06-19 08:01:56 +02:00
|
|
|
* Only useful if you're shutting down the server!
|
|
|
|
*/
|
2003-11-14 16:54:54 +01:00
|
|
|
void
|
2007-04-09 23:33:15 +02:00
|
|
|
CloseDownDevices(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
DeviceIntPtr dev, next;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2007-11-16 01:50:22 +01:00
|
|
|
/* Float all SDs before closing them. Note that at this point resources
|
|
|
|
* (e.g. cursors) have been freed already, so we can't just call
|
|
|
|
* AttachDevice(NULL, dev, NULL). Instead, we have to forcibly set master
|
|
|
|
* to NULL and pretend nothing happened.
|
|
|
|
*/
|
|
|
|
for (dev = inputInfo.devices; dev; dev = dev->next)
|
|
|
|
{
|
|
|
|
if (!dev->isMaster && dev->u.master)
|
|
|
|
dev->u.master = NULL;
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
for (dev = inputInfo.devices; dev; dev = next)
|
|
|
|
{
|
|
|
|
next = dev->next;
|
2008-02-22 01:31:51 +01:00
|
|
|
DeleteInputDeviceRequest(dev);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
for (dev = inputInfo.off_devices; dev; dev = next)
|
|
|
|
{
|
|
|
|
next = dev->next;
|
2008-02-22 01:31:51 +01:00
|
|
|
DeleteInputDeviceRequest(dev);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2007-09-06 09:57:28 +02:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
inputInfo.devices = NULL;
|
|
|
|
inputInfo.off_devices = NULL;
|
|
|
|
inputInfo.keyboard = NULL;
|
|
|
|
inputInfo.pointer = NULL;
|
2008-06-01 07:50:42 +02:00
|
|
|
#ifdef XKB
|
|
|
|
XkbDeleteRulesDflts();
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2007-04-09 12:01:59 +02:00
|
|
|
/**
|
|
|
|
* Remove the cursor sprite for all devices. This needs to be done before any
|
|
|
|
* resources are freed or any device is deleted.
|
|
|
|
*/
|
2007-11-13 07:28:23 +01:00
|
|
|
void
|
2007-04-09 12:01:59 +02:00
|
|
|
UndisplayDevices()
|
|
|
|
{
|
|
|
|
DeviceIntPtr dev;
|
|
|
|
ScreenPtr screen = screenInfo.screens[0];
|
|
|
|
|
|
|
|
for (dev = inputInfo.devices; dev; dev = dev->next)
|
2008-05-12 12:44:05 +02:00
|
|
|
screen->DisplayCursor(dev, screen, NullCursor);
|
2007-04-09 12:01:59 +02:00
|
|
|
}
|
|
|
|
|
2007-06-19 08:01:56 +02:00
|
|
|
/**
|
|
|
|
* Remove a device from the device list, closes it and thus frees all
|
2007-11-13 07:28:23 +01:00
|
|
|
* resources.
|
2007-06-19 08:01:56 +02:00
|
|
|
* Removes both enabled and disabled devices and notifies all devices about
|
|
|
|
* the removal of the device.
|
2008-04-28 04:07:52 +02:00
|
|
|
*
|
|
|
|
* No PresenceNotify is sent for device that the client never saw. This can
|
|
|
|
* happen if a malloc fails during the addition of master devices. If
|
|
|
|
* dev->init is FALSE it means the client never received a DeviceAdded event,
|
|
|
|
* so let's not send a DeviceRemoved event either.
|
2007-06-19 08:01:56 +02:00
|
|
|
*/
|
2006-07-20 22:39:54 +02:00
|
|
|
int
|
|
|
|
RemoveDevice(DeviceIntPtr dev)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-07-20 22:39:54 +02:00
|
|
|
DeviceIntPtr prev,tmp,next;
|
|
|
|
int ret = BadMatch;
|
|
|
|
devicePresenceNotify ev;
|
|
|
|
DeviceIntRec dummyDev;
|
2007-04-09 12:01:59 +02:00
|
|
|
ScreenPtr screen = screenInfo.screens[0];
|
2007-04-24 14:04:47 +02:00
|
|
|
int deviceid;
|
2008-04-28 04:07:52 +02:00
|
|
|
int initialized;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-10-08 17:26:26 +02:00
|
|
|
DebugF("(dix) removing device %d\n", dev->id);
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2006-08-07 22:02:17 +02:00
|
|
|
if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer)
|
2006-07-20 22:39:54 +02:00
|
|
|
return BadImplementation;
|
|
|
|
|
2008-04-28 04:07:52 +02:00
|
|
|
initialized = dev->inited;
|
2008-05-14 15:00:15 +02:00
|
|
|
if (DevHasCursor(dev))
|
|
|
|
screen->DisplayCursor(dev, screen, NullCursor);
|
2007-04-09 12:01:59 +02:00
|
|
|
|
2007-04-24 14:04:47 +02:00
|
|
|
deviceid = dev->id;
|
2007-04-24 15:22:33 +02:00
|
|
|
DisableDevice(dev);
|
2007-04-24 14:04:47 +02:00
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
prev = NULL;
|
|
|
|
for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
next = tmp->next;
|
2006-07-20 22:39:54 +02:00
|
|
|
if (tmp == dev) {
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (prev==NULL)
|
|
|
|
inputInfo.devices = next;
|
|
|
|
else
|
|
|
|
prev->next = next;
|
2006-07-20 22:39:54 +02:00
|
|
|
|
2007-04-09 12:01:59 +02:00
|
|
|
CloseDevice(tmp);
|
2006-07-20 22:39:54 +02:00
|
|
|
ret = Success;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
prev = NULL;
|
|
|
|
for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
next = tmp->next;
|
2006-07-20 22:39:54 +02:00
|
|
|
if (tmp == dev) {
|
2003-11-14 16:54:54 +01:00
|
|
|
CloseDevice(tmp);
|
2006-07-20 22:39:54 +02:00
|
|
|
|
|
|
|
if (prev == NULL)
|
2003-11-14 16:54:54 +01:00
|
|
|
inputInfo.off_devices = next;
|
|
|
|
else
|
|
|
|
prev->next = next;
|
2006-07-20 22:39:54 +02:00
|
|
|
|
|
|
|
ret = Success;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2008-04-28 04:07:52 +02:00
|
|
|
if (ret == Success && initialized) {
|
2007-04-10 22:57:48 +02:00
|
|
|
inputInfo.numDevices--;
|
2006-07-20 22:39:54 +02:00
|
|
|
ev.type = DevicePresenceNotify;
|
|
|
|
ev.time = currentTime.milliseconds;
|
2007-04-24 14:04:47 +02:00
|
|
|
ev.devchange = DeviceRemoved;
|
|
|
|
ev.deviceid = deviceid;
|
2008-10-31 06:46:18 +01:00
|
|
|
dummyDev.id = MAXDEVICES;
|
2006-07-20 22:39:54 +02:00
|
|
|
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
2006-10-08 19:32:16 +02:00
|
|
|
(xEvent *) &ev, 1);
|
2006-07-20 22:39:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2007-04-09 23:33:15 +02:00
|
|
|
NumMotionEvents(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-11-13 07:28:23 +01:00
|
|
|
/* only called to fill data in initial connection reply.
|
2007-03-02 07:44:37 +01:00
|
|
|
* VCP is ok here, it is the only fixed device we have. */
|
2003-11-14 16:54:54 +01:00
|
|
|
return inputInfo.pointer->valuator->numMotionEvents;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-06-01 21:22:38 +02:00
|
|
|
RegisterPointerDevice(DeviceIntPtr device)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-07-20 22:39:54 +02:00
|
|
|
RegisterOtherDevice(device);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-06-01 21:22:38 +02:00
|
|
|
RegisterKeyboardDevice(DeviceIntPtr device)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-07-20 22:39:54 +02:00
|
|
|
RegisterOtherDevice(device);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2007-09-28 14:02:00 +02:00
|
|
|
int
|
|
|
|
dixLookupDevice(DeviceIntPtr *pDev, int id, ClientPtr client, Mask access_mode)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
DeviceIntPtr dev;
|
2007-09-28 14:02:00 +02:00
|
|
|
int rc;
|
|
|
|
*pDev = NULL;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (dev=inputInfo.devices; dev; dev=dev->next) {
|
|
|
|
if (dev->id == (CARD8)id)
|
2007-09-28 14:02:00 +02:00
|
|
|
goto found;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
for (dev=inputInfo.off_devices; dev; dev=dev->next) {
|
|
|
|
if (dev->id == (CARD8)id)
|
2007-09-28 14:02:00 +02:00
|
|
|
goto found;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2007-09-28 14:02:00 +02:00
|
|
|
return BadDevice;
|
|
|
|
|
|
|
|
found:
|
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
|
|
|
|
if (rc == Success)
|
|
|
|
*pDev = dev;
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-03-08 00:02:59 +01:00
|
|
|
QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
if (inputInfo.keyboard) {
|
|
|
|
*minCode = inputInfo.keyboard->key->curKeySyms.minKeyCode;
|
|
|
|
*maxCode = inputInfo.keyboard->key->curKeySyms.maxKeyCode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
2007-03-08 08:20:19 +01:00
|
|
|
SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
int rowDif = src->minKeyCode - dst->minKeyCode;
|
|
|
|
|
2006-07-20 22:39:54 +02:00
|
|
|
/* if keysym map size changes, grow map first */
|
2003-11-14 16:54:54 +01:00
|
|
|
if (src->mapWidth < dst->mapWidth)
|
|
|
|
{
|
|
|
|
for (i = src->minKeyCode; i <= src->maxKeyCode; i++)
|
|
|
|
{
|
|
|
|
#define SI(r, c) (((r-src->minKeyCode)*src->mapWidth) + (c))
|
|
|
|
#define DI(r, c) (((r - dst->minKeyCode)*dst->mapWidth) + (c))
|
|
|
|
for (j = 0; j < src->mapWidth; j++)
|
|
|
|
dst->map[DI(i, j)] = src->map[SI(i, j)];
|
|
|
|
for (j = src->mapWidth; j < dst->mapWidth; j++)
|
|
|
|
dst->map[DI(i, j)] = NoSymbol;
|
|
|
|
#undef SI
|
|
|
|
#undef DI
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (src->mapWidth > dst->mapWidth)
|
|
|
|
{
|
|
|
|
KeySym *map;
|
|
|
|
int bytes = sizeof(KeySym) * src->mapWidth *
|
|
|
|
(dst->maxKeyCode - dst->minKeyCode + 1);
|
2007-11-15 06:53:48 +01:00
|
|
|
map = (KeySym *)xcalloc(1, bytes);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!map)
|
|
|
|
return FALSE;
|
|
|
|
if (dst->map)
|
|
|
|
{
|
|
|
|
for (i = 0; i <= dst->maxKeyCode-dst->minKeyCode; i++)
|
|
|
|
memmove((char *)&map[i*src->mapWidth],
|
|
|
|
(char *)&dst->map[i*dst->mapWidth],
|
|
|
|
dst->mapWidth * sizeof(KeySym));
|
|
|
|
xfree(dst->map);
|
|
|
|
}
|
|
|
|
dst->mapWidth = src->mapWidth;
|
|
|
|
dst->map = map;
|
2007-11-15 06:53:48 +01:00
|
|
|
} else if (!dst->map)
|
|
|
|
{
|
|
|
|
KeySym *map;
|
|
|
|
int bytes = sizeof(KeySym) * src->mapWidth *
|
|
|
|
(dst->maxKeyCode - dst->minKeyCode + 1);
|
|
|
|
map = (KeySym *)xcalloc(1, bytes);
|
|
|
|
if (!map)
|
|
|
|
return FALSE;
|
|
|
|
dst->map = map;
|
2008-06-04 03:40:46 +02:00
|
|
|
dst->mapWidth = src->mapWidth;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
memmove((char *)&dst->map[rowDif * dst->mapWidth],
|
|
|
|
(char *)src->map,
|
|
|
|
(int)(src->maxKeyCode - src->minKeyCode + 1) *
|
|
|
|
dst->mapWidth * sizeof(KeySym));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Bool
|
2007-03-08 08:20:19 +01:00
|
|
|
InitModMap(KeyClassPtr keyc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
CARD8 keysPerModifier[8];
|
|
|
|
CARD8 mask;
|
|
|
|
|
|
|
|
keyc->maxKeysPerModifier = 0;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
keysPerModifier[i] = 0;
|
|
|
|
for (i = 8; i < MAP_LENGTH; i++)
|
|
|
|
{
|
|
|
|
for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (mask & keyc->modifierMap[i])
|
|
|
|
{
|
|
|
|
if (++keysPerModifier[j] > keyc->maxKeysPerModifier)
|
|
|
|
keyc->maxKeysPerModifier = keysPerModifier[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-10-06 20:19:30 +02:00
|
|
|
keyc->modifierKeyMap = xcalloc(8, keyc->maxKeysPerModifier);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!keyc->modifierKeyMap && keyc->maxKeysPerModifier)
|
|
|
|
return (FALSE);
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
keysPerModifier[i] = 0;
|
|
|
|
for (i = 8; i < MAP_LENGTH; i++)
|
|
|
|
{
|
|
|
|
for (j = 0, mask = 1; j < 8; j++, mask <<= 1)
|
|
|
|
{
|
|
|
|
if (mask & keyc->modifierMap[i])
|
|
|
|
{
|
|
|
|
keyc->modifierKeyMap[(j*keyc->maxKeysPerModifier) +
|
|
|
|
keysPerModifier[j]] = i;
|
|
|
|
keysPerModifier[j]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2005-03-08 00:02:59 +01:00
|
|
|
InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers[])
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
KeyClassPtr keyc;
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2008-10-06 20:19:30 +02:00
|
|
|
keyc = xcalloc(1, sizeof(KeyClassRec));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!keyc)
|
|
|
|
return FALSE;
|
|
|
|
keyc->curKeySyms.minKeyCode = pKeySyms->minKeyCode;
|
|
|
|
keyc->curKeySyms.maxKeyCode = pKeySyms->maxKeyCode;
|
|
|
|
if (pModifiers)
|
|
|
|
memmove((char *)keyc->modifierMap, (char *)pModifiers, MAP_LENGTH);
|
|
|
|
if (!SetKeySymsMap(&keyc->curKeySyms, pKeySyms) || !InitModMap(keyc))
|
|
|
|
{
|
|
|
|
xfree(keyc->curKeySyms.map);
|
|
|
|
xfree(keyc->modifierKeyMap);
|
|
|
|
xfree(keyc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
dev->key = keyc;
|
|
|
|
#ifdef XKB
|
|
|
|
dev->key->xkbInfo= NULL;
|
|
|
|
if (!noXkbExtension) XkbInitDevice(dev);
|
|
|
|
#endif
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2007-11-13 07:28:23 +01:00
|
|
|
InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons,
|
2005-03-08 00:02:59 +01:00
|
|
|
CARD8 *map)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
ButtonClassPtr butc;
|
2003-11-14 16:54:54 +01:00
|
|
|
int i;
|
|
|
|
|
2008-10-06 20:19:30 +02:00
|
|
|
butc = xcalloc(1, sizeof(ButtonClassRec));
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!butc)
|
|
|
|
return FALSE;
|
|
|
|
butc->numButtons = numButtons;
|
|
|
|
for (i = 1; i <= numButtons; i++)
|
|
|
|
butc->map[i] = map[i];
|
|
|
|
dev->button = butc;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2007-11-13 07:28:23 +01:00
|
|
|
InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes,
|
2005-03-08 00:02:59 +01:00
|
|
|
int numMotionEvents, int mode)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
2007-03-08 08:20:19 +01:00
|
|
|
ValuatorClassPtr valc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-07-21 00:38:57 +02:00
|
|
|
if (!dev)
|
|
|
|
return FALSE;
|
|
|
|
|
2008-09-18 07:21:15 +02:00
|
|
|
valc = (ValuatorClassPtr)xcalloc(1, sizeof(ValuatorClassRec) +
|
2003-11-14 16:54:54 +01:00
|
|
|
numAxes * sizeof(AxisInfo) +
|
|
|
|
numAxes * sizeof(unsigned int));
|
|
|
|
if (!valc)
|
|
|
|
return FALSE;
|
2006-10-25 00:08:29 +02:00
|
|
|
|
|
|
|
valc->motion = NULL;
|
|
|
|
valc->first_motion = 0;
|
|
|
|
valc->last_motion = 0;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
valc->numMotionEvents = numMotionEvents;
|
|
|
|
valc->motionHintWindow = NullWindow;
|
|
|
|
valc->numAxes = numAxes;
|
|
|
|
valc->mode = mode;
|
|
|
|
valc->axes = (AxisInfoPtr)(valc + 1);
|
|
|
|
valc->axisVal = (int *)(valc->axes + numAxes);
|
|
|
|
dev->valuator = valc;
|
2006-10-25 00:08:29 +02:00
|
|
|
|
2008-05-25 15:19:54 +02:00
|
|
|
AllocateMotionHistory(dev);
|
2006-10-25 00:08:29 +02:00
|
|
|
|
2006-07-21 00:38:57 +02:00
|
|
|
for (i=0; i<numAxes; i++) {
|
2008-04-30 04:15:19 +02:00
|
|
|
InitValuatorAxisStruct(dev, i, NO_AXIS_LIMITS, NO_AXIS_LIMITS,
|
|
|
|
0, 0, 0);
|
2006-07-21 00:38:57 +02:00
|
|
|
valc->axisVal[i]=0;
|
|
|
|
}
|
2008-05-23 04:21:53 +02:00
|
|
|
|
|
|
|
dev->last.numValuators = numAxes;
|
2008-09-28 15:02:44 +02:00
|
|
|
if(dev->isMaster) /* master devs do not accelerate */
|
|
|
|
InitPointerAccelerationScheme(dev, PtrAccelNoOp);
|
|
|
|
else
|
2008-07-10 15:03:39 +02:00
|
|
|
InitPointerAccelerationScheme(dev, PtrAccelDefault);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* global list of acceleration schemes */
|
|
|
|
ValuatorAccelerationRec pointerAccelerationScheme[] = {
|
|
|
|
{PtrAccelNoOp, NULL, NULL, NULL},
|
|
|
|
{PtrAccelPredictable, acceleratePointerPredictable, NULL, AccelerationDefaultCleanup},
|
2008-07-23 11:10:22 +02:00
|
|
|
{PtrAccelLightweight, acceleratePointerLightweight, NULL, NULL},
|
2008-07-10 15:03:39 +02:00
|
|
|
{-1, NULL, NULL, NULL} /* terminator */
|
|
|
|
};
|
|
|
|
|
2008-07-23 11:10:22 +02:00
|
|
|
/**
|
2008-11-19 06:05:50 +01:00
|
|
|
* install an acceleration scheme. returns TRUE on success, and should not
|
2008-07-23 11:10:22 +02:00
|
|
|
* change anything if unsuccessful.
|
|
|
|
*/
|
2008-07-10 15:03:39 +02:00
|
|
|
_X_EXPORT Bool
|
|
|
|
InitPointerAccelerationScheme(DeviceIntPtr dev,
|
|
|
|
int scheme)
|
|
|
|
{
|
|
|
|
int x, i = -1;
|
|
|
|
void* data = NULL;
|
|
|
|
ValuatorClassPtr val;
|
|
|
|
|
2008-07-23 11:10:22 +02:00
|
|
|
val = dev->valuator;
|
|
|
|
|
2008-09-28 15:02:44 +02:00
|
|
|
if(!val)
|
2008-07-10 15:03:39 +02:00
|
|
|
return FALSE;
|
|
|
|
|
2008-09-28 15:02:44 +02:00
|
|
|
if(dev->isMaster && (scheme != PtrAccelNoOp))
|
|
|
|
scheme = PtrAccelNoOp; /* no accel for master devices */
|
|
|
|
|
2008-07-10 15:03:39 +02:00
|
|
|
for(x = 0; pointerAccelerationScheme[x].number >= 0; x++) {
|
|
|
|
if(pointerAccelerationScheme[x].number == scheme){
|
|
|
|
i = x;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(-1 == i)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
/* init scheme-specific data */
|
|
|
|
switch(scheme){
|
|
|
|
case PtrAccelPredictable:
|
|
|
|
{
|
|
|
|
DeviceVelocityPtr s;
|
|
|
|
s = (DeviceVelocityPtr)xalloc(sizeof(DeviceVelocityRec));
|
2008-07-23 11:10:22 +02:00
|
|
|
if(!s)
|
|
|
|
return FALSE;
|
2008-07-10 15:03:39 +02:00
|
|
|
InitVelocityData(s);
|
|
|
|
data = s;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
val->accelScheme = pointerAccelerationScheme[i];
|
|
|
|
val->accelScheme.accelData = data;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-07-20 22:45:15 +02:00
|
|
|
_X_EXPORT Bool
|
2006-10-21 10:24:49 +02:00
|
|
|
InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
|
2006-07-20 22:45:15 +02:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
AbsoluteClassPtr abs;
|
2006-07-20 22:45:15 +02:00
|
|
|
|
2006-10-21 10:24:49 +02:00
|
|
|
abs = (AbsoluteClassPtr)xalloc(sizeof(AbsoluteClassRec));
|
|
|
|
if (!abs)
|
2006-07-20 22:45:15 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* we don't do anything sensible with these, but should */
|
2008-04-30 04:15:19 +02:00
|
|
|
abs->min_x = NO_AXIS_LIMITS;
|
|
|
|
abs->min_y = NO_AXIS_LIMITS;
|
|
|
|
abs->max_x = NO_AXIS_LIMITS;
|
|
|
|
abs->max_y = NO_AXIS_LIMITS;
|
2006-10-21 10:24:49 +02:00
|
|
|
abs->flip_x = 0;
|
|
|
|
abs->flip_y = 0;
|
|
|
|
abs->rotation = 0;
|
|
|
|
abs->button_threshold = 0;
|
|
|
|
|
|
|
|
abs->offset_x = 0;
|
|
|
|
abs->offset_y = 0;
|
2008-04-30 04:15:19 +02:00
|
|
|
abs->width = NO_AXIS_LIMITS;
|
|
|
|
abs->height = NO_AXIS_LIMITS;
|
2006-10-21 10:24:49 +02:00
|
|
|
abs->following = 0;
|
2007-06-04 12:39:02 +02:00
|
|
|
abs->screen = 0;
|
2006-10-21 10:24:49 +02:00
|
|
|
|
|
|
|
dev->absolute = abs;
|
2006-07-20 22:45:15 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2005-03-08 00:02:59 +01:00
|
|
|
InitFocusClassDeviceStruct(DeviceIntPtr dev)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
FocusClassPtr focc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
focc = (FocusClassPtr)xalloc(sizeof(FocusClassRec));
|
|
|
|
if (!focc)
|
|
|
|
return FALSE;
|
|
|
|
focc->win = PointerRootWin;
|
|
|
|
focc->revert = None;
|
|
|
|
focc->time = currentTime;
|
|
|
|
focc->trace = (WindowPtr *)NULL;
|
|
|
|
focc->traceSize = 0;
|
|
|
|
focc->traceGood = 0;
|
|
|
|
dev->focus = focc;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2007-11-13 07:28:23 +01:00
|
|
|
InitKbdFeedbackClassDeviceStruct(DeviceIntPtr dev, BellProcPtr bellProc,
|
2005-03-08 00:02:59 +01:00
|
|
|
KbdCtrlProcPtr controlProc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
KbdFeedbackPtr feedc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
feedc = (KbdFeedbackPtr)xalloc(sizeof(KbdFeedbackClassRec));
|
|
|
|
if (!feedc)
|
|
|
|
return FALSE;
|
|
|
|
feedc->BellProc = bellProc;
|
|
|
|
feedc->CtrlProc = controlProc;
|
|
|
|
#ifdef XKB
|
|
|
|
defaultKeyboardControl.autoRepeat = TRUE;
|
|
|
|
#endif
|
|
|
|
feedc->ctrl = defaultKeyboardControl;
|
|
|
|
feedc->ctrl.id = 0;
|
2003-11-14 17:49:22 +01:00
|
|
|
if ((feedc->next = dev->kbdfeed) != 0)
|
2003-11-14 16:54:54 +01:00
|
|
|
feedc->ctrl.id = dev->kbdfeed->ctrl.id + 1;
|
|
|
|
dev->kbdfeed = feedc;
|
|
|
|
#ifdef XKB
|
|
|
|
feedc->xkb_sli= NULL;
|
|
|
|
if (!noXkbExtension)
|
|
|
|
XkbFinishDeviceInit(dev);
|
|
|
|
#endif
|
|
|
|
(*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2005-03-08 00:02:59 +01:00
|
|
|
InitPtrFeedbackClassDeviceStruct(DeviceIntPtr dev, PtrCtrlProcPtr controlProc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
PtrFeedbackPtr feedc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
feedc = (PtrFeedbackPtr)xalloc(sizeof(PtrFeedbackClassRec));
|
|
|
|
if (!feedc)
|
|
|
|
return FALSE;
|
|
|
|
feedc->CtrlProc = controlProc;
|
|
|
|
feedc->ctrl = defaultPointerControl;
|
|
|
|
feedc->ctrl.id = 0;
|
|
|
|
if ( (feedc->next = dev->ptrfeed) )
|
|
|
|
feedc->ctrl.id = dev->ptrfeed->ctrl.id + 1;
|
|
|
|
dev->ptrfeed = feedc;
|
|
|
|
(*controlProc)(dev, &feedc->ctrl);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-25 18:27:01 +02:00
|
|
|
static LedCtrl defaultLedControl = {
|
2003-11-14 16:54:54 +01:00
|
|
|
DEFAULT_LEDS, DEFAULT_LEDS_MASK, 0};
|
|
|
|
|
2007-03-25 18:27:01 +02:00
|
|
|
static BellCtrl defaultBellControl = {
|
2003-11-14 16:54:54 +01:00
|
|
|
DEFAULT_BELL,
|
|
|
|
DEFAULT_BELL_PITCH,
|
|
|
|
DEFAULT_BELL_DURATION,
|
|
|
|
0};
|
|
|
|
|
2007-03-25 18:27:01 +02:00
|
|
|
static IntegerCtrl defaultIntegerControl = {
|
2003-11-14 16:54:54 +01:00
|
|
|
DEFAULT_INT_RESOLUTION,
|
|
|
|
DEFAULT_INT_MIN_VALUE,
|
|
|
|
DEFAULT_INT_MAX_VALUE,
|
|
|
|
DEFAULT_INT_DISPLAYED,
|
|
|
|
0};
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2005-03-08 00:02:59 +01:00
|
|
|
InitStringFeedbackClassDeviceStruct (
|
2007-11-13 07:28:23 +01:00
|
|
|
DeviceIntPtr dev, StringCtrlProcPtr controlProc,
|
2005-03-08 00:02:59 +01:00
|
|
|
int max_symbols, int num_symbols_supported, KeySym *symbols)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
2007-03-08 08:20:19 +01:00
|
|
|
StringFeedbackPtr feedc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
feedc = (StringFeedbackPtr)xalloc(sizeof(StringFeedbackClassRec));
|
|
|
|
if (!feedc)
|
|
|
|
return FALSE;
|
|
|
|
feedc->CtrlProc = controlProc;
|
|
|
|
feedc->ctrl.num_symbols_supported = num_symbols_supported;
|
|
|
|
feedc->ctrl.num_symbols_displayed = 0;
|
|
|
|
feedc->ctrl.max_symbols = max_symbols;
|
2007-11-13 07:28:23 +01:00
|
|
|
feedc->ctrl.symbols_supported = (KeySym *)
|
2003-11-14 16:54:54 +01:00
|
|
|
xalloc (sizeof (KeySym) * num_symbols_supported);
|
2007-11-13 07:28:23 +01:00
|
|
|
feedc->ctrl.symbols_displayed = (KeySym *)
|
2003-11-14 16:54:54 +01:00
|
|
|
xalloc (sizeof (KeySym) * max_symbols);
|
|
|
|
if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed)
|
|
|
|
{
|
|
|
|
if (feedc->ctrl.symbols_supported)
|
|
|
|
xfree(feedc->ctrl.symbols_supported);
|
|
|
|
if (feedc->ctrl.symbols_displayed)
|
|
|
|
xfree(feedc->ctrl.symbols_displayed);
|
|
|
|
xfree(feedc);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
for (i=0; i<num_symbols_supported; i++)
|
|
|
|
*(feedc->ctrl.symbols_supported+i) = *symbols++;
|
|
|
|
for (i=0; i<max_symbols; i++)
|
|
|
|
*(feedc->ctrl.symbols_displayed+i) = (KeySym) NULL;
|
|
|
|
feedc->ctrl.id = 0;
|
|
|
|
if ( (feedc->next = dev->stringfeed) )
|
|
|
|
feedc->ctrl.id = dev->stringfeed->ctrl.id + 1;
|
|
|
|
dev->stringfeed = feedc;
|
|
|
|
(*controlProc)(dev, &feedc->ctrl);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2007-11-13 07:28:23 +01:00
|
|
|
InitBellFeedbackClassDeviceStruct (DeviceIntPtr dev, BellProcPtr bellProc,
|
2005-03-08 00:02:59 +01:00
|
|
|
BellCtrlProcPtr controlProc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
BellFeedbackPtr feedc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
feedc = (BellFeedbackPtr)xalloc(sizeof(BellFeedbackClassRec));
|
|
|
|
if (!feedc)
|
|
|
|
return FALSE;
|
|
|
|
feedc->CtrlProc = controlProc;
|
|
|
|
feedc->BellProc = bellProc;
|
|
|
|
feedc->ctrl = defaultBellControl;
|
|
|
|
feedc->ctrl.id = 0;
|
|
|
|
if ( (feedc->next = dev->bell) )
|
|
|
|
feedc->ctrl.id = dev->bell->ctrl.id + 1;
|
|
|
|
dev->bell = feedc;
|
|
|
|
(*controlProc)(dev, &feedc->ctrl);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2005-03-08 00:02:59 +01:00
|
|
|
InitLedFeedbackClassDeviceStruct (DeviceIntPtr dev, LedCtrlProcPtr controlProc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
LedFeedbackPtr feedc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
feedc = (LedFeedbackPtr)xalloc(sizeof(LedFeedbackClassRec));
|
|
|
|
if (!feedc)
|
|
|
|
return FALSE;
|
|
|
|
feedc->CtrlProc = controlProc;
|
|
|
|
feedc->ctrl = defaultLedControl;
|
|
|
|
feedc->ctrl.id = 0;
|
|
|
|
if ( (feedc->next = dev->leds) )
|
|
|
|
feedc->ctrl.id = dev->leds->ctrl.id + 1;
|
|
|
|
#ifdef XKB
|
|
|
|
feedc->xkb_sli= NULL;
|
|
|
|
#endif
|
|
|
|
dev->leds = feedc;
|
|
|
|
(*controlProc)(dev, &feedc->ctrl);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2005-03-08 00:02:59 +01:00
|
|
|
InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr controlProc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
IntegerFeedbackPtr feedc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
feedc = (IntegerFeedbackPtr)xalloc(sizeof(IntegerFeedbackClassRec));
|
|
|
|
if (!feedc)
|
|
|
|
return FALSE;
|
|
|
|
feedc->CtrlProc = controlProc;
|
|
|
|
feedc->ctrl = defaultIntegerControl;
|
|
|
|
feedc->ctrl.id = 0;
|
|
|
|
if ( (feedc->next = dev->intfeed) )
|
|
|
|
feedc->ctrl.id = dev->intfeed->ctrl.id + 1;
|
|
|
|
dev->intfeed = feedc;
|
|
|
|
(*controlProc)(dev, &feedc->ctrl);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2007-11-13 07:28:23 +01:00
|
|
|
InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons,
|
2006-07-20 22:39:54 +02:00
|
|
|
PtrCtrlProcPtr controlProc, int numMotionEvents,
|
|
|
|
int numAxes)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
DeviceIntPtr dev = (DeviceIntPtr)device;
|
|
|
|
|
|
|
|
return(InitButtonClassDeviceStruct(dev, numButtons, map) &&
|
2008-05-25 15:19:54 +02:00
|
|
|
InitValuatorClassDeviceStruct(dev, numAxes,
|
2003-11-14 16:54:54 +01:00
|
|
|
numMotionEvents, 0) &&
|
|
|
|
InitPtrFeedbackClassDeviceStruct(dev, controlProc));
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT Bool
|
2007-11-13 07:28:23 +01:00
|
|
|
InitKeyboardDeviceStruct(DevicePtr device, KeySymsPtr pKeySyms,
|
|
|
|
CARD8 pModifiers[], BellProcPtr bellProc,
|
|
|
|
KbdCtrlProcPtr controlProc)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
DeviceIntPtr dev = (DeviceIntPtr)device;
|
|
|
|
|
|
|
|
return(InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers) &&
|
|
|
|
InitFocusClassDeviceStruct(dev) &&
|
|
|
|
InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc));
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT void
|
2007-01-29 08:53:24 +01:00
|
|
|
SendMappingNotify(DeviceIntPtr pDev, unsigned request, unsigned firstKeyCode,
|
|
|
|
unsigned count, ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
xEvent event;
|
|
|
|
|
|
|
|
event.u.u.type = MappingNotify;
|
|
|
|
event.u.mappingNotify.request = request;
|
|
|
|
if (request == MappingKeyboard)
|
|
|
|
{
|
|
|
|
event.u.mappingNotify.firstKeyCode = firstKeyCode;
|
|
|
|
event.u.mappingNotify.count = count;
|
|
|
|
}
|
|
|
|
#ifdef XKB
|
|
|
|
if (!noXkbExtension &&
|
|
|
|
((request == MappingKeyboard) || (request == MappingModifier))) {
|
2007-01-29 08:53:24 +01:00
|
|
|
XkbApplyMappingChange(pDev,request,firstKeyCode,count, client);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* 0 is the server client */
|
|
|
|
for (i=1; i<currentMaxClients; i++)
|
|
|
|
{
|
|
|
|
if (clients[i] && clients[i]->clientState == ClientStateRunning)
|
|
|
|
{
|
|
|
|
#ifdef XKB
|
|
|
|
if (!noXkbExtension &&
|
|
|
|
(request == MappingKeyboard) &&
|
|
|
|
(clients[i]->xkbClientFlags != 0) &&
|
|
|
|
(clients[i]->mapNotifyMask&XkbKeySymsMask))
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
event.u.u.sequenceNumber = clients[i]->sequence;
|
|
|
|
WriteEventsToClient(clients[i], 1, &event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-07-21 09:35:04 +02:00
|
|
|
* Check if the given buffer contains elements between low (inclusive) and
|
|
|
|
* high (inclusive) only.
|
|
|
|
*
|
|
|
|
* @return TRUE if the device map is invalid, FALSE otherwise.
|
2003-11-14 16:54:54 +01:00
|
|
|
*/
|
|
|
|
Bool
|
2007-03-08 08:20:19 +01:00
|
|
|
BadDeviceMap(BYTE *buff, int length, unsigned low, unsigned high, XID *errval)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2008-07-21 09:35:04 +02:00
|
|
|
int i;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (i = 0; i < length; i++)
|
|
|
|
if (buff[i]) /* only check non-zero elements */
|
|
|
|
{
|
|
|
|
if ((low > buff[i]) || (high < buff[i]))
|
|
|
|
{
|
|
|
|
*errval = buff[i];
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Bool
|
|
|
|
AllModifierKeysAreUp(dev, map1, per1, map2, per2)
|
2007-03-08 08:20:19 +01:00
|
|
|
DeviceIntPtr dev;
|
|
|
|
CARD8 *map1, *map2;
|
2003-11-14 16:54:54 +01:00
|
|
|
int per1, per2;
|
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
int i, j, k;
|
|
|
|
CARD8 *down = dev->key->down;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
for (i = 8; --i >= 0; map2 += per2)
|
|
|
|
{
|
|
|
|
for (j = per1; --j >= 0; map1++)
|
|
|
|
{
|
|
|
|
if (*map1 && BitIsOn(down, *map1))
|
|
|
|
{
|
|
|
|
for (k = per2; (--k >= 0) && (*map1 != map2[k]);)
|
|
|
|
;
|
|
|
|
if (k < 0)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
static int
|
|
|
|
DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
|
2007-08-28 21:10:20 +02:00
|
|
|
int numKeyPerModifier, xSetModifierMappingReply *rep)
|
2006-09-28 23:34:23 +02:00
|
|
|
{
|
|
|
|
DeviceIntPtr pDev = NULL;
|
2008-08-07 04:25:10 +02:00
|
|
|
DeviceIntPtr cp = PickKeyboard(client); /* ClientPointer keyboard */
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc, i = 0, inputMapLen = numKeyPerModifier * 8;
|
2006-09-28 23:34:23 +02:00
|
|
|
|
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
|
2008-08-07 04:25:10 +02:00
|
|
|
if (pDev == cp || (!pDev->isMaster && (pDev->u.master == cp) && pDev->key)) {
|
2006-09-28 23:34:23 +02:00
|
|
|
for (i = 0; i < inputMapLen; i++) {
|
|
|
|
/* Check that all the new modifiers fall within the advertised
|
|
|
|
* keycode range, and are okay with the DDX. */
|
|
|
|
if (inputMap[i] && ((inputMap[i] < pDev->key->curKeySyms.minKeyCode ||
|
|
|
|
inputMap[i] > pDev->key->curKeySyms.maxKeyCode) ||
|
|
|
|
!LegalModifier(inputMap[i], pDev))) {
|
|
|
|
client->errorValue = inputMap[i];
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
}
|
2006-10-13 17:10:45 +02:00
|
|
|
|
2008-02-14 01:39:49 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-10-13 17:10:45 +02:00
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
/* None of the modifiers (old or new) may be down while we change
|
|
|
|
* the map. */
|
|
|
|
if (!AllModifierKeysAreUp(pDev, pDev->key->modifierKeyMap,
|
|
|
|
pDev->key->maxKeysPerModifier,
|
|
|
|
inputMap, numKeyPerModifier) ||
|
|
|
|
!AllModifierKeysAreUp(pDev, inputMap, numKeyPerModifier,
|
|
|
|
pDev->key->modifierKeyMap,
|
|
|
|
pDev->key->maxKeysPerModifier)) {
|
2007-08-28 21:10:20 +02:00
|
|
|
rep->success = MappingBusy;
|
|
|
|
return Success;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
|
2006-10-13 17:10:45 +02:00
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
|
|
|
|
bzero(pDev->key->modifierMap, MAP_LENGTH);
|
|
|
|
|
|
|
|
/* Annoyingly, we lack a modifierKeyMap size, so we have to just free
|
|
|
|
* and re-alloc it every time. */
|
|
|
|
if (pDev->key->modifierKeyMap)
|
|
|
|
xfree(pDev->key->modifierKeyMap);
|
|
|
|
|
|
|
|
if (inputMapLen) {
|
|
|
|
pDev->key->modifierKeyMap = (KeyCode *) xalloc(inputMapLen);
|
|
|
|
if (!pDev->key->modifierKeyMap)
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
memcpy(pDev->key->modifierKeyMap, inputMap, inputMapLen);
|
|
|
|
pDev->key->maxKeysPerModifier = numKeyPerModifier;
|
|
|
|
|
|
|
|
for (i = 0; i < inputMapLen; i++) {
|
|
|
|
if (inputMap[i]) {
|
|
|
|
pDev->key->modifierMap[inputMap[i]] |=
|
|
|
|
(1 << (((unsigned int)i) / numKeyPerModifier));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pDev->key->modifierKeyMap = NULL;
|
2007-04-23 20:34:01 +02:00
|
|
|
pDev->key->maxKeysPerModifier = 0;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-28 21:10:20 +02:00
|
|
|
rep->success = Success;
|
2006-09-28 23:34:23 +02:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2007-11-13 07:28:23 +01:00
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcSetModifierMapping(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xSetModifierMappingReply rep;
|
2007-09-23 16:17:03 +02:00
|
|
|
DeviceIntPtr dev;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xSetModifierMappingReq);
|
|
|
|
REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
|
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
if (client->req_len != ((stuff->numKeyPerModifier << 1) +
|
|
|
|
(sizeof (xSetModifierMappingReq) >> 2)))
|
2003-11-14 16:54:54 +01:00
|
|
|
return BadLength;
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
|
2007-08-28 21:10:20 +02:00
|
|
|
rc = DoSetModifierMapping(client, (KeyCode *)&stuff[1],
|
|
|
|
stuff->numKeyPerModifier, &rep);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2007-09-23 16:17:03 +02:00
|
|
|
for (dev = inputInfo.devices; dev; dev = dev->next)
|
|
|
|
if (dev->key && dev->coreEvents)
|
|
|
|
SendDeviceMappingNotify(client, MappingModifier, 0, 0, dev);
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
|
2006-09-28 23:34:23 +02:00
|
|
|
return client->noClientException;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcGetModifierMapping(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xGetModifierMappingReply rep;
|
2008-01-03 07:34:54 +01:00
|
|
|
DeviceIntPtr dev = PickKeyboard(client);
|
|
|
|
KeyClassPtr keyc = dev->key;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2007-08-28 21:10:20 +02:00
|
|
|
|
2008-01-03 07:34:54 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGetAttrAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.numKeyPerModifier = keyc->maxKeysPerModifier;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
/* length counts 4 byte quantities - there are 8 modifiers 1 byte big */
|
|
|
|
rep.length = keyc->maxKeysPerModifier << 1;
|
|
|
|
|
|
|
|
WriteReplyToClient(client, sizeof(xGetModifierMappingReply), &rep);
|
|
|
|
|
|
|
|
/* Use the (modified by DDX) map that SetModifierMapping passed in */
|
|
|
|
(void)WriteToClient(client, (int)(keyc->maxKeysPerModifier << 3),
|
|
|
|
(char *)keyc->modifierKeyMap);
|
|
|
|
return client->noClientException;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcChangeKeyboardMapping(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
REQUEST(xChangeKeyboardMappingReq);
|
|
|
|
unsigned len;
|
|
|
|
KeySymsRec keysyms;
|
2007-10-09 15:37:51 +02:00
|
|
|
KeySymsPtr curKeySyms = &PickKeyboard(client)->key->curKeySyms;
|
2006-09-28 23:34:23 +02:00
|
|
|
DeviceIntPtr pDev = NULL;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
|
|
|
|
|
2007-11-13 07:28:23 +01:00
|
|
|
len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);
|
2003-11-14 16:54:54 +01:00
|
|
|
if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
|
|
|
|
return BadLength;
|
2006-09-28 23:34:23 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
|
2006-09-28 23:34:23 +02:00
|
|
|
(stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->firstKeyCode;
|
|
|
|
return BadValue;
|
2006-09-28 23:34:23 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) >
|
|
|
|
curKeySyms->maxKeyCode) || (stuff->keySymsPerKeyCode == 0)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->keySymsPerKeyCode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
|
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
|
|
|
|
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
|
2008-02-14 01:39:49 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
keysyms.minKeyCode = stuff->firstKeyCode;
|
|
|
|
keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1;
|
|
|
|
keysyms.mapWidth = stuff->keySymsPerKeyCode;
|
|
|
|
keysyms.map = (KeySym *)&stuff[1];
|
2007-09-23 16:17:03 +02:00
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
|
|
|
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key)
|
2006-09-28 23:34:23 +02:00
|
|
|
if (!SetKeySymsMap(&pDev->key->curKeySyms, &keysyms))
|
|
|
|
return BadAlloc;
|
|
|
|
|
2007-09-23 16:17:03 +02:00
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
|
|
|
|
if (pDev->key && pDev->coreEvents)
|
|
|
|
SendDeviceMappingNotify(client, MappingKeyboard,
|
|
|
|
stuff->firstKeyCode, stuff->keyCodes,
|
|
|
|
pDev);
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return client->noClientException;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2007-08-28 21:10:20 +02:00
|
|
|
DoSetPointerMapping(ClientPtr client, DeviceIntPtr device, BYTE *map, int n)
|
2006-09-28 23:34:23 +02:00
|
|
|
{
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc, i = 0;
|
2006-09-28 23:34:23 +02:00
|
|
|
DeviceIntPtr dev = NULL;
|
|
|
|
|
|
|
|
if (!device || !device->button)
|
|
|
|
return BadDevice;
|
|
|
|
|
2007-08-28 21:10:20 +02:00
|
|
|
for (dev = inputInfo.devices; dev; dev = dev->next) {
|
|
|
|
if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
|
2008-02-14 01:39:49 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixManageAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
for (dev = inputInfo.devices; dev; dev = dev->next) {
|
|
|
|
if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
if ((device->button->map[i + 1] != map[i]) &&
|
2008-06-15 12:30:41 +02:00
|
|
|
device->button->down[i + 1]) {
|
2006-09-28 23:34:23 +02:00
|
|
|
return MappingBusy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
for (dev = inputInfo.devices; dev; dev = dev->next) {
|
|
|
|
if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
dev->button->map[i + 1] = map[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Success;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcSetPointerMapping(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
BYTE *map;
|
2006-09-28 23:34:23 +02:00
|
|
|
int ret;
|
2008-07-21 09:35:04 +02:00
|
|
|
int i, j;
|
2007-03-02 07:44:37 +01:00
|
|
|
DeviceIntPtr ptr = PickPointer(client);
|
2003-11-14 16:54:54 +01:00
|
|
|
xSetPointerMappingReply rep;
|
2007-08-28 21:10:20 +02:00
|
|
|
REQUEST(xSetPointerMappingReq);
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
|
2007-08-28 21:10:20 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2)
|
|
|
|
return BadLength;
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.success = MappingSuccess;
|
|
|
|
map = (BYTE *)&stuff[1];
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
/* So we're bounded here by the number of core buttons. This check
|
|
|
|
* probably wants disabling through XFixes. */
|
2007-03-02 07:44:37 +01:00
|
|
|
/* MPX: With ClientPointer, we can return the right number of buttons.
|
|
|
|
* Let's just hope nobody changed ClientPointer between GetPointerMapping
|
|
|
|
* and SetPointerMapping
|
|
|
|
*/
|
|
|
|
if (stuff->nElts != ptr->button->numButtons) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->nElts;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue))
|
|
|
|
return BadValue;
|
2006-09-28 23:34:23 +02:00
|
|
|
|
2008-07-21 09:35:04 +02:00
|
|
|
/* core protocol specs don't allow for duplicate mappings. */
|
|
|
|
for (i = 0; i < stuff->nElts; i++)
|
|
|
|
{
|
|
|
|
for (j = i + 1; j < stuff->nElts; j++)
|
|
|
|
{
|
|
|
|
if (map[i] && map[i] == map[j])
|
|
|
|
{
|
|
|
|
client->errorValue = map[i];
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-03 07:34:54 +01:00
|
|
|
ret = DoSetPointerMapping(client, ptr, map, stuff->nElts);
|
2006-09-28 23:34:23 +02:00
|
|
|
if (ret != Success) {
|
|
|
|
rep.success = ret;
|
|
|
|
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Send mapping notifies for all the extended devices as well. */
|
2007-03-02 07:44:37 +01:00
|
|
|
SendMappingNotify(ptr, MappingPointer, 0, 0, client);
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcGetKeyboardMapping(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xGetKeyboardMappingReply rep;
|
2007-03-02 07:44:37 +01:00
|
|
|
DeviceIntPtr kbd = PickKeyboard(client);
|
|
|
|
KeySymsPtr curKeySyms = &kbd->key->curKeySyms;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
|
|
|
REQUEST(xGetKeyboardMappingReq);
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_SIZE_MATCH(xGetKeyboardMappingReq);
|
|
|
|
|
2008-01-03 07:34:54 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
|
2006-09-28 23:34:23 +02:00
|
|
|
(stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->firstKeyCode;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
if (stuff->firstKeyCode + stuff->count >
|
2006-09-28 23:34:23 +02:00
|
|
|
(unsigned)(curKeySyms->maxKeyCode + 1)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->count;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.keySymsPerKeyCode = curKeySyms->mapWidth;
|
|
|
|
/* length is a count of 4 byte quantities and KeySyms are 4 bytes */
|
|
|
|
rep.length = (curKeySyms->mapWidth * stuff->count);
|
|
|
|
WriteReplyToClient(client, sizeof(xGetKeyboardMappingReply), &rep);
|
2003-11-14 17:49:22 +01:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) CopySwap32Write;
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteSwappedDataToClient(
|
|
|
|
client,
|
|
|
|
curKeySyms->mapWidth * stuff->count * sizeof(KeySym),
|
|
|
|
&curKeySyms->map[(stuff->firstKeyCode - curKeySyms->minKeyCode) *
|
|
|
|
curKeySyms->mapWidth]);
|
|
|
|
|
|
|
|
return client->noClientException;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcGetPointerMapping(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xGetPointerMappingReply rep;
|
2007-03-02 07:44:37 +01:00
|
|
|
/* Apps may get different values each time they call GetPointerMapping as
|
|
|
|
* the ClientPointer could change. */
|
2008-01-03 07:34:54 +01:00
|
|
|
DeviceIntPtr ptr = PickPointer(client);
|
|
|
|
ButtonClassPtr butc = ptr->button;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2007-08-28 21:10:20 +02:00
|
|
|
|
2008-01-03 07:34:54 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.nElts = butc->numButtons;
|
|
|
|
rep.length = ((unsigned)rep.nElts + (4-1))/4;
|
|
|
|
WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep);
|
|
|
|
(void)WriteToClient(client, (int)rep.nElts, (char *)&butc->map[1]);
|
2007-11-13 07:28:23 +01:00
|
|
|
return Success;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-03-08 00:02:59 +01:00
|
|
|
NoteLedState(DeviceIntPtr keybd, int led, Bool on)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
KeybdCtrl *ctrl = &keybd->kbdfeed->ctrl;
|
|
|
|
if (on)
|
|
|
|
ctrl->leds |= ((Leds)1 << (led - 1));
|
|
|
|
else
|
|
|
|
ctrl->leds &= ~((Leds)1 << (led - 1));
|
|
|
|
}
|
|
|
|
|
2006-02-15 21:44:13 +01:00
|
|
|
_X_EXPORT int
|
2005-03-08 00:02:59 +01:00
|
|
|
Ones(unsigned long mask) /* HACKMEM 169 */
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-08 08:20:19 +01:00
|
|
|
unsigned long y;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
y = (mask >> 1) &033333333333;
|
|
|
|
y = mask - y - ((y >>1) & 033333333333);
|
|
|
|
return (((y + (y >> 3)) & 030707070707) % 077);
|
|
|
|
}
|
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
static int
|
|
|
|
DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist,
|
|
|
|
BITS32 vmask)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
#define DO_ALL (-1)
|
|
|
|
KeybdCtrl ctrl;
|
|
|
|
int t;
|
|
|
|
int led = DO_ALL;
|
|
|
|
int key = DO_ALL;
|
2006-09-28 23:34:23 +02:00
|
|
|
BITS32 index2;
|
|
|
|
int mask = vmask, i;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
ctrl = keybd->kbdfeed->ctrl;
|
2006-09-28 23:34:23 +02:00
|
|
|
while (vmask) {
|
2003-11-14 17:49:22 +01:00
|
|
|
index2 = (BITS32) lowbit (vmask);
|
|
|
|
vmask &= ~index2;
|
2006-09-28 23:34:23 +02:00
|
|
|
switch (index2) {
|
2007-11-13 07:28:23 +01:00
|
|
|
case KBKeyClickPercent:
|
2003-11-14 16:54:54 +01:00
|
|
|
t = (INT8)*vlist;
|
|
|
|
vlist++;
|
2006-09-28 23:34:23 +02:00
|
|
|
if (t == -1) {
|
2003-11-14 16:54:54 +01:00
|
|
|
t = defaultKeyboardControl.click;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
else if (t < 0 || t > 100) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = t;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
ctrl.click = t;
|
|
|
|
break;
|
|
|
|
case KBBellPercent:
|
|
|
|
t = (INT8)*vlist;
|
|
|
|
vlist++;
|
2006-09-28 23:34:23 +02:00
|
|
|
if (t == -1) {
|
2003-11-14 16:54:54 +01:00
|
|
|
t = defaultKeyboardControl.bell;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
else if (t < 0 || t > 100) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = t;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
ctrl.bell = t;
|
|
|
|
break;
|
|
|
|
case KBBellPitch:
|
|
|
|
t = (INT16)*vlist;
|
|
|
|
vlist++;
|
2006-09-28 23:34:23 +02:00
|
|
|
if (t == -1) {
|
2003-11-14 16:54:54 +01:00
|
|
|
t = defaultKeyboardControl.bell_pitch;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
else if (t < 0) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = t;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
ctrl.bell_pitch = t;
|
|
|
|
break;
|
|
|
|
case KBBellDuration:
|
|
|
|
t = (INT16)*vlist;
|
|
|
|
vlist++;
|
|
|
|
if (t == -1)
|
|
|
|
t = defaultKeyboardControl.bell_duration;
|
2006-09-28 23:34:23 +02:00
|
|
|
else if (t < 0) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = t;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
ctrl.bell_duration = t;
|
|
|
|
break;
|
|
|
|
case KBLed:
|
|
|
|
led = (CARD8)*vlist;
|
|
|
|
vlist++;
|
2006-09-28 23:34:23 +02:00
|
|
|
if (led < 1 || led > 32) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = led;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
if (!(mask & KBLedMode))
|
2003-11-14 16:54:54 +01:00
|
|
|
return BadMatch;
|
|
|
|
break;
|
|
|
|
case KBLedMode:
|
|
|
|
t = (CARD8)*vlist;
|
|
|
|
vlist++;
|
2006-09-28 23:34:23 +02:00
|
|
|
if (t == LedModeOff) {
|
2003-11-14 16:54:54 +01:00
|
|
|
if (led == DO_ALL)
|
|
|
|
ctrl.leds = 0x0;
|
|
|
|
else
|
|
|
|
ctrl.leds &= ~(((Leds)(1)) << (led - 1));
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else if (t == LedModeOn) {
|
2003-11-14 16:54:54 +01:00
|
|
|
if (led == DO_ALL)
|
|
|
|
ctrl.leds = ~0L;
|
|
|
|
else
|
|
|
|
ctrl.leds |= (((Leds)(1)) << (led - 1));
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = t;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
#ifdef XKB
|
2006-09-28 23:34:23 +02:00
|
|
|
if (!noXkbExtension) {
|
|
|
|
XkbEventCauseRec cause;
|
|
|
|
XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client);
|
|
|
|
XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))),
|
2003-11-14 16:54:54 +01:00
|
|
|
ctrl.leds, &cause);
|
2006-09-28 23:34:23 +02:00
|
|
|
ctrl.leds = keybd->kbdfeed->ctrl.leds;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case KBKey:
|
|
|
|
key = (KeyCode)*vlist;
|
|
|
|
vlist++;
|
2008-01-03 09:21:44 +01:00
|
|
|
if ((KeyCode)key < keybd->key->curKeySyms.minKeyCode ||
|
|
|
|
(KeyCode)key > keybd->key->curKeySyms.maxKeyCode) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = key;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
if (!(mask & KBAutoRepeatMode))
|
2003-11-14 16:54:54 +01:00
|
|
|
return BadMatch;
|
|
|
|
break;
|
|
|
|
case KBAutoRepeatMode:
|
|
|
|
i = (key >> 3);
|
|
|
|
mask = (1 << (key & 7));
|
|
|
|
t = (CARD8)*vlist;
|
|
|
|
vlist++;
|
|
|
|
#ifdef XKB
|
2006-09-28 23:34:23 +02:00
|
|
|
if (!noXkbExtension && key != DO_ALL)
|
|
|
|
XkbDisableComputedAutoRepeats(keybd,key);
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2006-09-28 23:34:23 +02:00
|
|
|
if (t == AutoRepeatModeOff) {
|
2003-11-14 16:54:54 +01:00
|
|
|
if (key == DO_ALL)
|
|
|
|
ctrl.autoRepeat = FALSE;
|
|
|
|
else
|
|
|
|
ctrl.autoRepeats[i] &= ~mask;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else if (t == AutoRepeatModeOn) {
|
2003-11-14 16:54:54 +01:00
|
|
|
if (key == DO_ALL)
|
|
|
|
ctrl.autoRepeat = TRUE;
|
|
|
|
else
|
|
|
|
ctrl.autoRepeats[i] |= mask;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else if (t == AutoRepeatModeDefault) {
|
2003-11-14 16:54:54 +01:00
|
|
|
if (key == DO_ALL)
|
|
|
|
ctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
|
|
|
|
else
|
|
|
|
ctrl.autoRepeats[i] =
|
|
|
|
(ctrl.autoRepeats[i] & ~mask) |
|
|
|
|
(defaultKeyboardControl.autoRepeats[i] & mask);
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = t;
|
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2006-09-28 23:34:23 +02:00
|
|
|
client->errorValue = mask;
|
2003-11-14 16:54:54 +01:00
|
|
|
return BadValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
keybd->kbdfeed->ctrl = ctrl;
|
2006-09-28 23:34:23 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef XKB
|
|
|
|
/* The XKB RepeatKeys control and core protocol global autorepeat */
|
|
|
|
/* value are linked */
|
2006-09-28 23:34:23 +02:00
|
|
|
if (!noXkbExtension)
|
|
|
|
XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat);
|
2003-11-14 16:54:54 +01:00
|
|
|
else
|
|
|
|
#endif
|
2006-09-28 23:34:23 +02:00
|
|
|
(*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl);
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return Success;
|
2006-09-28 23:34:23 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#undef DO_ALL
|
2007-11-13 07:28:23 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
int
|
|
|
|
ProcChangeKeyboardControl (ClientPtr client)
|
|
|
|
{
|
|
|
|
XID *vlist;
|
|
|
|
BITS32 vmask;
|
|
|
|
int ret = Success, error = Success;
|
|
|
|
DeviceIntPtr pDev = NULL;
|
|
|
|
REQUEST(xChangeKeyboardControlReq);
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
|
|
|
|
|
|
|
|
vmask = stuff->mask;
|
|
|
|
vlist = (XID *)&stuff[1];
|
|
|
|
|
|
|
|
if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
|
|
|
|
return BadLength;
|
|
|
|
|
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
|
|
|
|
if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
|
|
|
|
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
|
2008-02-14 01:39:49 +01:00
|
|
|
ret = XaceHook(XACE_DEVICE_ACCESS, client, pDev, DixManageAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (ret != Success)
|
|
|
|
return ret;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
|
|
|
|
if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
|
|
|
|
pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
|
|
|
|
ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
|
|
|
|
if (ret != Success)
|
|
|
|
error = ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcGetKeyboardControl (ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc, i;
|
2008-01-03 07:34:54 +01:00
|
|
|
DeviceIntPtr kbd = PickKeyboard(client);
|
|
|
|
KeybdCtrl *ctrl = &kbd->kbdfeed->ctrl;
|
2003-11-14 16:54:54 +01:00
|
|
|
xGetKeyboardControlReply rep;
|
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2007-08-28 21:10:20 +02:00
|
|
|
|
2008-01-03 07:34:54 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, kbd, DixGetAttrAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 5;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.globalAutoRepeat = ctrl->autoRepeat;
|
|
|
|
rep.keyClickPercent = ctrl->click;
|
|
|
|
rep.bellPercent = ctrl->bell;
|
|
|
|
rep.bellPitch = ctrl->bell_pitch;
|
|
|
|
rep.bellDuration = ctrl->bell_duration;
|
|
|
|
rep.ledMask = ctrl->leds;
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
rep.map[i] = ctrl->autoRepeats[i];
|
|
|
|
WriteReplyToClient(client, sizeof(xGetKeyboardControlReply), &rep);
|
|
|
|
return Success;
|
2007-11-13 07:28:23 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcBell(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-10-09 15:37:51 +02:00
|
|
|
DeviceIntPtr keybd = PickKeyboard(client);
|
2003-11-14 16:54:54 +01:00
|
|
|
int base = keybd->kbdfeed->ctrl.bell;
|
|
|
|
int newpercent;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xBellReq);
|
|
|
|
REQUEST_SIZE_MATCH(xBellReq);
|
2006-08-12 20:50:39 +02:00
|
|
|
|
2007-11-14 04:38:21 +01:00
|
|
|
/* Seems like no keyboard actually has the BellProc set. Returning
|
|
|
|
* BadDevice (previous code) will make apps crash badly. The man pages
|
|
|
|
* doesn't say anything about a BadDevice being returned either.
|
|
|
|
* So just quietly do nothing and pretend everything has worked.
|
|
|
|
*/
|
2006-08-12 20:50:39 +02:00
|
|
|
if (!keybd->kbdfeed->BellProc)
|
2007-11-14 04:38:21 +01:00
|
|
|
return Success;
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2006-09-28 23:34:23 +02:00
|
|
|
if (stuff->percent < -100 || stuff->percent > 100) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->percent;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
newpercent = (base * stuff->percent) / 100;
|
|
|
|
if (stuff->percent < 0)
|
|
|
|
newpercent = base + newpercent;
|
|
|
|
else
|
2007-11-13 07:28:23 +01:00
|
|
|
newpercent = base - newpercent + stuff->percent;
|
2006-09-28 23:34:23 +02:00
|
|
|
|
|
|
|
for (keybd = inputInfo.devices; keybd; keybd = keybd->next) {
|
|
|
|
if ((keybd->coreEvents || keybd == inputInfo.keyboard) &&
|
|
|
|
keybd->kbdfeed && keybd->kbdfeed->BellProc) {
|
2007-08-28 21:10:20 +02:00
|
|
|
|
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixBellAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef XKB
|
2006-09-28 23:34:23 +02:00
|
|
|
if (!noXkbExtension)
|
|
|
|
XkbHandleBell(FALSE, FALSE, keybd, newpercent,
|
|
|
|
&keybd->kbdfeed->ctrl, 0, None, NULL, client);
|
|
|
|
else
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
2006-09-28 23:34:23 +02:00
|
|
|
(*keybd->kbdfeed->BellProc)(newpercent, keybd,
|
|
|
|
&keybd->kbdfeed->ctrl, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return Success;
|
2007-11-13 07:28:23 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcChangePointerControl(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-02 07:44:37 +01:00
|
|
|
DeviceIntPtr mouse = PickPointer(client);
|
2003-11-14 16:54:54 +01:00
|
|
|
PtrCtrl ctrl; /* might get BadValue part way through */
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST(xChangePointerControlReq);
|
|
|
|
REQUEST_SIZE_MATCH(xChangePointerControlReq);
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2006-08-12 20:50:39 +02:00
|
|
|
if (!mouse->ptrfeed->CtrlProc)
|
|
|
|
return BadDevice;
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
ctrl = mouse->ptrfeed->ctrl;
|
2006-09-28 23:34:23 +02:00
|
|
|
if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->doAccel;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->doThresh;
|
|
|
|
return(BadValue);
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
if (stuff->doAccel) {
|
|
|
|
if (stuff->accelNum == -1) {
|
2003-11-14 16:54:54 +01:00
|
|
|
ctrl.num = defaultPointerControl.num;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
else if (stuff->accelNum < 0) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->accelNum;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else {
|
|
|
|
ctrl.num = stuff->accelNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stuff->accelDenum == -1) {
|
2003-11-14 16:54:54 +01:00
|
|
|
ctrl.den = defaultPointerControl.den;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
else if (stuff->accelDenum <= 0) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->accelDenum;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else {
|
|
|
|
ctrl.den = stuff->accelDenum;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
if (stuff->doThresh) {
|
|
|
|
if (stuff->threshold == -1) {
|
2003-11-14 16:54:54 +01:00
|
|
|
ctrl.threshold = defaultPointerControl.threshold;
|
2006-09-28 23:34:23 +02:00
|
|
|
}
|
|
|
|
else if (stuff->threshold < 0) {
|
2003-11-14 16:54:54 +01:00
|
|
|
client->errorValue = stuff->threshold;
|
|
|
|
return BadValue;
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
else {
|
|
|
|
ctrl.threshold = stuff->threshold;
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
|
2007-08-28 21:10:20 +02:00
|
|
|
for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
|
|
|
|
if ((mouse->coreEvents || mouse == inputInfo.pointer) &&
|
|
|
|
mouse->ptrfeed && mouse->ptrfeed->CtrlProc) {
|
2008-02-14 01:39:49 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixManageAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
2006-09-28 23:34:23 +02:00
|
|
|
|
|
|
|
for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
|
2007-03-02 07:44:37 +01:00
|
|
|
if ((mouse->coreEvents || mouse == PickPointer(client)) &&
|
2006-09-28 23:34:23 +02:00
|
|
|
mouse->ptrfeed && mouse->ptrfeed->CtrlProc) {
|
|
|
|
mouse->ptrfeed->ctrl = ctrl;
|
|
|
|
(*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
return Success;
|
2007-11-13 07:28:23 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcGetPointerControl(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-03-02 07:44:37 +01:00
|
|
|
DeviceIntPtr ptr = PickPointer(client);
|
|
|
|
PtrCtrl *ctrl = &ptr->ptrfeed->ctrl;
|
2003-11-14 16:54:54 +01:00
|
|
|
xGetPointerControlReply rep;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
2007-08-28 21:10:20 +02:00
|
|
|
|
2008-01-03 07:34:54 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, ptr, DixGetAttrAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.length = 0;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.threshold = ctrl->threshold;
|
|
|
|
rep.accelNumerator = ctrl->num;
|
|
|
|
rep.accelDenominator = ctrl->den;
|
|
|
|
WriteReplyToClient(client, sizeof(xGenericReply), &rep);
|
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-03-08 08:20:19 +01:00
|
|
|
MaybeStopHint(DeviceIntPtr dev, ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2007-05-14 05:04:53 +02:00
|
|
|
GrabPtr grab = dev->deviceGrab.grab;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
if ((grab && SameClient(grab, client) &&
|
|
|
|
((grab->eventMask & PointerMotionHintMask) ||
|
|
|
|
(grab->ownerEvents &&
|
|
|
|
(EventMaskForClient(dev->valuator->motionHintWindow, client) &
|
|
|
|
PointerMotionHintMask)))) ||
|
|
|
|
(!grab &&
|
|
|
|
(EventMaskForClient(dev->valuator->motionHintWindow, client) &
|
|
|
|
PointerMotionHintMask)))
|
|
|
|
dev->valuator->motionHintWindow = NullWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcGetMotionEvents(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
WindowPtr pWin;
|
|
|
|
xTimecoord * coords = (xTimecoord *) NULL;
|
|
|
|
xGetMotionEventsReply rep;
|
2006-12-15 21:50:46 +01:00
|
|
|
int i, count, xmin, xmax, ymin, ymax, rc;
|
2003-11-14 16:54:54 +01:00
|
|
|
unsigned long nEvents;
|
2007-03-02 07:44:37 +01:00
|
|
|
DeviceIntPtr mouse = PickPointer(client);
|
2003-11-14 16:54:54 +01:00
|
|
|
TimeStamp start, stop;
|
|
|
|
REQUEST(xGetMotionEventsReq);
|
|
|
|
REQUEST_SIZE_MATCH(xGetMotionEventsReq);
|
2007-08-28 21:10:20 +02:00
|
|
|
|
|
|
|
rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
|
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess);
|
2006-12-15 21:50:46 +01:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
2007-08-28 21:10:20 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (mouse->valuator->motionHintWindow)
|
|
|
|
MaybeStopHint(mouse, client);
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
nEvents = 0;
|
|
|
|
start = ClientTimeToServerTime(stuff->start);
|
|
|
|
stop = ClientTimeToServerTime(stuff->stop);
|
|
|
|
if ((CompareTimeStamps(start, stop) != LATER) &&
|
|
|
|
(CompareTimeStamps(start, currentTime) != LATER) &&
|
|
|
|
mouse->valuator->numMotionEvents)
|
|
|
|
{
|
|
|
|
if (CompareTimeStamps(stop, currentTime) == LATER)
|
|
|
|
stop = currentTime;
|
2008-05-26 09:05:23 +02:00
|
|
|
count = GetMotionHistory(mouse, &coords, start.milliseconds,
|
|
|
|
stop.milliseconds, pWin->drawable.pScreen,
|
|
|
|
TRUE);
|
2003-11-14 16:54:54 +01:00
|
|
|
xmin = pWin->drawable.x - wBorderWidth (pWin);
|
|
|
|
xmax = pWin->drawable.x + (int)pWin->drawable.width +
|
|
|
|
wBorderWidth (pWin);
|
|
|
|
ymin = pWin->drawable.y - wBorderWidth (pWin);
|
|
|
|
ymax = pWin->drawable.y + (int)pWin->drawable.height +
|
|
|
|
wBorderWidth (pWin);
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
if ((xmin <= coords[i].x) && (coords[i].x < xmax) &&
|
|
|
|
(ymin <= coords[i].y) && (coords[i].y < ymax))
|
|
|
|
{
|
|
|
|
coords[nEvents].time = coords[i].time;
|
|
|
|
coords[nEvents].x = coords[i].x - pWin->drawable.x;
|
|
|
|
coords[nEvents].y = coords[i].y - pWin->drawable.y;
|
|
|
|
nEvents++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rep.length = nEvents * (sizeof(xTimecoord) >> 2);
|
|
|
|
rep.nEvents = nEvents;
|
|
|
|
WriteReplyToClient(client, sizeof(xGetMotionEventsReply), &rep);
|
|
|
|
if (nEvents)
|
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
client->pSwapReplyFunc = (ReplySwapPtr) SwapTimeCoordWrite;
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteSwappedDataToClient(client, nEvents * sizeof(xTimecoord),
|
|
|
|
(char *)coords);
|
|
|
|
}
|
|
|
|
if (coords)
|
2007-11-05 15:12:59 +01:00
|
|
|
xfree(coords);
|
2003-11-14 16:54:54 +01:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2005-03-08 00:02:59 +01:00
|
|
|
ProcQueryKeymap(ClientPtr client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
xQueryKeymapReply rep;
|
2007-08-28 21:10:20 +02:00
|
|
|
int rc, i;
|
2008-01-03 07:34:54 +01:00
|
|
|
DeviceIntPtr keybd = PickKeyboard(client);
|
|
|
|
CARD8 *down = keybd->key->down;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xReq);
|
|
|
|
rep.type = X_Reply;
|
|
|
|
rep.sequenceNumber = client->sequence;
|
|
|
|
rep.length = 2;
|
2006-12-02 02:48:15 +01:00
|
|
|
|
2008-01-03 07:34:54 +01:00
|
|
|
rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);
|
2007-08-28 21:10:20 +02:00
|
|
|
if (rc != Success)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
for (i = 0; i<32; i++)
|
|
|
|
rep.map[i] = down[i];
|
2006-12-02 02:48:15 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
|
2007-11-13 07:28:23 +01:00
|
|
|
|
2007-02-21 00:38:41 +01:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2007-10-16 03:48:31 +02:00
|
|
|
/**
|
|
|
|
* Attach device 'dev' to device 'master'.
|
|
|
|
* Client is set to the client that issued the request, or NULL if it comes
|
|
|
|
* from some internal automatic pairing.
|
|
|
|
*
|
2007-11-13 07:28:23 +01:00
|
|
|
* Master may be NULL to set the device floating.
|
2007-10-23 09:58:03 +02:00
|
|
|
*
|
2007-10-16 03:48:31 +02:00
|
|
|
* We don't allow multi-layer hierarchies right now. You can't attach a slave
|
2007-11-13 07:28:23 +01:00
|
|
|
* to another slave.
|
2007-10-16 03:48:31 +02:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
|
|
|
|
{
|
2008-05-22 15:55:20 +02:00
|
|
|
ScreenPtr screen;
|
2007-11-16 01:15:28 +01:00
|
|
|
DeviceIntPtr oldmaster;
|
2007-11-13 07:28:23 +01:00
|
|
|
if (!dev || dev->isMaster)
|
2007-10-16 03:48:31 +02:00
|
|
|
return BadDevice;
|
|
|
|
|
2007-10-23 09:58:03 +02:00
|
|
|
if (master && !master->isMaster) /* can't attach to slaves */
|
2007-10-16 03:48:31 +02:00
|
|
|
return BadDevice;
|
|
|
|
|
2007-10-23 09:58:03 +02:00
|
|
|
/* set from floating to floating? */
|
|
|
|
if (!dev->u.master && !master)
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
/* free the existing sprite. */
|
2008-04-10 00:55:36 +02:00
|
|
|
if (!dev->u.master && dev->spriteInfo->paired == dev)
|
2008-05-22 15:55:20 +02:00
|
|
|
{
|
|
|
|
screen = miPointerGetScreen(dev);
|
|
|
|
screen->DeviceCursorCleanup(dev, screen);
|
2007-10-23 09:58:03 +02:00
|
|
|
xfree(dev->spriteInfo->sprite);
|
2008-05-22 15:55:20 +02:00
|
|
|
}
|
2007-10-23 09:58:03 +02:00
|
|
|
|
2007-11-16 01:15:28 +01:00
|
|
|
oldmaster = dev->u.master;
|
2007-10-16 10:08:13 +02:00
|
|
|
dev->u.master = master;
|
2007-10-23 09:58:03 +02:00
|
|
|
|
|
|
|
/* If device is set to floating, we need to create a sprite for it,
|
|
|
|
* otherwise things go bad. However, we don't want to render the cursor,
|
|
|
|
* so we reset spriteOwner.
|
2008-04-10 00:55:36 +02:00
|
|
|
* Sprite has to be forced to NULL first, otherwise InitializeSprite won't
|
|
|
|
* alloc new memory but overwrite the previous one.
|
2007-10-23 09:58:03 +02:00
|
|
|
*/
|
|
|
|
if (!master)
|
|
|
|
{
|
2008-04-10 00:55:36 +02:00
|
|
|
WindowPtr currentRoot = dev->spriteInfo->sprite->spriteTrace[0];
|
2008-05-22 15:55:20 +02:00
|
|
|
/* we need to init a fake sprite */
|
|
|
|
screen = currentRoot->drawable.pScreen;
|
|
|
|
screen->DeviceCursorInitialize(dev, screen);
|
2008-04-10 00:55:36 +02:00
|
|
|
dev->spriteInfo->sprite = NULL;
|
|
|
|
InitializeSprite(dev, currentRoot);
|
2007-10-23 09:58:03 +02:00
|
|
|
dev->spriteInfo->spriteOwner = FALSE;
|
2008-04-10 00:55:36 +02:00
|
|
|
dev->spriteInfo->paired = dev;
|
2008-05-22 15:55:20 +02:00
|
|
|
|
2007-11-16 01:15:28 +01:00
|
|
|
} else
|
2008-04-10 00:55:36 +02:00
|
|
|
{
|
2007-11-16 01:15:28 +01:00
|
|
|
dev->spriteInfo->sprite = master->spriteInfo->sprite;
|
2008-04-10 00:55:36 +02:00
|
|
|
dev->spriteInfo->paired = master;
|
|
|
|
dev->spriteInfo->spriteOwner = FALSE;
|
|
|
|
}
|
2007-11-16 01:15:28 +01:00
|
|
|
|
|
|
|
/* If we were connected to master device before, this MD may need to
|
|
|
|
* change back to it's original classes.
|
|
|
|
*/
|
|
|
|
if (oldmaster)
|
|
|
|
{
|
|
|
|
DeviceIntPtr it;
|
2007-11-12 02:05:18 +01:00
|
|
|
for (it = inputInfo.devices; it; it = it->next)
|
2007-11-16 01:15:28 +01:00
|
|
|
if (!it->isMaster && it->u.master == oldmaster)
|
2007-11-12 02:05:18 +01:00
|
|
|
break;
|
2007-11-16 01:15:28 +01:00
|
|
|
}
|
2007-10-16 03:48:31 +02:00
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|
2007-03-02 05:51:46 +01:00
|
|
|
|
2007-10-16 05:39:35 +02:00
|
|
|
/**
|
|
|
|
* Return the device paired with the given device or NULL.
|
|
|
|
* Returns the device paired with the parent master if the given device is a
|
|
|
|
* slave device.
|
2007-03-13 09:46:56 +01:00
|
|
|
*/
|
|
|
|
_X_EXPORT DeviceIntPtr
|
2007-10-16 04:27:42 +02:00
|
|
|
GetPairedDevice(DeviceIntPtr dev)
|
2007-03-13 09:46:56 +01:00
|
|
|
{
|
2007-10-16 10:08:13 +02:00
|
|
|
if (!dev->isMaster && dev->u.master)
|
|
|
|
dev = dev->u.master;
|
2007-10-16 05:39:35 +02:00
|
|
|
|
2007-10-16 04:27:42 +02:00
|
|
|
return dev->spriteInfo->paired;
|
2007-03-13 09:46:56 +01:00
|
|
|
}
|
|
|
|
|
2007-10-16 04:00:32 +02:00
|
|
|
|
2007-10-16 11:10:15 +02:00
|
|
|
/**
|
|
|
|
* Create a new master device (== one pointer, one keyboard device).
|
|
|
|
* Only allocates the devices, you will need to call ActivateDevice() and
|
|
|
|
* EnableDevice() manually.
|
|
|
|
*/
|
|
|
|
int
|
2008-01-21 14:13:53 +01:00
|
|
|
AllocMasterDevice(ClientPtr client, char* name, DeviceIntPtr* ptr, DeviceIntPtr* keybd)
|
2007-10-16 11:10:15 +02:00
|
|
|
{
|
|
|
|
DeviceIntPtr pointer;
|
|
|
|
DeviceIntPtr keyboard;
|
2008-04-13 12:18:28 +02:00
|
|
|
ClassesPtr classes;
|
2007-10-19 07:06:37 +02:00
|
|
|
*ptr = *keybd = NULL;
|
2007-10-16 11:10:15 +02:00
|
|
|
|
2008-01-21 14:13:53 +01:00
|
|
|
pointer = AddInputDevice(client, CorePointerProc, TRUE);
|
2007-10-16 11:10:15 +02:00
|
|
|
if (!pointer)
|
|
|
|
return BadAlloc;
|
|
|
|
|
2007-10-16 11:16:12 +02:00
|
|
|
pointer->name = xcalloc(strlen(name) + strlen(" pointer") + 1, sizeof(char));
|
2007-10-16 11:10:15 +02:00
|
|
|
strcpy(pointer->name, name);
|
2007-10-16 11:16:12 +02:00
|
|
|
strcat(pointer->name, " pointer");
|
2007-10-16 11:10:15 +02:00
|
|
|
|
|
|
|
#ifdef XKB
|
|
|
|
pointer->public.processInputProc = ProcessOtherEvent;
|
|
|
|
pointer->public.realInputProc = ProcessOtherEvent;
|
|
|
|
if (!noXkbExtension)
|
|
|
|
XkbSetExtension(pointer, ProcessPointerEvent);
|
|
|
|
#else
|
|
|
|
pointer->public.processInputProc = ProcessPointerEvent;
|
|
|
|
pointer->public.realInputProc = ProcessPointerEvent;
|
|
|
|
#endif
|
|
|
|
pointer->deviceGrab.ActivateGrab = ActivatePointerGrab;
|
|
|
|
pointer->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
|
|
|
|
pointer->coreEvents = TRUE;
|
|
|
|
pointer->spriteInfo->spriteOwner = TRUE;
|
|
|
|
|
|
|
|
pointer->u.lastSlave = NULL;
|
|
|
|
pointer->isMaster = TRUE;
|
|
|
|
|
2008-01-21 14:13:53 +01:00
|
|
|
keyboard = AddInputDevice(client, CoreKeyboardProc, TRUE);
|
2007-10-16 11:10:15 +02:00
|
|
|
if (!keyboard)
|
2008-04-28 04:07:52 +02:00
|
|
|
{
|
|
|
|
RemoveDevice(pointer);
|
2007-10-16 11:10:15 +02:00
|
|
|
return BadAlloc;
|
2008-04-28 04:07:52 +02:00
|
|
|
}
|
2007-10-16 11:10:15 +02:00
|
|
|
|
2007-10-16 11:16:12 +02:00
|
|
|
keyboard->name = xcalloc(strlen(name) + strlen(" keyboard") + 1, sizeof(char));
|
2007-10-16 11:10:15 +02:00
|
|
|
strcpy(keyboard->name, name);
|
2007-10-16 11:16:12 +02:00
|
|
|
strcat(keyboard->name, " keyboard");
|
2007-10-16 11:10:15 +02:00
|
|
|
|
|
|
|
#ifdef XKB
|
|
|
|
keyboard->public.processInputProc = ProcessOtherEvent;
|
|
|
|
keyboard->public.realInputProc = ProcessOtherEvent;
|
|
|
|
if (!noXkbExtension)
|
|
|
|
XkbSetExtension(keyboard, ProcessKeyboardEvent);
|
|
|
|
#else
|
|
|
|
keyboard->public.processInputProc = ProcessKeyboardEvent;
|
|
|
|
keyboard->public.realInputProc = ProcessKeyboardEvent;
|
|
|
|
#endif
|
|
|
|
keyboard->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
|
|
|
|
keyboard->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
|
|
|
|
keyboard->coreEvents = TRUE;
|
|
|
|
keyboard->spriteInfo->spriteOwner = FALSE;
|
|
|
|
|
|
|
|
keyboard->u.lastSlave = NULL;
|
|
|
|
keyboard->isMaster = TRUE;
|
|
|
|
|
2008-04-13 12:18:28 +02:00
|
|
|
|
|
|
|
/* The ClassesRec stores the device classes currently not used. */
|
|
|
|
classes = xcalloc(1, sizeof(ClassesRec));
|
|
|
|
dixSetPrivate(&pointer->devPrivates, UnusedClassesPrivateKey, classes);
|
|
|
|
classes = xcalloc(1, sizeof(ClassesRec));
|
|
|
|
dixSetPrivate(&keyboard->devPrivates, UnusedClassesPrivateKey, classes);
|
|
|
|
|
2007-10-16 11:10:15 +02:00
|
|
|
*ptr = pointer;
|
|
|
|
*keybd = keyboard;
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
}
|