aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/dix/touch.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-06-04 09:07:26 +0200
committermarha <marha@users.sourceforge.net>2013-06-04 09:07:26 +0200
commit150771e7aabf4c864b0b970c5b8d773634793abe (patch)
tree3d544cc0d8d06dd70e843d6ca7e4b0ef421d2758 /xorg-server/dix/touch.c
parentfbe681216618af573ce29ca03b382b39b5919a52 (diff)
downloadvcxsrv-150771e7aabf4c864b0b970c5b8d773634793abe.tar.gz
vcxsrv-150771e7aabf4c864b0b970c5b8d773634793abe.tar.bz2
vcxsrv-150771e7aabf4c864b0b970c5b8d773634793abe.zip
xwininfo fontconfig libX11 libXau libXdmcp libXext mesa libXinerama libxcb libxcb/xcb-proto libfontenc pixman xkbcomp mkfontscale xkeyboard-config git update 4 Jun 2013
xserver commit c21344add2fc589df83b29be5831c36a372201bd libxcb commit 9ae84ad187e2ba440c40f44b8eb21c82c2fdbf12 libxcb/xcb-proto commit bdfedfa57a13ff805580cfacafc70f9cc55df363 xkeyboard-config commit dad9ade4e83d1ef5a517fcc4cc9ad3a79b47acce libX11 commit 8496122eb00ce6cd5d2308ee54f64b68c378e455 libXdmcp commit 0b443c1b769b9c9a3b45b4252afe07e18b709ff4 libXext commit d8366afbb0d2e4fbb1e419b1187f490522270bea libfontenc commit 3acba630d8b57084f7e92c15732408711ed5137a libXinerama commit 6e1d1dc328ba8162bba2f4694e7f3c706a1491ff libXau commit 899790011304c4029e15abf410e49ce7cec17e0a xkbcomp commit ed582f4fccd4e23abcfba8b3b03649fea6414f44 pixman commit 2acfac5f8e097ee2ae225d986f981b55d65dd152 mkfontscale commit 19e2cb7c6a3ec2c5b1bc0d24866fa685eef0ee13 xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 fontconfig commit cd9b1033a68816a7acfbba1718ba0aa5888f6ec7 mesa commit 7bafd88c153e395274b632e7eae4bc9fc3aec1d2
Diffstat (limited to 'xorg-server/dix/touch.c')
-rw-r--r--xorg-server/dix/touch.c118
1 files changed, 98 insertions, 20 deletions
diff --git a/xorg-server/dix/touch.c b/xorg-server/dix/touch.c
index 891cc7803..a4b6d7eea 100644
--- a/xorg-server/dix/touch.c
+++ b/xorg-server/dix/touch.c
@@ -263,6 +263,7 @@ void
TouchFreeTouchPoint(DeviceIntPtr device, int index)
{
TouchPointInfoPtr ti;
+ int i;
if (!device->touch || index >= device->touch->num_touches)
return;
@@ -271,6 +272,9 @@ TouchFreeTouchPoint(DeviceIntPtr device, int index)
if (ti->active)
TouchEndTouch(device, ti);
+ for (i = 0; i < ti->num_listeners; i++)
+ TouchRemoveListener(ti, ti->listeners[0].listener);
+
valuator_mask_free(&ti->valuators);
free(ti->sprite.spriteTrace);
ti->sprite.spriteTrace = NULL;
@@ -365,6 +369,8 @@ TouchBeginTouch(DeviceIntPtr dev, int sourceid, uint32_t touchid,
void
TouchEndTouch(DeviceIntPtr dev, TouchPointInfoPtr ti)
{
+ int i;
+
if (ti->emulate_pointer) {
GrabPtr grab;
@@ -376,6 +382,9 @@ TouchEndTouch(DeviceIntPtr dev, TouchPointInfoPtr ti)
}
}
+ for (i = 0; i < ti->num_listeners; i++)
+ TouchRemoveListener(ti, ti->listeners[0].listener);
+
ti->active = FALSE;
ti->pending_finish = FALSE;
ti->sprite.spriteTraceGood = 0;
@@ -474,7 +483,21 @@ TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev, XID resource)
DeviceEvent *ev = &ti->history[i];
ev->flags |= TOUCH_REPLAYING;
- DeliverTouchEvents(dev, ti, (InternalEvent *) ev, resource);
+ ev->resource = resource;
+ /* FIXME:
+ We're replaying ti->history which contains the TouchBegin +
+ all TouchUpdates for ti. This needs to be passed on to the next
+ listener. If that is a touch listener, everything is dandy.
+ If the TouchBegin however triggers a sync passive grab, the
+ TouchUpdate events must be sent to EnqueueEvent so the events end
+ up in syncEvents.pending to be forwarded correctly in a
+ subsequent ComputeFreeze().
+
+ However, if we just send them to EnqueueEvent the sync'ing device
+ prevents handling of touch events for ownership listeners who
+ want the events right here, right now.
+ */
+ dev->public.processInputProc((InternalEvent*)ev, dev);
}
}
@@ -620,14 +643,14 @@ TouchConvertToPointerEvent(const InternalEvent *event,
BUG_WARN_MSG(!(event->device_event.flags & TOUCH_POINTER_EMULATED),
"Non-emulating touch event\n");
- *motion_event = *event;
+ motion_event->device_event = event->device_event;
motion_event->any.type = ET_Motion;
motion_event->device_event.detail.button = 0;
motion_event->device_event.flags = XIPointerEmulated;
if (nevents > 1) {
BUG_RETURN_VAL(!button_event, 0);
- *button_event = *event;
+ button_event->device_event = event->device_event;
button_event->any.type = ptrtype;
button_event->device_event.flags = XIPointerEmulated;
/* detail is already correct */
@@ -678,15 +701,23 @@ void
TouchAddListener(TouchPointInfoPtr ti, XID resource, int resource_type,
enum InputLevel level, enum TouchListenerType type,
enum TouchListenerState state, WindowPtr window,
- GrabPtr grab)
+ const GrabPtr grab)
{
+ GrabPtr g = NULL;
+
+ /* We need a copy of the grab, not the grab itself since that may be
+ * deleted by a UngrabButton request and leaves us with a dangling
+ * pointer */
+ if (grab)
+ g = AllocGrab(grab);
+
ti->listeners[ti->num_listeners].listener = resource;
ti->listeners[ti->num_listeners].resource_type = resource_type;
ti->listeners[ti->num_listeners].level = level;
ti->listeners[ti->num_listeners].state = state;
ti->listeners[ti->num_listeners].type = type;
ti->listeners[ti->num_listeners].window = window;
- ti->listeners[ti->num_listeners].grab = grab;
+ ti->listeners[ti->num_listeners].grab = g;
if (grab)
ti->num_grabs++;
ti->num_listeners++;
@@ -704,21 +735,25 @@ TouchRemoveListener(TouchPointInfoPtr ti, XID resource)
int i;
for (i = 0; i < ti->num_listeners; i++) {
- if (ti->listeners[i].listener == resource) {
- int j;
+ int j;
+ TouchListener *listener = &ti->listeners[i];
- if (ti->listeners[i].grab) {
- ti->listeners[i].grab = NULL;
- ti->num_grabs--;
- }
+ if (listener->listener != resource)
+ continue;
- for (j = i; j < ti->num_listeners - 1; j++)
- ti->listeners[j] = ti->listeners[j + 1];
- ti->num_listeners--;
- ti->listeners[ti->num_listeners].listener = 0;
- ti->listeners[ti->num_listeners].state = LISTENER_AWAITING_BEGIN;
- return TRUE;
+ if (listener->grab) {
+ FreeGrab(listener->grab);
+ listener->grab = NULL;
+ ti->num_grabs--;
}
+
+ for (j = i; j < ti->num_listeners - 1; j++)
+ ti->listeners[j] = ti->listeners[j + 1];
+ ti->num_listeners--;
+ ti->listeners[ti->num_listeners].listener = 0;
+ ti->listeners[ti->num_listeners].state = LISTENER_AWAITING_BEGIN;
+
+ return TRUE;
}
return FALSE;
}
@@ -874,7 +909,7 @@ TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev)
SpritePtr sprite = &ti->sprite;
WindowPtr win;
- if (dev->deviceGrab.grab)
+ if (dev->deviceGrab.grab && !dev->deviceGrab.fromPassiveGrab)
TouchAddActiveGrabListener(dev, ti, ev, dev->deviceGrab.grab);
/* We set up an active touch listener for existing touches, but not any
@@ -954,11 +989,11 @@ TouchListenerGone(XID resource)
continue;
for (j = 0; j < ti->num_listeners; j++) {
- if (ti->listeners[j].listener != resource)
+ if (CLIENT_BITS(ti->listeners[j].listener) != resource)
continue;
nev = GetTouchOwnershipEvents(events, dev, ti, XIRejectTouch,
- resource, 0);
+ ti->listeners[j].listener, 0);
for (k = 0; k < nev; k++)
mieqProcessDeviceEvent(dev, events + k, NULL);
@@ -1061,3 +1096,46 @@ TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
FreeEventList(eventlist, GetMaximumEventsNum());
}
+
+/**
+ * Generate and deliver a TouchEnd event.
+ *
+ * @param dev The device to deliver the event for.
+ * @param ti The touch point record to deliver the event for.
+ * @param flags Internal event flags. The called does not need to provide
+ * TOUCH_CLIENT_ID and TOUCH_POINTER_EMULATED, this function will ensure
+ * they are set appropriately.
+ * @param resource The client resource to deliver to, or 0 for all clients.
+ */
+void
+TouchEmitTouchEnd(DeviceIntPtr dev, TouchPointInfoPtr ti, int flags, XID resource)
+{
+ InternalEvent event;
+
+ /* We're not processing a touch end for a frozen device */
+ if (dev->deviceGrab.sync.frozen)
+ return;
+
+ flags |= TOUCH_CLIENT_ID;
+ if (ti->emulate_pointer)
+ flags |= TOUCH_POINTER_EMULATED;
+ TouchDeliverDeviceClassesChangedEvent(ti, GetTimeInMillis(), resource);
+ GetDixTouchEnd(&event, dev, ti, flags);
+ DeliverTouchEvents(dev, ti, &event, resource);
+ if (ti->num_grabs == 0)
+ UpdateDeviceState(dev, &event.device_event);
+}
+
+void
+TouchAcceptAndEnd(DeviceIntPtr dev, int touchid)
+{
+ TouchPointInfoPtr ti = TouchFindByClientID(dev, touchid);
+ if (!ti)
+ return;
+
+ TouchListenerAcceptReject(dev, ti, 0, XIAcceptTouch);
+ if (ti->pending_finish)
+ TouchEmitTouchEnd(dev, ti, 0, 0);
+ if (ti->num_listeners <= 1)
+ TouchEndTouch(dev, ti);
+}