Xi: adding MPX checks to ProcessOtherEvents

mpx:    adding QueryPointer request and reply
	adjusting names of requests to Xlib compatible naming (xMPX*** instead of
	mpx***)
This commit is contained in:
Peter Hutterer 2006-12-05 15:45:18 +10:30 committed by Peter Hutterer
parent 416f1bb99a
commit 2a511492f9
13 changed files with 222 additions and 70 deletions

View File

@ -1,4 +1,26 @@
MPX Changelog file
== 05.12.06 ==
Xi: adding MPX checks to ProcessOtherEvents
mpx: adding QueryPointer request and reply
adjusting names of requests to Xlib compatible naming (xMPX*** instead of
mpx***)
Files:
Xi/exevents.c
mpx/Makefile.am
mpx/extinit.c
mpx/getevbase.c
mpx/getvers.c
mpx/queryptr.c
mpx/queryptr.h
mpx/selectev.c
mpx/listdev.h
mpx/listdev.c
include/mpxextinit.h
== 01.12.06 ==
mpx: SelectEvents and GetEventBase requests.

View File

@ -73,6 +73,12 @@ SOFTWARE.
#include "dixgrabs.h" /* CreateGrab() */
#include "scrnintstr.h"
#ifdef MPX
#include <X11/extensions/MPXconst.h>
#include <X11/extensions/MPXproto.h>
#include "mpxglobals.h"
#endif
#define WID(w) ((w) ? ((w)->drawable.id) : 0)
#define AllModifiersMask ( \
ShiftMask | LockMask | ControlMask | Mod1Mask | Mod2Mask | \
@ -230,7 +236,11 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
if (other->fromPassiveGrab && (key == other->activatingKey))
deactivateDeviceGrab = TRUE;
} else if (xE->u.u.type == DeviceButtonPress) {
} else if (xE->u.u.type == DeviceButtonPress
#ifdef MPX
|| xE->u.u.type == MPXButtonPress
#endif
) {
if (!b)
return;
@ -246,11 +256,17 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
if (xE->u.u.detail <= 5)
b->state |= (Button1Mask >> 1) << xE->u.u.detail;
SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
if (!grab)
if (CheckDeviceGrabs(other, xE, 0, count))
return;
#ifdef MPX
if (xE->u.u.type == DeviceButtonPress)
#endif
if (!grab)
if (CheckDeviceGrabs(other, xE, 0, count))
return;
} else if (xE->u.u.type == DeviceButtonRelease) {
} else if (xE->u.u.type == DeviceButtonRelease
#ifdef MPX
|| xE->u.u.type == MPXButtonRelease
#endif) {
if (!b)
return;
@ -266,8 +282,11 @@ ProcessOtherEvent(xEventPtr xE, register DeviceIntPtr other, int count)
if (xE->u.u.detail <= 5)
b->state &= ~((Button1Mask >> 1) << xE->u.u.detail);
SetMaskForEvent(Motion_Filter(b), DeviceMotionNotify);
if (!b->state && other->fromPassiveGrab)
deactivateDeviceGrab = TRUE;
#ifdef MPX
if (xE->u.u.type == DeviceButtonRelease)
#endif
if (!b->state && other->fromPassiveGrab)
deactivateDeviceGrab = TRUE;
} else if (xE->u.u.type == ProximityIn)
other->valuator->mode &= ~OutOfProximity;
else if (xE->u.u.type == ProximityOut)

View File

@ -28,7 +28,7 @@ void
SReplyMPXDispatch (
ClientPtr /* client */,
int /* len */,
mpxGetExtensionVersionReply * /* rep */
xMPXGetExtensionVersionReply * /* rep */
);
void

View File

@ -12,5 +12,7 @@ libmpx_la_SOURCES = \
selectev.h \
mpxglobals.h \
getevbase.c \
getevbase.h
getevbase.h \
queryptr.h \
queryptr.c

View File

@ -7,7 +7,6 @@
#include <X11/X.h>
#include <X11/Xproto.h>
#include "inputstr.h"
//#include "gcstruct.h" /* pointer for extnsionst.h */
#include "extnsionst.h" /* extension entry */
#include <X11/extensions/MPX.h>
#include <X11/extensions/MPXproto.h>
@ -21,6 +20,7 @@
#include "listdev.h"
#include "selectev.h"
#include "getevbase.h"
#include "queryptr.h"
static Mask lastExtEventMask = 1;
int MPXEventIndex;
@ -74,7 +74,6 @@ int MPXLastEvent;
*/
static MPXExtensionVersion thisversion = {
MPX_Present,
MPX_Major,
MPX_Minor
};
@ -125,14 +124,16 @@ int
ProcMPXDispatch(register ClientPtr client)
{
REQUEST(xReq);
if (stuff->data == MPX_GetExtensionVersion)
if (stuff->data == X_MPXGetExtensionVersion)
return (ProcMPXGetExtensionVersion(client));
if (stuff->data == MPX_ListDevices)
if (stuff->data == X_MPXListDevices)
return (ProcMPXListDevices(client));
if (stuff->data == MPX_SelectEvents)
if (stuff->data == X_MPXSelectEvents)
return (ProcMPXSelectEvents(client));
if (stuff->data == MPX_GetEventBase)
if (stuff->data == X_MPXGetEventBase)
return (ProcMPXGetEventBase(client));
if (stuff->data == X_MPXQueryPointer)
return (ProcMPXQueryPointer(client));
else {
SendErrorToClient(client, MPXReqCode, stuff->data, 0, BadRequest);
}
@ -153,14 +154,16 @@ int
SProcMPXDispatch(register ClientPtr client)
{
REQUEST(xReq);
if (stuff->data == MPX_GetExtensionVersion)
if (stuff->data == X_MPXGetExtensionVersion)
return (SProcMPXGetExtensionVersion(client));
if (stuff->data == MPX_ListDevices)
if (stuff->data == X_MPXListDevices)
return (SProcMPXListDevices(client));
if (stuff->data == MPX_SelectEvents)
if (stuff->data == X_MPXSelectEvents)
return (SProcMPXSelectEvents(client));
if (stuff->data == MPX_GetEventBase)
if (stuff->data == X_MPXGetEventBase)
return (SProcMPXGetEventBase(client));
if (stuff->data == X_MPXQueryPointer)
return (SProcMPXQueryPointer(client));
else {
SendErrorToClient(client, MPXReqCode, stuff->data, 0, BadRequest);
}
@ -188,14 +191,14 @@ MPXResetProc(ExtensionEntry* unused)
}
void SReplyMPXDispatch(ClientPtr client, int len, mpxGetExtensionVersionReply* rep)
void SReplyMPXDispatch(ClientPtr client, int len, xMPXGetExtensionVersionReply* rep)
{
if (rep->RepType == MPX_GetExtensionVersion)
if (rep->RepType == X_MPXGetExtensionVersion)
SRepMPXGetExtensionVersion(client, len,
(mpxGetExtensionVersionReply*) rep);
if (rep->RepType == MPX_ListDevices)
(xMPXGetExtensionVersionReply*) rep);
if (rep->RepType == X_MPXListDevices)
SRepMPXListDevices(client, len,
(mpxListDevicesReply*) rep);
(xMPXListDevicesReply*) rep);
else {
FatalError("MPX confused sending swapped reply");
}

View File

@ -20,20 +20,20 @@
int
ProcMPXGetEventBase(register ClientPtr client)
{
mpxGetEventBaseReply rep;
xMPXGetEventBaseReply rep;
REQUEST(mpxGetEventBaseReq);
REQUEST_SIZE_MATCH(mpxGetEventBaseReq);
REQUEST(xMPXGetEventBaseReq);
REQUEST_SIZE_MATCH(xMPXGetEventBaseReq);
memset(&rep, 0, sizeof(mpxGetEventBaseReply));
memset(&rep, 0, sizeof(xMPXGetEventBaseReply));
rep.repType = X_Reply;
rep.RepType = MPX_GetEventBase;
rep.RepType = X_MPXGetEventBase;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.eventBase = MPXEventBase;
WriteReplyToClient(client, sizeof(mpxGetEventBaseReply), &rep);
WriteReplyToClient(client, sizeof(xMPXGetEventBaseReply), &rep);
return Success;
}
@ -47,9 +47,9 @@ SProcMPXGetEventBase(register ClientPtr client)
{
register char n;
REQUEST(mpxGetEventBaseReq);
REQUEST(xMPXGetEventBaseReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(mpxGetEventBaseReq);
REQUEST_SIZE_MATCH(xMPXGetEventBaseReq);
return (ProcMPXGetEventBase(client));
}

View File

@ -26,11 +26,11 @@ SProcMPXGetExtensionVersion(register ClientPtr client)
{
register char n;
REQUEST(mpxGetExtensionVersionReq);
REQUEST(xMPXGetExtensionVersionReq);
swaps(&stuff->length, n);
swaps(&stuff->major_version, n);
swaps(&stuff->minor_version, n);
REQUEST_AT_LEAST_SIZE(mpxGetExtensionVersionReq);
REQUEST_AT_LEAST_SIZE(xMPXGetExtensionVersionReq);
return (ProcMPXGetExtensionVersion(client));
}
/***********************************************************************
@ -41,19 +41,19 @@ SProcMPXGetExtensionVersion(register ClientPtr client)
int
ProcMPXGetExtensionVersion(register ClientPtr client)
{
mpxGetExtensionVersionReply rep;
xMPXGetExtensionVersionReply rep;
REQUEST(mpxGetExtensionVersionReq);
REQUEST_SIZE_MATCH(mpxGetExtensionVersionReq);
REQUEST(xMPXGetExtensionVersionReq);
REQUEST_SIZE_MATCH(xMPXGetExtensionVersionReq);
rep.repType = X_Reply;
rep.RepType = MPX_GetExtensionVersion;
rep.RepType = X_MPXGetExtensionVersion;
rep.length = 0;
rep.sequenceNumber = client->sequence;
rep.major_version = AllExtensionVersions[MPXReqCode - 128].major_version;
rep.minor_version = AllExtensionVersions[MPXReqCode - 128].minor_version;
WriteReplyToClient(client, sizeof(mpxGetExtensionVersionReply), &rep);
rep.major_version = AllExtensionVersions[MPXReqCode - 128].major;
rep.minor_version = AllExtensionVersions[MPXReqCode - 128].minor;
WriteReplyToClient(client, sizeof(xMPXGetExtensionVersionReply), &rep);
return Success;
}
@ -67,7 +67,7 @@ ProcMPXGetExtensionVersion(register ClientPtr client)
void
SRepMPXGetExtensionVersion(ClientPtr client, int size,
mpxGetExtensionVersionReply * rep)
xMPXGetExtensionVersionReply * rep)
{
register char n;

View File

@ -15,7 +15,7 @@ int ProcMPXGetExtensionVersion(ClientPtr /* client */
void SRepMPXGetExtensionVersion(ClientPtr /* client */ ,
int /* size */ ,
mpxGetExtensionVersionReply * /* rep */
xMPXGetExtensionVersionReply * /* rep */
);
#endif

View File

@ -25,7 +25,7 @@ int SProcMPXListDevices(register ClientPtr client)
{
register char n;
REQUEST(mpxListDevicesReq);
REQUEST(xMPXListDevicesReq);
swaps(&stuff->length, n);
return (ProcMPXListDevices(client));
}
@ -38,7 +38,7 @@ int SProcMPXListDevices(register ClientPtr client)
*/
int ProcMPXListDevices(register ClientPtr client)
{
mpxListDevicesReply rep;
xMPXListDevicesReply rep;
int numdevs = 0;
int namesize = 1; /* need 1 extra byte for strcpy */
int size = 0;
@ -46,13 +46,13 @@ int ProcMPXListDevices(register ClientPtr client)
char* devbuf;
char* namebuf;
char *savbuf;
mpxDeviceInfoPtr dev;
xMPXDeviceInfoPtr dev;
DeviceIntPtr d;
REQUEST_SIZE_MATCH(mpxListDevicesReq);
memset(&rep, 0, sizeof(mpxListDevicesReply));
REQUEST_SIZE_MATCH(xMPXListDevicesReq);
memset(&rep, 0, sizeof(xMPXListDevicesReply));
rep.repType = X_Reply;
rep.RepType = MPX_ListDevices;
rep.RepType = X_MPXListDevices;
rep.length = 0;
rep.sequenceNumber = client->sequence;
@ -72,12 +72,12 @@ int ProcMPXListDevices(register ClientPtr client)
}
}
total_length = numdevs * sizeof(mpxDeviceInfo) + size + namesize;
total_length = numdevs * sizeof(xMPXDeviceInfo) + size + namesize;
devbuf = (char *)xalloc(total_length);
namebuf = devbuf + (numdevs * sizeof(mpxDeviceInfo));
namebuf = devbuf + (numdevs * sizeof(xMPXDeviceInfo));
savbuf = devbuf;
dev = (mpxDeviceInfoPtr) devbuf;
dev = (xMPXDeviceInfoPtr) devbuf;
for (d = inputInfo.devices; d; d = d->next, dev++)
if (d->isMPDev)
SetMPXDeviceInfo(client, d, dev, &devbuf, &namebuf);
@ -87,7 +87,7 @@ int ProcMPXListDevices(register ClientPtr client)
rep.ndevices = numdevs;
rep.length = (total_length + 3) >> 2;
WriteReplyToClient(client, sizeof(mpxListDevicesReply), &rep);
WriteReplyToClient(client, sizeof(xMPXListDevicesReply), &rep);
WriteToClient(client, total_length, savbuf);
xfree(savbuf);
return Success;
@ -115,7 +115,7 @@ SizeMPXDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
*/
void
SetMPXDeviceInfo(ClientPtr client, DeviceIntPtr d, mpxDeviceInfoPtr dev,
SetMPXDeviceInfo(ClientPtr client, DeviceIntPtr d, xMPXDeviceInfoPtr dev,
char **devbuf, char **namebuf)
{
MPXCopyDeviceName(namebuf, d->name);
@ -157,17 +157,17 @@ void
MPXCopySwapDevice(register ClientPtr client, DeviceIntPtr d, char **buf)
{
register char n;
mpxDeviceInfoPtr dev;
xMPXDeviceInfoPtr dev;
dev = (mpxDeviceInfoPtr) * buf;
memset(dev, 0, sizeof(mpxDeviceInfo));
dev = (xMPXDeviceInfoPtr) * buf;
memset(dev, 0, sizeof(xMPXDeviceInfo));
dev->id = d->id;
dev->type = d->type;
if (client->swapped) {
swapl(&dev->type, n); /* macro - braces are required */
}
*buf += sizeof(mpxDeviceInfo);
*buf += sizeof(xMPXDeviceInfo);
}
/***********************************************************************
@ -177,7 +177,7 @@ MPXCopySwapDevice(register ClientPtr client, DeviceIntPtr d, char **buf)
*
*/
void
SRepMPXListDevices(ClientPtr client, int size, mpxListDevicesReply * rep)
SRepMPXListDevices(ClientPtr client, int size, xMPXListDevicesReply * rep)
{
register char n;

View File

@ -31,7 +31,7 @@ void SizeMPXDeviceInfo(DeviceIntPtr /* d */ ,
void SetMPXDeviceInfo(ClientPtr /* client */ ,
DeviceIntPtr /* d */ ,
mpxDeviceInfoPtr /* dev */ ,
xMPXDeviceInfoPtr /* dev */ ,
char ** /* devbuf */ ,
char ** /* namebuf */
);
@ -48,6 +48,6 @@ void MPXCopySwapDevice(ClientPtr /* client */ ,
void SRepMPXListDevices(ClientPtr /* client */ ,
int /* size */ ,
mpxListDevicesReply * /* rep */
xMPXListDevicesReply * /* rep */
);
#endif

90
mpx/queryptr.c Normal file
View File

@ -0,0 +1,90 @@
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "inputstr.h"
#include "windowstr.h"
#include <X11/extensions/MPX.h>
#include <X11/extensions/MPXproto.h>
#include "mpxglobals.h"
#include "queryptr.h"
/***********************************************************************
*
* This procedure writes the reply for the MPXQueryPointer function.
*/
int
ProcMPXQueryPointer(register ClientPtr client)
{
xMPXQueryPointerReply rep;
DeviceIntPtr pDev;
WindowPtr root, win;
int x, y;
REQUEST(xMPXQueryPointerReq);
REQUEST_SIZE_MATCH(xMPXQueryPointerReq);
pDev = LookupDeviceIntRec(stuff->deviceid);
if (!pDev->isMPDev)
{
SendErrorToClient(client, MPXReqCode, X_MPXQueryPointer,
stuff->deviceid, BadValue);
return Success;
}
memset(&rep, 0, sizeof(xMPXQueryPointerReply));
rep.repType = X_Reply;
rep.RepType = X_MPXQueryPointer;
rep.length = 0;
rep.sequenceNumber = client->sequence;
root = GetCurrentRootWindow();
win = GetSpriteWindow(pDev);
GetSpritePosition(pDev, &x, &y);
rep.root = root->drawable.id;
rep.root_x = x;
rep.root_y = y;
if (win != root)
{
rep.child = win->drawable.id;
rep.win_x = x - win->drawable.x;
rep.win_y = y - win->drawable.y;
}
else
{
rep.child = None;
rep.win_x = x;
rep.win_y = y;
}
rep.mask = pDev->button->state | inputInfo.keyboard->key->state;
WriteReplyToClient(client, sizeof(xMPXQueryPointerReply), &rep);
return Success;
}
/***********************************************************************
*
* This procedure writes the reply for the MPXQueryPointer function.
*/
int
SProcMPXQueryPointer(register ClientPtr client)
{
register char n;
REQUEST(xMPXQueryPointerReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(xMPXQueryPointerReq);
return (ProcMPXQueryPointer(client));
}

16
mpx/queryptr.h Normal file
View File

@ -0,0 +1,16 @@
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef QUERYPTR_H
#define QUERYPTR_H 1
int SProcMPXQueryPointer(ClientPtr /* client */
);
int ProcMPXQueryPointer(ClientPtr /* client */
);
#endif /* QUERYPTR_H */

View File

@ -42,9 +42,9 @@ SProcMPXSelectEvents(register ClientPtr client)
{
register char n;
REQUEST(mpxSelectEventsReq);
REQUEST(xMPXSelectEventsReq);
swaps(&stuff->length, n);
REQUEST_SIZE_MATCH(mpxSelectEventsReq);
REQUEST_SIZE_MATCH(xMPXSelectEventsReq);
swapl(&stuff->window, n);
return (ProcMPXSelectEvents(client));
}
@ -61,12 +61,12 @@ ProcMPXSelectEvents(register ClientPtr client)
int ret;
WindowPtr pWin;
REQUEST(mpxSelectEventsReq);
REQUEST_SIZE_MATCH(mpxSelectEventsReq);
REQUEST(xMPXSelectEventsReq);
REQUEST_SIZE_MATCH(xMPXSelectEventsReq);
if (stuff->length != (sizeof(mpxSelectEventsReq) >> 2))
if (stuff->length != (sizeof(xMPXSelectEventsReq) >> 2))
{
SendErrorToClient(client, MPXReqCode, MPX_SelectEvents, 0,
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0,
BadLength);
return Success;
}
@ -75,7 +75,7 @@ ProcMPXSelectEvents(register ClientPtr client)
if (!pWin)
{
client->errorValue = stuff->window;
SendErrorToClient(client, MPXReqCode, MPX_SelectEvents, 0,
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0,
BadWindow);
return Success;
}
@ -83,13 +83,13 @@ ProcMPXSelectEvents(register ClientPtr client)
if (stuff->mask >= MPXHighestMask)
{
client->errorValue = stuff->mask;
SendErrorToClient(client, MPXReqCode, MPX_SelectEvents, 0,
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0,
BadValue);
}
if ((ret = MPXSelectForWindow(pWin, client, stuff->mask)) != Success)
{
SendErrorToClient(client, MPXReqCode, MPX_SelectEvents, 0, ret);
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0, ret);
return Success;
}