removing MPX extension files
This commit is contained in:
parent
b55e1239ac
commit
056c919d84
|
@ -30,6 +30,14 @@ Files:
|
|||
include/extinit.h
|
||||
Xi/extinit.c
|
||||
|
||||
____________________________________________________________
|
||||
removing MPX extension files
|
||||
|
||||
Files:
|
||||
mpx/
|
||||
include/mpxevents.h
|
||||
include/mpxextinit.h
|
||||
|
||||
== 18.12.06 ==
|
||||
mi: removing MPX ifdefs
|
||||
global sprite renaming in mipointer and misprite
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef MPXEVENTS_H
|
||||
#define MPXEVENTS_H 1
|
||||
|
||||
#include <X11/X.h> /* for inputstr.h */
|
||||
#include <X11/Xproto.h> /* Request macro */
|
||||
#include "inputstr.h" /* DeviceIntPtr */
|
||||
|
||||
extern int MPXSelectForWindow(
|
||||
WindowPtr /* pWin */,
|
||||
ClientPtr /* client */,
|
||||
int /* mask */);
|
||||
|
||||
#endif
|
|
@ -1,72 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
/********************************************************************
|
||||
* Interface of mpx/extinit.c
|
||||
*/
|
||||
|
||||
#ifndef MPXEXTINIT_H
|
||||
#define MPXEXTINIT_H
|
||||
|
||||
#include "extnsionst.h"
|
||||
|
||||
void
|
||||
MPXExtensionInit(
|
||||
void
|
||||
);
|
||||
|
||||
int
|
||||
ProcMPXDispatch (
|
||||
ClientPtr /* client */
|
||||
);
|
||||
|
||||
int
|
||||
SProcMPXDispatch(
|
||||
ClientPtr /* client */
|
||||
);
|
||||
|
||||
void
|
||||
SReplyMPXDispatch (
|
||||
ClientPtr /* client */,
|
||||
int /* len */,
|
||||
xMPXGetExtensionVersionReply * /* rep */
|
||||
);
|
||||
|
||||
void
|
||||
SEventMPXDispatch (
|
||||
xEvent * /* from */,
|
||||
xEvent * /* to */
|
||||
);
|
||||
|
||||
void
|
||||
MPXFixExtensionEvents (
|
||||
ExtensionEntry * /* extEntry */
|
||||
);
|
||||
|
||||
void
|
||||
MPXResetProc(
|
||||
ExtensionEntry * /* unused */
|
||||
);
|
||||
|
||||
Mask
|
||||
MPXGetNextExtEventMask (
|
||||
void
|
||||
);
|
||||
|
||||
void
|
||||
MPXSetMaskForExtEvent(
|
||||
Mask /* mask */,
|
||||
int /* event */
|
||||
);
|
||||
|
||||
void
|
||||
MPXAllowPropagateSuppress (
|
||||
Mask /* mask */
|
||||
);
|
||||
|
||||
void
|
||||
MPXRestoreExtensionEvents (
|
||||
void
|
||||
);
|
||||
#endif
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
noinst_LTLIBRARIES = libmpx.la
|
||||
|
||||
AM_CFLAGS = $(DIX_CFLAGS)
|
||||
|
||||
libmpx_la_SOURCES = \
|
||||
extinit.c \
|
||||
getvers.c \
|
||||
getvers.h \
|
||||
listdev.c \
|
||||
listdev.h \
|
||||
selectev.c \
|
||||
selectev.h \
|
||||
mpxglobals.h \
|
||||
getevbase.c \
|
||||
getevbase.h \
|
||||
queryptr.h \
|
||||
queryptr.c
|
||||
|
299
mpx/extinit.c
299
mpx/extinit.c
|
@ -1,299 +0,0 @@
|
|||
/* 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 "extnsionst.h" /* extension entry */
|
||||
#include <X11/extensions/MPX.h>
|
||||
#include <X11/extensions/MPXproto.h>
|
||||
#include <X11/extensions/MPXconst.h>
|
||||
|
||||
#include "mpxglobals.h"
|
||||
#include "mpxextinit.h"
|
||||
#include "swaprep.h"
|
||||
|
||||
#include "getvers.h"
|
||||
#include "listdev.h"
|
||||
#include "selectev.h"
|
||||
#include "getevbase.h"
|
||||
#include "queryptr.h"
|
||||
|
||||
static Mask lastExtEventMask = 1;
|
||||
int MPXEventIndex;
|
||||
MPXExtEventInfo EventInfo[32];
|
||||
|
||||
/**
|
||||
* MPX piggybacks on the X Input extension's event system. Each window has an
|
||||
* array of event masks, from 0 to MAX_DEVICES. In XI, each device can have
|
||||
* separate event masks. Before an event is delivered, the array at the index
|
||||
* of the device is checked.
|
||||
*
|
||||
* Two things:
|
||||
* -) core devices do not send input extension events
|
||||
* -) MPX events are not device specific.
|
||||
*
|
||||
* Since the mask of the core pointer (index 1) is thus not used by XI, MPX
|
||||
* can use it for the event mask. This also makes MPX less intrusive.
|
||||
*/
|
||||
int MPXmskidx = 1;
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Externs defined elsewhere in the X server.
|
||||
*
|
||||
*/
|
||||
|
||||
extern MPXExtensionVersion AllExtensionVersions[];
|
||||
|
||||
Mask PropagateMask[MAX_DEVICES];
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Globals referenced elsewhere in the server.
|
||||
*
|
||||
*/
|
||||
|
||||
int MPXReqCode = 0;
|
||||
int MPXEventBase = 0;
|
||||
int MPXErrorBase = 0;
|
||||
|
||||
int MPXButtonPress;
|
||||
int MPXButtonRelease;
|
||||
int MPXMotionNotify;
|
||||
int MPXLastEvent;
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Declarations of local routines.
|
||||
*
|
||||
*/
|
||||
|
||||
static MPXExtensionVersion thisversion = {
|
||||
MPX_Major,
|
||||
MPX_Minor
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* MPXExtensionInit - initialize the input extension.
|
||||
*
|
||||
* Called from InitExtensions in main() or from QueryExtension() if the
|
||||
* extension is dynamically loaded.
|
||||
*
|
||||
* This extension has several events and errors.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
MPXExtensionInit(void)
|
||||
{
|
||||
ExtensionEntry *extEntry;
|
||||
|
||||
extEntry = AddExtension(MPXNAME, MPXEVENTS, MPXERRORS,
|
||||
ProcMPXDispatch, SProcMPXDispatch,
|
||||
MPXResetProc, StandardMinorOpcode);
|
||||
if (extEntry) {
|
||||
MPXReqCode = extEntry->base;
|
||||
MPXEventBase = extEntry->eventBase;
|
||||
MPXErrorBase = extEntry->errorBase;
|
||||
|
||||
AllExtensionVersions[MPXReqCode - 128] = thisversion;
|
||||
MPXFixExtensionEvents(extEntry);
|
||||
ReplySwapVector[MPXReqCode] = (ReplySwapPtr) SReplyMPXDispatch;
|
||||
EventSwapVector[MPXButtonPress] = SEventMPXDispatch;
|
||||
EventSwapVector[MPXButtonRelease] = SEventMPXDispatch;
|
||||
EventSwapVector[MPXMotionNotify] = SEventMPXDispatch;
|
||||
} else {
|
||||
FatalError("MPXExtensionInit: AddExtensions failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* ProcMPXDispatch - main dispatch routine for requests to this extension.
|
||||
* This routine is used if server and client have the same byte ordering.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
ProcMPXDispatch(register ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
if (stuff->data == X_MPXGetExtensionVersion)
|
||||
return (ProcMPXGetExtensionVersion(client));
|
||||
if (stuff->data == X_MPXListDevices)
|
||||
return (ProcMPXListDevices(client));
|
||||
if (stuff->data == X_MPXSelectEvents)
|
||||
return (ProcMPXSelectEvents(client));
|
||||
if (stuff->data == X_MPXGetEventBase)
|
||||
return (ProcMPXGetEventBase(client));
|
||||
if (stuff->data == X_MPXQueryPointer)
|
||||
return (ProcMPXQueryPointer(client));
|
||||
else {
|
||||
SendErrorToClient(client, MPXReqCode, stuff->data, 0, BadRequest);
|
||||
}
|
||||
|
||||
return (BadRequest);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* SProcMPXDispatch
|
||||
*
|
||||
* Main swapped dispatch routine for requests to this extension.
|
||||
* This routine is used if server and client do not have the same byte ordering.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
SProcMPXDispatch(register ClientPtr client)
|
||||
{
|
||||
REQUEST(xReq);
|
||||
if (stuff->data == X_MPXGetExtensionVersion)
|
||||
return (SProcMPXGetExtensionVersion(client));
|
||||
if (stuff->data == X_MPXListDevices)
|
||||
return (SProcMPXListDevices(client));
|
||||
if (stuff->data == X_MPXSelectEvents)
|
||||
return (SProcMPXSelectEvents(client));
|
||||
if (stuff->data == X_MPXGetEventBase)
|
||||
return (SProcMPXGetEventBase(client));
|
||||
if (stuff->data == X_MPXQueryPointer)
|
||||
return (SProcMPXQueryPointer(client));
|
||||
else {
|
||||
SendErrorToClient(client, MPXReqCode, stuff->data, 0, BadRequest);
|
||||
}
|
||||
|
||||
return (BadRequest);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* MPXResetProc.
|
||||
* Remove reply-swapping routine.
|
||||
* Remove event-swapping routine.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
MPXResetProc(ExtensionEntry* unused)
|
||||
{
|
||||
ReplySwapVector[MPXReqCode] = ReplyNotSwappd;
|
||||
EventSwapVector[MPXButtonPress] = NotImplemented;
|
||||
EventSwapVector[MPXButtonRelease] = NotImplemented;
|
||||
EventSwapVector[MPXMotionNotify] = NotImplemented;
|
||||
|
||||
MPXRestoreExtensionEvents();
|
||||
|
||||
}
|
||||
|
||||
void SReplyMPXDispatch(ClientPtr client, int len, xMPXGetExtensionVersionReply* rep)
|
||||
{
|
||||
if (rep->RepType == X_MPXGetExtensionVersion)
|
||||
SRepMPXGetExtensionVersion(client, len,
|
||||
(xMPXGetExtensionVersionReply*) rep);
|
||||
if (rep->RepType == X_MPXListDevices)
|
||||
SRepMPXListDevices(client, len,
|
||||
(xMPXListDevicesReply*) rep);
|
||||
else {
|
||||
FatalError("MPX confused sending swapped reply");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SEventMPXDispatch(xEvent* from, xEvent* to)
|
||||
{
|
||||
int type = from->u.u.type & 0177;
|
||||
if (type == MPXButtonPress) {
|
||||
SKeyButtonPtrEvent(from, to);
|
||||
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
||||
} else if (type == MPXButtonRelease) {
|
||||
SKeyButtonPtrEvent(from, to);
|
||||
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
||||
} else if (type == MPXMotionNotify) {
|
||||
SKeyButtonPtrEvent(from, to);
|
||||
to->u.keyButtonPointer.pad1 = from->u.keyButtonPointer.pad1;
|
||||
} else {
|
||||
FatalError("XInputExtension: Impossible event!\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MPXFixExtensionEvents(ExtensionEntry* extEntry)
|
||||
{
|
||||
MPXButtonPress = extEntry->eventBase;
|
||||
MPXButtonRelease = MPXButtonPress + 1;
|
||||
MPXMotionNotify = MPXButtonRelease + 1;
|
||||
MPXLastEvent = MPXMotionNotify + 1;
|
||||
|
||||
MPXSetMaskForExtEvent(MPXButtonPressMask, MPXButtonPress);
|
||||
MPXSetMaskForExtEvent(MPXButtonReleaseMask, MPXButtonRelease);
|
||||
MPXSetMaskForExtEvent(MPXPointerMotionMask, MPXMotionNotify);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Assign the specified mask to the specified event.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
MPXSetMaskForExtEvent(Mask mask, int event)
|
||||
{
|
||||
|
||||
EventInfo[MPXEventIndex].mask = mask;
|
||||
EventInfo[MPXEventIndex++].type = event;
|
||||
|
||||
if ((event < LASTEvent) || (event >= 128))
|
||||
FatalError("MaskForExtensionEvent: bogus event number");
|
||||
SetMaskForEvent(mask, event);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* This function restores extension event types and masks to their
|
||||
* initial state.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
MPXRestoreExtensionEvents(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
MPXReqCode = 0;
|
||||
for (i = 0; i < MPXEventIndex - 1; i++) {
|
||||
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
|
||||
SetMaskForEvent(0, EventInfo[i].type);
|
||||
EventInfo[i].mask = 0;
|
||||
EventInfo[i].type = 0;
|
||||
}
|
||||
|
||||
MPXEventIndex = 0;
|
||||
lastExtEventMask = 1;
|
||||
MPXButtonPress = 0;
|
||||
MPXButtonRelease = 1;
|
||||
MPXMotionNotify = 2;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Allow the specified event to have its propagation suppressed.
|
||||
* The default is to not allow suppression of propagation.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
MPXAllowPropagateSuppress(Mask mask)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_DEVICES; i++)
|
||||
PropagateMask[i] |= mask;
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <X11/X.h> /* for inputstr.h */
|
||||
#include <X11/Xproto.h> /* Request macro */
|
||||
#include "inputstr.h" /* DeviceIntPtr */
|
||||
#include <X11/extensions/MPX.h>
|
||||
#include <X11/extensions/MPXproto.h>
|
||||
|
||||
#include "mpxglobals.h"
|
||||
#include "getevbase.h"
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure writes the reply for the MPXGetEventBase function.
|
||||
*/
|
||||
int
|
||||
ProcMPXGetEventBase(register ClientPtr client)
|
||||
{
|
||||
xMPXGetEventBaseReply rep;
|
||||
|
||||
REQUEST(xMPXGetEventBaseReq);
|
||||
REQUEST_SIZE_MATCH(xMPXGetEventBaseReq);
|
||||
|
||||
memset(&rep, 0, sizeof(xMPXGetEventBaseReply));
|
||||
rep.repType = X_Reply;
|
||||
rep.RepType = X_MPXGetEventBase;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
||||
rep.eventBase = MPXEventBase;
|
||||
|
||||
WriteReplyToClient(client, sizeof(xMPXGetEventBaseReply), &rep);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure writes the reply for the MPXGetEventBase function.
|
||||
*/
|
||||
int
|
||||
SProcMPXGetEventBase(register ClientPtr client)
|
||||
{
|
||||
register char n;
|
||||
|
||||
REQUEST(xMPXGetEventBaseReq);
|
||||
swaps(&stuff->length, n);
|
||||
REQUEST_SIZE_MATCH(xMPXGetEventBaseReq);
|
||||
return (ProcMPXGetEventBase(client));
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef GETEVBASE_H
|
||||
#define GETEVBASE_H 1
|
||||
|
||||
int SProcMPXGetEventBase(ClientPtr /* client */
|
||||
);
|
||||
|
||||
int ProcMPXGetEventBase(ClientPtr /* client */
|
||||
);
|
||||
|
||||
#endif /* GETEVBASE_H */
|
|
@ -1,81 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <X11/X.h> /* for inputstr.h */
|
||||
#include <X11/Xproto.h> /* Request macro */
|
||||
#include "inputstr.h" /* DeviceIntPtr */
|
||||
#include <X11/extensions/MPX.h>
|
||||
#include <X11/extensions/MPXproto.h>
|
||||
|
||||
#include "mpxglobals.h"
|
||||
#include "getvers.h"
|
||||
|
||||
MPXExtensionVersion AllExtensionVersions[128];
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Handle a request from a client with a different byte order than us.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
SProcMPXGetExtensionVersion(register ClientPtr client)
|
||||
{
|
||||
register char n;
|
||||
|
||||
REQUEST(xMPXGetExtensionVersionReq);
|
||||
swaps(&stuff->length, n);
|
||||
swaps(&stuff->major_version, n);
|
||||
swaps(&stuff->minor_version, n);
|
||||
REQUEST_AT_LEAST_SIZE(xMPXGetExtensionVersionReq);
|
||||
return (ProcMPXGetExtensionVersion(client));
|
||||
}
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure writes the reply for the XGetExtensionVersion function.
|
||||
*/
|
||||
|
||||
int
|
||||
ProcMPXGetExtensionVersion(register ClientPtr client)
|
||||
{
|
||||
xMPXGetExtensionVersionReply rep;
|
||||
|
||||
REQUEST(xMPXGetExtensionVersionReq);
|
||||
REQUEST_SIZE_MATCH(xMPXGetExtensionVersionReq);
|
||||
|
||||
rep.repType = X_Reply;
|
||||
rep.RepType = X_MPXGetExtensionVersion;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
||||
rep.major_version = AllExtensionVersions[MPXReqCode - 128].major;
|
||||
rep.minor_version = AllExtensionVersions[MPXReqCode - 128].minor;
|
||||
WriteReplyToClient(client, sizeof(xMPXGetExtensionVersionReply), &rep);
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure writes the reply for the MPXGetExtensionVersion function,
|
||||
* if the client and server have a different byte ordering.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
SRepMPXGetExtensionVersion(ClientPtr client, int size,
|
||||
xMPXGetExtensionVersionReply * rep)
|
||||
{
|
||||
register char n;
|
||||
|
||||
swaps(&rep->sequenceNumber, n);
|
||||
swapl(&rep->length, n);
|
||||
swaps(&rep->major_version, n);
|
||||
swaps(&rep->minor_version, n);
|
||||
WriteToClient(client, size, (char *)rep);
|
||||
}
|
||||
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef GETVERS_H
|
||||
#define GETVERS_H 1
|
||||
|
||||
int SProcMPXGetExtensionVersion(ClientPtr /* client */
|
||||
);
|
||||
|
||||
int ProcMPXGetExtensionVersion(ClientPtr /* client */
|
||||
);
|
||||
|
||||
void SRepMPXGetExtensionVersion(ClientPtr /* client */ ,
|
||||
int /* size */ ,
|
||||
xMPXGetExtensionVersionReply * /* rep */
|
||||
);
|
||||
|
||||
#endif
|
||||
|
187
mpx/listdev.c
187
mpx/listdev.c
|
@ -1,187 +0,0 @@
|
|||
/* 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 <X11/extensions/MPX.h>
|
||||
#include <X11/extensions/MPXproto.h>
|
||||
|
||||
#include "mpxextinit.h"
|
||||
#include "mpxglobals.h"
|
||||
|
||||
#include "listdev.h"
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure lists the MPX devices available to the server.
|
||||
*
|
||||
*/
|
||||
int SProcMPXListDevices(register ClientPtr client)
|
||||
{
|
||||
register char n;
|
||||
|
||||
REQUEST(xMPXListDevicesReq);
|
||||
swaps(&stuff->length, n);
|
||||
return (ProcMPXListDevices(client));
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure lists the MPX devices available to the server.
|
||||
*
|
||||
* Strongly based on ProcXListInputDevices
|
||||
*/
|
||||
int ProcMPXListDevices(register ClientPtr client)
|
||||
{
|
||||
xMPXListDevicesReply rep;
|
||||
int numdevs = 0;
|
||||
int namesize = 1; /* need 1 extra byte for strcpy */
|
||||
int size = 0;
|
||||
int total_length;
|
||||
char* devbuf;
|
||||
char* namebuf;
|
||||
char *savbuf;
|
||||
xMPXDeviceInfoPtr dev;
|
||||
DeviceIntPtr d;
|
||||
|
||||
REQUEST_SIZE_MATCH(xMPXListDevicesReq);
|
||||
memset(&rep, 0, sizeof(xMPXListDevicesReply));
|
||||
rep.repType = X_Reply;
|
||||
rep.RepType = X_MPXListDevices;
|
||||
rep.length = 0;
|
||||
rep.sequenceNumber = client->sequence;
|
||||
|
||||
for (d = inputInfo.devices; d; d = d->next) {
|
||||
if (d->isMPDev)
|
||||
{
|
||||
SizeMPXDeviceInfo(d, &namesize, &size);
|
||||
numdevs++;
|
||||
}
|
||||
}
|
||||
|
||||
for (d = inputInfo.off_devices; d; d = d->next) {
|
||||
if (d->isMPDev)
|
||||
{
|
||||
SizeMPXDeviceInfo(d, &namesize, &size);
|
||||
numdevs++;
|
||||
}
|
||||
}
|
||||
|
||||
total_length = numdevs * sizeof(xMPXDeviceInfo) + size + namesize;
|
||||
devbuf = (char *)xalloc(total_length);
|
||||
namebuf = devbuf + (numdevs * sizeof(xMPXDeviceInfo));
|
||||
savbuf = devbuf;
|
||||
|
||||
dev = (xMPXDeviceInfoPtr) devbuf;
|
||||
for (d = inputInfo.devices; d; d = d->next, dev++)
|
||||
if (d->isMPDev)
|
||||
SetMPXDeviceInfo(client, d, dev, &devbuf, &namebuf);
|
||||
for (d = inputInfo.off_devices; d; d = d->next, dev++)
|
||||
if (d->isMPDev)
|
||||
SetMPXDeviceInfo(client, d, dev, &devbuf, &namebuf);
|
||||
|
||||
rep.ndevices = numdevs;
|
||||
rep.length = (total_length + 3) >> 2;
|
||||
WriteReplyToClient(client, sizeof(xMPXListDevicesReply), &rep);
|
||||
WriteToClient(client, total_length, savbuf);
|
||||
xfree(savbuf);
|
||||
return Success;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure calculates the size of the information to be returned
|
||||
* for an input device.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
SizeMPXDeviceInfo(DeviceIntPtr d, int *namesize, int *size)
|
||||
{
|
||||
*namesize += 1;
|
||||
if (d->name)
|
||||
*namesize += strlen(d->name);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure sets information to be returned for an input device.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
SetMPXDeviceInfo(ClientPtr client, DeviceIntPtr d, xMPXDeviceInfoPtr dev,
|
||||
char **devbuf, char **namebuf)
|
||||
{
|
||||
MPXCopyDeviceName(namebuf, d->name);
|
||||
MPXCopySwapDevice(client, d, devbuf);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure copies data to the DeviceInfo struct, swapping if necessary.
|
||||
*
|
||||
* We need the extra byte in the allocated buffer, because the trailing null
|
||||
* hammers one extra byte, which is overwritten by the next name except for
|
||||
* the last name copied.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
MPXCopyDeviceName(char **namebuf, char *name)
|
||||
{
|
||||
char *nameptr = (char *)*namebuf;
|
||||
|
||||
if (name) {
|
||||
*nameptr++ = strlen(name);
|
||||
strcpy(nameptr, name);
|
||||
*namebuf += (strlen(name) + 1);
|
||||
} else {
|
||||
*nameptr++ = 0;
|
||||
*namebuf += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure copies data to the DeviceInfo struct, swapping if necessary.
|
||||
*
|
||||
*/
|
||||
void
|
||||
MPXCopySwapDevice(register ClientPtr client, DeviceIntPtr d, char **buf)
|
||||
{
|
||||
register char n;
|
||||
xMPXDeviceInfoPtr dev;
|
||||
|
||||
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(xMPXDeviceInfo);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure writes the reply for the MPXListDevices function,
|
||||
* if the client and server have a different byte ordering.
|
||||
*
|
||||
*/
|
||||
void
|
||||
SRepMPXListDevices(ClientPtr client, int size, xMPXListDevicesReply * rep)
|
||||
{
|
||||
register char n;
|
||||
|
||||
swaps(&rep->sequenceNumber, n);
|
||||
swapl(&rep->length, n);
|
||||
WriteToClient(client, size, (char *)rep);
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef LISTDEV_H
|
||||
#define LISTDEV_H 1
|
||||
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xproto.h>
|
||||
#include "inputstr.h"
|
||||
|
||||
#include <X11/extensions/MPX.h>
|
||||
#include <X11/extensions/MPXproto.h>
|
||||
|
||||
#include "mpxextinit.h"
|
||||
#include "mpxglobals.h"
|
||||
|
||||
int SProcMPXListDevices(ClientPtr /* client */
|
||||
);
|
||||
|
||||
int ProcMPXListDevices(ClientPtr /* client */
|
||||
);
|
||||
|
||||
void SizeMPXDeviceInfo(DeviceIntPtr /* d */ ,
|
||||
int * /* namesize */ ,
|
||||
int * /* size */
|
||||
);
|
||||
|
||||
void SetMPXDeviceInfo(ClientPtr /* client */ ,
|
||||
DeviceIntPtr /* d */ ,
|
||||
xMPXDeviceInfoPtr /* dev */ ,
|
||||
char ** /* devbuf */ ,
|
||||
char ** /* namebuf */
|
||||
);
|
||||
|
||||
|
||||
void MPXCopyDeviceName(char ** /* namebuf */ ,
|
||||
char * /* name */
|
||||
);
|
||||
|
||||
void MPXCopySwapDevice(ClientPtr /* client */ ,
|
||||
DeviceIntPtr /* d */ ,
|
||||
char ** /* buf */
|
||||
);
|
||||
|
||||
void SRepMPXListDevices(ClientPtr /* client */ ,
|
||||
int /* size */ ,
|
||||
xMPXListDevicesReply * /* rep */
|
||||
);
|
||||
#endif
|
|
@ -1,29 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef MPXGLOBALS_H
|
||||
#define MPXGLOBALS_H 1
|
||||
|
||||
extern int MPXReqCode;
|
||||
extern int MPXEventBase;
|
||||
extern int MPXErrorBase;
|
||||
|
||||
extern Mask PropagateMask[];
|
||||
|
||||
extern int MPXmskidx;
|
||||
|
||||
/* events */
|
||||
extern int MPXButtonPress;
|
||||
extern int MPXButtonRelease;
|
||||
extern int MPXMotionNotify;
|
||||
extern int MPXLastEvent;
|
||||
|
||||
#define IsMPXEvent(xE) \
|
||||
((xE)->u.u.type >= MPXEventBase \
|
||||
&& (xE)->u.u.type < MPXLastEvent)
|
||||
|
||||
|
||||
#endif
|
|
@ -1,90 +0,0 @@
|
|||
/* 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));
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/* 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 */
|
146
mpx/selectev.c
146
mpx/selectev.c
|
@ -1,146 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <X11/X.h> /* for inputstr.h */
|
||||
#include <X11/Xproto.h> /* Request macro */
|
||||
#include "inputstr.h" /* DeviceIntPtr */
|
||||
#include "windowstr.h" /* window structure */
|
||||
#include <X11/extensions/MPX.h>
|
||||
#include <X11/extensions/MPXproto.h>
|
||||
#include "extnsionst.h"
|
||||
#include "mpxextinit.h" /* LookupDeviceIntRec */
|
||||
#include "mpxglobals.h"
|
||||
#include "mpxevents.h"
|
||||
|
||||
#include "selectev.h"
|
||||
|
||||
/* functions borrowed from XI */
|
||||
extern void RecalculateDeviceDeliverableEvents(
|
||||
WindowPtr /* pWin */);
|
||||
|
||||
extern int AddExtensionClient (
|
||||
WindowPtr /* pWin */,
|
||||
ClientPtr /* client */,
|
||||
Mask /* mask */,
|
||||
int /* mskidx */);
|
||||
extern Bool
|
||||
ShouldFreeInputMasks(WindowPtr /* pWin */,
|
||||
Bool /* ignoreSelectedEvents */);
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Handle requests from clients with a different byte order.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
SProcMPXSelectEvents(register ClientPtr client)
|
||||
{
|
||||
register char n;
|
||||
|
||||
REQUEST(xMPXSelectEventsReq);
|
||||
swaps(&stuff->length, n);
|
||||
REQUEST_SIZE_MATCH(xMPXSelectEventsReq);
|
||||
swapl(&stuff->window, n);
|
||||
return (ProcMPXSelectEvents(client));
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure selects input from an extension device.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
ProcMPXSelectEvents(register ClientPtr client)
|
||||
{
|
||||
int ret;
|
||||
WindowPtr pWin;
|
||||
|
||||
REQUEST(xMPXSelectEventsReq);
|
||||
REQUEST_SIZE_MATCH(xMPXSelectEventsReq);
|
||||
|
||||
if (stuff->length != (sizeof(xMPXSelectEventsReq) >> 2))
|
||||
{
|
||||
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0,
|
||||
BadLength);
|
||||
return Success;
|
||||
}
|
||||
|
||||
pWin = (WindowPtr) LookupWindow(stuff->window, client);
|
||||
if (!pWin)
|
||||
{
|
||||
client->errorValue = stuff->window;
|
||||
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0,
|
||||
BadWindow);
|
||||
return Success;
|
||||
}
|
||||
|
||||
if (stuff->mask >= MPXHighestMask)
|
||||
{
|
||||
client->errorValue = stuff->mask;
|
||||
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0,
|
||||
BadValue);
|
||||
}
|
||||
|
||||
if ((ret = MPXSelectForWindow(pWin, client, stuff->mask)) != Success)
|
||||
{
|
||||
SendErrorToClient(client, MPXReqCode, X_MPXSelectEvents, 0, ret);
|
||||
return Success;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects a set of events for a given window.
|
||||
* Different to XI, MPX is not device dependent. Either the client gets events
|
||||
* from all devices or none.
|
||||
*
|
||||
* This method borrows some functions from XI, due to the piggyback on the
|
||||
* core pointer (see comment in extinit.c)
|
||||
*/
|
||||
int
|
||||
MPXSelectForWindow(WindowPtr pWin, ClientPtr client, int mask)
|
||||
{
|
||||
InputClientsPtr others;
|
||||
int ret;
|
||||
|
||||
if (mask >= MPXHighestMask)
|
||||
{
|
||||
client->errorValue = mask;
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
if (wOtherInputMasks(pWin))
|
||||
{
|
||||
for (others = wOtherInputMasks(pWin)->inputClients; others;
|
||||
others = others->next)
|
||||
{
|
||||
if (SameClient(others, client)) {
|
||||
others->mask[MPXmskidx] = mask;
|
||||
if (mask == 0)
|
||||
{
|
||||
/* clean up stuff */
|
||||
RecalculateDeviceDeliverableEvents(pWin);
|
||||
if (ShouldFreeInputMasks(pWin, FALSE))
|
||||
FreeResource(others->resource, RT_NONE);
|
||||
return Success;
|
||||
}
|
||||
goto maskSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* borrow from XI here */
|
||||
if ((ret = AddExtensionClient(pWin, client, mask, MPXmskidx)) != Success)
|
||||
return ret;
|
||||
maskSet:
|
||||
RecalculateDeviceDeliverableEvents(pWin);
|
||||
return Success;
|
||||
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifndef SELECTEV_H
|
||||
#define SELECTEV_H 1
|
||||
|
||||
int SProcMPXSelectEvents(ClientPtr /* client */
|
||||
);
|
||||
|
||||
int ProcMPXSelectEvents(ClientPtr /* client */
|
||||
);
|
||||
|
||||
#endif /* SELECTEV_H */
|
Loading…
Reference in New Issue