Merge lp:~chasedouglas/geis/v1-device-add-subscribe-fix into lp:geis

Proposed by Chase Douglas
Status: Merged
Merged at revision: 273
Proposed branch: lp:~chasedouglas/geis/v1-device-add-subscribe-fix
Merge into: lp:geis
Prerequisite: lp:~chasedouglas/geis/v1-device-add-subscribe-test
Diff against target: 28 lines (+10/-7)
1 file modified
libutouch-geis/geis_v1.c (+10/-7)
To merge this branch: bzr merge lp:~chasedouglas/geis/v1-device-add-subscribe-fix
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
Chase Douglas (community) Needs Resubmitting
Review via email: mp+109414@code.launchpad.net

Description of the change

Fix for lp:1009270: Unity fails to use multitouch gestures if magic touchpad is connected after Unity has launched.

To post a comment you must log in.
Revision history for this message
Stephen M. Webb (bregma) wrote :

I ran into a race condition in the test case that caused this change to repeatedly fail. I modified the test case as follows and the test case passed.

The fix itself looks like it should do the right thing, #803408 notwithstanding, and when used with GEIS_DEBUG=3 produces the expected debug output.

=== modified file 'testsuite/geis1/gtest_devices.cpp'
--- testsuite/geis1/gtest_devices.cpp 2012-06-08 18:10:30 +0000
+++ testsuite/geis1/gtest_devices.cpp 2012-06-14 18:31:09 +0000
@@ -25,7 +25,12 @@
   void GestureUpdate(GeisGestureType type, GeisGestureId id, GeisSize count,
                      GeisGestureAttr* attrs);

+ void CreateNewDevice();
+
+ void UseNewDevice();
+
 protected:
+ std::unique_ptr<Testsuite::EvemuDevice> new_device_;
   bool saw_events_;
 };

@@ -42,6 +47,11 @@
                        GeisSize count, GeisGestureAttr* attrs) {
 }

+void device_callback(void* cookie, GeisInputDeviceId deviceId, void* attrs) {
+ Geis1DeviceTests* fixture = reinterpret_cast<Geis1DeviceTests*>(cookie);
+ fixture->UseNewDevice();
+}
+
 } // namespace

 void Geis1DeviceTests::GestureUpdate(GeisGestureType type, GeisGestureId id,
@@ -50,6 +60,14 @@
   saw_events_ = true;
 }

+void Geis1DeviceTests::CreateNewDevice() {
+ new_device_.reset(new Testsuite::EvemuDevice(TEST_DEVICE_PROP_FILE));
+}
+
+void Geis1DeviceTests::UseNewDevice() {
+ new_device_->play(TEST_DEVICE_EVENTS_FILE);
+}
+
 /*
  * Test case for lp:1009270 -- Geis v1 does not report gestures for new devices
  *
@@ -58,9 +76,6 @@
  */
 TEST_F(Geis1DeviceTests, addDeviceSubscription)
 {
- std::unique_ptr<Testsuite::EvemuDevice> new_device;
- GeisBoolean device_has_been_created = GEIS_FALSE;
- GeisBoolean gesture_events_received = GEIS_FALSE;

   static const char* gestures[] =
   {
@@ -76,13 +91,19 @@
     &gesture_null_func,
   };

+ static GeisInputFuncs inputfuncs = {
+ &device_callback,
+ &device_callback,
+ &device_callback
+ };
+
+ ASSERT_EQ(GEIS_STATUS_SUCCESS, geis_input_devices(geis(), &inputfuncs, this));
+
   ASSERT_EQ(GEIS_STATUS_SUCCESS,
             geis_subscribe(geis(), GEIS_ALL_INPUT_DEVICES, gestures, &callbacks,
                            this));

- new_device.reset(new Testsuite::EvemuDevice(TEST_DEVICE_PROP_FILE));
- sleep(1);
- new_device->play(TEST_DEVICE_EVENTS_FILE);
+ CreateNewDevice();

   while (1) {
     fd_set read_fds;

review: Needs Fixing
274. By Chase Douglas

Merged v1-device-add-subscribe-test into v1-device-add-subscribe-fix.

275. By Chase Douglas

Merged v1-device-add-subscribe-test into v1-device-add-subscribe-fix.

Revision history for this message
Chase Douglas (chasedouglas) wrote :

The previous pipe has been updated with the fix and pumped into this pipe. Please review.

review: Needs Resubmitting
Revision history for this message
Stephen M. Webb (bregma) wrote :

Works.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libutouch-geis/geis_v1.c'
2--- libutouch-geis/geis_v1.c 2012-04-12 14:56:24 +0000
3+++ libutouch-geis/geis_v1.c 2012-06-15 17:33:30 +0000
4@@ -619,14 +619,17 @@
5 {
6 const char **g;
7
8- geis_debug("subscribing device %d for the following gestures:", device_id);
9- result = geis_filter_add_term(instance->window_filter,
10- GEIS_FILTER_DEVICE,
11- GEIS_DEVICE_ATTRIBUTE_ID, GEIS_FILTER_OP_EQ, device_id,
12- NULL);
13- if (result != GEIS_STATUS_SUCCESS)
14+ if (device_id != 0)
15 {
16- geis_error("error adding device filter term");
17+ geis_debug("subscribing device %d for the following gestures:", device_id);
18+ result = geis_filter_add_term(instance->window_filter,
19+ GEIS_FILTER_DEVICE,
20+ GEIS_DEVICE_ATTRIBUTE_ID, GEIS_FILTER_OP_EQ,
21+ device_id, NULL);
22+ if (result != GEIS_STATUS_SUCCESS)
23+ {
24+ geis_error("error adding device filter term");
25+ }
26 }
27
28 for (g = gesture_list; *g; ++g)

Subscribers

People subscribed via source and target branches