summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xext/geext.c14
-rw-r--r--Xext/geext.h16
-rw-r--r--Xi/extgrbdev.c22
-rw-r--r--dix/events.c46
-rw-r--r--dix/window.c3
-rw-r--r--include/dix.h1
-rw-r--r--include/inputstr.h9
-rw-r--r--include/misc.h1
-rw-r--r--include/windowstr.h22
9 files changed, 66 insertions, 68 deletions
diff --git a/Xext/geext.c b/Xext/geext.c
index 0add5e1fb..0c5fcabac 100644
--- a/Xext/geext.c
+++ b/Xext/geext.c
@@ -207,7 +207,7 @@ GEExtensionInit(void)
GEClientPrivateIndex = AllocateClientPrivateIndex();
if (!AllocateClientPrivate(GEClientPrivateIndex,
- sizeof(GEClientRec)))
+ sizeof(GenericMaskRec)))
{
FatalError("GEExtensionInit: Alloc client private failed.\n");
}
@@ -277,8 +277,8 @@ static void
GERecalculateWinMask(WindowPtr pWin)
{
int i;
- GEClientPtr it;
- GEEventMasksPtr evmasks;
+ GenericMaskPtr it;
+ GenericClientMasksPtr evmasks;
if (!pWin->optional)
return;
@@ -304,7 +304,7 @@ GERecalculateWinMask(WindowPtr pWin)
/* Set generic event mask for given window. */
void GEWindowSetMask(ClientPtr pClient, WindowPtr pWin, int extension, Mask mask)
{
- GEClientPtr cli;
+ GenericMaskPtr cli;
extension = (extension & 0x7F);
@@ -322,7 +322,7 @@ void GEWindowSetMask(ClientPtr pClient, WindowPtr pWin, int extension, Mask mask
if (mask)
{
- GEEventMasksPtr evmasks = pWin->optional->geMasks;
+ GenericClientMasksPtr evmasks = pWin->optional->geMasks;
/* check for existing client */
cli = evmasks->geClients;
@@ -335,7 +335,7 @@ void GEWindowSetMask(ClientPtr pClient, WindowPtr pWin, int extension, Mask mask
if (!cli)
{
/* new client */
- cli = (GEClientPtr)xcalloc(1, sizeof(GEClientRec));
+ cli = (GenericMaskPtr)xcalloc(1, sizeof(GenericMaskRec));
if (!cli)
{
ErrorF("GE: Insufficient memory to alloc client.\n");
@@ -356,7 +356,7 @@ void GEWindowSetMask(ClientPtr pClient, WindowPtr pWin, int extension, Mask mask
xfree(cli);
} else
{
- GEClientPtr prev = cli;
+ GenericMaskPtr prev = cli;
cli = cli->next;
while(cli)
diff --git a/Xext/geext.h b/Xext/geext.h
index bac472662..f3352c2a6 100644
--- a/Xext/geext.h
+++ b/Xext/geext.h
@@ -34,6 +34,21 @@ from the author.
#define _GEEXT_H_
#include <X11/extensions/geproto.h>
+
+/**
+ * This struct is used both in the window and by grabs to determine the event
+ * mask for a client.
+ * A window will have a linked list of these structs, with one entry per
+ * client, null-terminated.
+ * A grab has only one instance of this struct.
+ */
+typedef struct _GenericMaskRec {
+ ClientPtr client; /* client who set the event mask */
+ Mask eventMask[MAXEXTENSIONS]; /* one mask per extension */
+ struct _GenericMaskRec* next;
+} GenericMaskRec, *GenericMaskPtr;
+
+
/* Struct to keep information about registered extensions
*
* evswap ... use to swap event fields for different byte ordered clients.
@@ -48,6 +63,7 @@ typedef struct _GEExtension {
);
} GEExtension, *GEExtensionPtr;
+
/* All registered extensions and their handling functions. */
extern GEExtension GEExtensions[MAXEXTENSIONS];
diff --git a/Xi/extgrbdev.c b/Xi/extgrbdev.c
index 8ae205339..c4011f5c3 100644
--- a/Xi/extgrbdev.c
+++ b/Xi/extgrbdev.c
@@ -194,19 +194,13 @@ ProcXExtendedGrabDevice(ClientPtr client)
(XGenericEventMask*)(((XEventClass*)&stuff[1]) + stuff->event_count);
gemasks = xcalloc(1, sizeof(GenericMaskRec));
- gemasks->extension = xgeMask->extension;
- gemasks->mask = xgeMask->evmask;
+ gemasks->client = client;
gemasks->next = NULL;
- xgeMask++;
+ gemasks->eventMask[xgeMask->extension & 0x7F] = xgeMask->evmask;
+ xgeMask++;
for (i = 1; i < stuff->generic_event_count; i++, xgeMask++)
- {
- gemasks->next = xcalloc(1, sizeof(GenericMaskRec));
- gemasks = gemasks->next;
- gemasks->extension = xgeMask->extension;
- gemasks->mask = xgeMask->evmask;
- gemasks->next = NULL;
- }
+ gemasks->eventMask[xgeMask->extension & 0x7F]= xgeMask->evmask;
}
ExtGrabDevice(client, dev, stuff->device_mode,
@@ -221,12 +215,8 @@ ProcXExtendedGrabDevice(ClientPtr client)
cleanup:
- while(gemasks)
- {
- GenericMaskPtr prev = gemasks;
- gemasks = gemasks->next;
- xfree(prev);
- }
+ if (gemasks)
+ xfree(gemasks);
if (err == Success)
{
diff --git a/dix/events.c b/dix/events.c
index d4af30731..1bec4fc5b 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1934,7 +1934,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
/* Handle generic events */
if (type == GenericEvent)
{
- GEClientPtr pClient;
+ GenericMaskPtr pClient;
/* We don't do more than one GenericEvent at a time. */
if (count > 1)
{
@@ -2017,7 +2017,24 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
inputMasks = wOtherInputMasks(pWin);
tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[pDev->id]: 0;
- tempGrab.genericMasks = NULL;
+ /* get the XGE event mask.
+ * FIXME: needs to be freed somewhere too.
+ */
+ if (!pWin->optional || !pWin->optional->geMasks)
+ tempGrab.genericMasks = NULL;
+ else
+ {
+ GenericClientMasksPtr gemasks = pWin->optional->geMasks;
+ GenericMaskPtr geclient = gemasks->geClients;
+ while(geclient && geclient->client != client)
+ geclient = geclient->next;
+ if (geclient)
+ {
+ tempGrab.genericMasks = xcalloc(1, sizeof(GenericMaskRec));
+ *tempGrab.genericMasks = *geclient;
+ tempGrab.genericMasks->next = NULL;
+ }
+ }
(*inputInfo.pointer->deviceGrab.ActivateGrab)(pDev, &tempGrab,
currentTime,
TRUE | ImplicitGrabMask);
@@ -3264,21 +3281,15 @@ DeliverGrabbedEvent(xEvent *xE, DeviceIntPtr thisDev,
{
/* find evmask for event's extension */
xGenericEvent* ge = ((xGenericEvent*)xE);
- GenericMaskPtr gemask = grab->genericMasks;
- while(gemask)
- {
- if (gemask->extension == ge->extension)
- break;
- gemask = gemask->next;
- }
+ GenericMaskPtr gemask = grab->genericMasks;
- if (!gemask)
+ if (!gemask->eventMask[GEEXTIDX(ge)])
return;
if (GEEventFill(xE))
GEEventFill(xE)(ge, thisDev, grab->window, grab);
deliveries = TryClientEvents(rClient(grab), xE, count,
- gemask->mask,
+ gemask->eventMask[GEEXTIDX(ge)],
generic_filters[GEEXTIDX(ge)][ge->evtype],
grab);
} else
@@ -4161,7 +4172,6 @@ FocusEvent(DeviceIntPtr dev, int type, int mode, int detail, WindowPtr pWin)
xEvent event;
int* numFoci; /* no of foci the window has already */
Bool sendevent = FALSE;
- FocusSemaphoresPtr focus;
if (dev != inputInfo.keyboard)
DeviceFocusEvent(dev, type, mode, detail, pWin);
@@ -5914,21 +5924,9 @@ ExtGrabDevice(ClientPtr client,
if (ge_masks)
{
- GenericMaskPtr last;
newGrab.genericMasks = xcalloc(1, sizeof(GenericMaskRec));
*newGrab.genericMasks = *ge_masks;
newGrab.genericMasks->next = NULL;
- ge_masks = ge_masks->next;
- last = newGrab.genericMasks;
-
- while(ge_masks)
- {
- last->next = xcalloc(1, sizeof(GenericMaskRec));
- last = last->next;
- *last = *ge_masks;
- last->next = NULL;
- ge_masks = ge_masks->next;
- }
}
if (IsPointerDevice(dev))
diff --git a/dix/window.c b/dix/window.c
index b49abdfe5..193f1aa33 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3751,7 +3751,8 @@ MakeWindowOptional (WindowPtr pWin)
#endif
optional->deviceCursors = NULL;
- optional->geMasks = (GEEventMasksPtr)xalloc(sizeof(GEEventMasksRec));
+ optional->geMasks =
+ (GenericClientMasksPtr)xalloc(sizeof(GenericClientMasksRec));
if (!optional->geMasks)
{
xfree(optional);
diff --git a/include/dix.h b/include/dix.h
index be1cb95f2..2fc625438 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -52,6 +52,7 @@ SOFTWARE.
#include "window.h"
#include "input.h"
#include "cursor.h"
+#include "geext.h"
#include <X11/extensions/XI.h>
#define EARLIER -1
diff --git a/include/inputstr.h b/include/inputstr.h
index d9128cce8..6c65aa46d 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -53,6 +53,7 @@ SOFTWARE.
#include "window.h"
#include "dixstruct.h"
#include "cursorstr.h"
+#include "geext.h"
#define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
@@ -102,12 +103,6 @@ typedef struct _DetailRec { /* Grab details may be bit masks */
Mask *pMask;
} DetailRec;
-typedef struct _GenericMaskRec {
- int extension;
- Mask mask;
- struct _GenericMaskRec* next;
-} GenericMaskRec;
-
/**
* Central struct for device grabs.
* The same struct is used for both core grabs and device grabs, with
@@ -139,7 +134,7 @@ typedef struct _GrabRec {
CursorPtr cursor; /* always NULL for keyboards */
Mask eventMask;
Mask deviceMask;
- GenericMaskPtr genericMasks; /* null terminated list */
+ GenericMaskPtr genericMasks;
} GrabRec;
typedef struct _KeyClassRec {
diff --git a/include/misc.h b/include/misc.h
index 14c848d1c..e6a5e9eb2 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -243,7 +243,6 @@ typedef struct pixman_box16 *BoxPtr;
typedef struct _xEvent *xEventPtr;
typedef struct _xRectangle *xRectanglePtr;
typedef struct _GrabRec *GrabPtr;
-typedef struct _GenericMaskRec *GenericMaskPtr;
/* typedefs from other places - duplicated here to minimize the amount
* of unnecessary junk that one would normally have to include to get
diff --git a/include/windowstr.h b/include/windowstr.h
index a1d501d37..959ea0ec1 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -77,17 +77,15 @@ 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;
+/* Mask structure for GE extension as stored on the window.
+ * Allows one mask per extension.
+ * .eventMask - Summary mask for all clients, used for quick checking.
+ * .geClients - list of clients with their specific mask.
+ */
+typedef struct _GenericClientMasks {
+ Mask eventMasks[MAXEXTENSIONS];
+ GenericMaskPtr geClients;
+} GenericClientMasksRec, *GenericClientMasksPtr;
typedef struct _WindowAccessRec {
int defaultRule; /* WindowAccessDenyAll */
@@ -117,7 +115,7 @@ typedef struct _WindowOpt {
struct _OtherInputMasks *inputMasks; /* default: NULL */
#endif
DevCursorList deviceCursors; /* default: NULL */
- struct _GEEventMasks* geMasks; /* default: NULL */
+ struct _GenericClientMasks *geMasks;/* default: NULL */
WindowAccessRec access;
} WindowOptRec, *WindowOptPtr;