Merge lp:~chasedouglas/unity/fix-EndDrag into lp:unity

Proposed by Chase Douglas
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2322
Proposed branch: lp:~chasedouglas/unity/fix-EndDrag
Merge into: lp:unity
Diff against target: 89 lines (+33/-3)
3 files modified
plugins/unityshell/src/GestureEngine.cpp (+2/-1)
tests/test-gesture-engine/compiz_mock/core/screen.h (+10/-2)
tests/test-gesture-engine/test_gesture_engine.cpp (+21/-0)
To merge this branch: bzr merge lp:~chasedouglas/unity/fix-EndDrag
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
Alex Launi (community) quality Approve
Review via email: mp+101657@code.launchpad.net

Commit message

Fix potential pointer lockup on initial drag gesture.

Description of the change

GestureEngine: Fix potential pointer lockup on initial drag gesture.

To post a comment you must log in.
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On tests/test-gesture-engine/test_gesture_engine.cpp:
230| drag_data.id = 0;

Might be worth adding a side comment there stating that it's important that the ID is specifically zero.
And/Or commenting on top of that test that it's a regression test for lp bug #979418

Revision history for this message
Alex Launi (alexlauni) wrote :

Tests looks good.

review: Approve (quality)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/GestureEngine.cpp'
2--- plugins/unityshell/src/GestureEngine.cpp 2012-04-10 01:41:16 +0000
3+++ plugins/unityshell/src/GestureEngine.cpp 2012-04-12 14:08:19 +0000
4@@ -32,6 +32,7 @@
5 _screen = screen;
6
7 _drag_id = 0;
8+ _drag_window = 0;
9 _pinch_id = 0;
10 _touch_id = 0;
11 _drag_grab = 0;
12@@ -174,7 +175,7 @@
13 void
14 GestureEngine::EndDrag()
15 {
16- if (_drag_id && _drag_window)
17+ if (_drag_window)
18 {
19 _screen->removeGrab(_drag_grab, NULL);
20 _drag_grab = 0;
21
22=== modified file 'tests/test-gesture-engine/compiz_mock/core/screen.h'
23--- tests/test-gesture-engine/compiz_mock/core/screen.h 2012-04-04 14:33:07 +0000
24+++ tests/test-gesture-engine/compiz_mock/core/screen.h 2012-04-12 14:08:19 +0000
25@@ -31,6 +31,8 @@
26
27 class CompScreenMock {
28 public:
29+ CompScreenMock() : _grab_count(0) {}
30+
31 typedef int GrabHandle;
32
33 int width() const {return _width;}
34@@ -47,8 +49,13 @@
35
36 Window root() {return _root;}
37
38- GrabHandle pushGrab(Cursor cursor, const char *name) {return 0;}
39- void removeGrab(GrabHandle handle, CompPoint *restorePointer) {}
40+ GrabHandle pushGrab(Cursor cursor, const char *name) {
41+ _grab_count++;
42+ return 0;
43+ }
44+ void removeGrab(GrabHandle handle, CompPoint *restorePointer) {
45+ _grab_count--;
46+ }
47
48 Cursor invisibleCursor() {return 1;}
49
50@@ -58,6 +65,7 @@
51 CompWindowMockVector _client_list;
52 CompWindowMockVector _client_list_stacking;
53 Window _root;
54+ int _grab_count;
55 };
56
57 extern CompScreenMock *screen_mock;
58
59=== modified file 'tests/test-gesture-engine/test_gesture_engine.cpp'
60--- tests/test-gesture-engine/test_gesture_engine.cpp 2012-04-04 16:47:51 +0000
61+++ tests/test-gesture-engine/test_gesture_engine.cpp 2012-04-12 14:08:19 +0000
62@@ -220,6 +220,27 @@
63 ASSERT_EQ(0, middle_window->_maximize_count);
64 }
65
66+/* Regression test for lp:979418, where the grab is not removed if the gesture
67+ * id is 0. */
68+TEST_F(GestureEngineTest, DragGrabCheck)
69+{
70+ screen_mock->_grab_count = 0;
71+
72+ GestureEngine gesture_engine(screen_mock);
73+
74+ GeisAdapterMock::GeisDragData drag_data;
75+ drag_data.id = 0;
76+ drag_data.touches = 3;
77+ drag_data.window = 123;
78+ drag_data.focus_x = 100; /* hits the middle window */
79+ drag_data.focus_y = 100;
80+ gesture_engine.OnDragStart(&drag_data);
81+
82+ gesture_engine.OnDragFinish(&drag_data);
83+
84+ ASSERT_EQ(0, screen_mock->_grab_count);
85+}
86+
87 int main(int argc, char** argv)
88 {
89 ::testing::InitGoogleTest(&argc, argv);