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

Use the same struct for generic event masks throughout the code.

Renaming those structs too.

Previously grabs were using a different struct than windows, which was
reasonably stupid.
parent c1a16bdc
......@@ -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)
......
......@@ -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];
......
......@@ -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)
{
......
......@@ -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))
......
......@@ -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);
......
......@@ -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
......
......@@ -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 {
......
......@@ -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
......
......@@ -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;
......
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