aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xi/exevents.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-12-16 20:45:15 +0100
committerMarc Haesen <marc@hc-consult.be>2011-12-16 20:45:15 +0100
commit47913e82955ec8e2b1ba4d4b145497dede9163b5 (patch)
treed23c322caf26864270171d54eb2805cee2721e4d /xorg-server/Xi/exevents.c
parent53d28537755790ee4625dc16f560cad5aa93f56b (diff)
downloadvcxsrv-47913e82955ec8e2b1ba4d4b145497dede9163b5.tar.gz
vcxsrv-47913e82955ec8e2b1ba4d4b145497dede9163b5.tar.bz2
vcxsrv-47913e82955ec8e2b1ba4d4b145497dede9163b5.zip
xserver git update 16 dec 2011
Diffstat (limited to 'xorg-server/Xi/exevents.c')
-rw-r--r--xorg-server/Xi/exevents.c147
1 files changed, 74 insertions, 73 deletions
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index b2e82ec06..45a289add 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -704,6 +704,55 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce)
}
/**
+ * Add state and motionMask to the filter for this event. The protocol
+ * supports some extra masks for motion when a button is down:
+ * ButtonXMotionMask and the DeviceButtonMotionMask to trigger only when at
+ * least one button (or that specific button is down). These masks need to
+ * be added to the filters for core/XI motion events.
+ *
+ * @param device The device to update the mask for
+ * @param state The current button state mask
+ * @param motion_mask The motion mask (DeviceButtonMotionMask or 0)
+ */
+static void
+UpdateDeviceMotionMask(DeviceIntPtr device, unsigned short state,
+ Mask motion_mask)
+{
+ Mask mask;
+
+ mask = DevicePointerMotionMask | state | motion_mask;
+ SetMaskForEvent(device->id, mask, DeviceMotionNotify);
+ mask = PointerMotionMask | state | motion_mask;
+ SetMaskForEvent(device->id, mask, MotionNotify);
+}
+
+static void
+IncreaseButtonCount(DeviceIntPtr dev, int key, CARD8 *buttons_down,
+ Mask *motion_mask, unsigned short *state)
+{
+ if (dev->valuator)
+ dev->valuator->motionHintWindow = NullWindow;
+
+ (*buttons_down)++;
+ *motion_mask = DeviceButtonMotionMask;
+ if (dev->button->map[key] <= 5)
+ *state |= (Button1Mask >> 1) << dev->button->map[key];
+}
+
+static void
+DecreaseButtonCount(DeviceIntPtr dev, int key, CARD8 *buttons_down,
+ Mask *motion_mask, unsigned short *state)
+{
+ if (dev->valuator)
+ dev->valuator->motionHintWindow = NullWindow;
+
+ if (*buttons_down >= 1 && !--(*buttons_down))
+ *motion_mask = 0;
+ if (dev->button->map[key] <= 5)
+ *state &= ~((Button1Mask >> 1) << dev->button->map[key]);
+}
+
+/**
* Update the device state according to the data in the event.
*
* return values are
@@ -801,7 +850,6 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
device->valuator->motionHintWindow = NullWindow;
set_key_up(device, key, KEY_PROCESSED);
} else if (event->type == ET_ButtonPress) {
- Mask mask;
if (!b)
return DONT_PROCESS;
@@ -809,22 +857,13 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
return DONT_PROCESS;
set_button_down(device, key, BUTTON_PROCESSED);
- if (device->valuator)
- device->valuator->motionHintWindow = NullWindow;
+
if (!b->map[key])
return DONT_PROCESS;
- b->buttonsDown++;
- b->motionMask = DeviceButtonMotionMask;
- if (b->map[key] <= 5)
- b->state |= (Button1Mask >> 1) << b->map[key];
-
- /* Add state and motionMask to the filter for this event */
- mask = DevicePointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, DeviceMotionNotify);
- mask = PointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, MotionNotify);
+
+ IncreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state);
+ UpdateDeviceMotionMask(device, b->state, b->motionMask);
} else if (event->type == ET_ButtonRelease) {
- Mask mask;
if (!b)
return DONT_PROCESS;
@@ -850,20 +889,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
}
}
set_button_up(device, key, BUTTON_PROCESSED);
- if (device->valuator)
- device->valuator->motionHintWindow = NullWindow;
if (!b->map[key])
return DONT_PROCESS;
- if (b->buttonsDown >= 1 && !--b->buttonsDown)
- b->motionMask = 0;
- if (b->map[key] <= 5)
- b->state &= ~((Button1Mask >> 1) << b->map[key]);
-
- /* Add state and motionMask to the filter for this event */
- mask = DevicePointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, DeviceMotionNotify);
- mask = PointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, MotionNotify);
+
+ DecreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state);
+ UpdateDeviceMotionMask(device, b->state, b->motionMask);
} else if (event->type == ET_ProximityIn)
device->proximity->in_proximity = TRUE;
else if (event->type == ET_ProximityOut)
@@ -885,7 +915,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
int key = 0, rootX, rootY;
ButtonClassPtr b;
int ret = 0;
- int corestate, i;
+ int corestate;
DeviceIntPtr mouse = NULL, kbd = NULL;
DeviceEvent *event = &ev->device_event;
@@ -915,33 +945,8 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
mouse = NULL;
}
- /* 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))
- SetBit(event->buttons, i);
-
- if (kbd && kbd->key)
- {
- XkbStatePtr state;
- /* we need the state before the event happens */
- if (event->type == ET_KeyPress || event->type == ET_KeyRelease)
- state = &kbd->key->xkbInfo->prev_state;
- else
- state = &kbd->key->xkbInfo->state;
-
- event->mods.base = state->base_mods;
- event->mods.latched = state->latched_mods;
- event->mods.locked = state->locked_mods;
- event->mods.effective = state->mods;
-
- event->group.base = state->base_group;
- event->group.latched = state->latched_group;
- event->group.locked = state->locked_group;
- event->group.effective = state->group;
- }
+ corestate = event_get_corestate(mouse, kbd);
+ event_set_state(mouse, kbd, event);
ret = UpdateDeviceState(device, event);
if (ret == DONT_PROCESS)
@@ -996,9 +1001,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
case ET_KeyRelease:
if (grab && device->deviceGrab.fromPassiveGrab &&
(key == device->deviceGrab.activatingKey) &&
- (device->deviceGrab.grab->type == KeyPress ||
- device->deviceGrab.grab->type == DeviceKeyPress ||
- device->deviceGrab.grab->type == XI_KeyPress))
+ GrabIsKeyboardGrab(device->deviceGrab.grab))
deactivateDeviceGrab = TRUE;
break;
case ET_ButtonPress:
@@ -1018,9 +1021,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
event->detail.button = b->map[key];
if (grab && !b->buttonsDown &&
device->deviceGrab.fromPassiveGrab &&
- (device->deviceGrab.grab->type == ButtonPress ||
- device->deviceGrab.grab->type == DeviceButtonPress ||
- device->deviceGrab.grab->type == XI_ButtonPress))
+ GrabIsPointerGrab(device->deviceGrab.grab))
deactivateDeviceGrab = TRUE;
default:
break;
@@ -1388,9 +1389,9 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
int
CheckGrabValues(ClientPtr client, GrabParameters* param)
{
- if (param->grabtype != GRABTYPE_CORE &&
- param->grabtype != GRABTYPE_XI &&
- param->grabtype != GRABTYPE_XI2)
+ if (param->grabtype != CORE &&
+ param->grabtype != XI &&
+ param->grabtype != XI2)
{
ErrorF("[Xi] grabtype is invalid. This is a bug.\n");
return BadImplementation;
@@ -1407,7 +1408,7 @@ CheckGrabValues(ClientPtr client, GrabParameters* param)
return BadValue;
}
- if (param->grabtype != GRABTYPE_XI2 && (param->modifiers != AnyModifier) &&
+ if (param->grabtype != XI2 && (param->modifiers != AnyModifier) &&
(param->modifiers & ~AllModifiersMask)) {
client->errorValue = param->modifiers;
return BadValue;
@@ -1422,7 +1423,7 @@ CheckGrabValues(ClientPtr client, GrabParameters* param)
int
GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
- int button, GrabParameters *param, GrabType grabtype,
+ int button, GrabParameters *param, enum InputLevel grabtype,
GrabMask *mask)
{
WindowPtr pWin, confineTo;
@@ -1462,9 +1463,9 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
if (rc != Success)
return rc;
- if (grabtype == GRABTYPE_XI)
+ if (grabtype == XI)
type = DeviceButtonPress;
- else if (grabtype == GRABTYPE_XI2)
+ else if (grabtype == XI2)
type = XI_ButtonPress;
grab = CreateGrab(client->index, dev, modifier_device, pWin, grabtype,
@@ -1475,12 +1476,12 @@ GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
}
/**
- * Grab the given key. If grabtype is GRABTYPE_XI, the key is a keycode. If
- * grabtype is GRABTYPE_XI2, the key is a keysym.
+ * Grab the given key. If grabtype is XI, the key is a keycode. If
+ * grabtype is XI2, the key is a keysym.
*/
int
GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
- int key, GrabParameters *param, GrabType grabtype, GrabMask *mask)
+ int key, GrabParameters *param, enum InputLevel grabtype, GrabMask *mask)
{
WindowPtr pWin;
GrabPtr grab;
@@ -1493,7 +1494,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
return rc;
if ((dev->id != XIAllDevices && dev->id != XIAllMasterDevices) && k == NULL)
return BadMatch;
- if (grabtype == GRABTYPE_XI)
+ if (grabtype == XI)
{
if ((key > k->xkbInfo->desc->max_key_code ||
key < k->xkbInfo->desc->min_key_code)
@@ -1502,7 +1503,7 @@ GrabKey(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device,
return BadValue;
}
type = DeviceKeyPress;
- } else if (grabtype == GRABTYPE_XI2)
+ } else if (grabtype == XI2)
type = XI_KeyPress;
rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess);
@@ -1557,7 +1558,7 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type,
if (rc != Success)
return rc;
- grab = CreateGrab(client->index, dev, dev, pWin, GRABTYPE_XI2,
+ grab = CreateGrab(client->index, dev, dev, pWin, XI2,
mask, param, (type == XIGrabtypeEnter) ? XI_Enter : XI_FocusIn,
0, NULL, cursor);