input: swap the server over to use the XI2mask struct
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
parent
b8b90cd161
commit
86bb3781b3
|
@ -1631,6 +1631,7 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
|
|||
static void
|
||||
FreeInputClient(InputClientsPtr *other)
|
||||
{
|
||||
xi2mask_free(&(*other)->xi2mask);
|
||||
free(*other);
|
||||
*other = NULL;
|
||||
}
|
||||
|
@ -1653,6 +1654,9 @@ AddExtensionClient(WindowPtr pWin, ClientPtr client, Mask mask, int mskidx)
|
|||
return BadAlloc;
|
||||
if (!pWin->optional->inputMasks && !MakeInputMasks(pWin))
|
||||
goto bail;
|
||||
others->xi2mask = xi2mask_new();
|
||||
if (!others->xi2mask)
|
||||
goto bail;
|
||||
others->mask[mskidx] = mask;
|
||||
others->resource = FakeClientID(client->index);
|
||||
others->next = pWin->optional->inputMasks->inputClients;
|
||||
|
@ -1674,6 +1678,12 @@ MakeInputMasks(WindowPtr pWin)
|
|||
imasks = calloc(1, sizeof(struct _OtherInputMasks));
|
||||
if (!imasks)
|
||||
return FALSE;
|
||||
imasks->xi2mask = xi2mask_new();
|
||||
if (!imasks->xi2mask)
|
||||
{
|
||||
free(imasks);
|
||||
return FALSE;
|
||||
}
|
||||
pWin->optional->inputMasks = imasks;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1681,6 +1691,7 @@ MakeInputMasks(WindowPtr pWin)
|
|||
static void
|
||||
FreeInputMask(OtherInputMasks **imask)
|
||||
{
|
||||
xi2mask_free(&(*imask)->xi2mask);
|
||||
free(*imask);
|
||||
*imask = NULL;
|
||||
}
|
||||
|
@ -1691,20 +1702,17 @@ RecalculateDeviceDeliverableEvents(WindowPtr pWin)
|
|||
InputClientsPtr others;
|
||||
struct _OtherInputMasks *inputMasks; /* default: NULL */
|
||||
WindowPtr pChild, tmp;
|
||||
int i, j;
|
||||
int i;
|
||||
|
||||
pChild = pWin;
|
||||
while (1) {
|
||||
if ((inputMasks = wOtherInputMasks(pChild)) != 0) {
|
||||
for (i = 0; i < EMASKSIZE; i++)
|
||||
memset(inputMasks->xi2mask[i], 0, sizeof(inputMasks->xi2mask[i]));
|
||||
xi2mask_zero(inputMasks->xi2mask, -1);
|
||||
for (others = inputMasks->inputClients; others;
|
||||
others = others->next) {
|
||||
for (i = 0; i < EMASKSIZE; i++)
|
||||
inputMasks->inputEvents[i] |= others->mask[i];
|
||||
for (i = 0; i < EMASKSIZE; i++)
|
||||
for (j = 0; j < XI2MASKSIZE; j++)
|
||||
inputMasks->xi2mask[i][j] |= others->xi2mask[i][j];
|
||||
xi2mask_merge(inputMasks->xi2mask, others->xi2mask);
|
||||
}
|
||||
for (i = 0; i < EMASKSIZE; i++)
|
||||
inputMasks->deliverableEvents[i] = inputMasks->inputEvents[i];
|
||||
|
@ -2188,14 +2196,12 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
|||
for (others = wOtherInputMasks(win)->inputClients; others;
|
||||
others = others->next) {
|
||||
if (SameClient(others, client)) {
|
||||
memset(others->xi2mask[dev->id], 0,
|
||||
sizeof(others->xi2mask[dev->id]));
|
||||
xi2mask_zero(others->xi2mask, dev->id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
len = min(len, sizeof(others->xi2mask[dev->id]));
|
||||
|
||||
if (len && !others)
|
||||
{
|
||||
|
@ -2204,11 +2210,14 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
|||
others= wOtherInputMasks(win)->inputClients;
|
||||
}
|
||||
|
||||
if (others)
|
||||
memset(others->xi2mask[dev->id], 0, sizeof(others->xi2mask[dev->id]));
|
||||
if (others) {
|
||||
xi2mask_zero(others->xi2mask, dev->id);
|
||||
len = min(len, xi2mask_mask_size(others->xi2mask));
|
||||
}
|
||||
|
||||
if (len)
|
||||
memcpy(others->xi2mask[dev->id], mask, len);
|
||||
if (len) {
|
||||
xi2mask_set_one_mask(others->xi2mask, dev->id, mask, len);
|
||||
}
|
||||
|
||||
RecalculateDeviceDeliverableEvents(win);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "exglobals.h" /* BadDevice */
|
||||
#include "exevents.h"
|
||||
#include "xigrabdev.h"
|
||||
#include "inpututils.h"
|
||||
|
||||
int
|
||||
SProcXIGrabDevice(ClientPtr client)
|
||||
|
@ -64,7 +65,7 @@ ProcXIGrabDevice(ClientPtr client)
|
|||
xXIGrabDeviceReply rep;
|
||||
int ret = Success;
|
||||
uint8_t status;
|
||||
GrabMask mask;
|
||||
GrabMask mask = { 0 };
|
||||
int mask_len;
|
||||
|
||||
REQUEST(xXIGrabDeviceReq);
|
||||
|
@ -81,9 +82,13 @@ ProcXIGrabDevice(ClientPtr client)
|
|||
stuff->mask_len * 4) != Success)
|
||||
return BadValue;
|
||||
|
||||
mask_len = min(sizeof(mask.xi2mask[stuff->deviceid]), stuff->mask_len * 4);
|
||||
memset(mask.xi2mask, 0, sizeof(mask.xi2mask));
|
||||
memcpy(mask.xi2mask, (char*)&stuff[1], mask_len);
|
||||
mask.xi2mask = xi2mask_new();
|
||||
if (!mask.xi2mask)
|
||||
return BadAlloc;
|
||||
|
||||
mask_len = min(xi2mask_mask_size(mask.xi2mask), stuff->mask_len * 4);
|
||||
/* FIXME: I think the old code was broken here */
|
||||
xi2mask_set_one_mask(mask.xi2mask, dev->id, (unsigned char*)&stuff[1], mask_len);
|
||||
|
||||
ret = GrabDevice(client, dev, stuff->grab_mode,
|
||||
stuff->paired_device_mode,
|
||||
|
@ -96,6 +101,8 @@ ProcXIGrabDevice(ClientPtr client)
|
|||
None /* confineTo */,
|
||||
&status);
|
||||
|
||||
xi2mask_free(&mask.xi2mask);
|
||||
|
||||
if (ret != Success)
|
||||
return ret;
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "xipassivegrab.h"
|
||||
#include "dixgrabs.h"
|
||||
#include "misc.h"
|
||||
#include "inpututils.h"
|
||||
|
||||
int
|
||||
SProcXIPassiveGrabDevice(ClientPtr client)
|
||||
|
@ -82,7 +83,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
|
|||
int i, ret = Success;
|
||||
uint32_t *modifiers;
|
||||
xXIGrabModifierInfo *modifiers_failed;
|
||||
GrabMask mask;
|
||||
GrabMask mask = { 0 };
|
||||
GrabParameters param;
|
||||
void *tmp;
|
||||
int mask_len;
|
||||
|
@ -124,9 +125,12 @@ ProcXIPassiveGrabDevice(ClientPtr client)
|
|||
stuff->mask_len * 4) != Success)
|
||||
return BadValue;
|
||||
|
||||
mask_len = min(sizeof(mask.xi2mask[stuff->deviceid]), stuff->mask_len * 4);
|
||||
memset(mask.xi2mask, 0, sizeof(mask.xi2mask));
|
||||
memcpy(mask.xi2mask[stuff->deviceid], &stuff[1], mask_len * 4);
|
||||
mask.xi2mask = xi2mask_new();
|
||||
if (!mask.xi2mask)
|
||||
return BadAlloc;
|
||||
|
||||
mask_len = min(xi2mask_mask_size(mask.xi2mask), stuff->mask_len * 4);
|
||||
xi2mask_set_one_mask(mask.xi2mask, stuff->deviceid, (unsigned char*)&stuff[1], mask_len * 4);
|
||||
|
||||
rep.repType = X_Reply;
|
||||
rep.RepType = X_XIPassiveGrabDevice;
|
||||
|
@ -212,6 +216,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
|
|||
|
||||
free(modifiers_failed);
|
||||
out:
|
||||
xi2mask_free(&mask.xi2mask);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "exglobals.h"
|
||||
#include "exevents.h"
|
||||
#include <X11/extensions/XI2proto.h>
|
||||
#include "inpututils.h"
|
||||
|
||||
#include "xiselectev.h"
|
||||
|
||||
|
@ -249,7 +250,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
|
|||
for (i = 0; i < MAXDEVICES; i++)
|
||||
{
|
||||
int j;
|
||||
unsigned char *devmask = others->xi2mask[i];
|
||||
const unsigned char *devmask = xi2mask_get_one_mask(others->xi2mask, i);
|
||||
|
||||
if (i > 2)
|
||||
{
|
||||
|
@ -259,7 +260,7 @@ ProcXIGetSelectedEvents(ClientPtr client)
|
|||
}
|
||||
|
||||
|
||||
for (j = XI2MASKSIZE - 1; j >= 0; j--)
|
||||
for (j = xi2mask_mask_size(others->xi2mask) - 1; j >= 0; j--)
|
||||
{
|
||||
if (devmask[j] != 0)
|
||||
{
|
||||
|
|
43
dix/events.c
43
dix/events.c
|
@ -420,12 +420,6 @@ GetXI2EventFilterMask(int evtype)
|
|||
return (1 << (evtype % 8));
|
||||
}
|
||||
|
||||
static inline int
|
||||
GetXI2EventFilterOffset(int evtype)
|
||||
{
|
||||
return (evtype / 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* For the given event, return the matching event filter. This filter may then
|
||||
* be AND'ed with the selected event mask.
|
||||
|
@ -459,12 +453,15 @@ GetEventFilter(DeviceIntPtr dev, xEvent *event)
|
|||
* for the event_type.
|
||||
*/
|
||||
static int
|
||||
GetXI2MaskByte(unsigned char xi2mask[][XI2MASKSIZE], DeviceIntPtr dev, int event_type)
|
||||
GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type)
|
||||
{
|
||||
int byte = GetXI2EventFilterOffset(event_type);
|
||||
return xi2mask[dev->id][byte] |
|
||||
xi2mask[XIAllDevices][byte] |
|
||||
(IsMaster(dev) ? xi2mask[XIAllMasterDevices][byte] : 0);
|
||||
/* we just return the matching filter because that's the only use
|
||||
* for this mask anyway.
|
||||
*/
|
||||
if (xi2mask_isset(mask, dev, event_type))
|
||||
return GetXI2EventFilterMask(event_type);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -476,16 +473,14 @@ Bool
|
|||
WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
|
||||
{
|
||||
OtherInputMasks *inputMasks = wOtherInputMasks(win);
|
||||
int filter;
|
||||
int evtype;
|
||||
|
||||
if (!inputMasks || xi2_get_type(ev) == 0)
|
||||
return 0;
|
||||
|
||||
evtype = ((xGenericEvent*)ev)->evtype;
|
||||
filter = GetEventFilter(dev, ev);
|
||||
|
||||
return !!(GetXI2MaskByte(inputMasks->xi2mask, dev, evtype) & filter);
|
||||
return xi2mask_isset(inputMasks->xi2mask, dev, evtype);
|
||||
}
|
||||
|
||||
Mask
|
||||
|
@ -2011,8 +2006,7 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
|
|||
tempGrab->deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
|
||||
|
||||
if (inputMasks)
|
||||
memcpy(tempGrab->xi2mask, inputMasks->xi2mask,
|
||||
sizeof(tempGrab->xi2mask));
|
||||
xi2mask_merge(tempGrab->xi2mask, inputMasks->xi2mask);
|
||||
|
||||
(*dev->deviceGrab.ActivateGrab)(dev, tempGrab,
|
||||
currentTime, TRUE | ImplicitGrabMask);
|
||||
|
@ -2561,10 +2555,7 @@ EventIsDeliverable(DeviceIntPtr dev, InternalEvent* event, WindowPtr win)
|
|||
|
||||
if ((type = GetXI2Type(event)) != 0)
|
||||
{
|
||||
filter = GetXI2EventFilterMask(type);
|
||||
|
||||
if (inputMasks &&
|
||||
(GetXI2MaskByte(inputMasks->xi2mask, dev, type) & filter))
|
||||
if (inputMasks && xi2mask_isset(inputMasks->xi2mask, dev, type))
|
||||
rc |= EVENT_XI2_MASK;
|
||||
}
|
||||
|
||||
|
@ -4155,12 +4146,11 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
|
|||
if (rc == Success)
|
||||
{
|
||||
int evtype = xi2_get_type(xi2);
|
||||
mask = GetXI2MaskByte(grab->xi2mask, thisDev, evtype);
|
||||
mask = xi2mask_isset(grab->xi2mask, thisDev, evtype);
|
||||
/* try XI2 event */
|
||||
FixUpEventFromWindow(pSprite, xi2, grab->window, None, TRUE);
|
||||
/* XXX: XACE */
|
||||
deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask,
|
||||
GetEventFilter(thisDev, xi2), grab);
|
||||
deliveries = TryClientEvents(rClient(grab), thisDev, xi2, 1, mask, 1, grab);
|
||||
} else if (rc != BadMatch)
|
||||
ErrorF("[dix] %s: XI2 conversion failed in DGE (%d, %d). Skipping delivery.\n",
|
||||
thisDev->name, event->any.type, rc);
|
||||
|
@ -4634,9 +4624,8 @@ DeviceEnterLeaveEvent(
|
|||
if (grab)
|
||||
{
|
||||
Mask mask;
|
||||
mask = GetXI2MaskByte(grab->xi2mask, mouse, type);
|
||||
TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask,
|
||||
filter, grab);
|
||||
mask = xi2mask_isset(grab->xi2mask, mouse, type);
|
||||
TryClientEvents(rClient(grab), mouse, (xEvent*)event, 1, mask, 1, grab);
|
||||
} else {
|
||||
if (!WindowXI2MaskIsset(mouse, pWin, (xEvent*)event))
|
||||
goto out;
|
||||
|
@ -5100,7 +5089,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev,
|
|||
else if (grabtype == GRABTYPE_XI)
|
||||
tempGrab->eventMask = mask->xi;
|
||||
else
|
||||
memcpy(tempGrab->xi2mask, mask->xi2mask, sizeof(tempGrab->xi2mask));
|
||||
xi2mask_merge(tempGrab->xi2mask, mask->xi2mask);
|
||||
tempGrab->device = dev;
|
||||
tempGrab->cursor = cursor;
|
||||
tempGrab->confineTo = confineTo;
|
||||
|
|
38
dix/grabs.c
38
dix/grabs.c
|
@ -60,6 +60,7 @@ SOFTWARE.
|
|||
#include "dixgrabs.h"
|
||||
#include "xace.h"
|
||||
#include "exevents.h"
|
||||
#include "inpututils.h"
|
||||
|
||||
#define BITMASK(i) (((Mask)1) << ((i) & 31))
|
||||
#define MASKIDX(i) ((i) >> 5)
|
||||
|
@ -122,13 +123,15 @@ PrintDeviceGrabInfo(DeviceIntPtr dev)
|
|||
}
|
||||
else if (grab->grabtype == GRABTYPE_XI2)
|
||||
{
|
||||
for (i = 0; i < EMASKSIZE; i++)
|
||||
for (i = 0; i < xi2mask_num_masks(grab->xi2mask); i++)
|
||||
{
|
||||
const unsigned char *mask;
|
||||
int print;
|
||||
print = 0;
|
||||
for (j = 0; j < XI2MASKSIZE; j++)
|
||||
{
|
||||
if (grab->xi2mask[i][j])
|
||||
mask = xi2mask_get_one_mask(grab->xi2mask, i);
|
||||
if (mask[j])
|
||||
{
|
||||
print = 1;
|
||||
break;
|
||||
|
@ -137,8 +140,8 @@ PrintDeviceGrabInfo(DeviceIntPtr dev)
|
|||
if (!print)
|
||||
continue;
|
||||
ErrorF(" xi2 event mask for device %d: 0x", dev->id);
|
||||
for (j = 0; j < XI2MASKSIZE; j++)
|
||||
ErrorF("%x", grab->xi2mask[i][j]);
|
||||
for (j = 0; j < xi2mask_mask_size(grab->xi2mask); j++)
|
||||
ErrorF("%x", mask[j]);
|
||||
ErrorF("\n");
|
||||
}
|
||||
}
|
||||
|
@ -185,6 +188,14 @@ AllocGrab(void)
|
|||
{
|
||||
GrabPtr grab = calloc(1, sizeof(GrabRec));
|
||||
|
||||
if (grab) {
|
||||
grab->xi2mask = xi2mask_new();
|
||||
if (!grab->xi2mask) {
|
||||
free(grab);
|
||||
grab = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return grab;
|
||||
}
|
||||
|
||||
|
@ -227,7 +238,7 @@ CreateGrab(
|
|||
grab->next = NULL;
|
||||
|
||||
if (grabtype == GRABTYPE_XI2)
|
||||
memcpy(grab->xi2mask, mask->xi2mask, sizeof(mask->xi2mask));
|
||||
xi2mask_merge(grab->xi2mask, mask->xi2mask);
|
||||
if (cursor)
|
||||
cursor->refcnt++;
|
||||
return grab;
|
||||
|
@ -243,6 +254,7 @@ FreeGrab(GrabPtr pGrab)
|
|||
if (pGrab->cursor)
|
||||
FreeCursor(pGrab->cursor, (Cursor)0);
|
||||
|
||||
xi2mask_free(&pGrab->xi2mask);
|
||||
free(pGrab);
|
||||
}
|
||||
|
||||
|
@ -251,6 +263,7 @@ CopyGrab(GrabPtr dst, const GrabPtr src)
|
|||
{
|
||||
Mask *mdetails_mask = NULL;
|
||||
Mask *details_mask = NULL;
|
||||
XI2Mask *xi2mask;
|
||||
|
||||
if (src->cursor)
|
||||
src->cursor->refcnt++;
|
||||
|
@ -273,9 +286,24 @@ CopyGrab(GrabPtr dst, const GrabPtr src)
|
|||
memcpy(details_mask, src->detail.pMask, len);
|
||||
}
|
||||
|
||||
if (!dst->xi2mask) {
|
||||
xi2mask = xi2mask_new();
|
||||
if (!xi2mask) {
|
||||
free(mdetails_mask);
|
||||
free(details_mask);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
xi2mask = dst->xi2mask;
|
||||
xi2mask_zero(xi2mask, -1);
|
||||
}
|
||||
|
||||
*dst = *src;
|
||||
dst->modifiersDetail.pMask = mdetails_mask;
|
||||
dst->detail.pMask = details_mask;
|
||||
dst->xi2mask = xi2mask;
|
||||
|
||||
xi2mask_merge(dst->xi2mask, src->xi2mask);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ typedef struct _InputClients {
|
|||
XID resource; /**< id for putting into resource manager */
|
||||
Mask mask[EMASKSIZE]; /**< Actual XI event mask, deviceid is index */
|
||||
/** XI2 event masks. One per device, each bit is a mask of (1 << type) */
|
||||
unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
|
||||
struct _XI2Mask *xi2mask;
|
||||
} InputClients;
|
||||
|
||||
/**
|
||||
|
@ -148,7 +148,7 @@ typedef struct _OtherInputMasks {
|
|||
/** The clients that selected for events */
|
||||
InputClientsPtr inputClients;
|
||||
/* XI2 event masks. One per device, each bit is a mask of (1 << type) */
|
||||
unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
|
||||
struct _XI2Mask *xi2mask;
|
||||
} OtherInputMasks;
|
||||
|
||||
/*
|
||||
|
@ -176,7 +176,7 @@ typedef enum {
|
|||
union _GrabMask {
|
||||
Mask core;
|
||||
Mask xi;
|
||||
char xi2mask[EMASKSIZE][XI2MASKSIZE];
|
||||
struct _XI2Mask *xi2mask;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -210,7 +210,7 @@ typedef struct _GrabRec {
|
|||
Mask eventMask;
|
||||
Mask deviceMask;
|
||||
/* XI2 event masks. One per device, each bit is a mask of (1 << type) */
|
||||
unsigned char xi2mask[EMASKSIZE][XI2MASKSIZE];
|
||||
struct _XI2Mask *xi2mask;
|
||||
} GrabRec;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue