Merge lp:~faenil/ubuntu-ui-toolkit/mousefilter_setHovered_onMouseMove into lp:ubuntu-ui-toolkit/staging

Proposed by Andrea Bernabei
Status: Merged
Approved by: Andrea Bernabei
Approved revision: 1809
Merged at revision: 1922
Proposed branch: lp:~faenil/ubuntu-ui-toolkit/mousefilter_setHovered_onMouseMove
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 132 lines (+104/-1)
3 files modified
src/Ubuntu/Components/plugin/ucmousefilters.cpp (+2/-1)
tests/unit_x11/tst_mousefilters/EnteredExitedOnMouseMove.qml (+32/-0)
tests/unit_x11/tst_mousefilters/tst_mousefilterstest.cpp (+70/-0)
To merge this branch: bzr merge lp:~faenil/ubuntu-ui-toolkit/mousefilter_setHovered_onMouseMove
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Zsombor Egri Approve
Review via email: mp+291033@code.launchpad.net

Commit message

Mouse filter: check if mouse is inside the area on mouse moves and setHovered accordingly. Fixes lp#1566378

To post a comment you must log in.
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Nice one, thanks for fixing!

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
1809. By Andrea Bernabei

send mouse event to top left of the view, not middle

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Ubuntu/Components/plugin/ucmousefilters.cpp'
--- src/Ubuntu/Components/plugin/ucmousefilters.cpp 2016-01-30 12:03:31 +0000
+++ src/Ubuntu/Components/plugin/ucmousefilters.cpp 2016-04-06 22:19:21 +0000
@@ -608,7 +608,8 @@
608 m_pressAndHoldTimer.stop();608 m_pressAndHoldTimer.stop();
609 }609 }
610610
611 setHovered(true, 0);611 setHovered(m_owner->contains(m_lastPos), Q_NULLPTR);
612
612 m_moved = true;613 m_moved = true;
613 m_doubleClicked = false;614 m_doubleClicked = false;
614 QQuickMouseEvent mev(m_lastPos.x(), m_lastPos.y(), m_lastButton, m_lastButtons, m_lastModifiers,615 QQuickMouseEvent mev(m_lastPos.x(), m_lastPos.y(), m_lastButton, m_lastButtons, m_lastModifiers,
615616
=== added file 'tests/unit_x11/tst_mousefilters/EnteredExitedOnMouseMove.qml'
--- tests/unit_x11/tst_mousefilters/EnteredExitedOnMouseMove.qml 1970-01-01 00:00:00 +0000
+++ tests/unit_x11/tst_mousefilters/EnteredExitedOnMouseMove.qml 2016-04-06 22:19:21 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.4
18import Ubuntu.Components 1.3
19
20Rectangle {
21 width: units.gu(50)
22 height: units.gu(40)
23
24 MouseArea {
25 anchors.fill: parent
26 anchors.margins: units.gu(10)
27
28 objectName: "FilterOwner"
29 hoverEnabled: true
30 Mouse.enabled: true
31 }
32}
0\ No newline at end of file33\ No newline at end of file
134
=== modified file 'tests/unit_x11/tst_mousefilters/tst_mousefilterstest.cpp'
--- tests/unit_x11/tst_mousefilters/tst_mousefilterstest.cpp 2016-02-09 13:15:19 +0000
+++ tests/unit_x11/tst_mousefilters/tst_mousefilterstest.cpp 2016-04-06 22:19:21 +0000
@@ -981,6 +981,76 @@
981 QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(x, i));981 QTest::mouseRelease(view.data(), Qt::LeftButton, 0, QPoint(x, i));
982 }982 }
983983
984 //This is to test that entered/exited events are fired as a consequence of a mouse move.
985 //When mouse is PRESSED, in fact, you won't get hover events. Mouse moves have to update
986 //the hovered state (and that will trigger entered()/exited()). This fixes lp:1566378
987 void testCase_enteredExitedOnMouseMove_lp1566378() {
988 QScopedPointer<QQuickView> view(loadTest("EnteredExitedOnMouseMove.qml"));
989 QVERIFY(view);
990 UCMouse *filter = attachedFilter<UCMouse>(view->rootObject(), "FilterOwner");
991 QVERIFY(filter);
992 QSignalSpy pressed(filter, SIGNAL(pressed(QQuickMouseEvent*, QQuickItem*)));
993 QSignalSpy positionChanged(filter, SIGNAL(positionChanged(QQuickMouseEvent*, QQuickItem*)));
994 QSignalSpy entered(filter, SIGNAL(entered(QQuickMouseEvent*, QQuickItem*)));
995 QSignalSpy exited(filter, SIGNAL(exited(QQuickMouseEvent*, QQuickItem*)));
996
997 QObject::connect(filter, SIGNAL(pressed(QQuickMouseEvent*, QQuickItem*)), this, SLOT(onMouseEvent(QQuickMouseEvent*, QQuickItem*)));
998 QObject::connect(filter, SIGNAL(positionChanged(QQuickMouseEvent*, QQuickItem*)), this, SLOT(onMouseEvent2(QQuickMouseEvent*, QQuickItem*)));
999 QObject::connect(filter, SIGNAL(entered(QQuickMouseEvent*, QQuickItem*)), this, SLOT(onMouseEvent3(QQuickMouseEvent*, QQuickItem*)));
1000 QObject::connect(filter, SIGNAL(exited(QQuickMouseEvent*, QQuickItem*)), this, SLOT(onMouseEvent3(QQuickMouseEvent*, QQuickItem*)));
1001
1002 preventDblClick();
1003
1004 //don't use guPoint(0,0) as it's the same as not passing any point, i.e. it sends mouseMove to the
1005 //center of the view
1006 QTest::mouseMove(view.data(), guPoint(1, 1));
1007 QTest::mouseMove(view.data(), guPoint(15, 15));
1008 QTest::waitForEvents();
1009
1010 QCOMPARE(entered.count(), 1);
1011 QCOMPARE(mouseEvent3Params.handler, QString("EVENT4"));
1012 QCOMPARE(mouseEvent3Params.pressedButton, Qt::NoButton);
1013
1014 QTest::mousePress(view.data(), Qt::LeftButton, 0, guPoint(15, 15));
1015 QTest::waitForEvents();
1016 QCOMPARE(mouseEventParams.handler, QString("EVENT1"));
1017 QCOMPARE(mouseEventParams.pressedButton, Qt::LeftButton);
1018
1019 QTest::mouseMove(view.data(), guPoint(25, 15));
1020
1021 //go out of the mousearea on the right
1022 QTest::mouseMove(view.data(), guPoint(45, 15));
1023 QTest::waitForEvents();
1024 QCOMPARE(mouseEvent2Params.handler, QString("EVENT2"));
1025 QCOMPARE(mouseEvent2Params.pressedButton, Qt::LeftButton);
1026 QCOMPARE(exited.count(), 1);
1027 QCOMPARE(mouseEvent3Params.handler, QString("EVENT4"));
1028 QCOMPARE(mouseEvent3Params.pressedButton, Qt::LeftButton);
1029
1030 //move back in
1031 QTest::mouseMove(view.data(), guPoint(25, 15));
1032 QTest::waitForEvents();
1033 QCOMPARE(mouseEvent2Params.handler, QString("EVENT2"));
1034 QCOMPARE(mouseEvent2Params.pressedButton, Qt::LeftButton);
1035 QCOMPARE(entered.count(), 2);
1036 QCOMPARE(mouseEvent3Params.handler, QString("EVENT4"));
1037 QCOMPARE(mouseEvent3Params.pressedButton, Qt::LeftButton);
1038
1039 //and out again
1040 QTest::mouseMove(view.data(), guPoint(45, 15));
1041 QTest::waitForEvents();
1042 QCOMPARE(mouseEvent2Params.handler, QString("EVENT2"));
1043 QCOMPARE(mouseEvent2Params.pressedButton, Qt::LeftButton);
1044 QCOMPARE(exited.count(), 2);
1045 QCOMPARE(mouseEvent3Params.handler, QString("EVENT4"));
1046 QCOMPARE(mouseEvent3Params.pressedButton, Qt::LeftButton);
1047
1048 QTest::mouseRelease(view.data(), Qt::LeftButton, 0, guPoint(45, 15));
1049 QTest::waitForEvents();
1050
1051 QCOMPARE(positionChanged.count(), 4);
1052 }
1053
984 void testCase_hoverEvents() {1054 void testCase_hoverEvents() {
985 QScopedPointer<QQuickView> view(loadTest("HoverEvent.qml"));1055 QScopedPointer<QQuickView> view(loadTest("HoverEvent.qml"));
986 QVERIFY(view);1056 QVERIFY(view);

Subscribers

People subscribed via source and target branches