add virtual core devices to DIX
Add virtual core devices, with proper keymaps etc, to the DIX.
This commit is contained in:
parent
737e6e4836
commit
1987af8c49
387
dix/devices.c
387
dix/devices.c
|
@ -80,6 +80,13 @@ SOFTWARE.
|
|||
#include "swaprep.h"
|
||||
#include "dixevents.h"
|
||||
|
||||
#ifdef XINPUT
|
||||
#include <X11/extensions/XIproto.h>
|
||||
#include "exglobals.h"
|
||||
#endif
|
||||
|
||||
int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
|
||||
|
||||
DeviceIntPtr
|
||||
AddInputDevice(DeviceProc deviceProc, Bool autoStart)
|
||||
{
|
||||
|
@ -87,7 +94,7 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
|
|||
|
||||
if (inputInfo.numDevices >= MAX_DEVICES)
|
||||
return (DeviceIntPtr)NULL;
|
||||
dev = (DeviceIntPtr) xalloc(sizeof(DeviceIntRec));
|
||||
dev = (DeviceIntPtr) xcalloc(sizeof(DeviceIntRec), 1);
|
||||
if (!dev)
|
||||
return (DeviceIntPtr)NULL;
|
||||
dev->name = (char *)NULL;
|
||||
|
@ -113,19 +120,21 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
|
|||
dev->button = (ButtonClassPtr)NULL;
|
||||
dev->focus = (FocusClassPtr)NULL;
|
||||
dev->proximity = (ProximityClassPtr)NULL;
|
||||
dev->touchscreen = (TouchscreenClassPtr)NULL;
|
||||
dev->kbdfeed = (KbdFeedbackPtr)NULL;
|
||||
dev->ptrfeed = (PtrFeedbackPtr)NULL;
|
||||
dev->intfeed = (IntegerFeedbackPtr)NULL;
|
||||
dev->stringfeed = (StringFeedbackPtr)NULL;
|
||||
dev->bell = (BellFeedbackPtr)NULL;
|
||||
dev->leds = (LedFeedbackPtr)NULL;
|
||||
dev->next = inputInfo.off_devices;
|
||||
#ifdef XKB
|
||||
dev->xkb_interest= NULL;
|
||||
dev->xkb_interest = NULL;
|
||||
#endif
|
||||
dev->nPrivates = 0;
|
||||
dev->devPrivates = NULL;
|
||||
dev->unwrapProc = NULL;
|
||||
dev->coreEvents = TRUE;
|
||||
dev->next = inputInfo.off_devices;
|
||||
inputInfo.off_devices = dev;
|
||||
return dev;
|
||||
}
|
||||
|
@ -134,14 +143,20 @@ Bool
|
|||
EnableDevice(register DeviceIntPtr dev)
|
||||
{
|
||||
register DeviceIntPtr *prev;
|
||||
int ret;
|
||||
|
||||
for (prev = &inputInfo.off_devices;
|
||||
*prev && (*prev != dev);
|
||||
prev = &(*prev)->next)
|
||||
;
|
||||
if ((*prev != dev) || !dev->inited ||
|
||||
((*dev->deviceProc)(dev, DEVICE_ON) != Success))
|
||||
((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
|
||||
ErrorF("couldn't enable device %d\n", dev->id);
|
||||
#ifdef DEBUG
|
||||
ErrorF("prev is %p, dev is %p, dev->inited is %d, ret is %d\n", prev, dev, dev->inited, ret);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
*prev = dev->next;
|
||||
dev->next = inputInfo.devices;
|
||||
inputInfo.devices = dev;
|
||||
|
@ -166,23 +181,221 @@ DisableDevice(register DeviceIntPtr dev)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
ActivateDevice(DeviceIntPtr dev)
|
||||
{
|
||||
int ret = Success;
|
||||
#ifdef XINPUT
|
||||
devicePresenceNotify ev;
|
||||
DeviceIntRec dummyDev;
|
||||
#endif
|
||||
|
||||
if (!dev || !dev->deviceProc)
|
||||
return BadImplementation;
|
||||
|
||||
ret = (*dev->deviceProc) (dev, DEVICE_INIT);
|
||||
dev->inited = (ret == Success);
|
||||
|
||||
#ifdef XINPUT
|
||||
ev.type = DevicePresenceNotify;
|
||||
ev.time = currentTime.milliseconds;
|
||||
dummyDev.id = 0;
|
||||
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
||||
&ev, 1);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer ctrl, int something)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
CoreKeyboardProc(DeviceIntPtr pDev, int what)
|
||||
{
|
||||
CARD8 *modMap;
|
||||
KeySymsRec keySyms;
|
||||
#ifdef XKB
|
||||
XkbComponentNamesRec names;
|
||||
#endif
|
||||
|
||||
switch (what) {
|
||||
case DEVICE_INIT:
|
||||
keySyms.minKeyCode = 8;
|
||||
keySyms.maxKeyCode = 255;
|
||||
keySyms.mapWidth = 4;
|
||||
keySyms.map = (KeySym *)xcalloc(sizeof(KeySym),
|
||||
(keySyms.maxKeyCode -
|
||||
keySyms.minKeyCode) *
|
||||
keySyms.mapWidth);
|
||||
if (!keySyms.map) {
|
||||
ErrorF("Couldn't allocate core keymap\n");
|
||||
return BadAlloc;
|
||||
}
|
||||
|
||||
modMap = (CARD8 *)xalloc(MAP_LENGTH);
|
||||
if (!modMap) {
|
||||
ErrorF("Couldn't allocate core modifier map\n");
|
||||
return BadAlloc;
|
||||
}
|
||||
bzero((char *)modMap, MAP_LENGTH);
|
||||
|
||||
#ifdef XKB
|
||||
if (!noXkbExtension) {
|
||||
bzero(&names, sizeof(names));
|
||||
XkbSetRulesDflts("base", "pc105", "us", NULL, NULL);
|
||||
XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, modMap,
|
||||
CoreKeyboardBell, CoreKeyboardCtl);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
|
||||
CoreKeyboardBell, CoreKeyboardCtl);
|
||||
break;
|
||||
|
||||
case DEVICE_CLOSE:
|
||||
/* This, uh, probably requires some explanation.
|
||||
* Press a key on another keyboard.
|
||||
* Watch its xkbInfo get pivoted into core's.
|
||||
* Kill the server.
|
||||
* Watch the first device's xkbInfo get freed.
|
||||
* Try to free ours, which points to same.
|
||||
*
|
||||
* ... yeah.
|
||||
*/
|
||||
pDev->key->xkbInfo = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
CorePointerProc(DeviceIntPtr pDev, int what)
|
||||
{
|
||||
BYTE map[33];
|
||||
int i = 0;
|
||||
|
||||
switch (what) {
|
||||
case DEVICE_INIT:
|
||||
for (i = 1; i <= 32; i++)
|
||||
map[i] = i;
|
||||
/* we don't keep history, for now. */
|
||||
InitPointerDeviceStruct((DevicePtr)pDev, map, 32,
|
||||
NULL, (PtrCtrlProcPtr)NoopDDA,
|
||||
0, 2);
|
||||
pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
|
||||
pDev->valuator->lastx = pDev->valuator->axisVal[0];
|
||||
pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
|
||||
pDev->valuator->lasty = pDev->valuator->axisVal[1];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
void
|
||||
InitCoreDevices()
|
||||
{
|
||||
register DeviceIntPtr dev;
|
||||
|
||||
if (CoreDevicePrivatesGeneration != serverGeneration) {
|
||||
CoreDevicePrivatesIndex = AllocateDevicePrivateIndex();
|
||||
CoreDevicePrivatesGeneration = serverGeneration;
|
||||
}
|
||||
|
||||
if (!inputInfo.keyboard) {
|
||||
dev = AddInputDevice(CoreKeyboardProc, TRUE);
|
||||
if (!dev)
|
||||
FatalError("Failed to allocate core keyboard");
|
||||
dev->name = strdup("Virtual core keyboard");
|
||||
#ifdef XKB
|
||||
dev->public.processInputProc = CoreProcessKeyboardEvent;
|
||||
dev->public.realInputProc = CoreProcessKeyboardEvent;
|
||||
if (!noXkbExtension)
|
||||
XkbSetExtension(dev, ProcessKeyboardEvent);
|
||||
#else
|
||||
dev->public.processInputProc = ProcessKeyboardEvent;
|
||||
dev->public.realInputProc = ProcessKeyboardEvent;
|
||||
#endif
|
||||
dev->ActivateGrab = ActivateKeyboardGrab;
|
||||
dev->DeactivateGrab = DeactivateKeyboardGrab;
|
||||
dev->coreEvents = FALSE;
|
||||
if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
|
||||
FatalError("Couldn't allocate keyboard devPrivates\n");
|
||||
dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
|
||||
(void)ActivateDevice(dev);
|
||||
inputInfo.keyboard = dev;
|
||||
}
|
||||
|
||||
if (!inputInfo.pointer) {
|
||||
dev = AddInputDevice(CorePointerProc, TRUE);
|
||||
if (!dev)
|
||||
FatalError("Failed to allocate core pointer");
|
||||
dev->name = strdup("Virtual core pointer");
|
||||
#ifdef XKB
|
||||
dev->public.processInputProc = CoreProcessPointerEvent;
|
||||
dev->public.realInputProc = CoreProcessPointerEvent;
|
||||
if (!noXkbExtension)
|
||||
XkbSetExtension(dev, ProcessPointerEvent);
|
||||
#else
|
||||
dev->public.processInputProc = ProcessPointerEvent;
|
||||
dev->public.realInputProc = ProcessPointerEvent;
|
||||
#endif
|
||||
dev->ActivateGrab = ActivatePointerGrab;
|
||||
dev->DeactivateGrab = DeactivatePointerGrab;
|
||||
dev->coreEvents = FALSE;
|
||||
if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
|
||||
FatalError("Couldn't allocate pointer devPrivates\n");
|
||||
dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
|
||||
(void)ActivateDevice(dev);
|
||||
inputInfo.pointer = dev;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
InitAndStartDevices()
|
||||
{
|
||||
register DeviceIntPtr dev, next;
|
||||
|
||||
for (dev = inputInfo.off_devices; dev; dev = dev->next)
|
||||
dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
|
||||
for (dev = inputInfo.off_devices; dev; dev = dev->next) {
|
||||
#ifdef DEBUG
|
||||
ErrorF("(dix) initialising device %d\n", dev->id);
|
||||
#endif
|
||||
ActivateDevice(dev);
|
||||
#ifdef DEBUG
|
||||
ErrorF("(dix) finished device %d, inited is %d\n", dev->id, dev->inited);
|
||||
#endif
|
||||
}
|
||||
for (dev = inputInfo.off_devices; dev; dev = next)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
ErrorF("(dix) enabling device %d\n", dev->id);
|
||||
#endif
|
||||
next = dev->next;
|
||||
if (dev->inited && dev->startup)
|
||||
(void)EnableDevice(dev);
|
||||
#ifdef DEBUG
|
||||
ErrorF("(dix) finished device %d\n", dev->id);
|
||||
#endif
|
||||
}
|
||||
for (dev = inputInfo.devices;
|
||||
dev && (dev != inputInfo.keyboard);
|
||||
dev = dev->next)
|
||||
;
|
||||
if (!dev || (dev != inputInfo.keyboard)) {
|
||||
ErrorF("No core keyboard\n");
|
||||
return BadImplementation;
|
||||
|
@ -210,9 +423,10 @@ CloseDevice(register DeviceIntPtr dev)
|
|||
|
||||
if (dev->inited)
|
||||
(void)(*dev->deviceProc)(dev, DEVICE_CLOSE);
|
||||
|
||||
xfree(dev->name);
|
||||
if (dev->key)
|
||||
{
|
||||
|
||||
if (dev->key) {
|
||||
#ifdef XKB
|
||||
if (dev->key->xkbInfo)
|
||||
XkbFreeInfo(dev->key->xkbInfo);
|
||||
|
@ -221,20 +435,27 @@ CloseDevice(register DeviceIntPtr dev)
|
|||
xfree(dev->key->modifierKeyMap);
|
||||
xfree(dev->key);
|
||||
}
|
||||
xfree(dev->valuator);
|
||||
|
||||
if (dev->valuator)
|
||||
xfree(dev->valuator);
|
||||
|
||||
if (dev->button) {
|
||||
#ifdef XKB
|
||||
if ((dev->button)&&(dev->button->xkb_acts))
|
||||
xfree(dev->button->xkb_acts);
|
||||
if (dev->button->xkb_acts)
|
||||
xfree(dev->button->xkb_acts);
|
||||
#endif
|
||||
xfree(dev->button);
|
||||
if (dev->focus)
|
||||
{
|
||||
xfree(dev->button);
|
||||
}
|
||||
|
||||
if (dev->focus) {
|
||||
xfree(dev->focus->trace);
|
||||
xfree(dev->focus);
|
||||
}
|
||||
xfree(dev->proximity);
|
||||
for (k=dev->kbdfeed; k; k=knext)
|
||||
{
|
||||
|
||||
if (dev->proximity)
|
||||
xfree(dev->proximity);
|
||||
|
||||
for (k = dev->kbdfeed; k; k = knext) {
|
||||
knext = k->next;
|
||||
#ifdef XKB
|
||||
if (k->xkb_sli)
|
||||
|
@ -242,30 +463,30 @@ CloseDevice(register DeviceIntPtr dev)
|
|||
#endif
|
||||
xfree(k);
|
||||
}
|
||||
for (p=dev->ptrfeed; p; p=pnext)
|
||||
{
|
||||
|
||||
for (p = dev->ptrfeed; p; p = pnext) {
|
||||
pnext = p->next;
|
||||
xfree(p);
|
||||
}
|
||||
for (i=dev->intfeed; i; i=inext)
|
||||
{
|
||||
|
||||
for (i = dev->intfeed; i; i = inext) {
|
||||
inext = i->next;
|
||||
xfree(i);
|
||||
}
|
||||
for (s=dev->stringfeed; s; s=snext)
|
||||
{
|
||||
|
||||
for (s = dev->stringfeed; s; s = snext) {
|
||||
snext = s->next;
|
||||
xfree(s->ctrl.symbols_supported);
|
||||
xfree(s->ctrl.symbols_displayed);
|
||||
xfree(s);
|
||||
}
|
||||
for (b=dev->bell; b; b=bnext)
|
||||
{
|
||||
|
||||
for (b = dev->bell; b; b = bnext) {
|
||||
bnext = b->next;
|
||||
xfree(b);
|
||||
}
|
||||
for (l=dev->leds; l; l=lnext)
|
||||
{
|
||||
|
||||
for (l = dev->leds; l; l = lnext) {
|
||||
lnext = l->next;
|
||||
#ifdef XKB
|
||||
if (l->xkb_sli)
|
||||
|
@ -273,11 +494,12 @@ CloseDevice(register DeviceIntPtr dev)
|
|||
#endif
|
||||
xfree(l);
|
||||
}
|
||||
|
||||
#ifdef XKB
|
||||
while (dev->xkb_interest) {
|
||||
while (dev->xkb_interest)
|
||||
XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
|
||||
}
|
||||
#endif
|
||||
|
||||
xfree(dev->sync.event);
|
||||
xfree(dev);
|
||||
}
|
||||
|
@ -303,48 +525,78 @@ CloseDownDevices()
|
|||
inputInfo.pointer = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
RemoveDevice(register DeviceIntPtr dev)
|
||||
int
|
||||
RemoveDevice(DeviceIntPtr dev)
|
||||
{
|
||||
register DeviceIntPtr prev,tmp,next;
|
||||
DeviceIntPtr prev,tmp,next;
|
||||
int ret = BadMatch;
|
||||
#ifdef XINPUT
|
||||
devicePresenceNotify ev;
|
||||
DeviceIntRec dummyDev;
|
||||
#endif
|
||||
|
||||
prev= NULL;
|
||||
for (tmp= inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
|
||||
#ifdef DEBUG
|
||||
ErrorF("want to remove device %p, kb is %p, pointer is %p\n", dev, inputInfo.keyboard, inputInfo.pointer);
|
||||
#endif
|
||||
|
||||
if (!dev)
|
||||
return BadImplementation;
|
||||
|
||||
prev = NULL;
|
||||
for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
|
||||
next = tmp->next;
|
||||
if (tmp==dev) {
|
||||
if (tmp == dev) {
|
||||
CloseDevice(tmp);
|
||||
|
||||
if (prev==NULL)
|
||||
inputInfo.devices = next;
|
||||
else
|
||||
prev->next = next;
|
||||
|
||||
inputInfo.numDevices--;
|
||||
|
||||
if (inputInfo.keyboard == tmp)
|
||||
inputInfo.keyboard = NULL;
|
||||
else if (inputInfo.pointer == tmp)
|
||||
inputInfo.pointer = NULL;
|
||||
return;
|
||||
|
||||
ret = Success;
|
||||
}
|
||||
}
|
||||
|
||||
prev= NULL;
|
||||
for (tmp= inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
|
||||
prev = NULL;
|
||||
for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
|
||||
next = tmp->next;
|
||||
if (tmp==dev) {
|
||||
if (tmp == dev) {
|
||||
CloseDevice(tmp);
|
||||
if (prev==NULL)
|
||||
|
||||
if (prev == NULL)
|
||||
inputInfo.off_devices = next;
|
||||
else
|
||||
prev->next = next;
|
||||
|
||||
inputInfo.numDevices--;
|
||||
|
||||
if (inputInfo.keyboard == tmp)
|
||||
inputInfo.keyboard = NULL;
|
||||
else if (inputInfo.pointer == tmp)
|
||||
inputInfo.pointer = NULL;
|
||||
return;
|
||||
|
||||
ret = Success;
|
||||
}
|
||||
}
|
||||
ErrorF("Internal Error! Attempt to remove a non-existent device\n");
|
||||
return;
|
||||
|
||||
#ifdef XINPUT
|
||||
if (ret == Success) {
|
||||
ev.type = DevicePresenceNotify;
|
||||
ev.time = currentTime.milliseconds;
|
||||
dummyDev.id = 0;
|
||||
SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
|
||||
&ev, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -356,47 +608,13 @@ NumMotionEvents()
|
|||
void
|
||||
RegisterPointerDevice(DeviceIntPtr device)
|
||||
{
|
||||
inputInfo.pointer = device;
|
||||
#ifdef XKB
|
||||
device->public.processInputProc = CoreProcessPointerEvent;
|
||||
device->public.realInputProc = CoreProcessPointerEvent;
|
||||
if (!noXkbExtension)
|
||||
XkbSetExtension(device,ProcessPointerEvent);
|
||||
#else
|
||||
device->public.processInputProc = ProcessPointerEvent;
|
||||
device->public.realInputProc = ProcessPointerEvent;
|
||||
#endif
|
||||
device->ActivateGrab = ActivatePointerGrab;
|
||||
device->DeactivateGrab = DeactivatePointerGrab;
|
||||
if (!device->name)
|
||||
{
|
||||
char *p = "pointer";
|
||||
device->name = (char *)xalloc(strlen(p) + 1);
|
||||
strcpy(device->name, p);
|
||||
}
|
||||
RegisterOtherDevice(device);
|
||||
}
|
||||
|
||||
void
|
||||
RegisterKeyboardDevice(DeviceIntPtr device)
|
||||
{
|
||||
inputInfo.keyboard = device;
|
||||
#ifdef XKB
|
||||
device->public.processInputProc = CoreProcessKeyboardEvent;
|
||||
device->public.realInputProc = CoreProcessKeyboardEvent;
|
||||
if (!noXkbExtension)
|
||||
XkbSetExtension(device,ProcessKeyboardEvent);
|
||||
#else
|
||||
device->public.processInputProc = ProcessKeyboardEvent;
|
||||
device->public.realInputProc = ProcessKeyboardEvent;
|
||||
#endif
|
||||
device->ActivateGrab = ActivateKeyboardGrab;
|
||||
device->DeactivateGrab = DeactivateKeyboardGrab;
|
||||
if (!device->name)
|
||||
{
|
||||
char *k = "keyboard";
|
||||
device->name = (char *)xalloc(strlen(k) + 1);
|
||||
strcpy(device->name, k);
|
||||
}
|
||||
RegisterOtherDevice(device);
|
||||
}
|
||||
|
||||
_X_EXPORT DevicePtr
|
||||
|
@ -441,8 +659,8 @@ SetKeySymsMap(register KeySymsPtr dst, register KeySymsPtr src)
|
|||
{
|
||||
int i, j;
|
||||
int rowDif = src->minKeyCode - dst->minKeyCode;
|
||||
/* if keysym map size changes, grow map first */
|
||||
|
||||
/* if keysym map size changes, grow map first */
|
||||
if (src->mapWidth < dst->mapWidth)
|
||||
{
|
||||
for (i = src->minKeyCode; i <= src->maxKeyCode; i++)
|
||||
|
@ -532,7 +750,7 @@ InitKeyClassDeviceStruct(DeviceIntPtr dev, KeySymsPtr pKeySyms, CARD8 pModifiers
|
|||
{
|
||||
int i;
|
||||
register KeyClassPtr keyc;
|
||||
|
||||
|
||||
keyc = (KeyClassPtr)xalloc(sizeof(KeyClassRec));
|
||||
if (!keyc)
|
||||
return FALSE;
|
||||
|
@ -808,12 +1026,13 @@ InitIntegerFeedbackClassDeviceStruct (DeviceIntPtr dev, IntegerCtrlProcPtr contr
|
|||
_X_EXPORT Bool
|
||||
InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons,
|
||||
ValuatorMotionProcPtr motionProc,
|
||||
PtrCtrlProcPtr controlProc, int numMotionEvents)
|
||||
PtrCtrlProcPtr controlProc, int numMotionEvents,
|
||||
int numAxes)
|
||||
{
|
||||
DeviceIntPtr dev = (DeviceIntPtr)device;
|
||||
|
||||
return(InitButtonClassDeviceStruct(dev, numButtons, map) &&
|
||||
InitValuatorClassDeviceStruct(dev, 2, motionProc,
|
||||
InitValuatorClassDeviceStruct(dev, numAxes, motionProc,
|
||||
numMotionEvents, 0) &&
|
||||
InitPtrFeedbackClassDeviceStruct(dev, controlProc));
|
||||
}
|
||||
|
|
|
@ -134,6 +134,7 @@ of the copyright holder.
|
|||
#include "globals.h"
|
||||
|
||||
#ifdef XKB
|
||||
#include <X11/extensions/XKBproto.h>
|
||||
#include <X11/extensions/XKBsrv.h>
|
||||
extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
|
||||
#endif
|
||||
|
@ -159,14 +160,13 @@ xEvent *xeviexE;
|
|||
#include <X11/extensions/XIproto.h>
|
||||
#include "exglobals.h"
|
||||
#include "exevents.h"
|
||||
#include "exglobals.h"
|
||||
#include "extnsionst.h"
|
||||
|
||||
#include "dixevents.h"
|
||||
#include "dixgrabs.h"
|
||||
#include "dispatch.h"
|
||||
|
||||
int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
|
||||
|
||||
#define EXTENSION_EVENT_BASE 64
|
||||
|
||||
#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
|
||||
|
|
|
@ -398,6 +398,7 @@ main(int argc, char *argv[], char *envp[])
|
|||
if (!CreateRootWindow(pScreen))
|
||||
FatalError("failed to create root window");
|
||||
}
|
||||
InitCoreDevices();
|
||||
InitInput(argc, argv);
|
||||
if (InitAndStartDevices() != Success)
|
||||
FatalError("failed to initialize core devices");
|
||||
|
|
|
@ -176,6 +176,9 @@ extern DeviceIntPtr AddInputDevice(
|
|||
extern Bool EnableDevice(
|
||||
DeviceIntPtr /*device*/);
|
||||
|
||||
extern Bool ActivateDevice(
|
||||
DeviceIntPtr /*device*/);
|
||||
|
||||
extern Bool DisableDevice(
|
||||
DeviceIntPtr /*device*/);
|
||||
|
||||
|
@ -183,7 +186,7 @@ extern int InitAndStartDevices(void);
|
|||
|
||||
extern void CloseDownDevices(void);
|
||||
|
||||
extern void RemoveDevice(
|
||||
extern int RemoveDevice(
|
||||
DeviceIntPtr /*dev*/);
|
||||
|
||||
extern int NumMotionEvents(void);
|
||||
|
@ -233,6 +236,9 @@ extern Bool InitValuatorClassDeviceStruct(
|
|||
int /*numMotionEvents*/,
|
||||
int /*mode*/);
|
||||
|
||||
extern Bool InitTouchscreenClassDeviceStruct(
|
||||
DeviceIntPtr /*device*/);
|
||||
|
||||
extern Bool InitFocusClassDeviceStruct(
|
||||
DeviceIntPtr /*device*/);
|
||||
|
||||
|
@ -302,7 +308,8 @@ extern Bool InitPointerDeviceStruct(
|
|||
int /*numButtons*/,
|
||||
ValuatorMotionProcPtr /*motionProc*/,
|
||||
PtrCtrlProcPtr /*controlProc*/,
|
||||
int /*numMotionEvents*/);
|
||||
int /*numMotionEvents*/,
|
||||
int /*numAxes*/);
|
||||
|
||||
extern Bool InitKeyboardDeviceStruct(
|
||||
DevicePtr /*device*/,
|
||||
|
|
|
@ -68,6 +68,8 @@ SOFTWARE.
|
|||
#define POINTER_ABSOLUTE (1 << 2)
|
||||
#define POINTER_ACCELERATE (1 << 3)
|
||||
|
||||
extern int CoreDevicePrivatesIndex, CoreDevicePrivatesGeneration;
|
||||
|
||||
/* Kludge: OtherClients and InputClients must be compatible, see code */
|
||||
|
||||
typedef struct _OtherClients {
|
||||
|
|
3
mi/mi.h
3
mi/mi.h
|
@ -171,8 +171,7 @@ typedef struct _DeviceRec *DevicePtr;
|
|||
#endif
|
||||
|
||||
extern Bool mieqInit(
|
||||
DevicePtr /*pKbd*/,
|
||||
DevicePtr /*pPtr*/
|
||||
void
|
||||
);
|
||||
|
||||
extern void mieqEnqueue(
|
||||
|
|
143
mi/mieq.c
143
mi/mieq.c
|
@ -43,35 +43,38 @@ in this Software without prior written authorization from The Open Group.
|
|||
# include "pixmapstr.h"
|
||||
# include "inputstr.h"
|
||||
# include "mi.h"
|
||||
# include "mipointer.h"
|
||||
# include "scrnintstr.h"
|
||||
# include <X11/extensions/XI.h>
|
||||
# include <X11/extensions/XIproto.h>
|
||||
# include "extinit.h"
|
||||
# include "exglobals.h"
|
||||
|
||||
#define QUEUE_SIZE 256
|
||||
|
||||
typedef struct _Event {
|
||||
xEvent event;
|
||||
ScreenPtr pScreen;
|
||||
xEvent event[2];
|
||||
int nevents;
|
||||
ScreenPtr pScreen;
|
||||
DeviceIntPtr pDev;
|
||||
} EventRec, *EventPtr;
|
||||
|
||||
typedef struct _EventQueue {
|
||||
HWEventQueueType head, tail; /* long for SetInputCheck */
|
||||
CARD32 lastEventTime; /* to avoid time running backwards */
|
||||
Bool lastMotion;
|
||||
EventRec events[QUEUE_SIZE]; /* static allocation for signals */
|
||||
DevicePtr pKbd, pPtr; /* device pointer, to get funcs */
|
||||
ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
|
||||
ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
|
||||
HWEventQueueType head, tail; /* long for SetInputCheck */
|
||||
CARD32 lastEventTime; /* to avoid time running backwards */
|
||||
int lastMotion; /* device ID if last event motion? */
|
||||
EventRec events[QUEUE_SIZE]; /* static allocation for signals */
|
||||
ScreenPtr pEnqueueScreen; /* screen events are being delivered to */
|
||||
ScreenPtr pDequeueScreen; /* screen events are being dispatched to */
|
||||
} EventQueueRec, *EventQueuePtr;
|
||||
|
||||
static EventQueueRec miEventQueue;
|
||||
|
||||
Bool
|
||||
mieqInit (pKbd, pPtr)
|
||||
DevicePtr pKbd, pPtr;
|
||||
mieqInit ()
|
||||
{
|
||||
miEventQueue.head = miEventQueue.tail = 0;
|
||||
miEventQueue.lastEventTime = GetTimeInMillis ();
|
||||
miEventQueue.pKbd = pKbd;
|
||||
miEventQueue.pPtr = pPtr;
|
||||
miEventQueue.lastMotion = FALSE;
|
||||
miEventQueue.pEnqueueScreen = screenInfo.screens[0];
|
||||
miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen;
|
||||
|
@ -87,32 +90,83 @@ mieqInit (pKbd, pPtr)
|
|||
*/
|
||||
|
||||
void
|
||||
mieqEnqueue (e)
|
||||
xEvent *e;
|
||||
mieqEnqueue (xEvent *e)
|
||||
{
|
||||
HWEventQueueType oldtail, newtail;
|
||||
Bool isMotion;
|
||||
HWEventQueueType oldtail = miEventQueue.tail, newtail;
|
||||
int isMotion = 0;
|
||||
DeviceIntPtr pDev = NULL;
|
||||
deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) e;
|
||||
deviceValuator *v = (deviceValuator *) e;
|
||||
EventPtr laste = &miEventQueue.events[oldtail - 1];
|
||||
deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *)
|
||||
&laste->event[0];
|
||||
|
||||
oldtail = miEventQueue.tail;
|
||||
isMotion = e->u.u.type == MotionNotify;
|
||||
if (isMotion && miEventQueue.lastMotion && oldtail != miEventQueue.head)
|
||||
{
|
||||
ErrorF("mieqEnqueue: slamming an event on to the queue from %d\n", kbp->deviceid & DEVICE_BITS);
|
||||
if (e->u.u.type == MotionNotify) {
|
||||
miPointerAbsoluteCursor(e->u.keyButtonPointer.rootX,
|
||||
e->u.keyButtonPointer.rootY,
|
||||
e->u.keyButtonPointer.time);
|
||||
pDev = inputInfo.pointer;
|
||||
isMotion = inputInfo.pointer->id & DEVICE_BITS;
|
||||
}
|
||||
else if (e->u.u.type == KeyPress || e->u.u.type == KeyRelease) {
|
||||
pDev = inputInfo.keyboard;
|
||||
}
|
||||
else if (e->u.u.type == ButtonPress || e->u.u.type == ButtonRelease) {
|
||||
pDev = inputInfo.pointer;
|
||||
}
|
||||
else {
|
||||
pDev = LookupDeviceIntRec(kbp->deviceid & DEVICE_BITS);
|
||||
|
||||
/* We silently steal valuator events: just tack them on to the last
|
||||
* motion event they need to be attached to. Sigh. */
|
||||
if (e->u.u.type == DeviceValuator) {
|
||||
if (laste->nevents >= 6) {
|
||||
ErrorF("mieqEnqueue: more than six valuator events; dropping.\n");
|
||||
return;
|
||||
}
|
||||
if (oldtail == miEventQueue.head ||
|
||||
!(lastkbp->type == DeviceMotionNotify ||
|
||||
lastkbp->type == DeviceButtonPress ||
|
||||
lastkbp->type == DeviceButtonRelease) ||
|
||||
((lastkbp->deviceid & DEVICE_BITS) !=
|
||||
(v->deviceid & DEVICE_BITS))) {
|
||||
ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
|
||||
return;
|
||||
}
|
||||
laste->event[laste->nevents++] = *e;
|
||||
ErrorF("put a valuator event into the queue\n");
|
||||
return;
|
||||
}
|
||||
else if (e->u.u.type == DeviceMotionNotify) {
|
||||
isMotion = pDev->id & DEVICE_BITS;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pDev)
|
||||
FatalError("Couldn't find device for event!\n");
|
||||
|
||||
if (isMotion && isMotion == miEventQueue.lastMotion &&
|
||||
oldtail != miEventQueue.head) {
|
||||
if (oldtail == 0)
|
||||
oldtail = QUEUE_SIZE;
|
||||
oldtail = oldtail - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
newtail = oldtail + 1;
|
||||
if (newtail == QUEUE_SIZE)
|
||||
newtail = 0;
|
||||
/* Toss events which come in late */
|
||||
if (newtail == miEventQueue.head)
|
||||
if (newtail == miEventQueue.head) {
|
||||
ErrorF("tossed event which came in late\n");
|
||||
return;
|
||||
}
|
||||
miEventQueue.tail = newtail;
|
||||
}
|
||||
miEventQueue.lastMotion = isMotion;
|
||||
miEventQueue.events[oldtail].event = *e;
|
||||
|
||||
miEventQueue.events[oldtail].event[0] = *e;
|
||||
miEventQueue.events[oldtail].nevents = 1;
|
||||
|
||||
/*
|
||||
* Make sure that event times don't go backwards - this
|
||||
* is "unnecessary", but very useful
|
||||
|
@ -120,18 +174,23 @@ mieqEnqueue (e)
|
|||
if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime &&
|
||||
miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
|
||||
{
|
||||
miEventQueue.events[oldtail].event.u.keyButtonPointer.time =
|
||||
ErrorF("mieq: rewinding event time from %d to %d\n",
|
||||
miEventQueue.lastEventTime,
|
||||
miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time);
|
||||
miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time =
|
||||
miEventQueue.lastEventTime;
|
||||
}
|
||||
miEventQueue.lastEventTime =
|
||||
miEventQueue.events[oldtail].event.u.keyButtonPointer.time;
|
||||
miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time;
|
||||
miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen;
|
||||
miEventQueue.events[oldtail].pDev = pDev;
|
||||
|
||||
miEventQueue.lastMotion = isMotion;
|
||||
ErrorF("bottom of mieqEnqueue\n");
|
||||
}
|
||||
|
||||
void
|
||||
mieqSwitchScreen (pScreen, fromDIX)
|
||||
ScreenPtr pScreen;
|
||||
Bool fromDIX;
|
||||
mieqSwitchScreen (ScreenPtr pScreen, Bool fromDIX)
|
||||
{
|
||||
miEventQueue.pEnqueueScreen = pScreen;
|
||||
if (fromDIX)
|
||||
|
@ -146,7 +205,8 @@ void mieqProcessInputEvents ()
|
|||
{
|
||||
EventRec *e;
|
||||
int x, y;
|
||||
xEvent xe;
|
||||
|
||||
ErrorF("mieqPIE: head %p, tail %p\n", miEventQueue.head, miEventQueue.tail);
|
||||
|
||||
while (miEventQueue.head != miEventQueue.tail)
|
||||
{
|
||||
|
@ -160,8 +220,8 @@ void mieqProcessInputEvents ()
|
|||
if (e->pScreen != miEventQueue.pDequeueScreen)
|
||||
{
|
||||
miEventQueue.pDequeueScreen = e->pScreen;
|
||||
x = e->event.u.keyButtonPointer.rootX;
|
||||
y = e->event.u.keyButtonPointer.rootY;
|
||||
x = e->event[0].u.keyButtonPointer.rootX;
|
||||
y = e->event[0].u.keyButtonPointer.rootY;
|
||||
if (miEventQueue.head == QUEUE_SIZE - 1)
|
||||
miEventQueue.head = 0;
|
||||
else
|
||||
|
@ -170,23 +230,12 @@ void mieqProcessInputEvents ()
|
|||
}
|
||||
else
|
||||
{
|
||||
xe = e->event;
|
||||
if (miEventQueue.head == QUEUE_SIZE - 1)
|
||||
miEventQueue.head = 0;
|
||||
else
|
||||
++miEventQueue.head;
|
||||
switch (xe.u.u.type)
|
||||
{
|
||||
case KeyPress:
|
||||
case KeyRelease:
|
||||
(*miEventQueue.pKbd->processInputProc)
|
||||
(&xe, (DeviceIntPtr)miEventQueue.pKbd, 1);
|
||||
break;
|
||||
default:
|
||||
(*miEventQueue.pPtr->processInputProc)
|
||||
(&xe, (DeviceIntPtr)miEventQueue.pPtr, 1);
|
||||
break;
|
||||
}
|
||||
ErrorF("calling pIP from mieqPIE\n");
|
||||
(*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -490,12 +490,6 @@ miPointerMove (pScreen, x, y, time)
|
|||
miPointer.y = y;
|
||||
miPointer.pScreen = pScreen;
|
||||
|
||||
xE.u.u.type = MotionNotify;
|
||||
xE.u.keyButtonPointer.rootX = x;
|
||||
xE.u.keyButtonPointer.rootY = y;
|
||||
xE.u.keyButtonPointer.time = time;
|
||||
(*pScreenPriv->screenFuncs->EnqueueEvent) (&xE);
|
||||
|
||||
end = miPointer.history_end;
|
||||
start = miPointer.history_start;
|
||||
prev = end - 1;
|
||||
|
@ -521,11 +515,3 @@ miPointerMove (pScreen, x, y, time)
|
|||
history->event.time = time;
|
||||
history->pScreen = pScreen;
|
||||
}
|
||||
|
||||
void
|
||||
miRegisterPointerDevice (pScreen, pDevice)
|
||||
ScreenPtr pScreen;
|
||||
DeviceIntPtr pDevice;
|
||||
{
|
||||
miPointer.pPointer = (DevicePtr)pDevice;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ typedef struct {
|
|||
Bool confined; /* pointer can't change screens */
|
||||
int x, y; /* hot spot location */
|
||||
int devx, devy; /* sprite position */
|
||||
DevicePtr pPointer; /* pointer device structure */
|
||||
miHistoryRec history[MOTION_SIZE];
|
||||
int history_start, history_end;
|
||||
} miPointerRec, *miPointerPtr;
|
||||
|
|
Loading…
Reference in New Issue
Block a user