mirror of
https://github.com/X11Libre/xserver.git
synced 2026-10-21 01:13:38 +00:00
mpx: Infrastructure for MPX extension, GetExtensionVersion request works.
This commit is contained in:
parent
bdf718907b
commit
afd6af6551
12 changed files with 475 additions and 8 deletions
9
mpx/Makefile.am
Normal file
9
mpx/Makefile.am
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
noinst_LTLIBRARIES = libmpx.la
|
||||
|
||||
AM_CFLAGS = $(DIX_CFLAGS)
|
||||
|
||||
libmpx_la_SOURCES = \
|
||||
extinit.c \
|
||||
getvers.c \
|
||||
getvers.h
|
||||
|
||||
287
mpx/extinit.c
Normal file
287
mpx/extinit.c
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
/* 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 "gcstruct.h" /* pointer for extnsionst.h */
|
||||
#include "extnsionst.h" /* extension entry */
|
||||
#include <X11/extensions/MPX.h>
|
||||
#include <X11/extensions/MPXproto.h>
|
||||
|
||||
#include "mpxextinit.h"
|
||||
#include "swaprep.h"
|
||||
|
||||
#include "getvers.h"
|
||||
|
||||
static Mask lastExtEventMask = 1;
|
||||
int ExtEventIndex;
|
||||
Mask ExtValidMasks[EMASKSIZE];
|
||||
|
||||
XExtEventInfo EventInfo[32];
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Externs defined elsewhere in the X server.
|
||||
*
|
||||
*/
|
||||
|
||||
extern XExtensionVersion 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;
|
||||
|
||||
/*****************************************************************
|
||||
*
|
||||
* Declarations of local routines.
|
||||
*
|
||||
*/
|
||||
|
||||
static XExtensionVersion thisversion = { MPX_Present,
|
||||
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 == MPX_GetExtensionVersion)
|
||||
return (ProcMPXGetExtensionVersion(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 == MPX_GetExtensionVersion)
|
||||
return (SProcMPXGetExtensionVersion(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;
|
||||
|
||||
}
|
||||
|
||||
void SReplyMPXDispatch(ClientPtr client, int len, mpxGetExtensionVersionReply* rep)
|
||||
{
|
||||
if (rep->RepType == MPX_GetExtensionVersion)
|
||||
SRepMPXGetExtensionVersion(client, len,
|
||||
(mpxGetExtensionVersionReply*) 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)
|
||||
{
|
||||
Mask mask;
|
||||
|
||||
MPXButtonPress = extEntry->eventBase;
|
||||
MPXButtonRelease = MPXButtonPress + 1;
|
||||
MPXMotionNotify = MPXButtonRelease + 1;
|
||||
|
||||
mask = MPXGetNextExtEventMask();
|
||||
MPXSetMaskForExtEvent(mask, MPXButtonPress);
|
||||
MPXAllowPropagateSuppress(mask);
|
||||
|
||||
mask = MPXGetNextExtEventMask();
|
||||
MPXSetMaskForExtEvent(mask, MPXButtonRelease);
|
||||
MPXAllowPropagateSuppress(mask);
|
||||
|
||||
mask = MPXGetNextExtEventMask();
|
||||
MPXSetMaskForExtEvent(mask, MPXMotionNotify);
|
||||
MPXAllowPropagateSuppress(mask);
|
||||
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Return the next available extension event mask.
|
||||
*
|
||||
*/
|
||||
Mask
|
||||
MPXGetNextExtEventMask(void)
|
||||
{
|
||||
int i;
|
||||
Mask mask = lastExtEventMask;
|
||||
|
||||
if (lastExtEventMask == 0) {
|
||||
FatalError("MPXGetNextExtEventMask: no more events are available.");
|
||||
}
|
||||
lastExtEventMask <<= 1;
|
||||
|
||||
for (i = 0; i < MAX_DEVICES; i++)
|
||||
ExtValidMasks[i] |= mask;
|
||||
return mask;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* Assign the specified mask to the specified event.
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
MPXSetMaskForExtEvent(Mask mask, int event)
|
||||
{
|
||||
|
||||
EventInfo[ExtEventIndex].mask = mask;
|
||||
EventInfo[ExtEventIndex++].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 < ExtEventIndex - 1; i++) {
|
||||
if ((EventInfo[i].type >= LASTEvent) && (EventInfo[i].type < 128))
|
||||
SetMaskForEvent(0, EventInfo[i].type);
|
||||
EventInfo[i].mask = 0;
|
||||
EventInfo[i].type = 0;
|
||||
}
|
||||
|
||||
ExtEventIndex = 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;
|
||||
}
|
||||
80
mpx/getvers.c
Normal file
80
mpx/getvers.c
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
/* 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"
|
||||
|
||||
XExtensionVersion AllExtensionVersions[128];
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* Handle a request from a client with a different byte order than us.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
SProcMPXGetExtensionVersion(register ClientPtr client)
|
||||
{
|
||||
register char n;
|
||||
|
||||
REQUEST(mpxGetExtensionVersionReq);
|
||||
swaps(&stuff->length, n);
|
||||
swaps(&stuff->major_version, n);
|
||||
swaps(&stuff->minor_version, n);
|
||||
REQUEST_AT_LEAST_SIZE(mpxGetExtensionVersionReq);
|
||||
return (ProcMPXGetExtensionVersion(client));
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* This procedure writes the reply for the XGetExtensionVersion function.
|
||||
*/
|
||||
|
||||
int
|
||||
ProcMPXGetExtensionVersion(register ClientPtr client)
|
||||
{
|
||||
mpxGetExtensionVersionReply rep;
|
||||
|
||||
REQUEST(mpxGetExtensionVersionReq);
|
||||
REQUEST_SIZE_MATCH(mpxGetExtensionVersionReq);
|
||||
|
||||
rep.repType = X_Reply;
|
||||
rep.RepType = MPX_GetExtensionVersion;
|
||||
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);
|
||||
|
||||
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,
|
||||
mpxGetExtensionVersionReply * 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);
|
||||
}
|
||||
22
mpx/getvers.h
Normal file
22
mpx/getvers.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/* 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 */ ,
|
||||
mpxGetExtensionVersionReply * /* rep */
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
15
mpx/mpxglobals.h
Normal file
15
mpx/mpxglobals.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/* Copyright 2006 by Peter Hutterer <peter@cs.unisa.edu.au> */
|
||||
|
||||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
extern int MPXReqCode;
|
||||
extern int MPXEventBase;
|
||||
extern int MPXErrorBase;
|
||||
|
||||
extern int MPXButtonPress;
|
||||
extern int MPXButtonRelease;
|
||||
extern int MPXMotionNotify;
|
||||
|
||||
extern Mask PropagateMask[];
|
||||
16
mpx/selectev.c
Normal file
16
mpx/selectev.c
Normal 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
|
||||
|
||||
#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 "extinit.h" /* LookupDeviceIntRec */
|
||||
|
||||
Loading…
Reference in a new issue