Skip to content

Commit

Permalink
Xi: remove dynamic mask assignment for XI events.
Browse files Browse the repository at this point in the history
They end up being the same anyway on startup, so let's not have a dynamic mask
assignment mechanism and instead just hardcode them already.
Also unexport SelectForWindow and remove the valid_masks parameter. We can
check that before calling, since there's only one caller anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Feb 16, 2009
1 parent 7057a9a commit 58f3127
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 122 deletions.
6 changes: 1 addition & 5 deletions Xi/exevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -1353,17 +1353,13 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,

int
SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
Mask mask, Mask exclusivemasks, Mask validmasks)
Mask mask, Mask exclusivemasks)
{
int mskidx = dev->id;
int i, ret;
Mask check;
InputClientsPtr others;

if (mask & ~validmasks) {
client->errorValue = mask;
return BadValue;
}
check = (mask & exclusivemasks);
if (wOtherInputMasks(pWin)) {
if (check & wOtherInputMasks(pWin)->inputEvents[mskidx]) { /* It is illegal for two different
Expand Down
25 changes: 13 additions & 12 deletions Xi/exglobals.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ extern int BadMode;
extern int DeviceBusy;
extern int BadClass;

extern Mask DevicePointerMotionMask;
extern Mask DevicePointerMotionHintMask;
extern Mask DeviceFocusChangeMask;
extern Mask DeviceStateNotifyMask;
extern Mask DeviceMappingNotifyMask;
extern Mask DeviceOwnerGrabButtonMask;
extern Mask DeviceButtonGrabMask;
extern Mask DeviceButtonMotionMask;
extern Mask DevicePresenceNotifyMask;
extern Mask DevicePropertyNotifyMask;
extern Mask DeviceEnterWindowMask;
extern Mask DeviceLeaveWindowMask;
/* Note: only the ones needed in files other than extinit.c are declared */
extern const Mask DevicePointerMotionMask;
extern const Mask DevicePointerMotionHintMask;
extern const Mask DeviceFocusChangeMask;
extern const Mask DeviceStateNotifyMask;
extern const Mask DeviceMappingNotifyMask;
extern const Mask DeviceOwnerGrabButtonMask;
extern const Mask DeviceButtonGrabMask;
extern const Mask DeviceButtonMotionMask;
extern const Mask DevicePresenceNotifyMask;
extern const Mask DevicePropertyNotifyMask;
extern const Mask XIAllMasks;

extern Mask PropagateMask[];

extern int DeviceValuator;
Expand Down
149 changes: 50 additions & 99 deletions Xi/extinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,37 @@ SOFTWARE.
#include "xiproperty.h"


static Mask lastExtEventMask = 1;
/* Masks for XI events have to be aligned with core event (partially anyway).
* If DeviceButtonMotionMask is != ButtonMotionMask, event delivery
* breaks down. The device needs the dev->button->motionMask. If DBMM is
* the same as BMM, we can ensure that both core and device events can be
* delivered, without the need for extra structures in the DeviceIntRec. */
const Mask DeviceKeyPressMask = KeyPressMask;
const Mask DeviceKeyReleaseMask = KeyReleaseMask;
const Mask DeviceButtonPressMask = ButtonPressMask;
const Mask DeviceButtonReleaseMask = ButtonReleaseMask;
const Mask DeviceProximityMask = (1L << 4);
const Mask DeviceStateNotifyMask = (1L << 5);
const Mask DevicePointerMotionMask = PointerMotionMask;
const Mask DevicePointerMotionHintMask = PointerMotionHintMask;
const Mask DeviceButton1MotionMask = Button1MotionMask;
const Mask DeviceButton2MotionMask = Button2MotionMask;
const Mask DeviceButton3MotionMask = Button3MotionMask;
const Mask DeviceButton4MotionMask = Button4MotionMask;
const Mask DeviceButton5MotionMask = Button5MotionMask;
const Mask DeviceButtonMotionMask = ButtonMotionMask;
const Mask DeviceFocusChangeMask = (1L << 14);
const Mask DeviceMappingNotifyMask = (1L << 15);
const Mask ChangeDeviceNotifyMask = (1L << 16);
const Mask DeviceButtonGrabMask = (1L << 17);
const Mask DeviceOwnerGrabButtonMask = (1L << 17);
const Mask DevicePresenceNotifyMask = (1L << 18);
const Mask DeviceEnterWindowMask = (1L << 18);
const Mask DeviceLeaveWindowMask = (1L << 19);
const Mask DevicePropertyNotifyMask = (1L << 20);
const Mask XIAllMasks = (1L << 21) - 1;

int ExtEventIndex;
Mask ExtValidMasks[EMASKSIZE];
Mask ExtExclusiveMasks[EMASKSIZE];


Expand Down Expand Up @@ -287,20 +315,6 @@ int BadMode = 2;
int DeviceBusy = 3;
int BadClass = 4;

Mask DevicePointerMotionMask;
Mask DevicePointerMotionHintMask;
Mask DeviceFocusChangeMask;
Mask DeviceStateNotifyMask;
static Mask ChangeDeviceNotifyMask;
Mask DeviceMappingNotifyMask;
Mask DeviceOwnerGrabButtonMask;
Mask DeviceButtonGrabMask;
Mask DeviceButtonMotionMask;
Mask DevicePresenceNotifyMask;
Mask DevicePropertyNotifyMask;
Mask DeviceEnterWindowMask;
Mask DeviceLeaveWindowMask;

int DeviceValuator;
int DeviceKeyPress;
int DeviceKeyRelease;
Expand Down Expand Up @@ -673,28 +687,6 @@ AllowPropagateSuppress(Mask mask)
PropagateMask[i] |= mask;
}

/**************************************************************************
*
* Return the next available extension event mask.
*
*/

static Mask
GetNextExtEventMask(void)
{
int i;
Mask mask = lastExtEventMask;

if (lastExtEventMask == 0) {
FatalError("GetNextExtEventMask: no more events are available.");
}
lastExtEventMask <<= 1;

for (i = 0; i < MAXDEVICES; i++)
ExtValidMasks[i] |= mask;
return mask;
}

/**************************************************************************
*
* Record an event mask where there is no unique corresponding event type.
Expand Down Expand Up @@ -762,8 +754,6 @@ SetMaskForExtEvent(Mask mask, int event)
static void
FixExtensionEvents(ExtensionEntry * extEntry)
{
Mask mask;

DeviceValuator = extEntry->eventBase;
DeviceKeyPress = DeviceValuator + 1;
DeviceKeyRelease = DeviceKeyPress + 1;
Expand Down Expand Up @@ -797,88 +787,50 @@ FixExtensionEvents(ExtensionEntry * extEntry)
DeviceBusy += extEntry->errorBase;
BadClass += extEntry->errorBase;

mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceKeyPress);
AllowPropagateSuppress(mask);
SetMaskForExtEvent(DeviceKeyPressMask, DeviceKeyPress);
AllowPropagateSuppress(DeviceKeyPressMask);

mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceKeyRelease);
AllowPropagateSuppress(mask);
SetMaskForExtEvent(DeviceKeyReleaseMask, DeviceKeyRelease);
AllowPropagateSuppress(DeviceKeyReleaseMask);

mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceButtonPress);
AllowPropagateSuppress(mask);
SetMaskForExtEvent(DeviceButtonPressMask, DeviceButtonPress);
AllowPropagateSuppress(DeviceButtonPressMask);

mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceButtonRelease);
AllowPropagateSuppress(mask);
SetMaskForExtEvent(DeviceButtonReleaseMask, DeviceButtonRelease);
AllowPropagateSuppress(DeviceButtonReleaseMask);

mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, ProximityIn);
SetMaskForExtEvent(mask, ProximityOut);
AllowPropagateSuppress(mask);
SetMaskForExtEvent(DeviceProximityMask, ProximityIn);
SetMaskForExtEvent(DeviceProximityMask, ProximityOut);

mask = GetNextExtEventMask();
DeviceStateNotifyMask = mask;
SetMaskForExtEvent(mask, DeviceStateNotify);
SetMaskForExtEvent(DeviceStateNotifyMask, DeviceStateNotify);

mask = GetNextExtEventMask();
DevicePointerMotionMask = mask;
SetMaskForExtEvent(mask, DeviceMotionNotify);
AllowPropagateSuppress(mask);
SetMaskForExtEvent(DevicePointerMotionMask, DeviceMotionNotify);
AllowPropagateSuppress(DevicePointerMotionMask);

DevicePointerMotionHintMask = GetNextExtEventMask();
SetEventInfo(DevicePointerMotionHintMask, _devicePointerMotionHint);
SetEventInfo(GetNextExtEventMask(), _deviceButton1Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton2Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton3Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton4Motion);
SetEventInfo(GetNextExtEventMask(), _deviceButton5Motion);

/* If DeviceButtonMotionMask is != ButtonMotionMask, event delivery
* breaks down. The device needs the dev->button->motionMask. If DBMM is
* the same as BMM, we can ensure that both core and device events can be
* delivered, without the need for extra structures in the DeviceIntRec.
*/
DeviceButtonMotionMask = GetNextExtEventMask();
SetEventInfo(DeviceButton1MotionMask, _deviceButton1Motion);
SetEventInfo(DeviceButton2MotionMask, _deviceButton2Motion);
SetEventInfo(DeviceButton3MotionMask, _deviceButton3Motion);
SetEventInfo(DeviceButton4MotionMask, _deviceButton4Motion);
SetEventInfo(DeviceButton5MotionMask, _deviceButton5Motion);
SetEventInfo(DeviceButtonMotionMask, _deviceButtonMotion);
if (DeviceButtonMotionMask != ButtonMotionMask)
{
/* This should never happen, but if it does, hide under the
* bed and cry for help. */
ErrorF("[Xi] DeviceButtonMotionMask != ButtonMotionMask. Trouble!\n");
}

DeviceFocusChangeMask = GetNextExtEventMask();
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusIn);
SetMaskForExtEvent(DeviceFocusChangeMask, DeviceFocusOut);

mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, DeviceMappingNotify);
DeviceMappingNotifyMask = mask;

mask = GetNextExtEventMask();
SetMaskForExtEvent(mask, ChangeDeviceNotify);
ChangeDeviceNotifyMask = mask;
SetMaskForExtEvent(DeviceMappingNotifyMask, DeviceMappingNotify);
SetMaskForExtEvent(ChangeDeviceNotifyMask, ChangeDeviceNotify);

DeviceButtonGrabMask = GetNextExtEventMask();
SetEventInfo(DeviceButtonGrabMask, _deviceButtonGrab);
SetExclusiveAccess(DeviceButtonGrabMask);

DeviceOwnerGrabButtonMask = GetNextExtEventMask();
SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);

DevicePresenceNotifyMask = GetNextExtEventMask();
SetEventInfo(DevicePresenceNotifyMask, _devicePresence);

DevicePropertyNotifyMask = GetNextExtEventMask();
SetMaskForExtEvent(DevicePropertyNotifyMask, DevicePropertyNotify);

DeviceEnterWindowMask = GetNextExtEventMask();
SetMaskForExtEvent(DeviceEnterWindowMask, DeviceEnterNotify);
AllowPropagateSuppress(DeviceEnterWindowMask);

DeviceLeaveWindowMask = GetNextExtEventMask();
SetMaskForExtEvent(DeviceLeaveWindowMask, DeviceLeaveNotify);
AllowPropagateSuppress(DeviceLeaveWindowMask);

Expand Down Expand Up @@ -910,7 +862,6 @@ RestoreExtensionEvents(void)
EventInfo[i].type = 0;
}
ExtEventIndex = 0;
lastExtEventMask = 1;
DeviceValuator = 0;
DeviceKeyPress = 1;
DeviceKeyRelease = 2;
Expand Down
8 changes: 5 additions & 3 deletions Xi/selectev.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ SOFTWARE.
#include "selectev.h"

extern Mask ExtExclusiveMasks[];
extern Mask ExtValidMasks[];

static int
HandleDevicePresenceMask(ClientPtr client, WindowPtr win,
Expand Down Expand Up @@ -173,10 +172,13 @@ ProcXSelectExtensionEvent(ClientPtr client)

for (i = 0; i < EMASKSIZE; i++)
if (tmp[i].dev != NULL) {
if (tmp[i].mask & ~XIAllMasks) {
client->errorValue = tmp[i].mask;
return BadValue;
}
if ((ret =
SelectForWindow((DeviceIntPtr) tmp[i].dev, pWin, client,
tmp[i].mask, ExtExclusiveMasks[i],
ExtValidMasks[i])) != Success)
tmp[i].mask, ExtExclusiveMasks[i]))!= Success)
return ret;
}

Expand Down
5 changes: 2 additions & 3 deletions include/exevents.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ extern _X_EXPORT int GrabKey(
BOOL /* ownerEvents */,
Mask /* mask */);

extern _X_EXPORT int SelectForWindow(
extern int SelectForWindow(
DeviceIntPtr /* dev */,
WindowPtr /* pWin */,
ClientPtr /* client */,
Mask /* mask */,
Mask /* exclusivemasks */,
Mask /* validmasks */);
Mask /* exclusivemasks */);

extern _X_EXPORT int AddExtensionClient (
WindowPtr /* pWin */,
Expand Down

0 comments on commit 58f3127

Please sign in to comment.