Integration of XEVIE branch to trunk, latest updates
https://freedesktop.org/bugzilla/show_bug.cgi?id=947 Modified Files: Imakefile xevie.c
This commit is contained in:
parent
e68bfc8016
commit
b2065f376b
425
Xext/xevie.c
425
Xext/xevie.c
|
@ -41,45 +41,31 @@ of the copyright holder.
|
||||||
#include "colormapst.h"
|
#include "colormapst.h"
|
||||||
#include "scrnintstr.h"
|
#include "scrnintstr.h"
|
||||||
#include "servermd.h"
|
#include "servermd.h"
|
||||||
#include "opaque.h"
|
|
||||||
#define _XEVIE_SERVER_
|
#define _XEVIE_SERVER_
|
||||||
#include "Xeviestr.h"
|
#include "Xeviestr.h"
|
||||||
#include "Xfuncproto.h"
|
#include "Xfuncproto.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "inputstr.h"
|
|
||||||
#include "windowstr.h"
|
|
||||||
#include "cursorstr.h"
|
|
||||||
#include "swaprep.h"
|
|
||||||
#include "panoramiX.h"
|
|
||||||
#include "panoramiXsrv.h"
|
|
||||||
|
|
||||||
#ifndef EXTMODULE
|
|
||||||
#include "../os/osdep.h"
|
#include "../os/osdep.h"
|
||||||
#else
|
|
||||||
#include "xf86_ansic.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
#define DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
# define ERR(x) ErrorF(x)
|
|
||||||
#else
|
|
||||||
#define ERR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int xevieFlag = 0;
|
|
||||||
static int xevieClientIndex = 0;
|
|
||||||
static Mask xevieMask = 0;
|
|
||||||
static Bool xeviegrabState = FALSE;
|
|
||||||
static unsigned int xevieServerGeneration;
|
|
||||||
static int xevieDevicePrivateIndex;
|
|
||||||
static Bool xevieModifiersOn = FALSE;
|
|
||||||
|
|
||||||
#define XEVIEINFO(dev) ((xevieDeviceInfoPtr)dev->devPrivates[xevieDevicePrivateIndex].ptr)
|
|
||||||
#define NoSuchEvent 0x80000000
|
#define NoSuchEvent 0x80000000
|
||||||
|
|
||||||
|
extern Bool noXkbExtension;
|
||||||
|
extern int xeviegrabState;
|
||||||
|
|
||||||
|
static int ProcDispatch (), SProcDispatch ();
|
||||||
|
static void ResetProc ();
|
||||||
|
|
||||||
|
static unsigned char ReqCode = 0;
|
||||||
|
static int ErrorBase;
|
||||||
|
|
||||||
|
int xevieFlag = 0;
|
||||||
|
int xevieClientIndex = 0;
|
||||||
|
DeviceIntPtr xeviekb = NULL;
|
||||||
|
DeviceIntPtr xeviemouse = NULL;
|
||||||
|
Mask xevieMask = 0;
|
||||||
|
int xevieEventSent = 0;
|
||||||
|
int xevieKBEventSent = 0;
|
||||||
Mask xevieFilters[128] =
|
Mask xevieFilters[128] =
|
||||||
{
|
{
|
||||||
NoSuchEvent, /* 0 */
|
NoSuchEvent, /* 0 */
|
||||||
|
@ -90,72 +76,50 @@ Mask xevieFilters[128] =
|
||||||
ButtonReleaseMask, /* ButtonRelease */
|
ButtonReleaseMask, /* ButtonRelease */
|
||||||
PointerMotionMask /* MotionNotify (initial state) */
|
PointerMotionMask /* MotionNotify (initial state) */
|
||||||
};
|
};
|
||||||
#undef NoSuchEvent
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
ProcessInputProc processInputProc;
|
|
||||||
ProcessInputProc realInputProc;
|
|
||||||
DeviceUnwrapProc unwrapProc;
|
|
||||||
} xevieDeviceInfoRec, *xevieDeviceInfoPtr;
|
|
||||||
|
|
||||||
static int ProcDispatch (ClientPtr), SProcDispatch (ClientPtr);
|
|
||||||
static void ResetProc (ExtensionEntry*);
|
|
||||||
|
|
||||||
static unsigned char ReqCode = 0;
|
|
||||||
static int ErrorBase;
|
|
||||||
|
|
||||||
static Bool XevieStart(void);
|
|
||||||
static void XevieEnd(int clientIndex);
|
static void XevieEnd(int clientIndex);
|
||||||
static void XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
|
static void XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
|
||||||
pointer calldata);
|
pointer calldata);
|
||||||
static void XevieServerGrabStateCallback(CallbackListPtr *pcbl,
|
static void XevieServerGrabStateCallback(CallbackListPtr *pcbl,
|
||||||
pointer nulldata,
|
pointer nulldata,
|
||||||
pointer calldata);
|
pointer calldata);
|
||||||
|
|
||||||
static Bool XevieAdd(DeviceIntPtr device, pointer data);
|
|
||||||
static void XevieWrap(DeviceIntPtr device, ProcessInputProc proc);
|
|
||||||
static Bool XevieRemove(DeviceIntPtr device, pointer data);
|
|
||||||
static void doSendEvent(xEvent *xE, DeviceIntPtr device);
|
|
||||||
static void XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev,
|
|
||||||
int count);
|
|
||||||
static void XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XevieExtensionInit (INITARGS)
|
XevieExtensionInit ()
|
||||||
{
|
{
|
||||||
ExtensionEntry* extEntry;
|
ExtensionEntry* extEntry;
|
||||||
|
|
||||||
if (serverGeneration != xevieServerGeneration) {
|
|
||||||
if ((xevieDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1)
|
|
||||||
return;
|
|
||||||
xevieServerGeneration = serverGeneration;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL))
|
if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((extEntry = AddExtension (XEVIENAME,
|
if (extEntry = AddExtension (XEVIENAME,
|
||||||
0,
|
0,
|
||||||
XevieNumberErrors,
|
XevieNumberErrors,
|
||||||
ProcDispatch,
|
ProcDispatch,
|
||||||
SProcDispatch,
|
SProcDispatch,
|
||||||
ResetProc,
|
ResetProc,
|
||||||
StandardMinorOpcode))) {
|
StandardMinorOpcode)) {
|
||||||
ReqCode = (unsigned char)extEntry->base;
|
ReqCode = (unsigned char)extEntry->base;
|
||||||
ErrorBase = extEntry->errorBase;
|
ErrorBase = extEntry->errorBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PC servers initialize the desktop colors (citems) here! */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
static
|
static
|
||||||
void ResetProc (ExtensionEntry* extEntry)
|
void ResetProc (extEntry)
|
||||||
|
ExtensionEntry* extEntry;
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int ProcQueryVersion (ClientPtr client)
|
int ProcQueryVersion (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
|
REQUEST (xXevieQueryVersionReq);
|
||||||
xXevieQueryVersionReply rep;
|
xXevieQueryVersionReply rep;
|
||||||
|
register int n;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH (xXevieQueryVersionReq);
|
REQUEST_SIZE_MATCH (xXevieQueryVersionReq);
|
||||||
rep.type = X_Reply;
|
rep.type = X_Reply;
|
||||||
|
@ -168,30 +132,26 @@ int ProcQueryVersion (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int ProcStart (ClientPtr client)
|
int ProcStart (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
|
REQUEST (xXevieStartReq);
|
||||||
xXevieStartReply rep;
|
xXevieStartReply rep;
|
||||||
|
register int n;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH (xXevieStartReq);
|
REQUEST_SIZE_MATCH (xXevieStartReq);
|
||||||
rep.pad1 = 0;
|
rep.pad1 = 0;
|
||||||
|
|
||||||
if(!xevieFlag){
|
if(!xevieFlag){
|
||||||
if (AddCallback(&ClientStateCallback,XevieClientStateCallback,NULL)) {
|
if (AddCallback(&ClientStateCallback,XevieClientStateCallback,NULL)) {
|
||||||
xevieFlag = 1;
|
xevieFlag = 1;
|
||||||
rep.pad1 = 1;
|
rep.pad1 = 1;
|
||||||
xevieClientIndex = client->index;
|
xevieClientIndex = client->index;
|
||||||
} else
|
} else
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
} else
|
} else
|
||||||
return BadAccess;
|
return BadAccess;
|
||||||
|
|
||||||
if (!XevieStart()) {
|
|
||||||
DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL);
|
|
||||||
return BadAlloc;
|
|
||||||
}
|
|
||||||
|
|
||||||
xevieModifiersOn = FALSE;
|
|
||||||
|
|
||||||
rep.type = X_Reply;
|
rep.type = X_Reply;
|
||||||
rep.sequence_number = client->sequence;
|
rep.sequence_number = client->sequence;
|
||||||
WriteToClient (client, sizeof (xXevieStartReply), (char *)&rep);
|
WriteToClient (client, sizeof (xXevieStartReply), (char *)&rep);
|
||||||
|
@ -199,18 +159,13 @@ int ProcStart (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int ProcEnd (ClientPtr client)
|
int ProcEnd (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
xXevieEndReply rep;
|
xXevieEndReply rep;
|
||||||
|
|
||||||
if (xevieFlag) {
|
XevieEnd(xevieClientIndex);
|
||||||
if (client->index != xevieClientIndex)
|
|
||||||
return BadAccess;
|
|
||||||
|
|
||||||
DeleteCallback(&ClientStateCallback,XevieClientStateCallback,NULL);
|
|
||||||
XevieEnd(xevieClientIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
rep.type = X_Reply;
|
rep.type = X_Reply;
|
||||||
rep.sequence_number = client->sequence;
|
rep.sequence_number = client->sequence;
|
||||||
WriteToClient (client, sizeof (xXevieEndReply), (char *)&rep);
|
WriteToClient (client, sizeof (xXevieEndReply), (char *)&rep);
|
||||||
|
@ -218,18 +173,15 @@ int ProcEnd (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int ProcSend (ClientPtr client)
|
int ProcSend (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
REQUEST (xXevieSendReq);
|
REQUEST (xXevieSendReq);
|
||||||
xXevieSendReply rep;
|
xXevieSendReply rep;
|
||||||
xEvent *xE;
|
xEvent *xE;
|
||||||
|
OsCommPtr oc;
|
||||||
static unsigned char lastDetail = 0, lastType = 0;
|
static unsigned char lastDetail = 0, lastType = 0;
|
||||||
|
|
||||||
ERR("ProcSend\n");
|
|
||||||
|
|
||||||
if (client->index != xevieClientIndex)
|
|
||||||
return BadAccess;
|
|
||||||
|
|
||||||
xE = (xEvent *)&stuff->event;
|
xE = (xEvent *)&stuff->event;
|
||||||
rep.type = X_Reply;
|
rep.type = X_Reply;
|
||||||
rep.sequence_number = client->sequence;
|
rep.sequence_number = client->sequence;
|
||||||
|
@ -238,31 +190,33 @@ int ProcSend (ClientPtr client)
|
||||||
switch(xE->u.u.type) {
|
switch(xE->u.u.type) {
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
doSendEvent(xE, inputInfo.keyboard);
|
xevieKBEventSent = 1;
|
||||||
|
#ifdef XKB
|
||||||
|
if(noXkbExtension)
|
||||||
|
#endif
|
||||||
|
CoreProcessKeyboardEvent (xE, xeviekb, 1);
|
||||||
break;
|
break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
doSendEvent(xE, inputInfo.pointer);
|
xevieEventSent = 1;
|
||||||
|
CoreProcessPointerEvent(xE, xeviemouse, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastType = xE->u.u.type;
|
lastType = xE->u.u.type;
|
||||||
lastDetail = xE->u.u.detail;
|
lastDetail = xE->u.u.detail;
|
||||||
|
|
||||||
return client->noClientException;
|
return client->noClientException;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int ProcSelectInput (ClientPtr client)
|
int ProcSelectInput (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
REQUEST (xXevieSelectInputReq);
|
REQUEST (xXevieSelectInputReq);
|
||||||
xXevieSelectInputReply rep;
|
xXevieSelectInputReply rep;
|
||||||
|
|
||||||
if (client->index != xevieClientIndex)
|
|
||||||
return BadAccess;
|
|
||||||
|
|
||||||
xevieMask = (long)stuff->event_mask;
|
xevieMask = (long)stuff->event_mask;
|
||||||
rep.type = X_Reply;
|
rep.type = X_Reply;
|
||||||
rep.sequence_number = client->sequence;
|
rep.sequence_number = client->sequence;
|
||||||
|
@ -271,7 +225,8 @@ int ProcSelectInput (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int ProcDispatch (ClientPtr client)
|
int ProcDispatch (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
REQUEST (xReq);
|
REQUEST (xReq);
|
||||||
switch (stuff->data)
|
switch (stuff->data)
|
||||||
|
@ -292,7 +247,8 @@ int ProcDispatch (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int SProcQueryVersion (ClientPtr client)
|
int SProcQueryVersion (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
|
|
||||||
|
@ -302,7 +258,8 @@ int SProcQueryVersion (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int SProcStart (ClientPtr client)
|
int SProcStart (client)
|
||||||
|
ClientPtr client;
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
|
|
||||||
|
@ -314,9 +271,12 @@ int SProcStart (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int SProcEnd (ClientPtr client)
|
int SProcEnd (client)
|
||||||
|
ClientPtr client;
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
|
int count;
|
||||||
|
xColorItem* pItem;
|
||||||
|
|
||||||
REQUEST (xXevieEndReq);
|
REQUEST (xXevieEndReq);
|
||||||
swaps (&stuff->length, n);
|
swaps (&stuff->length, n);
|
||||||
|
@ -326,9 +286,11 @@ int SProcEnd (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int SProcSend (ClientPtr client)
|
int SProcSend (client)
|
||||||
|
ClientPtr client;
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
|
int count;
|
||||||
|
|
||||||
REQUEST (xXevieSendReq);
|
REQUEST (xXevieSendReq);
|
||||||
swaps (&stuff->length, n);
|
swaps (&stuff->length, n);
|
||||||
|
@ -338,9 +300,11 @@ int SProcSend (ClientPtr client)
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
int SProcSelectInput (ClientPtr client)
|
int SProcSelectInput (client)
|
||||||
|
ClientPtr client;
|
||||||
{
|
{
|
||||||
register int n;
|
register int n;
|
||||||
|
int count;
|
||||||
|
|
||||||
REQUEST (xXevieSelectInputReq);
|
REQUEST (xXevieSelectInputReq);
|
||||||
swaps (&stuff->length, n);
|
swaps (&stuff->length, n);
|
||||||
|
@ -351,7 +315,8 @@ int SProcSelectInput (ClientPtr client)
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
int SProcDispatch (ClientPtr client)
|
int SProcDispatch (client)
|
||||||
|
register ClientPtr client;
|
||||||
{
|
{
|
||||||
REQUEST(xReq);
|
REQUEST(xReq);
|
||||||
switch (stuff->data)
|
switch (stuff->data)
|
||||||
|
@ -371,258 +336,36 @@ int SProcDispatch (ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*=====================================================*/
|
|
||||||
|
|
||||||
|
|
||||||
#define WRAP_INPUTPROC(dev,store,inputProc) \
|
|
||||||
store->processInputProc = dev->public.processInputProc; \
|
|
||||||
dev->public.processInputProc = inputProc; \
|
|
||||||
store->realInputProc = dev->public.realInputProc; \
|
|
||||||
dev->public.realInputProc = inputProc;
|
|
||||||
|
|
||||||
#define COND_WRAP_INPUTPROC(dev,store,inputProc) \
|
|
||||||
if (dev->public.processInputProc == dev->public.realInputProc) \
|
|
||||||
dev->public.processInputProc = inputProc; \
|
|
||||||
store->processInputProc = \
|
|
||||||
store->realInputProc = dev->public.realInputProc; \
|
|
||||||
dev->public.realInputProc = inputProc;
|
|
||||||
|
|
||||||
#define UNWRAP_INPUTPROC(dev,restore) \
|
|
||||||
dev->public.processInputProc = restore->processInputProc; \
|
|
||||||
dev->public.realInputProc = restore->realInputProc;
|
|
||||||
|
|
||||||
#define UNWRAP_INPUTPROC(dev,restore) \
|
|
||||||
dev->public.processInputProc = restore->processInputProc; \
|
|
||||||
dev->public.realInputProc = restore->realInputProc;
|
|
||||||
|
|
||||||
#define XEVIE_EVENT(xE) \
|
|
||||||
(xevieFlag \
|
|
||||||
&& !xeviegrabState \
|
|
||||||
&& clients[xevieClientIndex] \
|
|
||||||
&& (xevieMask & xevieFilters[xE->u.u.type]))
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
sendEvent(ClientPtr pClient, xEvent *xE)
|
|
||||||
{
|
|
||||||
if(pClient->swapped) {
|
|
||||||
xEvent eventTo;
|
|
||||||
|
|
||||||
/* Remember to strip off the leading bit of type in case
|
|
||||||
this event was sent with "SendEvent." */
|
|
||||||
(*EventSwapVector[xE->u.u.type & 0177]) (xE, &eventTo);
|
|
||||||
(void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo);
|
|
||||||
} else {
|
|
||||||
(void)WriteToClient(pClient, sizeof(xEvent), (char *) xE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
XevieKbdProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count)
|
|
||||||
{
|
|
||||||
int key, bit;
|
|
||||||
BYTE *kptr;
|
|
||||||
ProcessInputProc tmp;
|
|
||||||
KeyClassPtr keyc = dev->key;
|
|
||||||
xevieDeviceInfoPtr xeviep = XEVIEINFO(dev);
|
|
||||||
|
|
||||||
if(XEVIE_EVENT(xE)) {
|
|
||||||
ERR("XevieKbdProcessInputProc\n");
|
|
||||||
|
|
||||||
key = xE->u.u.detail;
|
|
||||||
kptr = &keyc->down[key >> 3];
|
|
||||||
bit = 1 << (key & 7);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is a horrible hack: with xkb on we must zero the modifiers
|
|
||||||
* before sending an event sent back by xevie to
|
|
||||||
* CoreProcessKeyboardEvent.
|
|
||||||
* Since we cannot probe for xkb directly we need to check if the
|
|
||||||
* modifers are set at this point. If they are we know that xkb
|
|
||||||
* isn't active.
|
|
||||||
*/
|
|
||||||
if (dev->key->modifierMap[xE->u.u.detail])
|
|
||||||
xevieModifiersOn = TRUE;
|
|
||||||
|
|
||||||
xE->u.keyButtonPointer.event = xeviewin->drawable.id;
|
|
||||||
xE->u.keyButtonPointer.root = GetCurrentRootWindow()->drawable.id;
|
|
||||||
xE->u.keyButtonPointer.child = (xeviewin->firstChild)
|
|
||||||
? xeviewin->firstChild->drawable.id:0;
|
|
||||||
xE->u.keyButtonPointer.rootX = xeviehot.x;
|
|
||||||
xE->u.keyButtonPointer.rootY = xeviehot.y;
|
|
||||||
xE->u.keyButtonPointer.state = keyc->state;
|
|
||||||
/* fix bug: sequence lost in Xlib */
|
|
||||||
xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence;
|
|
||||||
sendEvent(clients[xevieClientIndex], xE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = dev->public.realInputProc;
|
|
||||||
UNWRAP_INPUTPROC(dev,xeviep);
|
|
||||||
dev->public.processInputProc(xE,dev,count);
|
|
||||||
COND_WRAP_INPUTPROC(dev,xeviep,tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
XeviePointerProcessInputProc(xEvent *xE, DeviceIntPtr dev, int count)
|
|
||||||
{
|
|
||||||
xevieDeviceInfoPtr xeviep = XEVIEINFO(dev);
|
|
||||||
ProcessInputProc tmp;
|
|
||||||
|
|
||||||
if (XEVIE_EVENT(xE)) {
|
|
||||||
ERR("XeviePointerProcessInputProc\n");
|
|
||||||
/* fix bug: sequence lost in Xlib */
|
|
||||||
xE->u.u.sequenceNumber = clients[xevieClientIndex]->sequence;
|
|
||||||
sendEvent(clients[xevieClientIndex], xE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp = dev->public.realInputProc;
|
|
||||||
UNWRAP_INPUTPROC(dev,xeviep);
|
|
||||||
dev->public.processInputProc(xE,dev,count);
|
|
||||||
COND_WRAP_INPUTPROC(dev,xeviep,tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
|
||||||
XevieStart(void)
|
|
||||||
{
|
|
||||||
ProcessInputProc prp;
|
|
||||||
prp = XevieKbdProcessInputProc;
|
|
||||||
if (!XevieAdd(inputInfo.keyboard,&prp))
|
|
||||||
return FALSE;
|
|
||||||
prp = XeviePointerProcessInputProc;
|
|
||||||
if (!XevieAdd(inputInfo.pointer,&prp))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XevieEnd(int clientIndex)
|
XevieEnd(int clientIndex)
|
||||||
{
|
{
|
||||||
if (!clientIndex || clientIndex == xevieClientIndex) {
|
if (!clientIndex || clientIndex == xevieClientIndex) {
|
||||||
XevieRemove(inputInfo.keyboard,NULL);
|
xevieFlag = 0;
|
||||||
XevieRemove(inputInfo.pointer,NULL);
|
xevieClientIndex = 0;
|
||||||
xevieFlag = 0;
|
DeleteCallback (&ClientStateCallback, XevieClientStateCallback, NULL);
|
||||||
xevieClientIndex = 0;
|
|
||||||
DeleteCallback (&ClientStateCallback, XevieClientStateCallback, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
|
XevieClientStateCallback(CallbackListPtr *pcbl, pointer nulldata,
|
||||||
pointer calldata)
|
pointer calldata)
|
||||||
{
|
{
|
||||||
NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
|
NewClientInfoRec *pci = (NewClientInfoRec *)calldata;
|
||||||
ClientPtr client = pci->client;
|
ClientPtr client = pci->client;
|
||||||
if (client->clientState == ClientStateGone
|
if (client->clientState == ClientStateGone
|
||||||
|| client->clientState == ClientStateRetained)
|
|| client->clientState == ClientStateRetained)
|
||||||
XevieEnd(client->index);
|
XevieEnd(client->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XevieServerGrabStateCallback(CallbackListPtr *pcbl, pointer nulldata,
|
XevieServerGrabStateCallback(CallbackListPtr *pcbl, pointer nulldata,
|
||||||
pointer calldata)
|
pointer calldata)
|
||||||
{
|
{
|
||||||
ServerGrabInfoRec *grbinfo = (ServerGrabInfoRec *)calldata;
|
ServerGrabInfoRec *grbinfo = (ServerGrabInfoRec *)calldata;
|
||||||
if (grbinfo->grabstate == SERVER_GRABBED)
|
if (grbinfo->grabstate == SERVER_GRABBED)
|
||||||
xeviegrabState = TRUE;
|
xeviegrabState = TRUE;
|
||||||
else
|
else
|
||||||
xeviegrabState = FALSE;
|
xeviegrabState = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UNWRAP_UNWRAPPROC(device,proc_store) \
|
|
||||||
device->unwrapProc = proc_store;
|
|
||||||
|
|
||||||
#define WRAP_UNWRAPPROC(device,proc_store,proc) \
|
|
||||||
proc_store = device->unwrapProc; \
|
|
||||||
device->unwrapProc = proc;
|
|
||||||
|
|
||||||
static void
|
|
||||||
xevieUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, pointer data)
|
|
||||||
{
|
|
||||||
xevieDeviceInfoPtr xeviep = XEVIEINFO(device);
|
|
||||||
ProcessInputProc tmp = device->public.processInputProc;
|
|
||||||
|
|
||||||
UNWRAP_INPUTPROC(device,xeviep);
|
|
||||||
UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc);
|
|
||||||
proc(device,data);
|
|
||||||
WRAP_INPUTPROC(device,xeviep,tmp);
|
|
||||||
WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
|
||||||
XevieUnwrapAdd(DeviceIntPtr device, void* data)
|
|
||||||
{
|
|
||||||
if (device->unwrapProc)
|
|
||||||
device->unwrapProc(device,XevieUnwrapAdd,data);
|
|
||||||
else {
|
|
||||||
ProcessInputProc *ptr = data;
|
|
||||||
XevieWrap(device,*ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
|
||||||
XevieAdd(DeviceIntPtr device, void* data)
|
|
||||||
{
|
|
||||||
xevieDeviceInfoPtr xeviep;
|
|
||||||
|
|
||||||
if (!AllocateDevicePrivate(device, xevieDevicePrivateIndex))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
xeviep = xcalloc (sizeof (xevieDeviceInfoRec),1);
|
|
||||||
if (!xeviep)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
device->devPrivates[xevieDevicePrivateIndex].ptr = xeviep;
|
|
||||||
XevieUnwrapAdd(device, data);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
|
||||||
XevieRemove(DeviceIntPtr device,pointer data)
|
|
||||||
{
|
|
||||||
xevieDeviceInfoPtr xeviep = XEVIEINFO(device);
|
|
||||||
|
|
||||||
if (!xeviep) return TRUE;
|
|
||||||
|
|
||||||
UNWRAP_INPUTPROC(device,xeviep);
|
|
||||||
UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc);
|
|
||||||
|
|
||||||
xfree(xeviep);
|
|
||||||
device->devPrivates[xevieDevicePrivateIndex].ptr = NULL;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
XevieWrap(DeviceIntPtr device, ProcessInputProc proc)
|
|
||||||
{
|
|
||||||
xevieDeviceInfoPtr xeviep = XEVIEINFO(device);
|
|
||||||
|
|
||||||
WRAP_INPUTPROC(device,xeviep,proc);
|
|
||||||
WRAP_UNWRAPPROC(device,xeviep->unwrapProc,xevieUnwrapProc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
doSendEvent(xEvent *xE, DeviceIntPtr dev)
|
|
||||||
{
|
|
||||||
xevieDeviceInfoPtr xeviep = XEVIEINFO(dev);
|
|
||||||
ProcessInputProc tmp = dev->public.realInputProc;
|
|
||||||
if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))
|
|
||||||
&& !xevieModifiersOn) {
|
|
||||||
CARD8 realModes = dev->key->modifierMap[xE->u.u.detail];
|
|
||||||
dev->key->modifierMap[xE->u.u.detail] = 0;
|
|
||||||
|
|
||||||
UNWRAP_INPUTPROC(dev,xeviep);
|
|
||||||
dev->public.processInputProc(xE,dev,1);
|
|
||||||
COND_WRAP_INPUTPROC(dev,xeviep,tmp);
|
|
||||||
dev->key->modifierMap[xE->u.u.detail] = realModes;
|
|
||||||
} else {
|
|
||||||
UNWRAP_INPUTPROC(dev,xeviep);
|
|
||||||
dev->public.processInputProc(xE,dev,1);
|
|
||||||
COND_WRAP_INPUTPROC(dev,xeviep,tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue