aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xi
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/Xi')
-rw-r--r--xorg-server/Xi/exevents.c88
-rw-r--r--xorg-server/Xi/ungrdevb.c32
-rw-r--r--xorg-server/Xi/ungrdevk.c31
-rw-r--r--xorg-server/Xi/xichangehierarchy.c15
-rw-r--r--xorg-server/Xi/xigrabdev.c15
-rw-r--r--xorg-server/Xi/xipassivegrab.c50
-rw-r--r--xorg-server/Xi/xiselectev.c5
7 files changed, 146 insertions, 90 deletions
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index 35f929731..1fa030a92 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -887,7 +887,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
int key = 0, rootX, rootY;
ButtonClassPtr b;
int ret = 0;
- int state, i;
+ int corestate, i;
DeviceIntPtr mouse = NULL, kbd = NULL;
DeviceEvent *event = &ev->device_event;
@@ -917,9 +917,9 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
mouse = NULL;
}
- /* State needs to be assembled BEFORE the device is updated. */
- state = (kbd && kbd->key) ? XkbStateFieldFromRec(&kbd->key->xkbInfo->state) : 0;
- state |= (mouse && mouse->button) ? (mouse->button->state) : 0;
+ /* core state needs to be assembled BEFORE the device is updated. */
+ corestate = (kbd && kbd->key) ? XkbStateFieldFromRec(&kbd->key->xkbInfo->state) : 0;
+ corestate |= (mouse && mouse->button) ? (mouse->button->state) : 0;
for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
if (BitIsOn(mouse->button->down, i))
@@ -969,7 +969,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
event->root_x = rootX;
event->root_y = rootY;
NoticeEventTime((InternalEvent*)event);
- event->corestate = state;
+ event->corestate = corestate;
key = event->detail.key;
break;
default:
@@ -1006,11 +1006,9 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
deactivateDeviceGrab = TRUE;
break;
case ET_ButtonPress:
- event->detail.button = b->map[key];
- if (!event->detail.button) { /* there's no button 0 */
- event->detail.button = key;
+ if (b->map[key] == 0) /* there's no button 0 */
return;
- }
+ event->detail.button = b->map[key];
if (!grab && CheckDeviceGrabs(device, event, 0))
{
/* if a passive grab was activated, the event has been sent
@@ -1019,11 +1017,9 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
}
break;
case ET_ButtonRelease:
- event->detail.button = b->map[key];
- if (!event->detail.button) { /* there's no button 0 */
- event->detail.button = key;
+ if (b->map[key] == 0) /* there's no button 0 */
return;
- }
+ event->detail.button = b->map[key];
if (grab && !b->buttonsDown &&
device->deviceGrab.fromPassiveGrab &&
(device->deviceGrab.grab->type == ButtonPress ||
@@ -1037,7 +1033,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
if (grab)
DeliverGrabbedEvent((InternalEvent*)event, device, deactivateDeviceGrab);
- else if (device->focus && !IsPointerEvent((InternalEvent*)ev))
+ else if (device->focus && !IsPointerEvent(ev))
DeliverFocusedEvent(device, (InternalEvent*)event,
GetSpriteWindow(device));
else
@@ -1635,6 +1631,7 @@ SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
static void
FreeInputClient(InputClientsPtr *other)
{
+ xi2mask_free(&(*other)->xi2mask);
free(*other);
*other = NULL;
}
@@ -1657,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;
@@ -1678,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;
}
@@ -1685,6 +1691,7 @@ MakeInputMasks(WindowPtr pWin)
static void
FreeInputMask(OtherInputMasks **imask)
{
+ xi2mask_free(&(*imask)->xi2mask);
free(*imask);
*imask = NULL;
}
@@ -1695,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];
@@ -2032,20 +2036,25 @@ CheckDeviceGrabAndHintWindow(WindowPtr pWin, int type,
dev->valuator->motionHintWindow = pWin;
else if ((type == DeviceButtonPress) && (!grab) &&
(deliveryMask & DeviceButtonGrabMask)) {
- GrabRec tempGrab;
+ GrabPtr tempGrab;
- tempGrab.device = dev;
- tempGrab.resource = client->clientAsMask;
- tempGrab.window = pWin;
- tempGrab.ownerEvents =
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return;
+
+ tempGrab->device = dev;
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->window = pWin;
+ tempGrab->ownerEvents =
(deliveryMask & DeviceOwnerGrabButtonMask) ? TRUE : FALSE;
- tempGrab.eventMask = deliveryMask;
- tempGrab.keyboardMode = GrabModeAsync;
- tempGrab.pointerMode = GrabModeAsync;
- tempGrab.confineTo = NullWindow;
- tempGrab.cursor = NullCursor;
- tempGrab.next = NULL;
- (*dev->deviceGrab.ActivateGrab) (dev, &tempGrab, currentTime, TRUE);
+ tempGrab->eventMask = deliveryMask;
+ tempGrab->keyboardMode = GrabModeAsync;
+ tempGrab->pointerMode = GrabModeAsync;
+ tempGrab->confineTo = NullWindow;
+ tempGrab->cursor = NullCursor;
+ tempGrab->next = NULL;
+ (*dev->deviceGrab.ActivateGrab) (dev, tempGrab, currentTime, TRUE);
+ FreeGrab(tempGrab);
}
}
@@ -2191,14 +2200,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)
{
@@ -2207,11 +2214,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/xorg-server/Xi/ungrdevb.c b/xorg-server/Xi/ungrdevb.c
index 9e9ece47a..628024870 100644
--- a/xorg-server/Xi/ungrdevb.c
+++ b/xorg-server/Xi/ungrdevb.c
@@ -96,7 +96,7 @@ ProcXUngrabDeviceButton(ClientPtr client)
DeviceIntPtr dev;
DeviceIntPtr mdev;
WindowPtr pWin;
- GrabRec temporaryGrab;
+ GrabPtr temporaryGrab;
int rc;
REQUEST(xUngrabDeviceButtonReq);
@@ -126,17 +126,23 @@ ProcXUngrabDeviceButton(ClientPtr client)
(stuff->modifiers & ~AllModifiersMask))
return BadValue;
- temporaryGrab.resource = client->clientAsMask;
- temporaryGrab.device = dev;
- temporaryGrab.window = pWin;
- temporaryGrab.type = DeviceButtonPress;
- temporaryGrab.grabtype = GRABTYPE_XI;
- temporaryGrab.modifierDevice = mdev;
- temporaryGrab.modifiersDetail.exact = stuff->modifiers;
- temporaryGrab.modifiersDetail.pMask = NULL;
- temporaryGrab.detail.exact = stuff->button;
- temporaryGrab.detail.pMask = NULL;
-
- DeletePassiveGrabFromList(&temporaryGrab);
+ temporaryGrab = AllocGrab();
+ if (!temporaryGrab)
+ return BadAlloc;
+
+ temporaryGrab->resource = client->clientAsMask;
+ temporaryGrab->device = dev;
+ temporaryGrab->window = pWin;
+ temporaryGrab->type = DeviceButtonPress;
+ temporaryGrab->grabtype = GRABTYPE_XI;
+ temporaryGrab->modifierDevice = mdev;
+ temporaryGrab->modifiersDetail.exact = stuff->modifiers;
+ temporaryGrab->modifiersDetail.pMask = NULL;
+ temporaryGrab->detail.exact = stuff->button;
+ temporaryGrab->detail.pMask = NULL;
+
+ DeletePassiveGrabFromList(temporaryGrab);
+
+ FreeGrab(temporaryGrab);
return Success;
}
diff --git a/xorg-server/Xi/ungrdevk.c b/xorg-server/Xi/ungrdevk.c
index 526347db4..b0d83cbbc 100644
--- a/xorg-server/Xi/ungrdevk.c
+++ b/xorg-server/Xi/ungrdevk.c
@@ -98,7 +98,7 @@ ProcXUngrabDeviceKey(ClientPtr client)
DeviceIntPtr dev;
DeviceIntPtr mdev;
WindowPtr pWin;
- GrabRec temporaryGrab;
+ GrabPtr temporaryGrab;
int rc;
REQUEST(xUngrabDeviceKeyReq);
@@ -133,17 +133,22 @@ ProcXUngrabDeviceKey(ClientPtr client)
(stuff->modifiers & ~AllModifiersMask))
return BadValue;
- temporaryGrab.resource = client->clientAsMask;
- temporaryGrab.device = dev;
- temporaryGrab.window = pWin;
- temporaryGrab.type = DeviceKeyPress;
- temporaryGrab.grabtype = GRABTYPE_XI;
- temporaryGrab.modifierDevice = mdev;
- temporaryGrab.modifiersDetail.exact = stuff->modifiers;
- temporaryGrab.modifiersDetail.pMask = NULL;
- temporaryGrab.detail.exact = stuff->key;
- temporaryGrab.detail.pMask = NULL;
-
- DeletePassiveGrabFromList(&temporaryGrab);
+ temporaryGrab = AllocGrab();
+ if (!temporaryGrab)
+ return BadAlloc;
+
+ temporaryGrab->resource = client->clientAsMask;
+ temporaryGrab->device = dev;
+ temporaryGrab->window = pWin;
+ temporaryGrab->type = DeviceKeyPress;
+ temporaryGrab->grabtype = GRABTYPE_XI;
+ temporaryGrab->modifierDevice = mdev;
+ temporaryGrab->modifiersDetail.exact = stuff->modifiers;
+ temporaryGrab->modifiersDetail.pMask = NULL;
+ temporaryGrab->detail.exact = stuff->key;
+ temporaryGrab->detail.pMask = NULL;
+
+ DeletePassiveGrabFromList(temporaryGrab);
+ FreeGrab(temporaryGrab);
return Success;
}
diff --git a/xorg-server/Xi/xichangehierarchy.c b/xorg-server/Xi/xichangehierarchy.c
index 614d23116..503404e64 100644
--- a/xorg-server/Xi/xichangehierarchy.c
+++ b/xorg-server/Xi/xichangehierarchy.c
@@ -200,6 +200,19 @@ unwind:
return rc;
}
+static void
+disable_clientpointer(DeviceIntPtr dev)
+{
+ int i;
+
+ for (i = 0; i < currentMaxClients; i++)
+ {
+ ClientPtr client = clients[i];
+ if (client && client->clientPtr == dev)
+ client->clientPtr = NULL;
+ }
+}
+
static int
remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
int flags[MAXDEVICES])
@@ -250,6 +263,8 @@ remove_master(ClientPtr client, xXIRemoveMasterInfo *r,
if (rc != Success)
goto unwind;
+ disable_clientpointer(ptr);
+
/* Disabling sends the devices floating, reattach them if
* desired. */
if (r->return_mode == XIAttachToMaster)
diff --git a/xorg-server/Xi/xigrabdev.c b/xorg-server/Xi/xigrabdev.c
index a9b655c0e..1cfbf243b 100644
--- a/xorg-server/Xi/xigrabdev.c
+++ b/xorg-server/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/xorg-server/Xi/xipassivegrab.c b/xorg-server/Xi/xipassivegrab.c
index 2f13a95e8..4860757fc 100644
--- a/xorg-server/Xi/xipassivegrab.c
+++ b/xorg-server/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;
}
@@ -253,7 +258,7 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
{
DeviceIntPtr dev, mod_dev;
WindowPtr win;
- GrabRec tempGrab;
+ GrabPtr tempGrab;
uint32_t* modifiers;
int i, rc;
@@ -293,29 +298,36 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
mod_dev = (IsFloating(dev)) ? dev : GetMaster(dev, MASTER_KEYBOARD);
- tempGrab.resource = client->clientAsMask;
- tempGrab.device = dev;
- tempGrab.window = win;
+
+ tempGrab = AllocGrab();
+ if (!tempGrab)
+ return BadAlloc;
+
+ tempGrab->resource = client->clientAsMask;
+ tempGrab->device = dev;
+ tempGrab->window = win;
switch(stuff->grab_type)
{
- case XIGrabtypeButton: tempGrab.type = XI_ButtonPress; break;
- case XIGrabtypeKeycode: tempGrab.type = XI_KeyPress; break;
- case XIGrabtypeEnter: tempGrab.type = XI_Enter; break;
- case XIGrabtypeFocusIn: tempGrab.type = XI_FocusIn; break;
+ case XIGrabtypeButton: tempGrab->type = XI_ButtonPress; break;
+ case XIGrabtypeKeycode: tempGrab->type = XI_KeyPress; break;
+ case XIGrabtypeEnter: tempGrab->type = XI_Enter; break;
+ case XIGrabtypeFocusIn: tempGrab->type = XI_FocusIn; break;
}
- tempGrab.grabtype = GRABTYPE_XI2;
- tempGrab.modifierDevice = mod_dev;
- tempGrab.modifiersDetail.pMask = NULL;
- tempGrab.detail.exact = stuff->detail;
- tempGrab.detail.pMask = NULL;
+ tempGrab->grabtype = GRABTYPE_XI2;
+ tempGrab->modifierDevice = mod_dev;
+ tempGrab->modifiersDetail.pMask = NULL;
+ tempGrab->detail.exact = stuff->detail;
+ tempGrab->detail.pMask = NULL;
modifiers = (uint32_t*)&stuff[1];
for (i = 0; i < stuff->num_modifiers; i++, modifiers++)
{
- tempGrab.modifiersDetail.exact = *modifiers;
- DeletePassiveGrabFromList(&tempGrab);
+ tempGrab->modifiersDetail.exact = *modifiers;
+ DeletePassiveGrabFromList(tempGrab);
}
+ FreeGrab(tempGrab);
+
return Success;
}
diff --git a/xorg-server/Xi/xiselectev.c b/xorg-server/Xi/xiselectev.c
index 3af4f1fb9..ee14edb6d 100644
--- a/xorg-server/Xi/xiselectev.c
+++ b/xorg-server/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)
{