summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-11-04 11:29:01 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-12-09 14:56:23 +1000
commit86bb3781b336c09e4279136ed81974de5acdba7f (patch)
tree56f325228d63a7a77507df0bc524bcf9c4fe095b /Xi
parentb8b90cd1610331ff12fa3f70bf372670af7795ec (diff)
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>
Diffstat (limited to 'Xi')
-rw-r--r--Xi/exevents.c35
-rw-r--r--Xi/xigrabdev.c15
-rw-r--r--Xi/xipassivegrab.c13
-rw-r--r--Xi/xiselectev.c5
4 files changed, 45 insertions, 23 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 8ef974609..7a84c6b3d 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -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);
diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index a9b655c0e..1cfbf243b 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -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;
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index 4fa887a42..4860757fc 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -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;
}
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 3af4f1fb9..ee14edb6d 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -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)
{