Commit 5e439109 authored by Peter Hutterer's avatar Peter Hutterer

Add GenericEvent extension to Xext.

This adds (unconditional) support for the GE extension. Anything from now on
that sends events in MPX will have to use the GE extension. No GE, no MPX
events. GE is not actually used yet from anywhere with this commit.

You will need to update x11proto, xextproto, libX11, libXext and xcb to the
matching xge branches. Things will _NOT_ work without the updated protocol
headers and libraries.
parent f28eea06
......@@ -23,7 +23,8 @@ BUILTIN_SRCS = \
shape.c \
sleepuntil.c \
sleepuntil.h \
xtest.c
xtest.c \
geext.c
# Sources always included in libXextmodule.la & libXext.la
MODULE_SRCS = \
......@@ -178,5 +179,6 @@ EXTRA_DIST = \
$(EXTRA_MULTIBUFFER_SRCS) \
$(FONTCACHE_SRCS) \
$(BIGFONT_SRCS) \
$(DPMS_SRCS)
$(DPMS_SRCS) \
$(GE_SRCS)
This diff is collapsed.
/*
Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the author shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the author.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _GEEXT_H_
#define _GEEXT_H_
#include <X11/extensions/geproto.h>
/* Returns the extension offset from the event */
#define GEEXT(ev) (((xGenericEvent*)(ev))->extension)
#define GEEXTIDX(ev) (GEEXT(ev) & 0x7F)
/* Typecast to generic event */
#define GEV(ev) ((xGenericEvent*)(ev))
/* True if mask is set for extension on window */
#define GEMaskIsSet(pWin, extension, mask) \
((pWin)->optional && \
(pWin)->optional->geMasks && \
((pWin)->optional->geMasks->eventMasks[(extension) & 0x7F] & (mask)))
/* Returns first client */
#define GECLIENT(pWin) \
(((pWin)->optional) ? (pWin)->optional->geMasks->geClients : NULL)
/* Interface for other extensions */
Mask GENextMask(int extension);
void GEWindowSetMask(ClientPtr pClient, WindowPtr pWin, int extension, Mask mask);
void GERegisterExtension(
int extension,
void (*ev_dispatch)(xGenericEvent* from, xGenericEvent* to));
void GEInitEvent(xGenericEvent* ev, int extension);
void GEExtensionInit(void);
#endif /* _GEEXT_H_ */
/*
Copyright 2007 Peter Hutterer <peter@cs.unisa.edu.au>
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of the author shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from the author.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#ifndef _GEINT_H_
#define _GEINT_H_
#define NEED_EVENTS
#include <X11/X.h>
#include <X11/Xproto.h>
#include "misc.h"
#include "os.h"
#include "dixstruct.h"
#include "extnsionst.h"
#include <X11/extensions/geproto.h>
extern int GEEventType;
extern int GEEventBase;
extern int GEErrorBase;
extern int GEClientPrivateIndex;
typedef struct _GEClientInfo {
CARD32 major_version;
CARD32 minor_version;
} GEClientInfoRec, *GEClientInfoPtr;
#define GEGetClient(pClient) ((GEClientInfoPtr) (pClient)->devPrivates[GEClientPrivateIndex].ptr)
extern int (*ProcGEVector[/*GENumRequests*/])(ClientPtr);
extern int (*SProcGEVector[/*GENumRequests*/])(ClientPtr);
#endif /* _GEINT_H_ */
......@@ -178,6 +178,11 @@ static xEvent *xeviexE;
#include "dixevents.h"
#include "dixgrabs.h"
#include "dispatch.h"
#include <X11/extensions/ge.h>
#include "geext.h"
#include "geint.h"
/**
* Extension events type numbering starts at EXTENSION_EVENT_BASE.
*/
......@@ -260,6 +265,9 @@ static struct {
#define RootWindow(dev) dev->spriteInfo->sprite->spriteTrace[0]
static xEvent* swapEvent = NULL;
static int swapEventLen = 0;
/**
* True if device owns a cursor, false if device shares a cursor sprite with
* another device.
......@@ -1850,7 +1858,8 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
return 0;
/* CantBeFiltered means only window owner gets the event */
if ((filter == CantBeFiltered) || !(type & EXTENSION_EVENT_BASE))
if ((filter == CantBeFiltered) ||
(!(type & EXTENSION_EVENT_BASE) && type != GenericEvent))
{
/* if nobody ever wants to see this event, skip some work */
if (filter != CantBeFiltered &&
......@@ -1875,37 +1884,70 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
}
if (filter != CantBeFiltered)
{
if (type & EXTENSION_EVENT_BASE)
{
OtherInputMasks *inputMasks;
/* Handle generic events */
if (type == GenericEvent)
{
GEClientPtr pClient;
/* FIXME: We don't do more than one GenericEvent at a time yet. */
if (count > 1)
{
ErrorF("Do not send more than one GenericEvent at a time!\n");
return 0;
}
inputMasks = wOtherInputMasks(pWin);
if (!inputMasks ||
!(inputMasks->inputEvents[mskidx] & filter))
return 0;
other = inputMasks->inputClients;
}
else
other = (InputClients *)wOtherClients(pWin);
for (; other; other = other->next)
{
/* core event? check for grab interference */
if (!(type & EXTENSION_EVENT_BASE) &&
IsInterferingGrab(rClient(other), pWin, pDev, pEvents))
continue;
/* if we get here, filter should be set to the GE specific mask.
check if any client wants it */
if (!GEMaskIsSet(pWin, GEEXT(pEvents), filter))
return 0;
if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
other->mask[mskidx], filter, grab)) )
{
if (attempt > 0)
{
deliveries++;
client = rClient(other);
deliveryMask = other->mask[mskidx];
} else
nondeliveries--;
}
}
/* run through all clients, deliver event */
for (pClient = GECLIENT(pWin); pClient; pClient = pClient->next)
{
if (pClient->eventMask[GEEXTIDX(pEvents)] & filter)
{
if (TryClientEvents(pClient->client, pEvents, count,
pClient->eventMask[GEEXTIDX(pEvents)], filter, grab) > 0)
{
deliveries++;
} else
nondeliveries--;
}
}
}
else {
/* Traditional event */
if (type & EXTENSION_EVENT_BASE)
{
OtherInputMasks *inputMasks;
inputMasks = wOtherInputMasks(pWin);
if (!inputMasks ||
!(inputMasks->inputEvents[mskidx] & filter))
return 0;
other = inputMasks->inputClients;
}
else
other = (InputClients *)wOtherClients(pWin);
for (; other; other = other->next)
{
/* core event? check for grab interference */
if (!(type & EXTENSION_EVENT_BASE) &&
IsInterferingGrab(rClient(other), pWin, pDev, pEvents))
continue;
if ( (attempt = TryClientEvents(rClient(other), pEvents, count,
other->mask[mskidx], filter, grab)) )
{
if (attempt > 0)
{
deliveries++;
client = rClient(other);
deliveryMask = other->mask[mskidx];
} else
nondeliveries--;
}
}
}
}
if ((type == ButtonPress) && deliveries && (!grab))
{
......@@ -5378,8 +5420,9 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
#ifdef PANORAMIX
xEvent eventCopy;
#endif
xEvent eventTo, *eventFrom;
int i;
xEvent *eventTo, *eventFrom;
int i,
eventlength = sizeof(xEvent);
#ifdef XKB
if ((!noXkbExtension)&&(!XkbFilterEvents(pClient, count, events)))
......@@ -5436,21 +5479,53 @@ WriteEventsToClient(ClientPtr pClient, int count, xEvent *events)
}
}
#endif
/* Just a safety check to make sure we only have one GenericEvent, it just
* makes things easier for me right now. (whot) */
for (i = 1; i < count; i++)
{
if (events[i].u.u.type == GenericEvent)
{
ErrorF("TryClientEvents: Only one GenericEvent at a time.");
return;
}
}
if (events->u.u.type == GenericEvent)
{
eventlength += ((xGenericEvent*)events)->length * 4;
if (eventlength > swapEventLen)
{
swapEventLen = eventlength;
swapEvent = Xrealloc(swapEvent, swapEventLen);
if (!swapEvent)
{
FatalError("WriteEventsToClient: Out of memory.\n");
return;
}
}
}
if(pClient->swapped)
{
for(i = 0; i < count; i++)
{
eventFrom = &events[i];
eventTo = swapEvent;
/* Remember to strip off the leading bit of type in case
this event was sent with "SendEvent." */
(*EventSwapVector[eventFrom->u.u.type & 0177])
(eventFrom, &eventTo);
(void)WriteToClient(pClient, sizeof(xEvent), (char *)&eventTo);
(eventFrom, eventTo);
(void)WriteToClient(pClient, eventlength, (char *)&eventTo);
}
}
else
{
(void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events);
/* only one GenericEvent, remember? that means either count is 1 and
* eventlength is arbitrary or eventlength is 32 and count doesn't
* matter. And we're all set. Woohoo. */
(void)WriteToClient(pClient, count * eventlength, (char *) events);
}
}
......
......@@ -455,6 +455,7 @@ CreateRootWindow(ScreenPtr pScreen)
#ifdef XINPUT
pWin->optional->inputMasks = NULL;
pWin->optional->deviceCursors = NULL;
pWin->optional->geMasks = NULL;
#endif
pWin->optional->access.perm = NULL;
......@@ -3700,6 +3701,9 @@ CheckWindowOptionalNeed (WindowPtr w)
optional->access.ndeny != 0)
return;
if (optional->geMasks != NULL)
return;
parentOptional = FindWindowWithOptional(w)->optional;
if (optional->visual != parentOptional->visual)
return;
......@@ -3746,6 +3750,19 @@ MakeWindowOptional (WindowPtr pWin)
optional->inputMasks = NULL;
#endif
optional->deviceCursors = NULL;
optional->geMasks = (GEEventMasksPtr)xalloc(sizeof(GEEventMasksRec));
if (!optional->geMasks)
{
xfree(optional);
return FALSE;
} else {
int i;
optional->geMasks->geClients = 0;
for (i = 0; i < MAXEXTENSIONS; i++)
optional->geMasks->eventMasks[i] = 0;
}
optional->access.nperm = 0;
optional->access.ndeny = 0;
optional->access.perm = NULL;
......
......@@ -77,6 +77,18 @@ typedef struct _DevCursorNode {
struct _DevCursorNode* next;
} DevCursNodeRec, *DevCursNodePtr, *DevCursorList;
typedef struct _GEClientRec {
Mask eventMask[MAXEXTENSIONS];
ClientPtr client;
struct _GEClientRec* next;
} GEClientRec, *GEClientPtr;
/* Mask structure for GE extension. Allows one mask per extension. */
typedef struct _GEEventMasks {
Mask eventMasks[MAXEXTENSIONS];
struct _GEClientRec* geClients;
} GEEventMasksRec, *GEEventMasksPtr;
typedef struct _WindowAccessRec {
int defaultRule; /* WindowAccessDenyAll */
DeviceIntPtr* perm;
......@@ -105,6 +117,7 @@ typedef struct _WindowOpt {
struct _OtherInputMasks *inputMasks; /* default: NULL */
#endif
DevCursorList deviceCursors; /* default: NULL */
struct _GEEventMasks* geMasks; /* default: NULL */
WindowAccessRec access;
} WindowOptRec, *WindowOptPtr;
......
......@@ -215,6 +215,7 @@ extern Bool noXIdleExtension;
#ifdef XV
extern Bool noXvExtension;
#endif
extern Bool noGEExtension;
#ifndef XFree86LOADER
#define INITARGS void
......@@ -386,6 +387,7 @@ extern void DamageExtensionInit(INITARGS);
#ifdef COMPOSITE
extern void CompositeExtensionInit(INITARGS);
#endif
extern void GEExtensionInit(INITARGS);
/* The following is only a small first step towards run-time
* configurable extensions.
......@@ -398,6 +400,7 @@ typedef struct {
static ExtensionToggle ExtensionToggleList[] =
{
/* sort order is extension name string as shown in xdpyinfo */
{ "Generic Events", &noGEExtension },
#ifdef BIGREQS
{ "BIG-REQUESTS", &noBigReqExtension },
#endif
......@@ -531,6 +534,8 @@ InitExtensions(argc, argv)
int argc;
char *argv[];
{
if (!noGEExtension) GEExtensionInit();
#ifdef XCSECURITY
SecurityExtensionSetup();
#endif
......@@ -684,6 +689,7 @@ InitVisualWrap()
#else /* XFree86LOADER */
/* List of built-in (statically linked) extensions */
static ExtensionModule staticExtensions[] = {
{ GEExtensionInit, "Generic Event Extension", &noGEExtension, NULL, NULL},
#ifdef MITSHM
{ ShmExtensionInit, SHMNAME, &noMITShmExtension, NULL, NULL },
#endif
......
......@@ -236,6 +236,8 @@ _X_EXPORT Bool noXIdleExtension = FALSE;
_X_EXPORT Bool noXvExtension = FALSE;
#endif
_X_EXPORT Bool noGEExtension = FALSE;
#define X_INCLUDE_NETDB_H
#include <X11/Xos_r.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment