Merge lp:~aacid/ubuntu-ui-toolkit/swipeAreaPressedSignal into lp:ubuntu-ui-toolkit/staging

Proposed by Albert Astals Cid on 2015-12-07
Status: Merged
Approved by: Zoltan Balogh on 2015-12-09
Approved revision: 1734
Merged at revision: 1748
Proposed branch: lp:~aacid/ubuntu-ui-toolkit/swipeAreaPressedSignal
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 70 lines (+21/-17)
2 files modified
src/Ubuntu/Components/plugin/gestures/ucswipearea.cpp (+14/-17)
tests/unit_x11/tst_swipearea/tst_swipearea.cpp (+7/-0)
To merge this branch: bzr merge lp:~aacid/ubuntu-ui-toolkit/swipeAreaPressedSignal
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-12-09
Daniel d'Andrada (community) code Approve on 2015-12-07
Christian Dywan 2015-12-07 Pending
Review via email: mp+279780@code.launchpad.net

Commit Message

Simplify logic for emitting draggingChanged/pressedChanged

No need for a switch that considers the possible cases, just store the status before and check after

Fixes an issue in which the SwipeArea pressedChanged signal was not emitted if switching
directly from WaitingForTouch to Recognized

To post a comment you must log in.
Daniel d'Andrada (dandrader) wrote :

Code looks ok, but it needs a test

1734. By Albert Astals Cid on 2015-12-07

Add a test for the pressed signal emission fix

Daniel d'Andrada (dandrader) wrote :

Code looks good to me (didn't test it myself though).

review: Approve (code)
Tim Peeters (tpeeters) wrote :

Can you add --wipe to the usage doc in the h) case?

Tim Peeters (tpeeters) wrote :

sorry, my previous comment was meant for another MR.

Christian Dywan (kalikiana) wrote :

The change looks sensible, and the test as well.

You seem to be hitting unrelated CI problems from the looks of it, which don't come from this change. As we are in the middle of looking into uncovering some test issues you may want to merge staging and see if it improves - if not, I'll take another look.

Albert Astals Cid (aacid) wrote :

> The change looks sensible, and the test as well.
>
> You seem to be hitting unrelated CI problems from the looks of it, which don't
> come from this change. As we are in the middle of looking into uncovering some
> test issues you may want to merge staging and see if it improves - if not,
> I'll take another look.

There's nothing in staging to merge as far as i can see.

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/gestures/ucswipearea.cpp'
2--- src/Ubuntu/Components/plugin/gestures/ucswipearea.cpp 2015-11-13 08:15:59 +0000
3+++ src/Ubuntu/Components/plugin/gestures/ucswipearea.cpp 2015-12-07 14:41:04 +0000
4@@ -714,29 +714,26 @@
5 recognitionTimer->stop();
6 }
7
8+ const bool wasDragging = q->dragging();
9+ const bool wasPressed = q->pressed();
10+
11 status = newStatus;
12 Q_EMIT statusChanged(status);
13
14 SA_TRACE(statusToString(oldStatus) << " -> " << statusToString(newStatus));
15
16- switch (newStatus) {
17- case WaitingForTouch:
18- if (oldStatus == Recognized) {
19- Q_EMIT q->draggingChanged(false);
20- }
21- Q_EMIT q->pressedChanged(false);
22- break;
23- case Undecided:
24- recognitionTimer->start();
25- Q_EMIT q->pressedChanged(true);
26- break;
27- case Recognized:
28- Q_EMIT q->draggingChanged(true);
29- break;
30- default:
31- // no-op
32- break;
33+ if (newStatus == Undecided) {
34+ recognitionTimer->start();
35 }
36+
37+ const bool isDragging = q->dragging();
38+ const bool isPressed = q->pressed();
39+
40+ if (isDragging != wasDragging)
41+ Q_EMIT q->draggingChanged(isDragging);
42+
43+ if (isPressed != wasPressed)
44+ Q_EMIT q->pressedChanged(isPressed);
45 }
46
47 void UCSwipeAreaPrivate::updatePosition(const QPointF &point)
48
49=== modified file 'tests/unit_x11/tst_swipearea/tst_swipearea.cpp'
50--- tests/unit_x11/tst_swipearea/tst_swipearea.cpp 2015-11-17 12:20:03 +0000
51+++ tests/unit_x11/tst_swipearea/tst_swipearea.cpp 2015-12-07 14:41:04 +0000
52@@ -884,11 +884,18 @@
53
54 QPoint touch0Pos(edgeDragArea->width()/2.0f, m_view->height()/2.0f);
55
56+ QSignalSpy pressedSpy(edgeDragArea, &UCSwipeArea::pressedChanged);
57+ QCOMPARE(edgeDragArea->pressed(), false);
58+
59 QTest::touchEvent(m_view, m_device).press(0, touch0Pos);
60
61 // check for immediate recognition
62 QCOMPARE((int)edgeDragArea->d->status, (int)UCSwipeAreaPrivate::Recognized);
63
64+ // and it is pressed
65+ QCOMPARE(edgeDragArea->pressed(), true);
66+ QCOMPARE(pressedSpy.count(), 1);
67+
68 // and therefore it should have immediately grabbed the touch point,
69 // not letting it leak to items behind him.
70 QCOMPARE(dummyItem->touchEvents.count(), 0);

Subscribers

People subscribed via source and target branches