xorg-server: Changes to 'upstream-1.11+input'
Xi/exevents.c | 951 ++++++++++++++++++++++++++++++
Xi/extinit.c | 28
Xi/xiallowev.c | 53 +
Xi/xipassivegrab.c | 27
Xi/xiquerydevice.c | 41 +
Xi/xiquerydevice.h | 1
Xi/xiselectev.c | 48 +
configure.ac | 2
dix/Makefile.am | 1
dix/devices.c | 87 ++
dix/eventconvert.c | 63 +-
dix/events.c | 64 +-
dix/getevents.c | 352 ++++++++++-
dix/grabs.c | 3
dix/inpututils.c | 5
dix/touch.c | 982 ++++++++++++++++++++++++++++++++
dix/window.c | 9
hw/xfree86/common/xf86Module.h | 2
hw/xfree86/common/xf86Xinput.c | 24
hw/xfree86/common/xf86Xinput.h | 3
include/dix.h | 7
include/events.h | 1
include/eventstr.h | 30
include/exevents.h | 12
include/input.h | 87 ++
include/inputstr.h | 55 +
include/misc.h | 4
include/protocol-versions.h | 2
mi/mieq.c | 37 -
test/Makefile.am | 3
test/input.c | 17
test/touch.c | 270 ++++++++
test/xi2/protocol-eventconvert.c | 106 +++
test/xi2/protocol-xipassivegrabdevice.c | 2
test/xi2/protocol-xiselectevents.c | 38 -
35 files changed, 3321 insertions(+), 96 deletions(-)
New commits:
commit 0c292448ebcfcc6e5072efada55f8135b60b7795
Author: Keith Packard <keithp@keithp.com>
Date: Thu Dec 22 09:35:51 2011 -0800
test/xi2: Fix infinite loop in test_convert_XITouchOwnershipEvent
The touchid test was using a loop like:
for(i = 1; i < 0xffffffff; i <<= 1)
When 'i' is a 32-bit variable, this infinite loops as it goes from
0x80000000 to 0. 'i' is declared as 'long', which is 32-bit in 32-bit mode.
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit e7df42ab68e30588a5e32ed543b0711821daf009)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index 752fbbf..2df9cb9 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -1017,10 +1017,12 @@ test_convert_XITouchOwnershipEvent(void)
test_XITouchOwnershipEvent(&in);
}
- for (i = 1; i <= 0xFFFFFFFF; i <<= 1)
+ for (i = 1; ; i <<= 1)
{
in.touchid = i;
test_XITouchOwnershipEvent(&in);
+ if (i == (1 << 31))
+ break;
}
}
commit 738549e470ea1ae792840bbc50766a017de23cff
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Dec 22 10:00:15 2011 +1000
test: fix grab mode value tests for new XIGrabModeTouch
This test checks that last-valid-mode + 1 returns a BadValue. With the
addition of XIGrabModeTouch, that value has changed - sync it up again.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit f75bdf7fbe757f4603e39139acc3c90538a45e15)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/test/input.c b/test/input.c
index 1ebf197..c665bfe 100644
--- a/test/input.c
+++ b/test/input.c
@@ -161,22 +161,31 @@ static void dix_check_grab_values(void)
rc = CheckGrabValues(&client, ¶m);
assert(rc == Success);
- param.this_device_mode = GrabModeAsync + 1;
+ param.this_device_mode = XIGrabModeTouch;
+ rc = CheckGrabValues(&client, ¶m);
+ assert(rc == Success);
+
+ param.this_device_mode = XIGrabModeTouch + 1;
rc = CheckGrabValues(&client, ¶m);
assert(rc == BadValue);
assert(client.errorValue == param.this_device_mode);
- assert(client.errorValue == GrabModeAsync + 1);
+ assert(client.errorValue == XIGrabModeTouch + 1);
param.this_device_mode = GrabModeSync;
param.other_devices_mode = GrabModeAsync;
rc = CheckGrabValues(&client, ¶m);
+
+ param.this_device_mode = GrabModeSync;
+ param.other_devices_mode = XIGrabModeTouch;
+ rc = CheckGrabValues(&client, ¶m);
+ assert(rc == Success);
assert(rc == Success);
- param.other_devices_mode = GrabModeAsync + 1;
+ param.other_devices_mode = XIGrabModeTouch + 1;
rc = CheckGrabValues(&client, ¶m);
assert(rc == BadValue);
assert(client.errorValue == param.other_devices_mode);
- assert(client.errorValue == GrabModeAsync + 1);
+ assert(client.errorValue == XIGrabModeTouch + 1);
param.other_devices_mode = GrabModeSync;
commit bc282a9a1492137b44486e39f08b2e4cbc34f92b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Dec 21 14:45:27 2011 +1000
Xi: only activate the device grab if we don't already have one
If the device is already grabbed, don't activate the passive grab, it screws
with our event masks. Just deliver to the grabbing client instead.
Reported-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 2bb282cd45cb8149b39d72397ef5bbcfebca11d2)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 0849690..db49e31 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1385,8 +1385,8 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent
if (grab)
{
/* this side-steps the usual activation mechansims, but... */
- if (ev->any.type == ET_TouchBegin)
- ActivatePassiveGrab(dev, grab, ptrev, ev); /* also delivers the event */
+ if (ev->any.type == ET_TouchBegin && !dev->deviceGrab.grab)
+ ActivatePassiveGrab(dev, grab, ptrev, ev); /* also delivers the event */
else {
int deliveries = 0;
/* 'grab' is the passive grab, but if the grab isn't active,
commit 3fc68a253e8f45bedeebf6d6a5e885cc720b68cf
Author: Carlos Garnacho <carlosg@gnome.org>
Date: Wed Dec 21 01:08:40 2011 +0100
dix: fix xi2 mask/filter when delivering grabbed events
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 475ef5cc8339fac3696fe654ef683f92f0b0cc2c)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/dix/events.c b/dix/events.c
index d802903..5360267 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4192,8 +4192,8 @@ DeliverOneGrabbedEvent(InternalEvent *event, DeviceIntPtr dev, enum InputLevel l
if (rc == Success)
{
int evtype = xi2_get_type(xE);
- mask = xi2mask_isset(grab->xi2mask, dev, evtype);
- filter = 1;
+ mask = GetXI2MaskByte(grab->xi2mask, dev, evtype);
+ filter = GetEventFilter(dev, xE);
}
break;
case XI:
commit a4d462fa2cdec99ae4444be843cd2eca8b7598ca
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Dec 19 09:08:05 2011 +1000
test: add a basic test for ownership event values
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 4551510f752624592f9201f73db89ac1325a234a)
Backported swap macros for test_values_XITouchOwnershipEvent.
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index a359feb..752fbbf 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -929,12 +929,108 @@ static void test_convert_XIDeviceChangedEvent(void)
}
}
+static void
+test_values_XITouchOwnershipEvent(TouchOwnershipEvent *in,
+ xXITouchOwnershipEvent *out,
+ BOOL swap)
+{
+ if (swap)
+ {
+ char n;
+
+ swaps(&out->sequenceNumber, n);
+ swapl(&out->length, n);
+ swaps(&out->evtype, n);
+ swaps(&out->deviceid, n);
+ swaps(&out->sourceid, n);
+ swapl(&out->time, n);
+ swapl(&out->touchid, n);
+ swapl(&out->root, n);
+ swapl(&out->event, n);
+ swapl(&out->child, n);
+ swapl(&out->time, n);
+ }
+
+ assert(out->type == GenericEvent);
+ assert(out->extension == 0); /* IReqCode defaults to 0 */
+ assert(out->evtype == GetXI2Type(in->type));
+ assert(out->time == in->time);
+ assert(out->deviceid == in->deviceid);
+ assert(out->sourceid == in->sourceid);
+ assert(out->touchid == in->touchid);
+ assert(out->flags == in->reason);
+}
+
+static void
+test_XITouchOwnershipEvent(TouchOwnershipEvent *in)
+{
+ xXITouchOwnershipEvent *out, *swapped;
+ int rc;
+
+ rc = EventToXI2((InternalEvent*)in, (xEvent**)&out);
+ assert(rc == Success);
+
+ test_values_XITouchOwnershipEvent(in, out, FALSE);
+
+ swapped = calloc(1, sizeof(xEvent) + out->length * 4);
+ XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped);
+ test_values_XITouchOwnershipEvent(in, swapped, TRUE);
+ free(out);
+ free(swapped);
+}
+
+static void
+test_convert_XITouchOwnershipEvent(void)
+{
+ TouchOwnershipEvent in;
+ long i;
+
+ memset(&in, 0, sizeof(in));
+ in.header = ET_Internal;
+ in.type = ET_TouchOwnership;
+ in.length = sizeof(in);
+ in.time = 0;
+ in.deviceid = 1;
+ in.sourceid = 2;
+ in.touchid = 0;
+ in.reason = 0;
+ in.resource = 0;
+ in.flags = 0;
+
+ test_XITouchOwnershipEvent(&in);
+
+ in.flags = XIAcceptTouch;
+ test_XITouchOwnershipEvent(&in);
+
+ in.flags = XIRejectTouch;
+ test_XITouchOwnershipEvent(&in);
+
+ for (i = 1; i <= 0xFFFF; i <<= 1)
+ {
+ in.deviceid = i;
+ test_XITouchOwnershipEvent(&in);
+ }
+
+ for (i = 1; i <= 0xFFFF; i <<= 1)
+ {
+ in.sourceid = i;
+ test_XITouchOwnershipEvent(&in);
+ }
+
+ for (i = 1; i <= 0xFFFFFFFF; i <<= 1)
+ {
+ in.touchid = i;
+ test_XITouchOwnershipEvent(&in);
+ }
+}
+
int main(int argc, char** argv)
{
test_convert_XIRawEvent();
test_convert_XIFocusEvent();
test_convert_XIDeviceEvent();
test_convert_XIDeviceChangedEvent();
+ test_convert_XITouchOwnershipEvent();
return 0;
}
commit 4f18583067c194b6e484405752a85708e2a1a00b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Mon Dec 19 08:31:37 2011 +1000
test: drop printfs from protocol-eventconvert.c
The test outputs are noisy enough, no need having these here too.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 0c661dc478b4b436a3e61066d31bc510c7a08456)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c
index 6bad33c..a359feb 100644
--- a/test/xi2/protocol-eventconvert.c
+++ b/test/xi2/protocol-eventconvert.c
@@ -197,7 +197,6 @@ static void test_convert_XIRawEvent(void)
memset(&in, 0, sizeof(in));
- printf("Testing all event types\n");
in.header = ET_Internal;
in.type = ET_RawMotion;
test_XIRawEvent(&in);
@@ -218,7 +217,6 @@ static void test_convert_XIRawEvent(void)
in.type = ET_RawButtonRelease;
test_XIRawEvent(&in);
- printf("Testing details and other fields\n");
in.detail.button = 1L;
test_XIRawEvent(&in);
in.detail.button = 1L << 8;
@@ -250,7 +248,6 @@ static void test_convert_XIRawEvent(void)
in.deviceid = ~0 & 0xFF;
test_XIRawEvent(&in);
- printf("Testing valuator masks\n");
for (i = 0; i < MAX_VALUATORS; i++)
{
XISetMask(in.valuators.mask, i);
@@ -439,7 +436,6 @@ static void test_convert_XIDeviceEvent(void)
memset(&in, 0, sizeof(in));
- printf("Testing simple field values\n");
in.header = ET_Internal;
in.type = ET_Motion;
in.length = sizeof(DeviceEvent);
@@ -463,7 +459,6 @@ static void test_convert_XIDeviceEvent(void)
test_XIDeviceEvent(&in);
- printf("Testing field ranges\n");
/* 32 bit */
in.detail.button = 1L;
test_XIDeviceEvent(&in);
@@ -611,7 +606,6 @@ static void test_convert_XIDeviceEvent(void)
in.mods.effective = ~0 & 0xFF;
test_XIDeviceEvent(&in);
- printf("Testing button masks\n");
for (i = 0; i < sizeof(in.buttons) * 8; i++)
{
XISetMask(in.buttons, i);
@@ -625,7 +619,6 @@ static void test_convert_XIDeviceEvent(void)
test_XIDeviceEvent(&in);
}
- printf("Testing valuator masks\n");
for (i = 0; i < MAX_VALUATORS; i++)
{
XISetMask(in.valuators.mask, i);
@@ -813,7 +806,6 @@ static void test_convert_XIDeviceChangedEvent(void)
DeviceChangedEvent in;
int i;
- printf("Testing simple field values\n");
memset(&in, 0, sizeof(in));
in.header = ET_Internal;
in.type = ET_DeviceChanged;
commit e3a9114e1e31378e96eaacf660e665ed6e50c428
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed Dec 21 11:11:48 2011 +1000
dix: remove requirement for client_id be the first element
Leftover code from an earlier version of GetTouchEvents.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 8080d785b2c1e5791312ed0975efd1b8aea58d98)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/dix/getevents.c b/dix/getevents.c
index b60ddc0..3b40a5b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1738,6 +1738,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
} touchpoint;
int need_rawevent = TRUE;
Bool emulate_pointer = FALSE;
+ int client_id = 0;
if (!dev->enabled || !t || !v)
return 0;
@@ -1761,6 +1762,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
}
need_rawevent = FALSE;
+ client_id = touchpoint.dix_ti->client_id;
} else /* a DDX-submitted touch */
{
touchpoint.ti = TouchFindByDDXID(dev, ddx_touchid, (type == XI_TouchBegin));
@@ -1770,6 +1772,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
type == XI_TouchBegin ? "begin" : "find", ddx_touchid);
return 0;
}
+ client_id = touchpoint.ti->client_id;
}
if (!(flags & TOUCH_CLIENT_ID))
@@ -1787,7 +1790,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
raw = &events->raw_event;
events++;
num_events++;
- init_raw(dev, raw, ms, type, touchpoint.ti->client_id);
+ init_raw(dev, raw, ms, type, client_id);
set_raw_valuators(raw, &mask, raw->valuators.data_raw);
}
@@ -1877,7 +1880,7 @@ GetTouchEvents(InternalEvent *events, DeviceIntPtr dev, uint32_t ddx_touchid,
event->root = scr->root->drawable.id;
event_set_root_coordinates(event, screenx, screeny);
- event->touchid = touchpoint.ti->client_id;
+ event->touchid = client_id;
event->flags = flags;
if (emulate_pointer)
diff --git a/include/inputstr.h b/include/inputstr.h
index 9881c7e..518e2f4 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -301,7 +301,6 @@ typedef struct _ValuatorClassRec {
} ValuatorClassRec;
typedef struct _TouchPointInfo {
- /* client_id must be first element, see GetTouchEvents */
uint32_t client_id; /* touch ID as seen in client events */
int sourceid; /* Source device's ID for this touchpoint */
Bool active; /* whether or not the touch is active */
@@ -328,7 +327,6 @@ typedef struct _TouchPointInfo {
typedef struct _TouchListener TouchListener;
typedef struct _DDXTouchPointInfo {
- /* client_id must be first element, see GetTouchEvents */
uint32_t client_id; /* touch ID as seen in client events */
Bool active; /* whether or not the touch is active */
uint32_t ddx_id; /* touch ID given by the DDX */
commit 717ac30a73beac953c6aa5d94ca8df1bce7bb97d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Dec 15 07:59:06 2011 +1000
mi: handle screen switching on pointer emulated touch events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 8a32c39c00789c16006de61112627722ce548be1)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/mi/mieq.c b/mi/mieq.c
index 5bdf971..6c46eb9 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -514,6 +514,12 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
if (!handler)
mieqMoveToNewScreen(dev, screen, &event->device_event);
break;
+ case ET_TouchBegin:
+ case ET_TouchUpdate:
+ case ET_TouchEnd:
+ if (!handler && (event->device_event.flags & TOUCH_POINTER_EMULATED))
+ mieqMoveToNewScreen(dev, screen, &event->device_event);
+ break;
default:
break;
}
commit 0f9cfff4971ba9f2559312e4ab75fe576aec4b1c
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Dec 15 07:57:47 2011 +1000
mi: split move to new screen logic to a helper function
No functional changes.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 48547068b115b1f5e5f46a70110454a2175fb9a4)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/mi/mieq.c b/mi/mieq.c
index ea8bcf0..5bdf971 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -471,6 +471,19 @@ CopyGetMasterEvent(DeviceIntPtr sdev,
}
+static void
+mieqMoveToNewScreen(DeviceIntPtr dev, ScreenPtr screen, DeviceEvent *event)
+{
+ if (dev && screen && screen != DequeueScreen(dev))
+ {
+ int x = 0, y = 0;
+ DequeueScreen(dev) = screen;
+ x = event->root_x;
+ y = event->root_y;
+ NewCurrentScreen (dev, DequeueScreen(dev), x, y);
+ }
+}
+
/**
* Post the given @event through the device hierarchy, as appropriate.
* Use this function if an event must be posted for a given device during the
@@ -482,7 +495,6 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
ScreenPtr screen)
{
mieqHandler handler;
- int x = 0, y = 0;
DeviceIntPtr master;
InternalEvent mevent; /* master event */
@@ -499,12 +511,8 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
case ET_KeyRelease:
case ET_ButtonPress:
case ET_ButtonRelease:
- if (dev && screen && screen != DequeueScreen(dev) && !handler) {
- DequeueScreen(dev) = screen;
- x = event->device_event.root_x;
- y = event->device_event.root_y;
- NewCurrentScreen (dev, DequeueScreen(dev), x, y);
- }
+ if (!handler)
+ mieqMoveToNewScreen(dev, screen, &event->device_event);
break;
default:
break;
commit 73d9c55a86bf1361fcaabb8780fd01ddf5fc5e57
Author: Daniel Stone <daniel@fooishbar.org>
Date: Thu Dec 15 07:52:28 2011 +1000
dix: Remove touch grabs if the grab disappears
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 3b1e2035cc4740711360c845cfcdff07f7b60558)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/dix/grabs.c b/dix/grabs.c
index da014df..701470c 100644
--- a/dix/grabs.c
+++ b/dix/grabs.c
@@ -266,6 +266,9 @@ CreateGrab(
void
FreeGrab(GrabPtr pGrab)
{
+ if (pGrab->grabtype == XI2 && pGrab->type == XI_TouchBegin)
+ TouchListenerGone(pGrab->resource);
+
free(pGrab->modifiersDetail.pMask);
free(pGrab->detail.pMask);
diff --git a/dix/touch.c b/dix/touch.c
index 9bd07c3..db0bf33 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -37,6 +37,7 @@
#include "inpututils.h"
#include "eventconvert.h"
#include "windowstr.h"
+#include "mi.h"
#define TOUCH_HISTORY_SIZE 100
@@ -936,3 +937,46 @@ TouchRemovePointerGrab(DeviceIntPtr dev)
if (!ti)
return;
}
+
+/* As touch grabs don't turn into active grabs with their own resources, we
+ * need to walk all the touches and remove this grab from any delivery
+ * lists. */
+void
+TouchListenerGone(XID resource)
+{
+ TouchPointInfoPtr ti;
+ DeviceIntPtr dev;
+ InternalEvent *events = InitEventList(GetMaximumEventsNum());
+ int i, j, k, nev;
+
+ if (!events)
+ FatalError("TouchListenerGone: couldn't allocate events\n");
+
+ for (dev = inputInfo.devices; dev; dev = dev->next)
+ {
+ if (!dev->touch)
+ continue;
+
+ for (i = 0; i < dev->touch->num_touches; i++)
+ {
+ ti = &dev->touch->touches[i];
+ if (!ti->active)
+ continue;
+
+ for (j = 0; j < ti->num_listeners; j++)
+ {
+ if (ti->listeners[j].listener != resource)
+ continue;
+
+ nev = GetTouchOwnershipEvents(events, dev, ti, XIRejectTouch,
+ resource, 0);
+ for (k = 0; k < nev; k++)
+ mieqProcessDeviceEvent(dev, events + k, NULL);
+
+ break;
+ }
+ }
+ }
+
+ FreeEventList(events, GetMaximumEventsNum());
+}
diff --git a/include/input.h b/include/input.h
index 41609fe..049eba8 100644
--- a/include/input.h
+++ b/include/input.h
@@ -627,6 +627,7 @@ extern int TouchConvertToPointerEvent(const InternalEvent *ev,
InternalEvent *motion, InternalEvent *button);
extern int TouchGetPointerEventType(const InternalEvent *ev);
extern void TouchRemovePointerGrab(DeviceIntPtr dev);
+extern void TouchListenerGone(XID resource);
/* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
commit dcb3ee2ba3f533f2cabbce9c0c94b7acde4d5fa3
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Dec 15 07:48:49 2011 +1000
dix: hook up passive grabs and pointer emulated passive grabs
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit cd3de8324e8908955a2e4be3000c8ffee8684c68)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/dix/events.c b/dix/events.c
index 51300cb..d802903 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -152,6 +152,7 @@ typedef const char *string;
#include "eventstr.h"
#include "enterleave.h"
#include "eventconvert.h"
+#include "mi.h"
/* Extension events type numbering starts at EXTENSION_EVENT_BASE. */
#define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */
@@ -1309,7 +1310,17 @@ ComputeFreezes(void)
event->root_x, event->root_y);
if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin))
{
- if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
+ if (IsTouchEvent((InternalEvent*)event))
+ {
+ InternalEvent *events = InitEventList(GetMaximumEventsNum());
+ int i, nev;
+ TouchPointInfoPtr ti = TouchFindByClientID(replayDev, event->touchid);
+ BUG_WARN(!ti);
+ nev = GetTouchOwnershipEvents(events, replayDev, ti, XIRejectTouch, ti->listeners[0].listener, 0);
+ for (i = 0; i < nev; i++)
+ mieqProcessDeviceEvent(replayDev, events + i, NULL);
+ ProcessInputEvents();
+ } else if (replayDev->focus && !IsPointerEvent((InternalEvent*)event))
DeliverFocusedEvent(replayDev, (InternalEvent*)event, w);
else
DeliverDeviceEvents(w, (InternalEvent*)event, NullGrab,
@@ -1514,6 +1525,8 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
Bool wasImplicit = (mouse->deviceGrab.fromPassiveGrab &&
mouse->deviceGrab.implicitGrab);
+ TouchRemovePointerGrab(mouse);
+
mouse->valuator->motionHintWindow = NullWindow;
mouse->deviceGrab.grab = NullGrab;
mouse->deviceGrab.sync.state = NOT_GRABBED;
@@ -3830,6 +3843,7 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
DeviceIntPtr gdev;
XkbSrvInfoPtr xkbi = NULL;
enum MatchFlags match = 0;
+ int emulated_type = 0;
gdev = grab->modifierDevice;
if (grab->grabtype == CORE)
@@ -3851,13 +3865,26 @@ CheckPassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event,
tempGrab->modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
/* Check for XI2 and XI grabs first */
- match = MatchForType(grab, tempGrab, XI2, GetXI2Type(event->any.type));
+ match = MatchForType(grab, tempGrab, XI2, event->any.type);
+
+ if (!match && IsTouchEvent(event) && (event->device_event.flags & TOUCH_POINTER_EMULATED))
+ {
+ emulated_type = TouchGetPointerEventType(event);
+ match = MatchForType(grab, tempGrab, XI2, emulated_type);
+ }
if (!match)
- match = MatchForType(grab, tempGrab, XI, GetXIType(event->any.type));
+ match = MatchForType(grab, tempGrab, XI, event->any.type);
+
+ if (!match && emulated_type)
+ match = MatchForType(grab, tempGrab, XI, emulated_type);
if (!match && checkCore)
- match = MatchForType(grab, tempGrab, CORE, GetCoreType(event->any.type));
+ {
+ match = MatchForType(grab, tempGrab, CORE, event->any.type);
+ if (!match && emulated_type)
+ match = MatchForType(grab, tempGrab, CORE, emulated_type);
+ }
if (!match || (grab->confineTo &&
(!grab->confineTo->realized ||
@@ -3931,6 +3958,8 @@ CheckPassiveGrabsOnWindow(
break;
case ET_ButtonPress:
case ET_ButtonRelease:
+ case ET_TouchBegin:
+ case ET_TouchEnd:
tempGrab->detail.exact = event->device_event.detail.button;
break;
default:
diff --git a/dix/touch.c b/dix/touch.c
index 5731d91..9bd07c3 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -910,3 +910,29 @@ TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev)
return;
}
}
+
+/**
+ * Remove the touch pointer grab from the device. Called from AllowSome()
+ */
+void
+TouchRemovePointerGrab(DeviceIntPtr dev)
+{
+ TouchPointInfoPtr ti;
+ GrabPtr grab;
+ DeviceEvent *ev;
+
+ if (!dev->touch)
+ return;
+
+ grab = dev->deviceGrab.grab;
+ if (!grab)
+ return;
+
+ ev = dev->deviceGrab.sync.event;
+ if (!IsTouchEvent((InternalEvent*)ev))
+ return;
+
+ ti = TouchFindByClientID(dev, ev->touchid);
+ if (!ti)
+ return;
+}
diff --git a/include/input.h b/include/input.h
index a5145f7..41609fe 100644
--- a/include/input.h
+++ b/include/input.h
@@ -626,6 +626,7 @@ extern Bool TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite);
extern int TouchConvertToPointerEvent(const InternalEvent *ev,
InternalEvent *motion, InternalEvent *button);
extern int TouchGetPointerEventType(const InternalEvent *ev);
+extern void TouchRemovePointerGrab(DeviceIntPtr dev);
/* misc event helpers */
extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
commit d87933d11530e056181bc13f0ee6724149c3d78c
Author: Carlos Garnacho <carlosg@gnome.org>
Date: Tue Dec 13 15:41:23 2011 +0100
Xi: assign correct grab_mode/other_device_mode in XI2 passive grabs
CreateGrab() expects the keyboard mode to be stored in grab_mode, and the
pointer mode in other_device_mode, so respect this in passive XI2 grabs,
and switch modes if needed.
Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 5b169cb695bd450d7f64e3800f00c9237ee67f96)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index cafc32a..d911702 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -153,11 +153,17 @@ ProcXIPassiveGrabDevice(ClientPtr client)
memset(¶m, 0, sizeof(param));
param.grabtype = XI2;
param.ownerEvents = stuff->owner_events;
- param.this_device_mode = stuff->grab_mode;
- param.other_devices_mode = stuff->paired_device_mode;
param.grabWindow = stuff->grab_window;
param.cursor = stuff->cursor;
+ if (IsKeyboardDevice(dev)) {
+ param.this_device_mode = stuff->grab_mode;
+ param.other_devices_mode = stuff->paired_device_mode;
+ } else {
+ param.this_device_mode = stuff->paired_device_mode;
+ param.other_devices_mode = stuff->grab_mode;
+ }
+
if (stuff->cursor != None)
{
ret = dixLookupResourceByType(&tmp, stuff->cursor,
commit 55e1e8691f2aa5f375a9c79bb469a3ad44ccd139
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Dec 15 07:42:12 2011 +1000
Xi: add the hooks for passive touch grabs
Co-authored-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
(cherry picked from commit 4469430b109fa2da7ba3d2fadf66eca78b7156a0)
Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
diff --git a/Xi/exevents.c b/Xi/exevents.c
index f1598f7..0849690 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -2253,12 +2253,14 @@ CheckGrabValues(ClientPtr client, GrabParameters* param)
}
if ((param->this_device_mode != GrabModeSync) &&
- (param->this_device_mode != GrabModeAsync)) {
+ (param->this_device_mode != GrabModeAsync) &&
+ (param->this_device_mode != XIGrabModeTouch)) {
client->errorValue = param->this_device_mode;
return BadValue;
}
if ((param->other_devices_mode != GrabModeSync) &&
- (param->other_devices_mode != GrabModeAsync)) {
+ (param->other_devices_mode != GrabModeAsync) &&
+ (param->other_devices_mode != XIGrabModeTouch)) {
client->errorValue = param->other_devices_mode;
return BadValue;
}
@@ -2423,6 +2425,34 @@ GrabWindow(ClientPtr client, DeviceIntPtr dev, int type,
return AddPassiveGrabToList(client, grab);
}
+/* Touch grab */
+int
+GrabTouch(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr mod_dev,
+ GrabParameters *param, GrabMask *mask)
+{
+ WindowPtr pWin;
+ GrabPtr grab;
+ int rc;
+
+ rc = CheckGrabValues(client, param);
+ if (rc != Success)
+ return rc;
+
+ rc = dixLookupWindow(&pWin, param->grabWindow, client, DixSetAttrAccess);
+ if (rc != Success)
+ return rc;
+ rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixGrabAccess);
+ if (rc != Success)
+ return rc;
+
+ grab = CreateGrab(client->index, dev, mod_dev, pWin, XI2,
+ mask, param, XI_TouchBegin, 0, NullWindow, NullCursor);
+ if (!grab)
+ return BadAlloc;
+
+ return AddPassiveGrabToList(client, grab);
+}
+
int
SelectForWindow(DeviceIntPtr dev, WindowPtr pWin, ClientPtr client,
Mask mask, Mask exclusivemasks)
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index f7aac87..cafc32a 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -110,19 +110,29 @@ ProcXIPassiveGrabDevice(ClientPtr client)
if (stuff->grab_type != XIGrabtypeButton &&
stuff->grab_type != XIGrabtypeKeycode &&
stuff->grab_type != XIGrabtypeEnter &&
- stuff->grab_type != XIGrabtypeFocusIn)
+ stuff->grab_type != XIGrabtypeFocusIn &&
+ stuff->grab_type != XIGrabtypeTouchBegin)
{
client->errorValue = stuff->grab_type;
return BadValue;
}
if ((stuff->grab_type == XIGrabtypeEnter ||
- stuff->grab_type == XIGrabtypeFocusIn) && stuff->detail != 0)
+ stuff->grab_type == XIGrabtypeFocusIn ||
+ stuff->grab_type == XIGrabtypeTouchBegin) && stuff->detail != 0)
{
client->errorValue = stuff->detail;
return BadValue;
}
+ if (stuff->grab_type == XIGrabtypeTouchBegin &&
+ (stuff->grab_mode != XIGrabModeTouch ||
+ stuff->paired_device_mode != GrabModeAsync))
+ {
+ client->errorValue = stuff->grab_mode;
+ return BadValue;
+ }
+
if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
stuff->mask_len * 4) != Success)
return BadValue;
@@ -196,6 +206,9 @@ ProcXIPassiveGrabDevice(ClientPtr client)
status = GrabWindow(client, dev, stuff->grab_type,
¶m, &mask);
break;
+ case XIGrabtypeTouchBegin:
+ status = GrabTouch(client, dev, mod_dev, ¶m, &mask);
+ break;
}
if (status != GrabSuccess)
diff --git a/include/exevents.h b/include/exevents.h
index 0186f53..bd16970 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -222,6 +222,14 @@ GrabWindow(
GrabMask* /* eventMask */);
extern int
+GrabTouch(
+ ClientPtr /* client */,
+ DeviceIntPtr /* dev */,
+ DeviceIntPtr /* mod_dev */,
+ GrabParameters* /* param */,
+ GrabMask* /* eventMask */);
+
+extern int
SelectForWindow(
DeviceIntPtr /* dev */,
WindowPtr /* pWin */,
commit 118d0e5841ea025f573df777491ff07abb3a616b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Thu Dec 15 07:21:38 2011 +1000
Xi: handle grab accept/reject requests
Reply to: