summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dix/devices.c1
-rw-r--r--dix/touch.c28
-rw-r--r--include/input.h1
3 files changed, 30 insertions, 0 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 66d440683..fd4916a3a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -443,6 +443,7 @@ DisableDevice(DeviceIntPtr dev, BOOL sendevent)
if (*prev != dev)
return FALSE;
+ TouchEndPhysicallyActiveTouches(dev);
ReleaseButtonsAndKeys(dev);
SyncRemoveDeviceIdleTime(dev->idle_counter);
dev->idle_counter = NULL;
diff --git a/dix/touch.c b/dix/touch.c
index 497ad7dac..e64a6262c 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -1029,3 +1029,31 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
return TouchListenerAcceptReject(dev, ti, i, mode);
}
+
+/**
+ * End physically active touches for a device.
+ */
+void
+TouchEndPhysicallyActiveTouches(DeviceIntPtr dev)
+{
+ InternalEvent *eventlist = InitEventList(GetMaximumEventsNum());
+ int i;
+
+ OsBlockSignals();
+ mieqProcessInputEvents();
+ for (i = 0; i < dev->last.num_touches; i++) {
+ DDXTouchPointInfoPtr ddxti = dev->last.touches + i;
+
+ if (ddxti->active) {
+ int j;
+ int nevents = GetTouchEvents(eventlist, dev, ddxti->ddx_id,
+ XI_TouchEnd, 0, NULL);
+
+ for (j = 0; j < nevents; j++)
+ mieqProcessDeviceEvent(dev, eventlist + j, NULL);
+ }
+ }
+ OsReleaseSignals();
+
+ FreeEventList(eventlist, GetMaximumEventsNum());
+}
diff --git a/include/input.h b/include/input.h
index 5747f3cd2..f8459b8c8 100644
--- a/include/input.h
+++ b/include/input.h
@@ -579,6 +579,7 @@ extern int TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti,
int listener, int mode);
extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
uint32_t touchid, Window grab_window, XID *error);
+extern void TouchEndPhysicallyActiveTouches(DeviceIntPtr dev);
/* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent *ev, InputClientsPtr clients);