Merge lp:~dandrader/unity8/controlTouchEmulationFromQML into lp:unity8

Proposed by Daniel d'Andrada on 2015-02-27
Status: Superseded
Proposed branch: lp:~dandrader/unity8/controlTouchEmulationFromQML
Merge into: lp:unity8
Diff against target: 411 lines (+137/-29)
12 files modified
src/Dash/main.cpp (+2/-2)
src/MouseTouchAdaptor.cpp (+40/-4)
src/MouseTouchAdaptor.h (+18/-5)
src/main.cpp (+2/-6)
tests/qmltests/Panel/tst_Panel.qml (+10/-2)
tests/qmltests/tst_Shell.qml (+4/-3)
tests/uqmlscene/CMakeLists.txt (+0/-1)
tests/uqmlscene/main.cpp (+0/-4)
tests/utils/modules/Unity/Test/CMakeLists.txt (+2/-0)
tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml (+43/-0)
tests/utils/modules/Unity/Test/plugin.cpp (+15/-2)
tests/utils/modules/Unity/Test/qmldir (+1/-0)
To merge this branch: bzr merge lp:~dandrader/unity8/controlTouchEmulationFromQML
Reviewer Review Type Date Requested Status
Michael Zanetti (community) 2015-02-27 Needs Fixing on 2015-03-02
PS Jenkins bot continuous-integration Needs Fixing on 2015-02-27
Review via email: mp+251308@code.launchpad.net

This proposal has been superseded by a proposal from 2015-03-02.

Commit Message

Make MouseTouchAdaptor controllable from within QML

Description of the Change

* Are there any related MPs required for this MP to build/function as expected? Please list.
No, but for better effect try this branch along with lp:~mzanetti/unity8/indicators-mouse and run "make tryPanel"

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

* Did you make sure that your branch does not contain spurious tags?
Yes.

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable.

* If you changed the UI, has there been a design review?
Not applicable.

To post a comment you must log in.
Michael Zanetti (mzanetti) wrote :

Functionality seems to work fine. Code-wise I'm ok too.

Does fail some tests in jenkins though.

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

> Functionality seems to work fine. Code-wise I'm ok too.
>
> Does fail some tests in jenkins though.

Those are old failures that should be fixed by now. I should probably resubmit to get a new jenkins run because I did "push --overwrite". :/

1638. By Daniel d'Andrada on 2015-03-03

Will that empty commit make Jenkins rebuild?

1639. By Daniel d'Andrada on 2015-03-03

And one more for good measure

1640. By Daniel d'Andrada on 2015-03-10

Merge trunk + ~dandrader/unity8/unifyShellTests

[ Albert Astals ]
* Don't precache items that are outisde the 1.5*height buffering area
  (LP: #1410131)
[ Albert Astals Cid ]
* Don't precache items that are outisde the 1.5*height buffering area
  (LP: #1410131)
[ Chris Townsend ]
* Add a wrapper for handling the
  /org/gnome/SessionManager/EndSessionDialog DBus object used by
  indicator-session. This allows indicator-session to properly talk to
  the Unity 8 session management functions. (LP: #1392187)
* Allow for proper logout session management. This uses the
  EndSession() Upstart DBus method on the current session bus. (LP:
  #1360316)
* Make the Unity 8 session dialogs behave in the same fashion as Unity
  7. From indicator-session: Clicking "Log Out" will now present a
  dialog to "Lock", "Log Out", or "Cancel". Clicking "Shut Down" will
  now present a dialog to "Reboot", "Shut Down", or "Cancel". (LP:
  #1416074)
[ Daniel d'Andrada ]
* Add NO_TESTS cmake option to skip tests and therefore speed up
  builds
* Remove enums and properties that doesn't exist in the real
  ApplicationManager
* Stabilize some Shell qml tests
[ Josh Arenson ]
* Create a PhysicalKeyMapper to handle all physical/hardware keys (LP:
  #1390393)
[ Michael Terry ]
* Make the draggable part of the right edge (during the tutorial) a
  constant size, instead of having it grow and shrink as the spread
  peeks out from the side.
[ MichaƂ Sawicz ]
* Create a PhysicalKeyMapper to handle all physical/hardware keys (LP:
  #1390393)
[ Robert Bruce Park ]
* Launchpad automatic translations update.
[ CI Train Bot ]
* New rebuild forced.
[ Pete Woods ]
* Only set scopes active when the screen is on (LP: #1422879)

Unmerged revisions

1636. By Launchpad Translations on behalf of unity-team on 2015-02-27

Launchpad automatic translations update.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Dash/main.cpp'
2--- src/Dash/main.cpp 2014-10-02 15:36:42 +0000
3+++ src/Dash/main.cpp 2015-03-02 12:41:55 +0000
4@@ -98,8 +98,7 @@
5 // Needed only when manually testing on a desktop.
6 MouseTouchAdaptor *mouseTouchAdaptor = 0;
7 if (parser.isSet(mousetouchOption)) {
8- mouseTouchAdaptor = new MouseTouchAdaptor;
9- application->installNativeEventFilter(mouseTouchAdaptor);
10+ mouseTouchAdaptor = MouseTouchAdaptor::instance();
11 }
12
13 QUrl source(::qmlDirectory()+"Dash/DashApplication.qml");
14@@ -115,6 +114,7 @@
15 int result = application->exec();
16
17 delete view;
18+ delete mouseTouchAdaptor;
19 delete application;
20
21 return result;
22
23=== modified file 'src/MouseTouchAdaptor.cpp'
24--- src/MouseTouchAdaptor.cpp 2013-12-17 14:56:25 +0000
25+++ src/MouseTouchAdaptor.cpp 2015-03-02 12:41:55 +0000
26@@ -1,5 +1,5 @@
27 /*
28- * Copyright (C) 2013 Canonical, Ltd.
29+ * Copyright (C) 2013,2015 Canonical, Ltd.
30 *
31 * This program is free software; you can redistribute it and/or modify
32 * it under the terms of the GNU General Public License as published by
33@@ -20,12 +20,15 @@
34
35 #include <qpa/qwindowsysteminterface.h>
36
37-#include <QtGui/QMouseEvent>
38-#include <QtTest/QTest>
39+#include <QCoreApplication>
40+#include <QMouseEvent>
41+#include <QTest>
42
43 using QTest::QTouchEventSequence;
44
45 namespace {
46+MouseTouchAdaptor *g_instance = nullptr;
47+
48 Qt::MouseButton translateMouseButton(xcb_button_t detail)
49 {
50 switch (detail) {
51@@ -39,16 +42,36 @@
52 } // end of anonymous namespace
53
54 MouseTouchAdaptor::MouseTouchAdaptor()
55- : m_leftButtonIsPressed(false)
56+ : QObject(nullptr), m_leftButtonIsPressed(false), m_enabled(true)
57 {
58+ QCoreApplication::instance()->installNativeEventFilter(this);
59+
60 m_touchDevice = new QTouchDevice;
61 m_touchDevice->setType(QTouchDevice::TouchScreen);
62 QWindowSystemInterface::registerTouchDevice(m_touchDevice);
63 }
64
65+MouseTouchAdaptor::~MouseTouchAdaptor()
66+{
67+ g_instance = nullptr;
68+}
69+
70+MouseTouchAdaptor* MouseTouchAdaptor::instance()
71+{
72+ if (!g_instance) {
73+ g_instance = new MouseTouchAdaptor;
74+ }
75+
76+ return g_instance;
77+}
78+
79 bool MouseTouchAdaptor::nativeEventFilter(const QByteArray & eventType,
80 void * message, long * /*result*/)
81 {
82+ if (!m_enabled) {
83+ return false;
84+ }
85+
86 if (eventType != "xcb_generic_event_t") {
87 // wrong backend.
88 qWarning("MouseTouchAdaptor: XCB backend not in use. Adaptor inoperative!");
89@@ -151,3 +174,16 @@
90 Q_ASSERT(foundWindow);
91 return foundWindow;
92 }
93+
94+bool MouseTouchAdaptor::enabled() const
95+{
96+ return m_enabled;
97+}
98+
99+void MouseTouchAdaptor::setEnabled(bool value)
100+{
101+ if (value != m_enabled) {
102+ m_enabled = value;
103+ Q_EMIT enabledChanged(value);
104+ }
105+}
106
107=== modified file 'src/MouseTouchAdaptor.h'
108--- src/MouseTouchAdaptor.h 2013-12-18 10:23:05 +0000
109+++ src/MouseTouchAdaptor.h 2015-03-02 12:41:55 +0000
110@@ -1,5 +1,5 @@
111 /*
112- * Copyright (C) 2013 Canonical, Ltd.
113+ * Copyright (C) 2013,2015 Canonical, Ltd.
114 *
115 * This program is free software; you can redistribute it and/or modify
116 * it under the terms of the GNU General Public License as published by
117@@ -27,15 +27,26 @@
118 class QTouchDevice;
119
120 // Transforms QMouseEvents into single-finger QTouchEvents.
121-class MouseTouchAdaptor : public QAbstractNativeEventFilter {
122-
123+class MouseTouchAdaptor : public QObject, public QAbstractNativeEventFilter {
124+ Q_OBJECT
125 public:
126- MouseTouchAdaptor();
127+ virtual ~MouseTouchAdaptor();
128+
129+ static MouseTouchAdaptor* instance();
130
131 // Filters mouse events and posts the equivalent QTouchEvents.
132- virtual bool nativeEventFilter(const QByteArray & eventType, void *message, long *result);
133+ bool nativeEventFilter(const QByteArray & eventType, void *message, long *result) override;
134+
135+ Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
136+
137+ bool enabled() const;
138+ void setEnabled(bool value);
139+
140+Q_SIGNALS:
141+ void enabledChanged(bool value);
142
143 private:
144+ MouseTouchAdaptor();
145
146 bool handleButtonPress(xcb_button_press_event_t *pressEvent);
147 bool handleButtonRelease(xcb_button_release_event_t *releaseEvent);
148@@ -44,6 +55,8 @@
149
150 QTouchDevice *m_touchDevice;
151 bool m_leftButtonIsPressed;
152+
153+ bool m_enabled;
154 };
155
156 #endif // MOUSE_TOUCH_ADAPTOR_H
157
158=== modified file 'src/main.cpp'
159--- src/main.cpp 2015-01-07 15:48:16 +0000
160+++ src/main.cpp 2015-03-02 12:41:55 +0000
161@@ -1,8 +1,5 @@
162 /*
163- * Copyright (C) 2012-2014 Canonical, Ltd.
164- *
165- * Authors:
166- * Gerry Boland <gerry.boland@canonical.com>
167+ * Copyright (C) 2012-2015 Canonical, Ltd.
168 *
169 * This program is free software; you can redistribute it and/or modify
170 * it under the terms of the GNU General Public License as published by
171@@ -130,8 +127,7 @@
172 // Needed only when manually testing on a desktop.
173 MouseTouchAdaptor *mouseTouchAdaptor = 0;
174 if (parser.isSet(mousetouchOption)) {
175- mouseTouchAdaptor = new MouseTouchAdaptor;
176- application->installNativeEventFilter(mouseTouchAdaptor);
177+ mouseTouchAdaptor = MouseTouchAdaptor::instance();
178 }
179
180 QUrl source(::qmlDirectory()+"Shell.qml");
181
182=== modified file 'tests/qmltests/Panel/tst_Panel.qml'
183--- tests/qmltests/Panel/tst_Panel.qml 2015-01-26 13:48:08 +0000
184+++ tests/qmltests/Panel/tst_Panel.qml 2015-03-02 12:41:55 +0000
185@@ -17,7 +17,7 @@
186 import QtQuick 2.1
187 import QtQuick.Layouts 1.1
188 import QtTest 1.0
189-import Unity.Test 0.1 as UT
190+import Unity.Test 0.1
191 import Ubuntu.Components 0.1
192 import Unity.Indicators 0.1 as Indicators
193 import Ubuntu.Telephony 0.1 as Telephony
194@@ -121,6 +121,14 @@
195 }
196 }
197 }
198+
199+ Rectangle {
200+ Layout.preferredHeight: units.dp(1);
201+ Layout.fillWidth: true;
202+ color: "black"
203+ }
204+
205+ MouseTouchEmulationCheckbox {}
206 }
207 }
208
209@@ -129,7 +137,7 @@
210 phoneNumber: "+447812221111"
211 }
212
213- UT.UnityTestCase {
214+ UnityTestCase {
215 name: "Panel"
216 when: windowShown
217
218
219=== modified file 'tests/qmltests/tst_Shell.qml'
220--- tests/qmltests/tst_Shell.qml 2015-02-23 15:43:41 +0000
221+++ tests/qmltests/tst_Shell.qml 2015-03-02 12:41:55 +0000
222@@ -29,14 +29,14 @@
223 import Unity.Connectivity 0.1
224 import Unity.Indicators 0.1
225 import Unity.Notifications 1.0
226-import Unity.Test 0.1 as UT
227+import Unity.Test 0.1
228 import Powerd 0.1
229
230 import "../../qml"
231
232 Item {
233 id: root
234- width: units.gu(60)
235+ width: units.gu(70)
236 height: units.gu(71)
237
238 Component.onCompleted: {
239@@ -117,6 +117,7 @@
240 shellLoader.active = true;
241 }
242 }
243+ MouseTouchEmulationCheckbox { color: "white" }
244 }
245 }
246 }
247@@ -178,7 +179,7 @@
248 phoneNumber: "+447812221111"
249 }
250
251- UT.UnityTestCase {
252+ UnityTestCase {
253 id: testCase
254 name: "Shell"
255 when: windowShown
256
257=== modified file 'tests/uqmlscene/CMakeLists.txt'
258--- tests/uqmlscene/CMakeLists.txt 2015-01-28 12:59:21 +0000
259+++ tests/uqmlscene/CMakeLists.txt 2015-03-02 12:41:55 +0000
260@@ -2,7 +2,6 @@
261 ${shellapplication_MOC_SRCS}
262 ActiveFocusLogger.cpp
263 main.cpp
264- ${CMAKE_SOURCE_DIR}/src/MouseTouchAdaptor.cpp
265 )
266
267 qt5_use_modules(uqmlscene Qml Quick Test)
268
269=== modified file 'tests/uqmlscene/main.cpp'
270--- tests/uqmlscene/main.cpp 2015-01-28 12:59:21 +0000
271+++ tests/uqmlscene/main.cpp 2015-03-02 12:41:55 +0000
272@@ -63,8 +63,6 @@
273 #include <QtCore/QTranslator>
274 #include <QtCore/QLibraryInfo>
275
276-#include <MouseTouchAdaptor.h>
277-
278 // UbuntuGestures lib
279 #include <TouchRegistry.h>
280
281@@ -436,8 +434,6 @@
282 app.setOrganizationName("Qt Project");
283 app.setOrganizationDomain("qt-project.org");
284
285- MouseTouchAdaptor mouseTouchAdaptor;
286- app.installNativeEventFilter(&mouseTouchAdaptor);
287 // Create it before loading the module, so that TestUtil
288 // doesn't create one with a fake timer factory.
289 // When interacting manually with a test we want the real deal.
290
291=== modified file 'tests/utils/modules/Unity/Test/CMakeLists.txt'
292--- tests/utils/modules/Unity/Test/CMakeLists.txt 2015-02-17 15:06:33 +0000
293+++ tests/utils/modules/Unity/Test/CMakeLists.txt 2015-03-02 12:41:55 +0000
294@@ -6,12 +6,14 @@
295 ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
296 ${Qt5Quick_PRIVATE_INCLUDE_DIRS}
297 ${CMAKE_SOURCE_DIR}/libs/UbuntuGestures
298+ ${CMAKE_SOURCE_DIR}/src
299 )
300
301 set(UnityTestQML_SOURCES
302 testutil.cpp
303 plugin.cpp
304 TouchEventSequenceWrapper.cpp
305+ ${CMAKE_SOURCE_DIR}/src/MouseTouchAdaptor.cpp
306 )
307
308 add_library(UnityTestQml MODULE ${UnityTestQML_SOURCES})
309
310=== added file 'tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml'
311--- tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml 1970-01-01 00:00:00 +0000
312+++ tests/utils/modules/Unity/Test/MouseTouchEmulationCheckbox.qml 2015-03-02 12:41:55 +0000
313@@ -0,0 +1,43 @@
314+/*
315+ * Copyright (C) 2015 Canonical, Ltd.
316+ *
317+ * This program is free software; you can redistribute it and/or modify
318+ * it under the terms of the GNU General Public License as published by
319+ * the Free Software Foundation; version 3.
320+ *
321+ * This program is distributed in the hope that it will be useful,
322+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
323+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
324+ * GNU General Public License for more details.
325+ *
326+ * You should have received a copy of the GNU General Public License
327+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
328+ */
329+
330+import QtQuick 2.0
331+import QtQuick.Layouts 1.1
332+import Ubuntu.Components 1.1
333+import Unity.Test 0.1
334+
335+RowLayout {
336+ id: root
337+ property alias color: label.color
338+
339+ Binding {
340+ target: MouseTouchAdaptor
341+ property: "enabled"
342+ value: checkbox.checked
343+ }
344+
345+ Layout.fillWidth: true
346+ CheckBox {
347+ id: checkbox
348+ checked: true
349+ activeFocusOnPress: false
350+ }
351+ Label {
352+ id: label
353+ text: "Mouse emulates touch"
354+ anchors.verticalCenter: parent.verticalCenter
355+ }
356+}
357
358=== modified file 'tests/utils/modules/Unity/Test/plugin.cpp'
359--- tests/utils/modules/Unity/Test/plugin.cpp 2013-06-05 22:03:08 +0000
360+++ tests/utils/modules/Unity/Test/plugin.cpp 2015-03-02 12:41:55 +0000
361@@ -1,5 +1,5 @@
362 /*
363- * Copyright (C) 2012, 2013 Canonical, Ltd.
364+ * Copyright (C) 2012, 2013, 2015 Canonical, Ltd.
365 *
366 * This program is free software; you can redistribute it and/or modify
367 * it under the terms of the GNU General Public License as published by
368@@ -17,20 +17,33 @@
369
370 #include "plugin.h"
371 #include "testutil.h"
372+#include <MouseTouchAdaptor.h>
373 #include "TouchEventSequenceWrapper.h"
374
375 #include <qqml.h>
376
377-static QObject *testutil_provider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
378+namespace {
379+QObject *testutil_provider(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
380 {
381 return new TestUtil();
382 }
383+QObject *getMouseTouchAdaptorQMLSingleton(QQmlEngine* /* engine */, QJSEngine* /* scriptEngine */)
384+{
385+ return MouseTouchAdaptor::instance();
386+}
387+} // anonymous namespace
388
389 void UnityTestPlugin::registerTypes(const char *uri)
390 {
391 Q_ASSERT(QLatin1String(uri) == QLatin1String("Unity.Test"));
392+
393+ // Ensure the instance gets created
394+ MouseTouchAdaptor::instance();
395+
396 // @uri Unity.Test
397 qmlRegisterSingletonType<TestUtil>(uri, 0, 1, "Util", testutil_provider);
398 qmlRegisterUncreatableType<TouchEventSequenceWrapper>(uri, 0, 1, "TouchEventSequence",
399 "You cannot directly create a TouchEventSequence object.");
400+ qmlRegisterSingletonType<MouseTouchAdaptor>(uri, 0, 1, "MouseTouchAdaptor",
401+ getMouseTouchAdaptorQMLSingleton);
402 }
403
404=== modified file 'tests/utils/modules/Unity/Test/qmldir'
405--- tests/utils/modules/Unity/Test/qmldir 2014-05-02 22:57:42 +0000
406+++ tests/utils/modules/Unity/Test/qmldir 2015-03-02 12:41:55 +0000
407@@ -3,3 +3,4 @@
408 typeinfo Test.qmltypes
409
410 UnityTestCase 0.1 UnityTestCase.qml
411+MouseTouchEmulationCheckbox 0.1 MouseTouchEmulationCheckbox.qml

Subscribers

People subscribed via source and target branches