summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-04-26 21:43:25 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-05-01 09:06:33 +1000
commite8e26f700c9c70d3f1bb53bdb71d1100f5c43a69 (patch)
tree8d3362053e193ed4cc4119e73822632ce4d07022
parent98a1fa994158feca8bc80a10296a7675465c0e56 (diff)
Xi: split some grab parameter checking out of GrabButton and GrabKey.
-rw-r--r--Xi/exevents.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index ed6a3edee..164f0713c 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1349,18 +1349,10 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
}
}
-int
-GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
- BYTE other_devices_mode, CARD16 modifiers,
- DeviceIntPtr modifier_device, CARD8 button, Window grabWindow,
- BOOL ownerEvents, Cursor rcursor, Window rconfineTo, Mask eventMask)
+static int
+CheckGrabValues(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
+ BYTE other_devices_mode, CARD16 modifiers, BOOL ownerEvents)
{
- WindowPtr pWin, confineTo;
- CursorPtr cursor;
- GrabPtr grab;
- Mask access_mode = DixGrabAccess;
- int rc;
-
if ((this_device_mode != GrabModeSync) &&
(this_device_mode != GrabModeAsync)) {
client->errorValue = this_device_mode;
@@ -1379,7 +1371,23 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
client->errorValue = ownerEvents;
return BadValue;
}
- rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
+ return Success;
+}
+
+int
+GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
+ BYTE other_devices_mode, CARD16 modifiers,
+ DeviceIntPtr modifier_device, CARD8 button, Window grabWindow,
+ BOOL ownerEvents, Cursor rcursor, Window rconfineTo, Mask eventMask)
+{
+ WindowPtr pWin, confineTo;
+ CursorPtr cursor;
+ GrabPtr grab;
+ int rc;
+ Mask access_mode = DixGrabAccess;
+
+ rc = CheckGrabValues(client, dev, this_device_mode, other_devices_mode,
+ modifiers, ownerEvents);
if (rc != Success)
return rc;
if (rconfineTo == None)
@@ -1406,6 +1414,10 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, access_mode);
if (rc != Success)
return rc;
+ rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+
grab = CreateGrab(client->index, dev, pWin, eventMask,
(Bool) ownerEvents, (Bool) this_device_mode,
@@ -1428,32 +1440,18 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, BYTE this_device_mode,
Mask access_mode = DixGrabAccess;
int rc;
+ rc = CheckGrabValues(client, dev, this_device_mode, other_devices_mode,
+ modifiers, ownerEvents);
+ if (rc != Success)
+ return rc;
if (k == NULL)
return BadMatch;
- if ((other_devices_mode != GrabModeSync) &&
- (other_devices_mode != GrabModeAsync)) {
- client->errorValue = other_devices_mode;
- return BadValue;
- }
- if ((this_device_mode != GrabModeSync) &&
- (this_device_mode != GrabModeAsync)) {
- client->errorValue = this_device_mode;
- return BadValue;
- }
if ((key > k->xkbInfo->desc->max_key_code ||
key < k->xkbInfo->desc->min_key_code)
&& (key != AnyKey)) {
client->errorValue = key;
return BadValue;
}
- if ((modifiers != AnyModifier) && (modifiers & ~AllModifiersMask)) {
- client->errorValue = modifiers;
- return BadValue;
- }
- if ((ownerEvents != xTrue) && (ownerEvents != xFalse)) {
- client->errorValue = ownerEvents;
- return BadValue;
- }
rc = dixLookupWindow(&pWin, grabWindow, client, DixSetAttrAccess);
if (rc != Success)
return rc;