Merge lp:~mir-team/qtmir/port-to-event-2.0 into lp:qtmir

Proposed by Robert Carr on 2015-01-30
Status: Merged
Approved by: Daniel d'Andrada on 2015-02-06
Approved revision: no longer in the source branch.
Merged at revision: 326
Proposed branch: lp:~mir-team/qtmir/port-to-event-2.0
Merge into: lp:qtmir
Diff against target: 1160 lines (+376/-374)
10 files modified
CMakeLists.txt (+2/-1)
src/common/debughelpers.cpp (+8/-24)
src/modules/Unity/Application/mirsurfaceitem.cpp (+169/-174)
src/modules/Unity/Application/mirsurfaceitem.h (+9/-1)
src/platforms/mirserver/qteventfeeder.cpp (+136/-114)
src/platforms/mirserver/qteventfeeder.h (+5/-3)
tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h (+2/-1)
tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp (+3/-32)
tests/modules/ApplicationManager/application_manager_test.cpp (+2/-0)
tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp (+40/-24)
To merge this branch: bzr merge lp:~mir-team/qtmir/port-to-event-2.0
Reviewer Review Type Date Requested Status
Gerry Boland Approve on 2015-02-20
Daniel d'Andrada (community) 2015-01-30 Approve on 2015-02-06
PS Jenkins bot continuous-integration Needs Fixing on 2015-02-06
Review via email: mp+248067@code.launchpad.net

Commit Message

Port to the new MirEvent API and add support for pointer events.

As when accessing events through the new API pointer events will not present as touch events and not adding the new support would have introduced a regression.

Description of the Change

Port qtmir to the new MirEvent API. Also adds support for pointer events (as when accessing events through the new API pointer events will not present as touch events and not adding the new support would have introduced a regression).

Some tests are not totally ported...they may remain unported until the new MirEvent definition is available....

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Daniel d'Andrada (dandrader) wrote :

In debian/control:

"""
               libmirclient-dev (>= 0.6.0),
               libmircommon-dev,
               libmirserver-dev (>= 0.10.0),
"""

The mir version we depend on should be higher now, right? As I cannot build this branch with the currently released mir version.

--------

Please update the copyright year (ie, add 2015) to all the modified header and cpp files

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

> In debian/control:
>
> """
> libmirclient-dev (>= 0.6.0),
> libmircommon-dev,
> libmirserver-dev (>= 0.10.0),
> """
>
> The mir version we depend on should be higher now, right? As I cannot build
> this branch with the currently released mir version.

And likely adding a minimum version requirement here as well, in CMakeList.txt:

"""
pkg_check_modules(MIRSERVER mirserver REQUIRED)
"""

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Daniel d'Andrada (dandrader) wrote :

In mirsurfaceitem.cpp:

"""
namespace {

// Would be better if QMouseEvent had nativeModifiers
MirInputEventModifiers
mir_modifiers_from_qt(Qt::KeyboardModifiers mods)
{
    MirInputEventModifiers m_mods = mir_input_event_modifier_none;
    if (mods & Qt::ShiftModifier)
"""

Please follow Qt coding style (function name)

Daniel d'Andrada (dandrader) wrote :

In mirsurfaceitem.cpp

"""
}
    <- HERE
mir::EventUPtr makeMirEvent(Qt::KeyboardModifiers qmods,
                            const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
                            Qt::TouchPointStates /* qtTouchPointStates */,
                            ulong qtTimestamp)
{
    auto modifiers = mir_modifiers_from_qt(qmods);
    auto ev = mir::events::make_event(0, static_cast<int64_t>(qtTimestamp) * 1000000,
                                      modifiers);
   <- HERE
    for (int i = 0; i < qtTouchPoints.count(); ++i) {

"""

Some trailing whitespace here and there

Daniel d'Andrada (dandrader) wrote :

"""
@@ -580,10 +552,10 @@ void MirSurfaceItem::endCurrentTouchSequ

         touchEvent.updateTouchPointStatesAndType();

- if (fillInMirEvent(mirEvent, touchEvent.touchPoints,
- touchEvent.touchPointStates, touchEvent.timestamp)) {
- m_surface->consume(mirEvent);
- }
+ auto ev = makeMirEvent(touchEvent.modifiers, touchEvent.touchPoints,
+ touchEvent.touchPointStates, touchEvent.timestamp);
+ m_surface->consume(*ev);
+ <- HERE
         *m_lastTouchEvent = touchEvent;

         touchEvent.touchPoints.removeAt(0);
"""

More trailing whitespace in mirsurfaceitem.cpp

PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Daniel d'Andrada (dandrader) wrote :

In src/platforms/mirserver/qteventfeeder.cpp

"""
 Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input")

 // from android-input AMOTION_EVENT_ACTION_*, hidden inside mir bowels
-// mir headers should define them
-const int QtEventFeeder::MirEventActionMask = 0xff;
-const int QtEventFeeder::MirEventActionPointerIndexMask = 0xff00;
-const int QtEventFeeder::MirEventActionPointerIndexShift = 8;
-

 // XKB Keysyms which do not map directly to Qt types (i.e. Unicode points)
 static const uint32_t KeyTable[] = {
"""

Should also remove the "from android-inpu" comment line

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

In src/platforms/mirserver/qteventfeeder.cpp:

"""
Qt::KeyboardModifiers qt_modifiers_from_mir(MirInputEventModifiers modifiers)
"""

Please use Qt's coding style.

Daniel d'Andrada (dandrader) wrote :

Looking good.

review: Approve
lp:~mir-team/qtmir/port-to-event-2.0 updated on 2015-02-10
310. By Gerry Boland on 2015-02-06

Explicitly setting GL-mode breaks GTK app rendering. Removing the hack appears to just work Fixes: #1401968
Approved by: Michał Sawicz, Stephen M. Webb, PS Jenkins bot

311. By Michał Sawicz on 2015-02-06

Add moot autopkgtest to run the standard unit tests

312. By Albert Astals Cid on 2015-02-06

Fix demo shell import name
Approved by: Gerry Boland

313. By Daniel d'Andrada on 2015-02-06

Don't suspend&resume the main stage app when switching focus from side to main stage
Approved by: Gerry Boland, PS Jenkins bot

314. By CI Train Bot Account on 2015-02-06

Releasing 0.4.4+15.04.20150206-0ubuntu1

315. By Alan Griffiths on 2015-02-09

Port to the msh::Shell API in Mir
Approved by: Alberto Aguirre, Gerry Boland

316. By Daniel van Vugt on 2015-02-09

QtMir changes required to support the Mir branch of the same name. Landing soon. Fixes: #1395581
Approved by: Gerry Boland

317. By Robert Carr <racarr@ocelot> on 2015-02-09

Bump build-dep to mir 0.11.

318. By CI Train Bot Account on 2015-02-09

Releasing 0.4.4+15.04.20150209-0ubuntu1

Gerry Boland (gerboland) wrote :

Something weird has happened to the history of this branch. These branches appear to have been reverted:
lp:~alan-griffiths/qtmir/delete-dead-code
lp:~vanvugt/qtmir/fix-buffers_ready_for_compositor
I can't see where the history got confused, perhaps someone better with bzr can figure it out? I made a branch to restore the reversions, but it doesn't deal well with file deletion & re-creation:
lp:~gerboland/qtmir/port-to-event-2.0-fixed

review: Needs Fixing
lp:~mir-team/qtmir/port-to-event-2.0 updated on 2015-02-16
319. By Timo Jyrinki on 2015-02-16

No-change rebuild against Qt 5.4.0.

Robert Carr (robertcarr) wrote :

https://code.launchpad.net/+branch/~vanvugt/qtmir/fix-buffers_ready_for_compositor contains https://code.launchpad.net/+branch/~alan-griffiths/qtmir/delete-dead-code

so I merged fix-buffers_ready_for_compositor with --take-other and think things should be fine.

lp:~mir-team/qtmir/port-to-event-2.0 updated on 2015-02-19
320. By Robert Carr on 2015-02-19

Port to MirEvent 2.0

Robert Carr (robertcarr) wrote :

Overwrote a rebased branch with extraneous changes removed.

lp:~mir-team/qtmir/port-to-event-2.0 updated on 2015-02-20
321. By Daniel d'Andrada on 2015-02-20

Fix virtual keyboard bug

While the virtual keyboard was up we were unable to interact
with the application behind it

322. By Daniel d'Andrada on 2015-02-20

Fix typo

Gerry Boland (gerboland) :
review: Approve
Michał Sawicz (saviq) :
Robert Carr (robertcarr) wrote :

It looks like the corresponding change from 0.11 is already there from another branch (probably fix-buffers-ready-for-compositor or port-to-msh-Shell)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-12-09 14:12:57 +0000
3+++ CMakeLists.txt 2015-02-20 15:57:56 +0000
4@@ -66,7 +66,7 @@
5 message(SEND_ERROR "protoc executable not found! Missing protobuf-compiler package?")
6 endif()
7
8-pkg_check_modules(MIRSERVER mirserver REQUIRED)
9+pkg_check_modules(MIRSERVER mirserver>=0.11 REQUIRED)
10
11 pkg_check_modules(GLIB glib-2.0 REQUIRED)
12 pkg_check_modules(PROCESS_CPP process-cpp REQUIRED)
13@@ -78,6 +78,7 @@
14 pkg_check_modules(GIO_UNIX gio-unix-2.0)
15 pkg_check_modules(LTTNG lttng-ust)
16
17+add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)
18
19 # We expect this to be set via debian/rules for GLES builds
20 if ("${USE_OPENGLES}" STREQUAL 1)
21
22=== modified file 'src/common/debughelpers.cpp'
23--- src/common/debughelpers.cpp 2014-08-27 11:51:28 +0000
24+++ src/common/debughelpers.cpp 2015-02-20 15:57:56 +0000
25@@ -1,5 +1,5 @@
26 /*
27- * Copyright (C) 2013-2014 Canonical, Ltd.
28+ * Copyright (C) 2013-2015 Canonical, Ltd.
29 *
30 * This program is free software: you can redistribute it and/or modify it under
31 * the terms of the GNU Lesser General Public License version 3, as published by
32@@ -176,31 +176,15 @@
33 }
34 }
35
36-const char *mirMotionActionToStr(int value)
37+const char *mirTouchActionToStr(MirTouchInputEventTouchAction action)
38 {
39- switch (value) {
40- case mir_motion_action_move:
41- return "move";
42- case mir_motion_action_down:
43+ switch (action) {
44+ case mir_touch_input_event_action_up:
45+ return "up";
46+ case mir_touch_input_event_action_down:
47 return "down";
48- case mir_motion_action_up:
49- return "up";
50- case mir_motion_action_pointer_down:
51- return "pointer_down";
52- case mir_motion_action_cancel:
53- return "cancel";
54- case mir_motion_action_pointer_up:
55- return "pointer_up";
56- case mir_motion_action_outside:
57- return "outside";
58- case mir_motion_action_hover_move:
59- return "hover_move";
60- case mir_motion_action_scroll:
61- return "scroll";
62- case mir_motion_action_hover_enter:
63- return "hover_enter";
64- case mir_motion_action_hover_exit:
65- return "hover_exit";
66+ case mir_touch_input_event_action_change:
67+ return "change";
68 default:
69 return "???";
70 }
71
72=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
73--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-02-20 10:08:31 +0000
74+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-02-20 15:57:56 +0000
75@@ -1,5 +1,5 @@
76 /*
77- * Copyright (C) 2013-2014 Canonical, Ltd.
78+ * Copyright (C) 2013-2015 Canonical, Ltd.
79 *
80 * This program is free software: you can redistribute it and/or modify it under
81 * the terms of the GNU Lesser General Public License version 3, as published by
82@@ -45,6 +45,7 @@
83
84 // Mir
85 #include <mir/geometry/rectangle.h>
86+#include <mir/events/event_builders.h>
87 #include <mir_toolkit/event.h>
88
89 namespace mg = mir::graphics;
90@@ -53,160 +54,109 @@
91
92 namespace {
93
94-bool fillInMirEvent(MirEvent &mirEvent, QKeyEvent *qtEvent)
95-{
96- mirEvent.type = mir_event_type_key;
97-
98- // don't care
99- mirEvent.key.device_id = 0;
100- mirEvent.key.source_id = 0;
101-
102- switch (qtEvent->type()) {
103- case QEvent::KeyPress:
104- mirEvent.key.action = mir_key_action_down;
105- break;
106- case QEvent::KeyRelease:
107- mirEvent.key.action = mir_key_action_up;
108- break;
109- default:
110- return false;
111- }
112-
113- // don't care
114- mirEvent.key.flags = (MirKeyFlag)0;
115-
116- mirEvent.key.modifiers = qtEvent->nativeModifiers();
117- mirEvent.key.key_code = qtEvent->nativeVirtualKey();
118- mirEvent.key.scan_code = qtEvent->nativeScanCode();
119-
120- // TODO: It's not the best that we lose the actual repeat count from
121- // the original mir event (pre QtEventFeeder)...of course it will
122- // not matter for Qt clients...so this is an improvement for now.
123- mirEvent.key.repeat_count = qtEvent->isAutoRepeat() ? 1 : 0;
124-
125- // Don't care
126- mirEvent.key.down_time = 0;
127-
128- mirEvent.key.event_time = qtEvent->timestamp() * 1000000;
129-
130- // Don't care
131- mirEvent.key.is_system_key = 0;
132-
133- return true;
134-}
135-
136-bool fillInMirEvent(MirEvent &mirEvent,
137- const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
138- Qt::TouchPointStates qtTouchPointStates,
139- ulong qtTimestamp)
140-{
141- mirEvent.type = mir_event_type_motion;
142-
143- // Hardcoding it for now
144- // TODO: Gather this info from a QTouchDevice-derived class created by QtEventFeeder
145- mirEvent.motion.device_id = 0;
146- mirEvent.motion.source_id = 0x00001002; // AINPUT_SOURCE_TOUCHSCREEN; https://bugs.launchpad.net/bugs/1311687
147-
148- // NB: it's assumed that touch points are pressed and released
149- // one at a time.
150-
151- if (qtTouchPointStates.testFlag(Qt::TouchPointPressed)) {
152- if (qtTouchPoints.count() > 1) {
153- mirEvent.motion.action = mir_motion_action_pointer_down;
154- } else {
155- mirEvent.motion.action = mir_motion_action_down;
156- }
157- } else if (qtTouchPointStates.testFlag(Qt::TouchPointReleased)) {
158- if (qtTouchPoints.count() > 1) {
159- mirEvent.motion.action = mir_motion_action_pointer_up;
160- } else {
161- mirEvent.motion.action = mir_motion_action_up;
162- }
163- } else {
164- mirEvent.motion.action = mir_motion_action_move;
165- }
166-
167- // not used
168- mirEvent.motion.flags = (MirMotionFlag) 0;
169-
170- // TODO: map QInputEvent::modifiers()
171- mirEvent.motion.modifiers = 0;
172-
173- // not used
174- mirEvent.motion.edge_flags = 0;
175-
176- // TODO
177- mirEvent.motion.button_state = (MirMotionButton) 0;
178-
179- // Does it matter?
180- mirEvent.motion.x_offset = 0.;
181- mirEvent.motion.y_offset = 0.;
182- mirEvent.motion.x_precision = 0.1;
183- mirEvent.motion.y_precision = 0.1;
184-
185- // TODO. Not useful to Qt at least...
186- mirEvent.motion.down_time = 0;
187-
188- // Note: QtEventFeeder scales the event time down, scale it back up - precision is
189- // lost but the time difference should still be accurate to milliseconds
190- mirEvent.motion.event_time = static_cast<nsecs_t>(qtTimestamp) * 1000000;
191-
192- mirEvent.motion.pointer_count = qtTouchPoints.count();
193+// Would be better if QMouseEvent had nativeModifiers
194+MirInputEventModifiers
195+getMirModifiersFromQt(Qt::KeyboardModifiers mods)
196+{
197+ MirInputEventModifiers m_mods = mir_input_event_modifier_none;
198+ if (mods & Qt::ShiftModifier)
199+ m_mods |= mir_input_event_modifier_shift;
200+ if (mods & Qt::ControlModifier)
201+ m_mods |= mir_input_event_modifier_ctrl;
202+ if (mods & Qt::AltModifier)
203+ m_mods |= mir_input_event_modifier_alt;
204+ if (mods & Qt::MetaModifier)
205+ m_mods |= mir_input_event_modifier_meta;
206+
207+ return m_mods;
208+}
209+
210+mir::EventUPtr makeMirEvent(QMouseEvent *qtEvent, MirPointerInputEventAction action)
211+{
212+ auto timestamp = qtEvent->timestamp() * 1000000;
213+ auto modifiers = getMirModifiersFromQt(qtEvent->modifiers());
214+
215+ std::vector<MirPointerInputEventButton> buttons;
216+ if (qtEvent->buttons() & Qt::LeftButton)
217+ buttons.push_back(mir_pointer_input_button_primary);
218+ if (qtEvent->buttons() & Qt::RightButton)
219+ buttons.push_back(mir_pointer_input_button_secondary);
220+ if (qtEvent->buttons() & Qt::MidButton)
221+ buttons.push_back(mir_pointer_input_button_tertiary);
222+
223+ return mir::events::make_event(0 /*DeviceID */, timestamp, modifiers, action,
224+ buttons, qtEvent->x(), qtEvent->y(), 0, 0);
225+}
226+
227+mir::EventUPtr makeMirEvent(QHoverEvent *qtEvent, MirPointerInputEventAction action)
228+{
229+ auto timestamp = qtEvent->timestamp() * 1000000;
230+
231+ std::vector<MirPointerInputEventButton> buttons;
232+
233+ return mir::events::make_event(0 /*DeviceID */, timestamp, mir_input_event_modifier_none, action,
234+ buttons, qtEvent->posF().x(), qtEvent->posF().y(), 0, 0);
235+}
236+
237+mir::EventUPtr makeMirEvent(QKeyEvent *qtEvent)
238+{
239+ MirKeyInputEventAction action = mir_key_input_event_action_down;
240+ switch (qtEvent->type())
241+ {
242+ case QEvent::KeyPress:
243+ action = mir_key_input_event_action_down;
244+ break;
245+ case QEvent::KeyRelease:
246+ action = mir_key_input_event_action_up;
247+ break;
248+ default:
249+ break;
250+ }
251+ if (qtEvent->isAutoRepeat())
252+ action = mir_key_input_event_action_repeat;
253+
254+ return mir::events::make_event(0 /* DeviceID */, qtEvent->timestamp() * 1000000,
255+ action, qtEvent->nativeVirtualKey(),
256+ qtEvent->nativeScanCode(),
257+ qtEvent->nativeModifiers());
258+}
259+
260+mir::EventUPtr makeMirEvent(Qt::KeyboardModifiers qmods,
261+ const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
262+ Qt::TouchPointStates /* qtTouchPointStates */,
263+ ulong qtTimestamp)
264+{
265+ auto modifiers = getMirModifiersFromQt(qmods);
266+ auto ev = mir::events::make_event(0, static_cast<int64_t>(qtTimestamp) * 1000000,
267+ modifiers);
268
269 for (int i = 0; i < qtTouchPoints.count(); ++i) {
270 auto touchPoint = qtTouchPoints.at(i);
271- auto &pointer = mirEvent.motion.pointer_coordinates[i];
272-
273- // FIXME: https://bugs.launchpad.net/mir/+bug/1311699
274- // When multiple touch points are transmitted with a MirEvent
275- // and one of them (only one is allowed) indicates a presse
276- // state change the index is encoded in the second byte of the
277- // action value.
278- const int mir_motion_event_pointer_index_shift = 8;
279- if (mirEvent.motion.action == mir_motion_action_pointer_up &&
280- touchPoint.state() == Qt::TouchPointReleased)
281- {
282- mirEvent.motion.action |= i << mir_motion_event_pointer_index_shift;
283- }
284- if (mirEvent.motion.action == mir_motion_action_pointer_down &&
285- touchPoint.state() == Qt::TouchPointPressed)
286- {
287- mirEvent.motion.action |= i << mir_motion_event_pointer_index_shift;
288- }
289-
290-
291- pointer.id = touchPoint.id();
292- pointer.x = touchPoint.pos().x();
293- pointer.y = touchPoint.pos().y();
294-
295- // FIXME: https://bugs.launchpad.net/mir/+bug/1311809
296-
297- if (touchPoint.rawScreenPositions().isEmpty()) {
298- pointer.raw_x = 0.;
299- pointer.raw_y = 0.;
300- } else {
301- pointer.raw_x = touchPoint.rawScreenPositions().at(0).x();
302- pointer.raw_y = touchPoint.rawScreenPositions().at(0).y();
303- }
304-
305- pointer.touch_major = touchPoint.rect().width();
306- pointer.touch_minor = touchPoint.rect().height();
307- pointer.size = 0.;
308- pointer.pressure = touchPoint.pressure();
309- pointer.orientation = 0.;
310- pointer.vscroll = 0.;
311- pointer.hscroll = 0.;
312-
313- // TODO: Mir supports a wider set of tool types (finger, stylus, mouse, eraser, unknown).
314- // so just because we are not TouchPoint::Pen does not mean we are motion_tool_type_finger...
315- // however this is the best we can do with the QtEventFeeder approach.
316+ auto id = touchPoint.id();
317+
318+ MirTouchInputEventTouchAction action = mir_touch_input_event_action_change;
319+ if (touchPoint.state() == Qt::TouchPointReleased)
320+ {
321+ action = mir_touch_input_event_action_up;
322+ }
323+ if (touchPoint.state() == Qt::TouchPointPressed)
324+ {
325+ action = mir_touch_input_event_action_down;
326+ }
327+
328+ MirTouchInputEventTouchTooltype tooltype = mir_touch_input_tool_type_finger;
329 if (touchPoint.flags() & QTouchEvent::TouchPoint::Pen)
330- pointer.tool_type = mir_motion_tool_type_stylus;
331- else
332- pointer.tool_type = mir_motion_tool_type_finger;
333+ tooltype = mir_touch_input_tool_type_stylus;
334+
335+ mir::events::add_touch(*ev, id, action, tooltype,
336+ touchPoint.pos().x(), touchPoint.pos().y(),
337+ touchPoint.pressure(),
338+ touchPoint.rect().width(),
339+ touchPoint.rect().height(),
340+ 0 /* size */);
341 }
342
343- return true;
344+ return ev;
345 }
346
347 } // namespace {
348@@ -512,18 +462,34 @@
349
350 void MirSurfaceItem::mousePressEvent(QMouseEvent *event)
351 {
352- // TODO: Implement for desktop support
353- event->ignore();
354+ if (type() == InputMethod) {
355+ // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place.
356+ if (isMouseInsideUbuntuKeyboard(event)) {
357+ auto ev = makeMirEvent(event, mir_pointer_input_event_action_button_down);
358+ m_surface->consume(*ev);
359+ event->accept();
360+ } else {
361+ event->ignore();
362+ }
363+ } else {
364+ auto ev = makeMirEvent(event, mir_pointer_input_event_action_button_down);
365+ m_surface->consume(*ev);
366+ event->accept();
367+ }
368 }
369
370 void MirSurfaceItem::mouseMoveEvent(QMouseEvent *event)
371 {
372- Q_UNUSED(event);
373+ auto ev = makeMirEvent(event, mir_pointer_input_event_action_motion);
374+ m_surface->consume(*ev);
375+ event->accept();
376 }
377
378 void MirSurfaceItem::mouseReleaseEvent(QMouseEvent *event)
379 {
380- Q_UNUSED(event);
381+ auto ev = makeMirEvent(event, mir_pointer_input_event_action_button_up);
382+ m_surface->consume(*ev);
383+ event->accept();
384 }
385
386 void MirSurfaceItem::wheelEvent(QWheelEvent *event)
387@@ -531,20 +497,39 @@
388 Q_UNUSED(event);
389 }
390
391+void MirSurfaceItem::hoverEnterEvent(QHoverEvent *event)
392+{
393+ auto ev = makeMirEvent(event, mir_pointer_input_event_action_enter);
394+ m_surface->consume(*ev);
395+ event->accept();
396+}
397+
398+void MirSurfaceItem::hoverLeaveEvent(QHoverEvent *event)
399+{
400+ auto ev = makeMirEvent(event, mir_pointer_input_event_action_leave);
401+ m_surface->consume(*ev);
402+ event->accept();
403+}
404+
405+void MirSurfaceItem::hoverMoveEvent(QHoverEvent *event)
406+{
407+ auto ev = makeMirEvent(event, mir_pointer_input_event_action_motion);
408+ m_surface->consume(*ev);
409+ event->accept();
410+}
411+
412 void MirSurfaceItem::keyPressEvent(QKeyEvent *qtEvent)
413 {
414- MirEvent mirEvent;
415- if (fillInMirEvent(mirEvent, qtEvent)) {
416- m_surface->consume(mirEvent);
417- }
418+ auto ev = makeMirEvent(qtEvent);
419+ m_surface->consume(*ev);
420+ qtEvent->accept();
421 }
422
423 void MirSurfaceItem::keyReleaseEvent(QKeyEvent *qtEvent)
424 {
425- MirEvent mirEvent;
426- if (fillInMirEvent(mirEvent, qtEvent)) {
427- m_surface->consume(mirEvent);
428- }
429+ auto ev = makeMirEvent(qtEvent);
430+ m_surface->consume(*ev);
431+ qtEvent->accept();
432 }
433
434 QString MirSurfaceItem::appId() const
435@@ -560,8 +545,6 @@
436
437 void MirSurfaceItem::endCurrentTouchSequence(ulong timestamp)
438 {
439- MirEvent mirEvent;
440-
441 Q_ASSERT(m_lastTouchEvent);
442 Q_ASSERT(m_lastTouchEvent->type != QEvent::TouchEnd);
443 Q_ASSERT(m_lastTouchEvent->touchPoints.count() > 0);
444@@ -585,10 +568,10 @@
445
446 touchEvent.updateTouchPointStatesAndType();
447
448- if (fillInMirEvent(mirEvent, touchEvent.touchPoints,
449- touchEvent.touchPointStates, touchEvent.timestamp)) {
450- m_surface->consume(mirEvent);
451- }
452+ auto ev = makeMirEvent(touchEvent.modifiers, touchEvent.touchPoints,
453+ touchEvent.touchPointStates, touchEvent.timestamp);
454+ m_surface->consume(*ev);
455+
456 *m_lastTouchEvent = touchEvent;
457
458 touchEvent.touchPoints.removeAt(0);
459@@ -597,11 +580,10 @@
460
461 void MirSurfaceItem::validateAndDeliverTouchEvent(int eventType,
462 ulong timestamp,
463+ Qt::KeyboardModifiers mods,
464 const QList<QTouchEvent::TouchPoint> &touchPoints,
465 Qt::TouchPointStates touchPointStates)
466 {
467- MirEvent mirEvent;
468-
469 if (eventType == QEvent::TouchBegin && m_lastTouchEvent && m_lastTouchEvent->type != QEvent::TouchEnd) {
470 qCWarning(QTMIR_SURFACES) << qPrintable(QString("MirSurfaceItem(%1) - Got a QEvent::TouchBegin while "
471 "there's still an active/unfinished touch sequence.").arg(appId()));
472@@ -609,9 +591,8 @@
473 endCurrentTouchSequence(timestamp);
474 }
475
476- if (fillInMirEvent(mirEvent, touchPoints, touchPointStates, timestamp)) {
477- m_surface->consume(mirEvent);
478- }
479+ auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp);
480+ m_surface->consume(*ev);
481
482 if (!m_lastTouchEvent) {
483 m_lastTouchEvent = new TouchEvent;
484@@ -626,6 +607,7 @@
485 {
486 bool accepted = processTouchEvent(event->type(),
487 event->timestamp(),
488+ event->modifiers(),
489 event->touchPoints(),
490 event->touchPointStates());
491 event->setAccepted(accepted);
492@@ -634,6 +616,7 @@
493 bool MirSurfaceItem::processTouchEvent(
494 int eventType,
495 ulong timestamp,
496+ Qt::KeyboardModifiers mods,
497 const QList<QTouchEvent::TouchPoint> &touchPoints,
498 Qt::TouchPointStates touchPointStates)
499 {
500@@ -641,7 +624,7 @@
501 if (type() == InputMethod && eventType == QEvent::TouchBegin) {
502 // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place.
503 if (hasTouchInsideUbuntuKeyboard(touchPoints)) {
504- validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates);
505+ validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates);
506 } else {
507 accepted = false;
508 }
509@@ -649,7 +632,7 @@
510 } else {
511 // NB: If we are getting QEvent::TouchUpdate or QEvent::TouchEnd it's because we've
512 // previously accepted the corresponding QEvent::TouchBegin
513- validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates);
514+ validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates);
515 }
516 return accepted;
517 }
518@@ -670,6 +653,18 @@
519 return false;
520 }
521
522+bool MirSurfaceItem::isMouseInsideUbuntuKeyboard(const QMouseEvent *event)
523+{
524+ UbuntuKeyboardInfo *ubuntuKeyboardInfo = UbuntuKeyboardInfo::instance();
525+
526+ const QPointF &pos = event->localPos();
527+
528+ return pos.x() >= ubuntuKeyboardInfo->x()
529+ && pos.x() <= (ubuntuKeyboardInfo->x() + ubuntuKeyboardInfo->width())
530+ && pos.y() >= ubuntuKeyboardInfo->y()
531+ && pos.y() <= (ubuntuKeyboardInfo->y() + ubuntuKeyboardInfo->height());
532+}
533+
534 void MirSurfaceItem::setType(const Type &type)
535 {
536 if (this->type() != type) {
537
538=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
539--- src/modules/Unity/Application/mirsurfaceitem.h 2015-02-06 09:47:21 +0000
540+++ src/modules/Unity/Application/mirsurfaceitem.h 2015-02-20 15:57:56 +0000
541@@ -1,5 +1,5 @@
542 /*
543- * Copyright (C) 2013-2014 Canonical, Ltd.
544+ * Copyright (C) 2013-2015 Canonical, Ltd.
545 *
546 * This program is free software: you can redistribute it and/or modify it under
547 * the terms of the GNU Lesser General Public License version 3, as published by
548@@ -108,6 +108,7 @@
549 // to allow easy touch event injection from tests
550 bool processTouchEvent(int eventType,
551 ulong timestamp,
552+ Qt::KeyboardModifiers modifiers,
553 const QList<QTouchEvent::TouchPoint> &touchPoints,
554 Qt::TouchPointStates touchPointStates);
555
556@@ -126,6 +127,9 @@
557 void mousePressEvent(QMouseEvent *event) override;
558 void mouseMoveEvent(QMouseEvent *event) override;
559 void mouseReleaseEvent(QMouseEvent *event) override;
560+ void hoverEnterEvent(QHoverEvent *event) override;
561+ void hoverLeaveEvent(QHoverEvent *event) override;
562+ void hoverMoveEvent(QHoverEvent *event) override;
563 void wheelEvent(QWheelEvent *event) override;
564
565 void keyPressEvent(QKeyEvent *event) override;
566@@ -158,6 +162,7 @@
567 void setSurfaceValid(const bool);
568
569 bool hasTouchInsideUbuntuKeyboard(const QList<QTouchEvent::TouchPoint> &touchPoints);
570+ bool isMouseInsideUbuntuKeyboard(const QMouseEvent *event);
571 void syncSurfaceSizeWithItemSize();
572
573 bool clientIsRunning() const;
574@@ -166,6 +171,7 @@
575 void endCurrentTouchSequence(ulong timestamp);
576 void validateAndDeliverTouchEvent(int eventType,
577 ulong timestamp,
578+ Qt::KeyboardModifiers modifiers,
579 const QList<QTouchEvent::TouchPoint> &touchPoints,
580 Qt::TouchPointStates touchPointStates);
581
582@@ -191,6 +197,7 @@
583 TouchEvent &operator= (const QTouchEvent &qtEvent) {
584 type = qtEvent.type();
585 timestamp = qtEvent.timestamp();
586+ modifiers = qtEvent.modifiers();
587 touchPoints = qtEvent.touchPoints();
588 touchPointStates = qtEvent.touchPointStates();
589 return *this;
590@@ -200,6 +207,7 @@
591
592 int type;
593 ulong timestamp;
594+ Qt::KeyboardModifiers modifiers;
595 QList<QTouchEvent::TouchPoint> touchPoints;
596 Qt::TouchPointStates touchPointStates;
597 } *m_lastTouchEvent;
598
599=== modified file 'src/platforms/mirserver/qteventfeeder.cpp'
600--- src/platforms/mirserver/qteventfeeder.cpp 2015-02-02 12:03:55 +0000
601+++ src/platforms/mirserver/qteventfeeder.cpp 2015-02-20 15:57:56 +0000
602@@ -1,5 +1,5 @@
603 /*
604- * Copyright © 2013-2014 Canonical Ltd.
605+ * Copyright © 2013-2015 Canonical Ltd.
606 *
607 * This program is free software: you can redistribute it and/or modify it under
608 * the terms of the GNU Lesser General Public License version 3, as published by
609@@ -32,13 +32,6 @@
610
611 Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input")
612
613-// from android-input AMOTION_EVENT_ACTION_*, hidden inside mir bowels
614-// mir headers should define them
615-const int QtEventFeeder::MirEventActionMask = 0xff;
616-const int QtEventFeeder::MirEventActionPointerIndexMask = 0xff00;
617-const int QtEventFeeder::MirEventActionPointerIndexShift = 8;
618-
619-
620 // XKB Keysyms which do not map directly to Qt types (i.e. Unicode points)
621 static const uint32_t KeyTable[] = {
622 XKB_KEY_Escape, Qt::Key_Escape,
623@@ -182,6 +175,15 @@
624 Q_ASSERT(!mTopLevelWindow.isNull());
625 QWindowSystemInterface::handleTouchEvent(mTopLevelWindow.data(), timestamp, device, points, mods);
626 }
627+
628+ void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) override
629+ {
630+ Q_ASSERT(!mTopLevelWindow.isNull());
631+ QWindowSystemInterface::handleMouseEvent(mTopLevelWindow.data(), timestamp, point, point, // local and global point are the same
632+ buttons, modifiers);
633+ }
634+
635+
636 private:
637 QPointer<QWindow> mTopLevelWindow;
638 };
639@@ -216,69 +218,123 @@
640
641 void QtEventFeeder::dispatch(MirEvent const& event)
642 {
643- switch (event.type) {
644- case mir_event_type_key:
645- dispatchKey(event.key);
646- break;
647- case mir_event_type_motion:
648- dispatchMotion(event.motion);
649- break;
650- case mir_event_type_surface:
651- // Just ignore these events: it doesn't make sense to pass them on.
652- break;
653+ auto type = mir_event_get_type(&event);
654+ if (type != mir_event_type_input)
655+ return;
656+ auto iev = mir_event_get_input_event(&event);
657+
658+ switch (mir_input_event_get_type(iev)) {
659+ case mir_input_event_type_key:
660+ dispatchKey(iev);
661+ break;
662+ case mir_input_event_type_touch:
663+ dispatchTouch(iev);
664+ break;
665+ case mir_input_event_type_pointer:
666+ dispatchPointer(iev);
667 default:
668- // mir_event_type_surface and mir_event_type_resize events go through
669- // mir's own protobuf channel instead of the android_input one. The latter
670- // being the one we're dealing with here.
671- qFatal("QtEventFeeder got unsupported event type from mir");
672 break;
673 }
674 }
675
676-void QtEventFeeder::dispatchKey(MirKeyEvent const& event)
677-{
678- if (!mQtWindowSystem->hasTargetWindow())
679- return;
680-
681- ulong timestamp = event.event_time / 1000000;
682- xkb_keysym_t xk_sym = static_cast<xkb_keysym_t>(event.key_code);
683+namespace
684+{
685+
686+Qt::KeyboardModifiers getQtModifiersFromMir(MirInputEventModifiers modifiers)
687+{
688+ int qtModifiers = Qt::NoModifier;
689+ if (modifiers & mir_input_event_modifier_shift) {
690+ qtModifiers |= Qt::ShiftModifier;
691+ }
692+ if (modifiers & mir_input_event_modifier_ctrl) {
693+ qtModifiers |= Qt::ControlModifier;
694+ }
695+ if (modifiers & mir_input_event_modifier_alt) {
696+ qtModifiers |= Qt::AltModifier;
697+ }
698+ if (modifiers & mir_input_event_modifier_meta) {
699+ qtModifiers |= Qt::MetaModifier;
700+ }
701+ return static_cast<Qt::KeyboardModifiers>(qtModifiers);
702+}
703+
704+Qt::MouseButton getQtMouseButtonsfromMirPointerEvent(MirPointerInputEvent const* pev)
705+{
706+ int buttons = Qt::NoButton;
707+ if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_primary))
708+ buttons |= Qt::LeftButton;
709+ if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_secondary))
710+ buttons |= Qt::RightButton;
711+ if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_tertiary))
712+ buttons |= Qt::MidButton;
713+
714+ // TODO: Should mir back and forward buttons exist?
715+ // should they be Qt::X button 1 and 2?
716+ return static_cast<Qt::MouseButton>(buttons);
717+}
718+}
719+
720+void QtEventFeeder::dispatchPointer(MirInputEvent const* ev)
721+{
722+ if (!mQtWindowSystem->hasTargetWindow())
723+ return;
724+
725+ auto timestamp = mir_input_event_get_event_time(ev) / 1000000;
726+
727+ auto pev = mir_input_event_get_pointer_input_event(ev);
728+ auto modifiers = getQtModifiersFromMir(mir_pointer_input_event_get_modifiers(pev));
729+ auto buttons = getQtMouseButtonsfromMirPointerEvent(pev);
730+
731+ auto local_point = QPointF(mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_x),
732+ mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_y));
733+
734+ mQtWindowSystem->handleMouseEvent(timestamp, local_point,
735+ buttons, modifiers);
736+}
737+
738+void QtEventFeeder::dispatchKey(MirInputEvent const* event)
739+{
740+ if (!mQtWindowSystem->hasTargetWindow())
741+ return;
742+
743+ ulong timestamp = mir_input_event_get_event_time(event) / 1000000;
744+
745+ auto kev = mir_input_event_get_key_input_event(event);
746+ xkb_keysym_t xk_sym = mir_key_input_event_get_key_code(kev);
747
748 // Key modifier and unicode index mapping.
749- const int kEventModifiers = event.modifiers;
750- Qt::KeyboardModifiers modifiers = Qt::NoModifier;
751- if (kEventModifiers & mir_key_modifier_shift) {
752- modifiers |= Qt::ShiftModifier;
753- }
754- if (kEventModifiers & mir_key_modifier_ctrl) {
755- modifiers |= Qt::ControlModifier;
756- }
757- if (kEventModifiers & mir_key_modifier_alt) {
758- modifiers |= Qt::AltModifier;
759- }
760- if (kEventModifiers & mir_key_modifier_meta) {
761- modifiers |= Qt::MetaModifier;
762- }
763+ auto modifiers = getQtModifiersFromMir(mir_key_input_event_get_modifiers(kev));
764
765 // Key action
766- QEvent::Type keyType;
767- if (event.action == mir_key_action_down) {
768+ QEvent::Type keyType = QEvent::KeyRelease;
769+ bool is_auto_rep = false;
770+
771+ switch (mir_key_input_event_get_action(kev))
772+ {
773+ case mir_key_input_event_action_repeat:
774+ is_auto_rep = true; // fall-through
775+ case mir_key_input_event_action_down:
776 keyType = QEvent::KeyPress;
777- } else {
778+ break;
779+ case mir_key_input_event_action_up:
780 keyType = QEvent::KeyRelease;
781+ break;
782+ default:
783+ break;
784 }
785
786 // Key event propagation.
787 char s[2];
788 int keyCode = translateKeysym(xk_sym, s, sizeof(s));
789 QString text = QString::fromLatin1(s);
790-
791- bool is_auto_rep = event.repeat_count > 0;
792
793 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();
794 if (context) {
795 // TODO: consider event.repeat_count
796 QKeyEvent qKeyEvent(keyType, keyCode, modifiers,
797- event.scan_code, event.key_code, event.modifiers,
798+ mir_key_input_event_get_scan_code(kev),
799+ mir_key_input_event_get_key_code(kev),
800+ mir_key_input_event_get_modifiers(kev),
801 text, is_auto_rep);
802 qKeyEvent.setTimestamp(timestamp);
803 if (context->filterEvent(&qKeyEvent)) {
804@@ -288,27 +344,17 @@
805 }
806
807 mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers,
808- event.scan_code, event.key_code, event.modifiers, text, is_auto_rep);
809+ mir_key_input_event_get_scan_code(kev),
810+ mir_key_input_event_get_key_code(kev),
811+ mir_key_input_event_get_modifiers(kev), text, is_auto_rep);
812 }
813
814-void QtEventFeeder::dispatchMotion(MirMotionEvent const& event)
815+void QtEventFeeder::dispatchTouch(MirInputEvent const* event)
816 {
817 if (!mQtWindowSystem->hasTargetWindow())
818 return;
819
820- const int mirMotionAction = event.action & MirEventActionMask;
821-
822- // Ignore the events that do not interest us (or that we currently don't support or know
823- // how to translate into Qt events)
824- if (mirMotionAction != mir_motion_action_move
825- && mirMotionAction != mir_motion_action_down
826- && mirMotionAction != mir_motion_action_up
827- && mirMotionAction != mir_motion_action_pointer_down
828- && mirMotionAction != mir_motion_action_pointer_up
829- && mirMotionAction != mir_motion_action_cancel) {
830- return;
831- }
832-
833+ auto tev = mir_input_event_get_touch_input_event(event);
834
835 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That
836 // needs to be fixed as soon as the compat input lib adds query support.
837@@ -318,72 +364,48 @@
838
839 // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left
840 // as Qt::TouchPointMoved
841- const int kPointerCount = (int) event.pointer_count;
842+ const int kPointerCount = mir_touch_input_event_get_touch_count(tev);
843 for (int i = 0; i < kPointerCount; ++i) {
844 QWindowSystemInterface::TouchPoint touchPoint;
845
846- const float kX = event.pointer_coordinates[i].x;
847- const float kY = event.pointer_coordinates[i].y;
848- const float kW = event.pointer_coordinates[i].touch_major;
849- const float kH = event.pointer_coordinates[i].touch_minor;
850- const float kP = event.pointer_coordinates[i].pressure;
851- touchPoint.id = event.pointer_coordinates[i].id;
852+ const float kX = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_x);
853+ const float kY = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_y);
854+ const float kW = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_touch_major);
855+ const float kH = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_touch_minor);
856+ const float kP = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_pressure);
857+ touchPoint.id = mir_touch_input_event_get_touch_id(tev, i);
858+
859 touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height());
860 touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH);
861 touchPoint.pressure = kP / kMaxPressure;
862- touchPoint.state = Qt::TouchPointMoved;
863+ switch (mir_touch_input_event_get_touch_action(tev, i))
864+ {
865+ case mir_touch_input_event_action_up:
866+ touchPoint.state = Qt::TouchPointReleased;
867+ break;
868+ case mir_touch_input_event_action_down:
869+ touchPoint.state = Qt::TouchPointPressed;
870+ break;
871+ case mir_touch_input_event_action_change:
872+ touchPoint.state = Qt::TouchPointMoved;
873+ break;
874+ default:
875+ break;
876+ }
877
878 touchPoints.append(touchPoint);
879 }
880
881- switch (mirMotionAction) {
882- case mir_motion_action_move:
883- // No extra work needed.
884- break;
885-
886- case mir_motion_action_down:
887- // NB: hardcoded index 0 because there's only a single touch point in this case
888- touchPoints[0].state = Qt::TouchPointPressed;
889- break;
890-
891- case mir_motion_action_up:
892- touchPoints[0].state = Qt::TouchPointReleased;
893- break;
894-
895- case mir_motion_action_pointer_down: {
896- const int index = (event.action & MirEventActionPointerIndexMask) >>
897- MirEventActionPointerIndexShift;
898- touchPoints[index].state = Qt::TouchPointPressed;
899- break;
900- }
901-
902- case mir_motion_action_cancel:
903- case mir_motion_action_pointer_up: {
904- const int index = (event.action & MirEventActionPointerIndexMask) >>
905- MirEventActionPointerIndexShift;
906- touchPoints[index].state = Qt::TouchPointReleased;
907- break;
908- }
909-
910- case mir_motion_action_outside:
911- case mir_motion_action_hover_move:
912- case mir_motion_action_scroll:
913- case mir_motion_action_hover_enter:
914- case mir_motion_action_hover_exit:
915- default:
916- // Should never reach this point. If so, it's a programming error.
917- qFatal("Trying to handle unsupported motion event action");
918- }
919-
920 // Qt needs a happy, sane stream of touch events. So let's make sure we're not forwarding
921 // any insanity.
922 validateTouches(touchPoints);
923
924 // Touch event propagation.
925 mQtWindowSystem->handleTouchEvent(
926- event.event_time / 1000000, //scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable
927- mTouchDevice,
928- touchPoints);
929+ //scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable
930+ mir_input_event_get_event_time(event) / 1000000,
931+ mTouchDevice,
932+ touchPoints);
933 }
934
935 void QtEventFeeder::start()
936
937=== modified file 'src/platforms/mirserver/qteventfeeder.h'
938--- src/platforms/mirserver/qteventfeeder.h 2015-02-02 12:03:55 +0000
939+++ src/platforms/mirserver/qteventfeeder.h 2015-02-20 15:57:56 +0000
940@@ -1,5 +1,5 @@
941 /*
942- * Copyright (C) 2013-2014 Canonical, Ltd.
943+ * Copyright (C) 2013-2015 Canonical, Ltd.
944 *
945 * This program is free software: you can redistribute it and/or modify it under
946 * the terms of the GNU Lesser General Public License version 3, as published by
947@@ -51,6 +51,7 @@
948 virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device,
949 const QList<struct QWindowSystemInterface::TouchPoint> &points,
950 Qt::KeyboardModifiers mods = Qt::NoModifier) = 0;
951+ virtual void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) = 0;
952 };
953
954 QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr);
955@@ -67,8 +68,9 @@
956 void stop() override;
957
958 private:
959- void dispatchKey(MirKeyEvent const& event);
960- void dispatchMotion(MirMotionEvent const& event);
961+ void dispatchKey(MirInputEvent const* event);
962+ void dispatchTouch(MirInputEvent const* event);
963+ void dispatchPointer(MirInputEvent const* event);
964 void validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints);
965 bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint);
966
967
968=== modified file 'tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h'
969--- tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2014-08-28 12:20:13 +0000
970+++ tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2015-02-20 15:57:56 +0000
971@@ -1,5 +1,5 @@
972 /*
973- * Copyright (C) 2014 Canonical, Ltd.
974+ * Copyright (C) 2014-2015 Canonical, Ltd.
975 *
976 * This program is free software: you can redistribute it and/or modify it under
977 * the terms of the GNU Lesser General Public License version 3, as published by
978@@ -34,6 +34,7 @@
979 MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device,
980 const QList<struct QWindowSystemInterface::TouchPoint> &points,
981 Qt::KeyboardModifiers mods));
982+ MOCK_METHOD4(handleMouseEvent, void(ulong, QPointF, Qt::MouseButton, Qt::KeyboardModifiers));
983 };
984
985 namespace testing
986
987=== modified file 'tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp'
988--- tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2014-08-28 13:12:30 +0000
989+++ tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2015-02-20 15:57:56 +0000
990@@ -1,5 +1,5 @@
991 /*
992- * Copyright (C) 2014 Canonical, Ltd.
993+ * Copyright (C) 2014-2015 Canonical, Ltd.
994 *
995 * This program is free software: you can redistribute it and/or modify it under
996 * the terms of the GNU Lesser General Public License version 3, as published by
997@@ -15,6 +15,8 @@
998 *
999 */
1000
1001+#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
1002+
1003 #include <gmock/gmock.h>
1004 #include <gtest/gtest.h>
1005
1006@@ -191,34 +193,3 @@
1007 ASSERT_TRUE(Mock::VerifyAndClearExpectations(mockWindowSystem));
1008 }
1009
1010-TEST_F(QtEventFeederTest, IgnoreHovering)
1011-{
1012- setIrrelevantMockWindowSystemExpectations();
1013- EXPECT_CALL(*mockWindowSystem, handleTouchEvent(_,_,_,_)).Times(0);
1014-
1015- MirEvent mirEvent;
1016- mirEvent.type = mir_event_type_motion;
1017- mirEvent.motion.pointer_count = 1;
1018- mirEvent.motion.pointer_coordinates[0].id = 0;
1019- mirEvent.motion.pointer_coordinates[0].x = 10;
1020- mirEvent.motion.pointer_coordinates[0].y = 10;
1021- mirEvent.motion.pointer_coordinates[0].touch_major = 1;
1022- mirEvent.motion.pointer_coordinates[0].touch_minor = 1;
1023- mirEvent.motion.pointer_coordinates[0].pressure = 10;
1024- mirEvent.motion.action = mir_motion_action_hover_enter;
1025- mirEvent.motion.event_time = 123 * 1000000;
1026-
1027- qtEventFeeder->dispatch(mirEvent);
1028-
1029- mirEvent.motion.pointer_coordinates[0].x = 20;
1030- mirEvent.motion.pointer_coordinates[0].y = 20;
1031- mirEvent.motion.action = mir_motion_action_hover_move;
1032- mirEvent.motion.event_time = 125 * 1000000;
1033-
1034- qtEventFeeder->dispatch(mirEvent);
1035-
1036- mirEvent.motion.action = mir_motion_action_hover_exit;
1037- mirEvent.motion.event_time = 127 * 1000000;
1038-
1039- qtEventFeeder->dispatch(mirEvent);
1040-}
1041
1042=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
1043--- tests/modules/ApplicationManager/application_manager_test.cpp 2015-01-27 12:13:48 +0000
1044+++ tests/modules/ApplicationManager/application_manager_test.cpp 2015-02-20 15:57:56 +0000
1045@@ -15,6 +15,8 @@
1046 *
1047 */
1048
1049+#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
1050+
1051 #include <thread>
1052 #include <condition_variable>
1053 #include <QSignalSpy>
1054
1055=== modified file 'tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp'
1056--- tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 2015-02-06 09:47:21 +0000
1057+++ tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 2015-02-20 15:57:56 +0000
1058@@ -1,5 +1,5 @@
1059 /*
1060- * Copyright (C) 2014 Canonical, Ltd.
1061+ * Copyright (C) 2014-2015 Canonical, Ltd.
1062 *
1063 * This program is free software: you can redistribute it and/or modify it under
1064 * the terms of the GNU Lesser General Public License version 3, as published by
1065@@ -15,6 +15,8 @@
1066 *
1067 */
1068
1069+#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
1070+
1071 #include <gtest/gtest.h>
1072
1073 #include <QLoggingCategory>
1074@@ -60,29 +62,43 @@
1075 EXPECT_CALL(*mockSurface, type()).Times(AnyNumber()).WillRepeatedly(Return(mir_surface_type_normal));
1076 EXPECT_CALL(*mockSession, setSurface(_)).Times(AnyNumber());
1077
1078+ auto getTouchEvent = [](MirEvent const& event) -> MirTouchInputEvent const*
1079+ {
1080+ if (mir_event_get_type(&event) != mir_event_type_input)
1081+ return nullptr;
1082+ auto const* input_event = mir_event_get_input_event(&event);
1083+ if (mir_input_event_get_type(input_event) != mir_input_event_type_touch)
1084+ return nullptr;
1085+ return mir_input_event_get_touch_input_event(input_event);
1086+ };
1087+
1088+ auto eventMatches = [&](MirEvent const& event,
1089+ int touch_count,
1090+ MirTouchInputEventTouchAction action,
1091+ MirTouchInputEventTouchId touch_id) ->void
1092+ {
1093+ auto const* touch_event = getTouchEvent(event);
1094+ ASSERT_NE(touch_event, nullptr);
1095+ ASSERT_EQ(touch_count, mir_touch_input_event_get_touch_count(touch_event));
1096+ ASSERT_EQ(action, mir_touch_input_event_get_touch_action(touch_event,0));
1097+ ASSERT_EQ(touch_id, mir_touch_input_event_get_touch_id(touch_event,0));
1098+ };
1099+
1100 // The touch event sequence we expect mir::input::surface to receive from MirSurfaceItem.
1101 // It should properly finish the sequence for touch 0 ('down', 'move' and 'up') before starting
1102 // the sequence for touch 1.
1103 EXPECT_CALL(*mockSurface, consume(_))
1104- .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1105- ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action);
1106- ASSERT_EQ(1, mirEvent.motion.pointer_count);
1107- ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);
1108- }))
1109- .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1110- ASSERT_EQ(mir_motion_action_move, mirEvent.motion.action);
1111- ASSERT_EQ(1, mirEvent.motion.pointer_count);
1112- ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);
1113- }))
1114- .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1115- ASSERT_EQ(mir_motion_action_up, mirEvent.motion.action);
1116- ASSERT_EQ(1, mirEvent.motion.pointer_count);
1117- ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);
1118- }))
1119- .WillOnce(Invoke([] (MirEvent const& mirEvent) {
1120- ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action);
1121- ASSERT_EQ(1, mirEvent.motion.pointer_count);
1122- ASSERT_EQ(1, mirEvent.motion.pointer_coordinates[0].id);
1123+ .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
1124+ eventMatches(mirEvent, 1, mir_touch_input_event_action_down, 0);
1125+ }))
1126+ .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
1127+ eventMatches(mirEvent, 1, mir_touch_input_event_action_change, 0);
1128+ }))
1129+ .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
1130+ eventMatches(mirEvent, 1, mir_touch_input_event_action_up, 0);
1131+ }))
1132+ .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
1133+ eventMatches(mirEvent, 1, mir_touch_input_event_action_down, 1);
1134 }));
1135
1136
1137@@ -95,19 +111,19 @@
1138 touchPoints[0].setId(0);
1139 touchPoints[0].setState(Qt::TouchPointPressed);
1140 surfaceItem->processTouchEvent(QEvent::TouchBegin,
1141- timestamp, touchPoints, touchPoints[0].state());
1142+ timestamp, Qt::NoModifier, touchPoints, touchPoints[0].state());
1143
1144 touchPoints[0].setState(Qt::TouchPointMoved);
1145 surfaceItem->processTouchEvent(QEvent::TouchUpdate,
1146- timestamp + 10, touchPoints, touchPoints[0].state());
1147+ timestamp + 10, Qt::NoModifier, touchPoints, touchPoints[0].state());
1148
1149 // Starting a new touch sequence (with touch 1) without ending the current one
1150 // (wich has touch 0).
1151 touchPoints[0].setId(1);
1152 touchPoints[0].setState(Qt::TouchPointPressed);
1153 surfaceItem->processTouchEvent(QEvent::TouchBegin,
1154- timestamp + 20, touchPoints, touchPoints[0].state());
1155-
1156+ timestamp + 20, Qt::NoModifier, touchPoints, touchPoints[0].state());
1157+
1158 delete surfaceItem;
1159 delete mockSession;
1160 }

Subscribers

People subscribed via source and target branches