Change GetXI2/XI/CoreType to just take a type argument
Avoids the dummy-event dance if we have an event type and need to get the matching XI2 type. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
parent
6cc0e6a0af
commit
e5aa00989c
|
@ -647,7 +647,7 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi)
|
|||
xde = (xXIDeviceEvent*)*xi;
|
||||
xde->type = GenericEvent;
|
||||
xde->extension = IReqCode;
|
||||
xde->evtype = GetXI2Type((InternalEvent*)ev);
|
||||
xde->evtype = GetXI2Type(ev->type);
|
||||
xde->time = ev->time;
|
||||
xde->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
xde->detail = ev->detail.button;
|
||||
|
@ -714,7 +714,7 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
|
|||
raw = (xXIRawEvent*)*xi;
|
||||
raw->type = GenericEvent;
|
||||
raw->extension = IReqCode;
|
||||
raw->evtype = GetXI2Type((InternalEvent*)ev);
|
||||
raw->evtype = GetXI2Type(ev->type);
|
||||
raw->time = ev->time;
|
||||
raw->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
raw->detail = ev->detail.button;
|
||||
|
@ -746,10 +746,10 @@ eventToRawEvent(RawDeviceEvent *ev, xEvent **xi)
|
|||
* equivalent exists.
|
||||
*/
|
||||
int
|
||||
GetCoreType(InternalEvent *event)
|
||||
GetCoreType(enum EventType type)
|
||||
{
|
||||
int coretype = 0;
|
||||
switch(event->any.type)
|
||||
switch(type)
|
||||
{
|
||||
case ET_Motion: coretype = MotionNotify; break;
|
||||
case ET_ButtonPress: coretype = ButtonPress; break;
|
||||
|
@ -767,10 +767,10 @@ GetCoreType(InternalEvent *event)
|
|||
* equivalent exists.
|
||||
*/
|
||||
int
|
||||
GetXIType(InternalEvent *event)
|
||||
GetXIType(enum EventType type)
|
||||
{
|
||||
int xitype = 0;
|
||||
switch(event->any.type)
|
||||
switch(type)
|
||||
{
|
||||
case ET_Motion: xitype = DeviceMotionNotify; break;
|
||||
case ET_ButtonPress: xitype = DeviceButtonPress; break;
|
||||
|
@ -790,11 +790,11 @@ GetXIType(InternalEvent *event)
|
|||
* equivalent exists.
|
||||
*/
|
||||
int
|
||||
GetXI2Type(InternalEvent *event)
|
||||
GetXI2Type(enum EventType type)
|
||||
{
|
||||
int xi2type = 0;
|
||||
|
||||
switch(event->any.type)
|
||||
switch(type)
|
||||
{
|
||||
case ET_Motion: xi2type = XI_Motion; break;
|
||||
case ET_ButtonPress: xi2type = XI_ButtonPress; break;
|
||||
|
|
14
dix/events.c
14
dix/events.c
|
@ -2553,13 +2553,13 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
|
|||
int type;
|
||||
OtherInputMasks *inputMasks = wOtherInputMasks(win);
|
||||
|
||||
if ((type = GetXI2Type(event)) != 0)
|
||||
if ((type = GetXI2Type(event->any.type)) != 0)
|
||||
{
|
||||
if (inputMasks && xi2mask_isset(inputMasks->xi2mask, dev, type))
|
||||
rc |= EVENT_XI2_MASK;
|
||||
}
|
||||
|
||||
if ((type = GetXIType(event)) != 0)
|
||||
if ((type = GetXIType(event->any.type)) != 0)
|
||||
{
|
||||
filter = GetEventFilterMask(dev, type);
|
||||
|
||||
|
@ -2575,7 +2575,7 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
|
|||
|
||||
}
|
||||
|
||||
if ((type = GetCoreType(event)) != 0)
|
||||
if ((type = GetCoreType(event->any.type)) != 0)
|
||||
{
|
||||
filter = GetEventFilterMask(dev, type);
|
||||
|
||||
|
@ -3712,7 +3712,7 @@ CheckPassiveGrabsOnWindow(
|
|||
tempGrab->modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
|
||||
|
||||
/* Check for XI2 and XI grabs first */
|
||||
tempGrab->type = GetXI2Type(event);
|
||||
tempGrab->type = GetXI2Type(event->any.type);
|
||||
tempGrab->grabtype = GRABTYPE_XI2;
|
||||
if (GrabMatchesSecond(tempGrab, grab, FALSE))
|
||||
match = XI2_MATCH;
|
||||
|
@ -3720,7 +3720,7 @@ CheckPassiveGrabsOnWindow(
|
|||
if (!match)
|
||||
{
|
||||
tempGrab->grabtype = GRABTYPE_XI;
|
||||
if ((tempGrab->type = GetXIType(event)) &&
|
||||
if ((tempGrab->type = GetXIType(event->any.type)) &&
|
||||
(GrabMatchesSecond(tempGrab, grab, FALSE)))
|
||||
match = XI_MATCH;
|
||||
}
|
||||
|
@ -3729,7 +3729,7 @@ CheckPassiveGrabsOnWindow(
|
|||
if (!match && checkCore)
|
||||
{
|
||||
tempGrab->grabtype = GRABTYPE_CORE;
|
||||
if ((tempGrab->type = GetCoreType(event)) &&
|
||||
if ((tempGrab->type = GetCoreType(event->any.type)) &&
|
||||
(GrabMatchesSecond(tempGrab, grab, TRUE)))
|
||||
match = CORE_MATCH;
|
||||
}
|
||||
|
@ -3784,7 +3784,7 @@ CheckPassiveGrabsOnWindow(
|
|||
|
||||
if (!activate)
|
||||
break;
|
||||
else if (!GetXIType(event) && !GetCoreType(event))
|
||||
else if (!GetXIType(event->any.type) && !GetCoreType(event->any.type))
|
||||
{
|
||||
ErrorF("Event type %d in CheckPassiveGrabsOnWindow is neither"
|
||||
" XI 1.x nor core\n", event->any.type);
|
||||
|
|
|
@ -1037,7 +1037,7 @@ DGAProcessKeyboardEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr keybd)
|
|||
if (pScreenPriv->client)
|
||||
{
|
||||
dgaEvent de;
|
||||
de.u.u.type = *XDGAEventBase + GetCoreType((InternalEvent*)&ev);
|
||||
de.u.u.type = *XDGAEventBase + GetCoreType(ev.type);
|
||||
de.u.u.detail = event->detail;
|
||||
de.u.event.time = event->time;
|
||||
de.u.event.dx = event->dx;
|
||||
|
@ -1091,7 +1091,7 @@ DGAProcessPointerEvent (ScreenPtr pScreen, DGAEvent *event, DeviceIntPtr mouse)
|
|||
dgaEvent de;
|
||||
int coreEquiv;
|
||||
|
||||
coreEquiv = GetCoreType((InternalEvent*)&ev);
|
||||
coreEquiv = GetCoreType(ev.type);
|
||||
|
||||
de.u.u.type = *XDGAEventBase + coreEquiv;
|
||||
de.u.u.detail = event->detail;
|
||||
|
|
|
@ -27,14 +27,15 @@
|
|||
#include <X11/extensions/XIproto.h>
|
||||
#include "input.h"
|
||||
#include "events.h"
|
||||
#include "eventstr.h"
|
||||
|
||||
#define FP1616(integral, frac) ((integral) * (1 << 16) + (frac) * (1 << 16))
|
||||
|
||||
_X_EXPORT int EventToCore(InternalEvent *event, xEvent **core, int *count);
|
||||
_X_EXPORT int EventToXI(InternalEvent *ev, xEvent **xi, int *count);
|
||||
_X_EXPORT int EventToXI2(InternalEvent *ev, xEvent **xi);
|
||||
_X_INTERNAL int GetCoreType(InternalEvent* ev);
|
||||
_X_INTERNAL int GetXIType(InternalEvent* ev);
|
||||
_X_INTERNAL int GetXI2Type(InternalEvent* ev);
|
||||
_X_INTERNAL int GetCoreType(enum EventType type);
|
||||
_X_INTERNAL int GetXIType(enum EventType type);
|
||||
_X_INTERNAL int GetXI2Type(enum EventType type);
|
||||
|
||||
#endif /* _EVENTCONVERT_H_ */
|
||||
|
|
|
@ -59,7 +59,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out,
|
|||
|
||||
assert(out->type == GenericEvent);
|
||||
assert(out->extension == 0); /* IReqCode defaults to 0 */
|
||||
assert(out->evtype == GetXI2Type((InternalEvent*)in));
|
||||
assert(out->evtype == GetXI2Type(in->type));
|
||||
assert(out->time == in->time);
|
||||
assert(out->detail == in->detail.button);
|
||||
assert(out->deviceid == in->deviceid);
|
||||
|
@ -305,7 +305,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out,
|
|||
}
|
||||
|
||||
assert(out->extension == 0); /* IReqCode defaults to 0 */
|
||||
assert(out->evtype == GetXI2Type((InternalEvent*)in));
|
||||
assert(out->evtype == GetXI2Type(in->type));
|
||||
assert(out->time == in->time);
|
||||
assert(out->detail == in->detail.button);
|
||||
assert(out->length >= 12);
|
||||
|
@ -662,7 +662,7 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in,
|
|||
|
||||
assert(out->type == GenericEvent);
|
||||
assert(out->extension == 0); /* IReqCode defaults to 0 */
|
||||
assert(out->evtype == GetXI2Type((InternalEvent*)in));
|
||||
assert(out->evtype == GetXI2Type(in->type));
|
||||
assert(out->time == in->time);
|
||||
assert(out->deviceid == in->deviceid);
|
||||
assert(out->sourceid == in->sourceid);
|
||||
|
|
Loading…
Reference in New Issue
Block a user