Merge lp:~mir-team/qtmir/port-to-msh-shell-and-mirevent2 into lp:qtmir

Proposed by kevin gunn
Status: Work in progress
Proposed branch: lp:~mir-team/qtmir/port-to-msh-shell-and-mirevent2
Merge into: lp:qtmir
Diff against target: 2466 lines (+813/-771)
38 files modified
CMakeLists.txt (+1/-0)
debian/changelog (+6/-0)
debian/control (+3/-3)
src/common/debughelpers.cpp (+7/-23)
src/modules/Unity/Application/application.cpp (+9/-7)
src/modules/Unity/Application/application.h (+4/-15)
src/modules/Unity/Application/application_manager.cpp (+3/-32)
src/modules/Unity/Application/desktopfilereader.cpp (+96/-0)
src/modules/Unity/Application/desktopfilereader.h (+5/-0)
src/modules/Unity/Application/mirsurfaceitem.cpp (+140/-211)
src/modules/Unity/Application/mirsurfaceitem.h (+25/-5)
src/modules/Unity/Application/mirsurfacemanager.cpp (+5/-5)
src/modules/Unity/Application/plugin.cpp (+1/-0)
src/modules/Unity/Application/sessionmanager.cpp (+1/-1)
src/platforms/mirserver/CMakeLists.txt (+1/-3)
src/platforms/mirserver/focussetter.cpp (+0/-24)
src/platforms/mirserver/focussetter.h (+0/-28)
src/platforms/mirserver/mirplacementstrategy.cpp (+0/-59)
src/platforms/mirserver/mirplacementstrategy.h (+0/-42)
src/platforms/mirserver/mirserver.cpp (+13/-20)
src/platforms/mirserver/mirserver.h (+4/-3)
src/platforms/mirserver/mirshell.cpp (+75/-0)
src/platforms/mirserver/mirshell.h (+56/-0)
src/platforms/mirserver/nativeinterface.cpp (+2/-2)
src/platforms/mirserver/qteventfeeder.cpp (+137/-113)
src/platforms/mirserver/qteventfeeder.h (+6/-4)
src/platforms/mirserver/surfaceconfigurator.cpp (+0/-34)
src/platforms/mirserver/surfaceconfigurator.h (+0/-41)
tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h (+1/-0)
tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp (+2/-31)
tests/modules/ApplicationManager/application_manager_test.cpp (+99/-0)
tests/modules/DesktopFileReader/desktopfilereader_test.cpp (+70/-0)
tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp (+38/-22)
tests/modules/common/mock_focus_controller.h (+0/-40)
tests/modules/common/mock_mir_session.h (+1/-0)
tests/modules/common/mock_renderable.h (+0/-2)
tests/modules/common/mock_surface.h (+2/-0)
tests/modules/common/qtmir_test.h (+0/-1)
To merge this branch: bzr merge lp:~mir-team/qtmir/port-to-msh-shell-and-mirevent2
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+248433@code.launchpad.net

Commit message

merge of qtmir port to shell and mirevent2

Description of the change

merge of qtmir port to shell and mirevent2

To post a comment you must log in.
320. By Andreas Pokorny

merged daniels branch into this one

321. By kevin gunn

fix typo

322. By Andreas Pokorny

duplicate mock entry oO

323. By Andreas Pokorny

fix test cases

324. By kevin gunn

added mirsurfaceattribute to the qtmir application

Unmerged revisions

324. By kevin gunn

added mirsurfaceattribute to the qtmir application

323. By Andreas Pokorny

fix test cases

322. By Andreas Pokorny

duplicate mock entry oO

321. By kevin gunn

fix typo

320. By Andreas Pokorny

merged daniels branch into this one

319. By kevin gunn

merge port to shell and mir event

318. By Robert Carr

Finish touch-event-support

317. By Robert Carr

Implement touch mods

316. By Robert Carr

Typo

315. By Robert Carr

Update to use chrono

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-12-09 14:12:57 +0000
+++ CMakeLists.txt 2015-02-05 10:26:37 +0000
@@ -78,6 +78,7 @@
78pkg_check_modules(GIO_UNIX gio-unix-2.0)78pkg_check_modules(GIO_UNIX gio-unix-2.0)
79pkg_check_modules(LTTNG lttng-ust)79pkg_check_modules(LTTNG lttng-ust)
8080
81add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1)
8182
82# We expect this to be set via debian/rules for GLES builds83# We expect this to be set via debian/rules for GLES builds
83if ("${USE_OPENGLES}" STREQUAL 1)84if ("${USE_OPENGLES}" STREQUAL 1)
8485
=== modified file 'debian/changelog'
--- debian/changelog 2015-01-15 15:19:46 +0000
+++ debian/changelog 2015-02-05 10:26:37 +0000
@@ -1,3 +1,9 @@
1qtmir (0.4.5) UNRELEASED; urgency=medium
2
3 * Add X-Ubuntu-Supported-Orientations desktop file entry
4
5 -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 31 Oct 2014 10:17:42 -0200
6
1qtmir (0.4.4+15.04.20150115-0ubuntu1) vivid; urgency=low7qtmir (0.4.4+15.04.20150115-0ubuntu1) vivid; urgency=low
28
3 [ Gerry Boland ]9 [ Gerry Boland ]
410
=== modified file 'debian/control'
--- debian/control 2015-01-14 09:07:31 +0000
+++ debian/control 2015-02-05 10:26:37 +0000
@@ -10,7 +10,7 @@
10# version. To allow cross-compiling to work, we also must10# version. To allow cross-compiling to work, we also must
11# append :native to g++-4.9 so we don't try to run armhf g++11# append :native to g++-4.9 so we don't try to run armhf g++
12# on an x86 CPU for example, when cross-compiling.12# on an x86 CPU for example, when cross-compiling.
13 g++-4.9:native,13 g++-4.9,
14 google-mock (>= 1.6.0+svn437),14 google-mock (>= 1.6.0+svn437),
15 libboost-system-dev,15 libboost-system-dev,
16 libfontconfig1-dev,16 libfontconfig1-dev,
@@ -26,7 +26,7 @@
26 libubuntu-app-launch2-dev,26 libubuntu-app-launch2-dev,
27 libubuntu-application-api-dev (>= 2.1.0),27 libubuntu-application-api-dev (>= 2.1.0),
28 libudev-dev,28 libudev-dev,
29 libunity-api-dev (>= 7.92),29 libunity-api-dev (>= 7.94),
30 liburl-dispatcher1-dev,30 liburl-dispatcher1-dev,
31 libxkbcommon-dev,31 libxkbcommon-dev,
32 libxrender-dev,32 libxrender-dev,
@@ -96,7 +96,7 @@
96Conflicts: libqtmir,96Conflicts: libqtmir,
97 libunity-mir1,97 libunity-mir1,
98Provides: unity-application-impl,98Provides: unity-application-impl,
99 unity-application-impl-4,99 unity-application-impl-5,
100Description: Qt plugin for Unity specific Mir APIs100Description: Qt plugin for Unity specific Mir APIs
101 QtMir provides Qt/QML bindings for Mir features that are exposed through the101 QtMir provides Qt/QML bindings for Mir features that are exposed through the
102 qtmir-desktop or qtmir-android QPA plugin such as Application management102 qtmir-desktop or qtmir-android QPA plugin such as Application management
103103
=== modified file 'src/common/debughelpers.cpp'
--- src/common/debughelpers.cpp 2014-08-27 11:51:28 +0000
+++ src/common/debughelpers.cpp 2015-02-05 10:26:37 +0000
@@ -176,31 +176,15 @@
176 }176 }
177}177}
178178
179const char *mirMotionActionToStr(int value)179const char *mirTouchActionToStr(MirTouchInputEventTouchAction action)
180{180{
181 switch (value) {181 switch (action) {
182 case mir_motion_action_move:182 case mir_touch_input_event_action_up:
183 return "move";183 return "up";
184 case mir_motion_action_down:184 case mir_touch_input_event_action_down:
185 return "down";185 return "down";
186 case mir_motion_action_up:186 case mir_touch_input_event_action_change:
187 return "up";187 return "change";
188 case mir_motion_action_pointer_down:
189 return "pointer_down";
190 case mir_motion_action_cancel:
191 return "cancel";
192 case mir_motion_action_pointer_up:
193 return "pointer_up";
194 case mir_motion_action_outside:
195 return "outside";
196 case mir_motion_action_hover_move:
197 return "hover_move";
198 case mir_motion_action_scroll:
199 return "scroll";
200 case mir_motion_action_hover_enter:
201 return "hover_enter";
202 case mir_motion_action_hover_exit:
203 return "hover_exit";
204 default:188 default:
205 return "???";189 return "???";
206 }190 }
207191
=== modified file 'src/modules/Unity/Application/application.cpp'
--- src/modules/Unity/Application/application.cpp 2015-01-08 12:35:41 +0000
+++ src/modules/Unity/Application/application.cpp 2015-02-05 10:26:37 +0000
@@ -60,12 +60,9 @@
60 // FIXME(greyback) need to save long appId internally until ubuntu-app-launch can hide it from us60 // FIXME(greyback) need to save long appId internally until ubuntu-app-launch can hide it from us
61 m_longAppId = desktopFileReader->file().remove(QRegExp(".desktop$")).split('/').last();61 m_longAppId = desktopFileReader->file().remove(QRegExp(".desktop$")).split('/').last();
6262
63 // FIXME: This is a hack. Remove once we have a real implementation for knowing the supported63 m_supportedOrientations = m_desktopData->supportedOrientations();
64 // orientations of an app64
65 m_supportedOrientations = PortraitOrientation65 m_rotatesWindowContents = m_desktopData->rotatesWindowContents();
66 | LandscapeOrientation
67 | InvertedPortraitOrientation
68 | InvertedLandscapeOrientation;
69}66}
7067
71Application::~Application()68Application::~Application()
@@ -353,11 +350,16 @@
353 return m_longAppId;350 return m_longAppId;
354}351}
355352
356Application::SupportedOrientations Application::supportedOrientations() const353Qt::ScreenOrientations Application::supportedOrientations() const
357{354{
358 return m_supportedOrientations;355 return m_supportedOrientations;
359}356}
360357
358bool Application::rotatesWindowContents() const
359{
360 return m_rotatesWindowContents;
361}
362
361Session* Application::session() const363Session* Application::session() const
362{364{
363 return m_session;365 return m_session;
364366
=== modified file 'src/modules/Unity/Application/application.h'
--- src/modules/Unity/Application/application.h 2015-01-08 12:35:41 +0000
+++ src/modules/Unity/Application/application.h 2015-02-05 10:26:37 +0000
@@ -47,27 +47,15 @@
47{47{
48 Q_OBJECT48 Q_OBJECT
4949
50 Q_FLAGS(Orientation SupportedOrientations)
51
52 Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT)50 Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT)
53 Q_PROPERTY(QString exec READ exec CONSTANT)51 Q_PROPERTY(QString exec READ exec CONSTANT)
54 Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)52 Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
55 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)53 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
56 Q_PROPERTY(SupportedOrientations supportedOrientations READ supportedOrientations CONSTANT)
57 Q_PROPERTY(Session* session READ session NOTIFY sessionChanged DESIGNABLE false)54 Q_PROPERTY(Session* session READ session NOTIFY sessionChanged DESIGNABLE false)
5855
59public:56public:
60 Q_DECLARE_FLAGS(Stages, Stage)57 Q_DECLARE_FLAGS(Stages, Stage)
6158
62 // Matching Qt::ScreenOrientation values for convenience
63 enum Orientation {
64 PortraitOrientation = 0x1,
65 LandscapeOrientation = 0x2,
66 InvertedPortraitOrientation = 0x4,
67 InvertedLandscapeOrientation = 0x8
68 };
69 Q_DECLARE_FLAGS(SupportedOrientations, Orientation)
70
71 Application(const QSharedPointer<TaskController>& taskController,59 Application(const QSharedPointer<TaskController>& taskController,
72 const QSharedPointer<SharedWakelock>& sharedWakelock,60 const QSharedPointer<SharedWakelock>& sharedWakelock,
73 DesktopFileReader *desktopFileReader,61 DesktopFileReader *desktopFileReader,
@@ -90,6 +78,8 @@
90 QColor splashColor() const override;78 QColor splashColor() const override;
91 QColor splashColorHeader() const override;79 QColor splashColorHeader() const override;
92 QColor splashColorFooter() const override;80 QColor splashColorFooter() const override;
81 Qt::ScreenOrientations supportedOrientations() const override;
82 bool rotatesWindowContents() const override;
9383
94 void setStage(Stage stage);84 void setStage(Stage stage);
95 void setState(State state);85 void setState(State state);
@@ -105,7 +95,6 @@
105 bool fullscreen() const;95 bool fullscreen() const;
10696
107 Stages supportedStages() const;97 Stages supportedStages() const;
108 SupportedOrientations supportedOrientations() const;
10998
110 pid_t pid() const;99 pid_t pid() const;
111100
@@ -140,7 +129,8 @@
140 bool m_focused;129 bool m_focused;
141 bool m_canBeResumed;130 bool m_canBeResumed;
142 QStringList m_arguments;131 QStringList m_arguments;
143 SupportedOrientations m_supportedOrientations;132 Qt::ScreenOrientations m_supportedOrientations;
133 bool m_rotatesWindowContents;
144 Session *m_session;134 Session *m_session;
145135
146 friend class ApplicationManager;136 friend class ApplicationManager;
@@ -151,6 +141,5 @@
151} // namespace qtmir141} // namespace qtmir
152142
153Q_DECLARE_METATYPE(qtmir::Application*)143Q_DECLARE_METATYPE(qtmir::Application*)
154Q_DECLARE_OPERATORS_FOR_FLAGS(qtmir::Application::SupportedOrientations)
155144
156#endif // APPLICATION_H145#endif // APPLICATION_H
157146
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2015-01-07 17:56:07 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2015-02-05 10:26:37 +0000
@@ -61,33 +61,6 @@
6161
62namespace {62namespace {
6363
64// FIXME: AppManager should not implement policy based on display geometry, shell should do that
65bool forceAllAppsIntoMainStage(const QSharedPointer<MirServer> &mirServer)
66{
67 const int tabletModeMinimimWithGU = 100;
68
69 // Obtain display size
70 mir::geometry::Rectangles view_area;
71 mirServer->the_display()->for_each_display_buffer(
72 [&view_area](const mir::graphics::DisplayBuffer & db)
73 {
74 view_area.add(db.view_area());
75 });
76
77 // Get current Grid Unit value
78 int gridUnitPx = 8;
79 QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
80 if (!gridUnitString.isEmpty()) {
81 bool ok;
82 int value = gridUnitString.toInt(&ok);
83 if (ok) {
84 gridUnitPx = value;
85 }
86 }
87
88 return (view_area.bounding_rectangle().size.width.as_int() < tabletModeMinimimWithGU * gridUnitPx);
89}
90
91// FIXME: To be removed once shell has fully adopted short appIds!!64// FIXME: To be removed once shell has fully adopted short appIds!!
92QString toShortAppIdIfPossible(const QString &appId) {65QString toShortAppIdIfPossible(const QString &appId) {
93 QRegExp longAppIdMask("[a-z0-9][a-z0-9+.-]+_[a-zA-Z0-9+.-]+_[0-9][a-zA-Z0-9.+:~-]*");66 QRegExp longAppIdMask("[a-z0-9][a-z0-9+.-]+_[a-zA-Z0-9+.-]+_[0-9][a-zA-Z0-9.+:~-]*");
@@ -413,7 +386,9 @@
413 if (m_focusedApplication) {386 if (m_focusedApplication) {
414 m_focusedApplication->setFocused(false);387 m_focusedApplication->setFocused(false);
415 Application *lastApplication = applicationForStage(application->stage());388 Application *lastApplication = applicationForStage(application->stage());
416 suspendApplication(lastApplication);389 if (lastApplication != application) {
390 suspendApplication(lastApplication);
391 }
417 }392 }
418393
419 if (application->stage() == Application::MainStage) {394 if (application->stage() == Application::MainStage) {
@@ -539,10 +514,6 @@
539 return;514 return;
540 }515 }
541516
542 // override stage if necessary (i.e. side stage invalid on phone)
543 if (application->stage() == Application::SideStage && forceAllAppsIntoMainStage(m_mirServer))
544 application->setStage(Application::MainStage);
545
546 add(application);517 add(application);
547 Q_EMIT focusRequested(appId);518 Q_EMIT focusRequested(appId);
548 }519 }
549520
=== modified file 'src/modules/Unity/Application/desktopfilereader.cpp'
--- src/modules/Unity/Application/desktopfilereader.cpp 2014-10-07 13:43:17 +0000
+++ src/modules/Unity/Application/desktopfilereader.cpp 2015-02-05 10:26:37 +0000
@@ -68,6 +68,8 @@
68 : d_ptr(new DesktopFileReaderPrivate(this))68 : d_ptr(new DesktopFileReaderPrivate(this))
69{69{
70 Q_D(DesktopFileReader);70 Q_D(DesktopFileReader);
71 qCDebug(QTMIR_APPLICATIONS) << "Loading desktop file" << desktopFile.absoluteFilePath()
72 << "for appId" << appId;
7173
72 d->appId = appId;74 d->appId = appId;
73 d->file = desktopFile.absoluteFilePath();75 d->file = desktopFile.absoluteFilePath();
@@ -202,6 +204,100 @@
202 return d->getKey("X-Ubuntu-Splash-Color-Footer");204 return d->getKey("X-Ubuntu-Splash-Color-Footer");
203}205}
204206
207Qt::ScreenOrientations DesktopFileReader::supportedOrientations() const
208{
209 Q_D(const DesktopFileReader);
210 Qt::ScreenOrientations result;
211
212 if (!parseOrientations(d->getKey("X-Ubuntu-Supported-Orientations"), result)) {
213 qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Supported-Orientations entry.";
214 }
215
216 return result;
217}
218
219bool DesktopFileReader::rotatesWindowContents() const
220{
221 Q_D(const DesktopFileReader);
222 bool result;
223
224 if (!parseBoolean(d->getKey("X-Ubuntu-Rotates-Window-Contents"), result)) {
225 qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Rotates-Window-Contents entry.";
226 }
227
228 return result;
229}
230
231bool DesktopFileReader::parseOrientations(const QString &rawString, Qt::ScreenOrientations &result)
232{
233 // Default to all orientations
234 result = Qt::PortraitOrientation | Qt::LandscapeOrientation
235 | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation;
236
237 if (rawString.isEmpty()) {
238 return true;
239 }
240
241 Qt::ScreenOrientations parsedOrientations = 0;
242 bool ok = true;
243
244 QStringList orientationsList = rawString
245 .simplified()
246 .replace(QChar(','), ";")
247 .remove(QChar(' '))
248 .remove(QChar('-'))
249 .remove(QChar('_'))
250 .toLower()
251 .split(";");
252
253 for (int i = 0; i < orientationsList.count() && ok; ++i) {
254 const QString &orientationString = orientationsList.at(i);
255 if (orientationString.isEmpty()) {
256 // skip it
257 continue;
258 }
259
260 if (orientationString == "portrait") {
261 parsedOrientations |= Qt::PortraitOrientation;
262 } else if (orientationString == "landscape") {
263 parsedOrientations |= Qt::LandscapeOrientation;
264 } else if (orientationString == "invertedportrait") {
265 parsedOrientations |= Qt::InvertedPortraitOrientation;
266 } else if (orientationString == "invertedlandscape") {
267 parsedOrientations |= Qt::InvertedLandscapeOrientation;
268 } else if (orientationsList.count() == 1 && orientationString == "primary") {
269 // Special case: primary orientation must be alone
270 // There's no sense in supporting primary orientation + other orientations
271 // like "primary,landscape"
272 parsedOrientations = Qt::PrimaryOrientation;
273 } else {
274 ok = false;
275 }
276 }
277
278 if (ok) {
279 result = parsedOrientations;
280 }
281
282 return ok;
283}
284
285bool DesktopFileReader::parseBoolean(const QString &rawString, bool &result)
286{
287 QString cookedString = rawString.trimmed().toLower();
288
289 result = cookedString == "y"
290 || cookedString == "1"
291 || cookedString == "yes"
292 || cookedString == "true";
293
294 return result || rawString.isEmpty()
295 || cookedString == "n"
296 || cookedString == "0"
297 || cookedString == "no"
298 || cookedString == "false";
299}
300
205bool DesktopFileReader::loaded() const301bool DesktopFileReader::loaded() const
206{302{
207 Q_D(const DesktopFileReader);303 Q_D(const DesktopFileReader);
208304
=== modified file 'src/modules/Unity/Application/desktopfilereader.h'
--- src/modules/Unity/Application/desktopfilereader.h 2014-10-14 19:39:43 +0000
+++ src/modules/Unity/Application/desktopfilereader.h 2015-02-05 10:26:37 +0000
@@ -55,8 +55,13 @@
55 virtual QString splashColor() const;55 virtual QString splashColor() const;
56 virtual QString splashColorHeader() const;56 virtual QString splashColorHeader() const;
57 virtual QString splashColorFooter() const;57 virtual QString splashColorFooter() const;
58 virtual Qt::ScreenOrientations supportedOrientations() const;
59 virtual bool rotatesWindowContents() const;
58 virtual bool loaded() const;60 virtual bool loaded() const;
5961
62 static bool parseOrientations(const QString &rawString, Qt::ScreenOrientations &result);
63 static bool parseBoolean(const QString &rawString, bool &result);
64
60protected:65protected:
61 DesktopFileReader(const QString &appId, const QFileInfo &desktopFile);66 DesktopFileReader(const QString &appId, const QFileInfo &desktopFile);
6267
6368
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-01-14 09:07:41 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-02-05 10:26:37 +0000
@@ -44,6 +44,7 @@
4444
45// Mir45// Mir
46#include <mir/geometry/rectangle.h>46#include <mir/geometry/rectangle.h>
47#include <mir/events/event_builders.h>
47#include <mir_toolkit/event.h>48#include <mir_toolkit/event.h>
4849
49namespace mg = mir::graphics;50namespace mg = mir::graphics;
@@ -52,160 +53,99 @@
5253
53namespace {54namespace {
5455
55bool fillInMirEvent(MirEvent &mirEvent, QKeyEvent *qtEvent)56// Would be better if QMouseEvent had nativeModifiers
56{57MirInputEventModifiers
57 mirEvent.type = mir_event_type_key;58mir_modifiers_from_qt(Qt::KeyboardModifiers mods)
5859{
59 // don't care60 MirInputEventModifiers m_mods = mir_input_event_modifier_none;
60 mirEvent.key.device_id = 0;61 if (mods & Qt::ShiftModifier)
61 mirEvent.key.source_id = 0;62 m_mods |= mir_input_event_modifier_shift;
6263 if (mods & Qt::ControlModifier)
63 switch (qtEvent->type()) {64 m_mods |= mir_input_event_modifier_ctrl;
64 case QEvent::KeyPress:65 if (mods & Qt::AltModifier)
65 mirEvent.key.action = mir_key_action_down;66 m_mods |= mir_input_event_modifier_alt;
66 break;67 if (mods & Qt::MetaModifier)
67 case QEvent::KeyRelease:68 m_mods |= mir_input_event_modifier_meta;
68 mirEvent.key.action = mir_key_action_up;69
69 break;70 return m_mods;
70 default:71}
71 return false;72
72 }73mir::EventUPtr makeMirEvent(QMouseEvent *qtEvent, MirPointerInputEventAction action)
7374{
74 // don't care75 auto timestamp = qtEvent->timestamp() * 1000000;
75 mirEvent.key.flags = (MirKeyFlag)0;76 auto modifiers = mir_modifiers_from_qt(qtEvent->modifiers());
7677
77 mirEvent.key.modifiers = qtEvent->nativeModifiers();78 std::vector<MirPointerInputEventButton> buttons;
78 mirEvent.key.key_code = qtEvent->nativeVirtualKey();79 if (qtEvent->buttons() & Qt::LeftButton)
79 mirEvent.key.scan_code = qtEvent->nativeScanCode();80 buttons.push_back(mir_pointer_input_button_primary);
8081 if (qtEvent->buttons() & Qt::RightButton)
81 // TODO: It's not the best that we lose the actual repeat count from82 buttons.push_back(mir_pointer_input_button_secondary);
82 // the original mir event (pre QtEventFeeder)...of course it will83 if (qtEvent->buttons() & Qt::MidButton)
83 // not matter for Qt clients...so this is an improvement for now.84 buttons.push_back(mir_pointer_input_button_tertiary);
84 mirEvent.key.repeat_count = qtEvent->isAutoRepeat() ? 1 : 0;85
8586 return mir::events::make_event(0 /*DeviceID */, timestamp, modifiers, action,
86 // Don't care87 buttons, qtEvent->x(), qtEvent->y(), 0, 0);
87 mirEvent.key.down_time = 0;88}
8889
89 mirEvent.key.event_time = qtEvent->timestamp() * 1000000;90mir::EventUPtr makeMirEvent(QKeyEvent *qtEvent)
9091{
91 // Don't care92 MirKeyInputEventAction action = mir_key_input_event_action_down;
92 mirEvent.key.is_system_key = 0;93 switch (qtEvent->type())
9394 {
94 return true;95 case QEvent::KeyPress:
95}96 action = mir_key_input_event_action_down;
9697 break;
97bool fillInMirEvent(MirEvent &mirEvent,98 case QEvent::KeyRelease:
98 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,99 action = mir_key_input_event_action_up;
99 Qt::TouchPointStates qtTouchPointStates,100 break;
100 ulong qtTimestamp)101 default:
101{102 break;
102 mirEvent.type = mir_event_type_motion;103 }
103104 if (qtEvent->isAutoRepeat())
104 // Hardcoding it for now105 action = mir_key_input_event_action_repeat;
105 // TODO: Gather this info from a QTouchDevice-derived class created by QtEventFeeder106
106 mirEvent.motion.device_id = 0;107 return mir::events::make_event(0 /* DeviceID */, qtEvent->timestamp() * 1000000,
107 mirEvent.motion.source_id = 0x00001002; // AINPUT_SOURCE_TOUCHSCREEN; https://bugs.launchpad.net/bugs/1311687108 action, qtEvent->nativeVirtualKey(),
108109 qtEvent->nativeScanCode(),
109 // NB: it's assumed that touch points are pressed and released110 qtEvent->nativeModifiers());
110 // one at a time.111}
111112
112 if (qtTouchPointStates.testFlag(Qt::TouchPointPressed)) {113mir::EventUPtr makeMirEvent(Qt::KeyboardModifiers qmods,
113 if (qtTouchPoints.count() > 1) {114 const QList<QTouchEvent::TouchPoint> &qtTouchPoints,
114 mirEvent.motion.action = mir_motion_action_pointer_down;115 Qt::TouchPointStates /* qtTouchPointStates */,
115 } else {116 ulong qtTimestamp)
116 mirEvent.motion.action = mir_motion_action_down;117{
117 }118 auto modifiers = mir_modifiers_from_qt(qmods);
118 } else if (qtTouchPointStates.testFlag(Qt::TouchPointReleased)) {119 auto ev = mir::events::make_event(0, static_cast<int64_t>(qtTimestamp) * 1000000,
119 if (qtTouchPoints.count() > 1) {120 modifiers);
120 mirEvent.motion.action = mir_motion_action_pointer_up;121
121 } else {
122 mirEvent.motion.action = mir_motion_action_up;
123 }
124 } else {
125 mirEvent.motion.action = mir_motion_action_move;
126 }
127
128 // not used
129 mirEvent.motion.flags = (MirMotionFlag) 0;
130
131 // TODO: map QInputEvent::modifiers()
132 mirEvent.motion.modifiers = 0;
133
134 // not used
135 mirEvent.motion.edge_flags = 0;
136
137 // TODO
138 mirEvent.motion.button_state = (MirMotionButton) 0;
139
140 // Does it matter?
141 mirEvent.motion.x_offset = 0.;
142 mirEvent.motion.y_offset = 0.;
143 mirEvent.motion.x_precision = 0.1;
144 mirEvent.motion.y_precision = 0.1;
145
146 // TODO. Not useful to Qt at least...
147 mirEvent.motion.down_time = 0;
148
149 // Note: QtEventFeeder scales the event time down, scale it back up - precision is
150 // lost but the time difference should still be accurate to milliseconds
151 mirEvent.motion.event_time = static_cast<nsecs_t>(qtTimestamp) * 1000000;
152
153 mirEvent.motion.pointer_count = qtTouchPoints.count();
154
155 for (int i = 0; i < qtTouchPoints.count(); ++i) {122 for (int i = 0; i < qtTouchPoints.count(); ++i) {
156 auto touchPoint = qtTouchPoints.at(i);123 auto touchPoint = qtTouchPoints.at(i);
157 auto &pointer = mirEvent.motion.pointer_coordinates[i];124 auto id = touchPoint.id();
158125
159 // FIXME: https://bugs.launchpad.net/mir/+bug/1311699126 MirTouchInputEventTouchAction action = mir_touch_input_event_action_change;
160 // When multiple touch points are transmitted with a MirEvent127 if (touchPoint.state() == Qt::TouchPointReleased)
161 // and one of them (only one is allowed) indicates a presse128 {
162 // state change the index is encoded in the second byte of the129 action = mir_touch_input_event_action_up;
163 // action value.130 }
164 const int mir_motion_event_pointer_index_shift = 8;131 if (touchPoint.state() == Qt::TouchPointPressed)
165 if (mirEvent.motion.action == mir_motion_action_pointer_up &&132 {
166 touchPoint.state() == Qt::TouchPointReleased)133 action = mir_touch_input_event_action_down;
167 {134 }
168 mirEvent.motion.action |= i << mir_motion_event_pointer_index_shift;135
169 }136 MirTouchInputEventTouchTooltype tooltype = mir_touch_input_tool_type_finger;
170 if (mirEvent.motion.action == mir_motion_action_pointer_down &&
171 touchPoint.state() == Qt::TouchPointPressed)
172 {
173 mirEvent.motion.action |= i << mir_motion_event_pointer_index_shift;
174 }
175
176
177 pointer.id = touchPoint.id();
178 pointer.x = touchPoint.pos().x();
179 pointer.y = touchPoint.pos().y();
180
181 // FIXME: https://bugs.launchpad.net/mir/+bug/1311809
182
183 if (touchPoint.rawScreenPositions().isEmpty()) {
184 pointer.raw_x = 0.;
185 pointer.raw_y = 0.;
186 } else {
187 pointer.raw_x = touchPoint.rawScreenPositions().at(0).x();
188 pointer.raw_y = touchPoint.rawScreenPositions().at(0).y();
189 }
190
191 pointer.touch_major = touchPoint.rect().width();
192 pointer.touch_minor = touchPoint.rect().height();
193 pointer.size = 0.;
194 pointer.pressure = touchPoint.pressure();
195 pointer.orientation = 0.;
196 pointer.vscroll = 0.;
197 pointer.hscroll = 0.;
198
199 // TODO: Mir supports a wider set of tool types (finger, stylus, mouse, eraser, unknown).
200 // so just because we are not TouchPoint::Pen does not mean we are motion_tool_type_finger...
201 // however this is the best we can do with the QtEventFeeder approach.
202 if (touchPoint.flags() & QTouchEvent::TouchPoint::Pen)137 if (touchPoint.flags() & QTouchEvent::TouchPoint::Pen)
203 pointer.tool_type = mir_motion_tool_type_stylus;138 tooltype = mir_touch_input_tool_type_stylus;
204 else139
205 pointer.tool_type = mir_motion_tool_type_finger;140 mir::events::add_touch(*ev, id, action, tooltype,
141 touchPoint.pos().x(), touchPoint.pos().y(),
142 touchPoint.pressure(),
143 touchPoint.rect().width(),
144 touchPoint.rect().height(),
145 0 /* size */);
206 }146 }
207147
208 return true;148 return ev;
209}149}
210150
211} // namespace {151} // namespace {
@@ -243,7 +183,7 @@
243 , m_session(session)183 , m_session(session)
244 , m_firstFrameDrawn(false)184 , m_firstFrameDrawn(false)
245 , m_live(true)185 , m_live(true)
246 , m_orientation(Qt::PortraitOrientation)186 , m_orientationAngle(Angle0)
247 , m_textureProvider(nullptr)187 , m_textureProvider(nullptr)
248 , m_lastTouchEvent(nullptr)188 , m_lastTouchEvent(nullptr)
249{189{
@@ -352,49 +292,42 @@
352 return static_cast<MirSurfaceItem::State>(m_surface->state());292 return static_cast<MirSurfaceItem::State>(m_surface->state());
353}293}
354294
355Qt::ScreenOrientation MirSurfaceItem::orientation() const295MirSurfaceItem::OrientationAngle MirSurfaceItem::orientationAngle() const
356{296{
357 return m_orientation;297 return m_orientationAngle;
358}298}
359299
360void MirSurfaceItem::setOrientation(const Qt::ScreenOrientation orientation)300void MirSurfaceItem::setOrientationAngle(MirSurfaceItem::OrientationAngle angle)
361{301{
362 qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::setOrientation - orientation=" << orientation;302 qCDebug(QTMIR_SURFACES, "MirSurfaceItem::setOrientationAngle(%d)", angle);
363303
364 if (m_orientation == orientation)304 if (m_orientationAngle == angle)
365 return;305 return;
366306
367 MirOrientation mirOrientation;307 MirOrientation mirOrientation;
368 Qt::ScreenOrientation nativeOrientation = QGuiApplication::primaryScreen()->nativeOrientation();308
369 const bool landscapeNativeOrientation = (nativeOrientation == Qt::LandscapeOrientation);309 switch (angle) {
370310 case Angle0:
371 Qt::ScreenOrientation requestedOrientation = orientation;311 mirOrientation = mir_orientation_normal;
372 if (orientation == Qt::PrimaryOrientation) { // means orientation equals native orientation, set it as such312 break;
373 requestedOrientation = nativeOrientation;313 case Angle90:
374 }314 mirOrientation = mir_orientation_right;
375315 break;
376 switch(requestedOrientation) {316 case Angle180:
377 case Qt::PortraitOrientation:317 mirOrientation = mir_orientation_inverted;
378 mirOrientation = (landscapeNativeOrientation) ? mir_orientation_right : mir_orientation_normal;318 break;
379 break;319 case Angle270:
380 case Qt::LandscapeOrientation:320 mirOrientation = mir_orientation_left;
381 mirOrientation = (landscapeNativeOrientation) ? mir_orientation_normal : mir_orientation_left;
382 break;
383 case Qt::InvertedPortraitOrientation:
384 mirOrientation = (landscapeNativeOrientation) ? mir_orientation_left : mir_orientation_inverted;
385 break;
386 case Qt::InvertedLandscapeOrientation:
387 mirOrientation = (landscapeNativeOrientation) ? mir_orientation_inverted : mir_orientation_right;
388 break;321 break;
389 default:322 default:
390 qWarning("Unrecognized Qt::ScreenOrientation!");323 qCWarning(QTMIR_SURFACES, "Unsupported orientation angle: %d", angle);
391 return;324 return;
392 }325 }
393326
394 m_surface->set_orientation(mirOrientation);327 m_surface->set_orientation(mirOrientation);
395328
396 m_orientation = orientation;329 m_orientationAngle = angle;
397 Q_EMIT orientationChanged();330 Q_EMIT orientationAngleChanged(angle);
398}331}
399332
400QString MirSurfaceItem::name() const333QString MirSurfaceItem::name() const
@@ -440,10 +373,11 @@
440 ensureProvider();373 ensureProvider();
441 bool textureUpdated = false;374 bool textureUpdated = false;
442375
376 const void* const user_id = (void*)123;
443 std::unique_ptr<mg::Renderable> renderable =377 std::unique_ptr<mg::Renderable> renderable =
444 m_surface->compositor_snapshot((void*)123/*user_id*/);378 m_surface->compositor_snapshot(user_id);
445379
446 if (renderable->buffers_ready_for_compositor() > 0) {380 if (m_surface->buffers_ready_for_compositor(user_id) > 0) {
447 if (!m_textureProvider->t) {381 if (!m_textureProvider->t) {
448 m_textureProvider->t = new MirBufferSGTexture(renderable->buffer());382 m_textureProvider->t = new MirBufferSGTexture(renderable->buffer());
449 } else {383 } else {
@@ -455,7 +389,7 @@
455 textureUpdated = true;389 textureUpdated = true;
456 }390 }
457391
458 if (renderable->buffers_ready_for_compositor() > 0) {392 if (m_surface->buffers_ready_for_compositor(user_id) > 0) {
459 QTimer::singleShot(0, this, SLOT(update()));393 QTimer::singleShot(0, this, SLOT(update()));
460 // restart the frame dropper so that we have enough time to render the next frame.394 // restart the frame dropper so that we have enough time to render the next frame.
461 m_frameDropperTimer.start();395 m_frameDropperTimer.start();
@@ -507,18 +441,20 @@
507441
508void MirSurfaceItem::mousePressEvent(QMouseEvent *event)442void MirSurfaceItem::mousePressEvent(QMouseEvent *event)
509{443{
510 // TODO: Implement for desktop support444 auto ev = makeMirEvent(event, mir_pointer_input_event_action_button_down);
511 event->ignore();445 m_surface->consume(*ev);
512}446}
513447
514void MirSurfaceItem::mouseMoveEvent(QMouseEvent *event)448void MirSurfaceItem::mouseMoveEvent(QMouseEvent *event)
515{449{
516 Q_UNUSED(event);450 auto ev = makeMirEvent(event, mir_pointer_input_event_action_motion);
451 m_surface->consume(*ev);
517}452}
518453
519void MirSurfaceItem::mouseReleaseEvent(QMouseEvent *event)454void MirSurfaceItem::mouseReleaseEvent(QMouseEvent *event)
520{455{
521 Q_UNUSED(event);456 auto ev = makeMirEvent(event, mir_pointer_input_event_action_button_up);
457 m_surface->consume(*ev);
522}458}
523459
524void MirSurfaceItem::wheelEvent(QWheelEvent *event)460void MirSurfaceItem::wheelEvent(QWheelEvent *event)
@@ -528,18 +464,14 @@
528464
529void MirSurfaceItem::keyPressEvent(QKeyEvent *qtEvent)465void MirSurfaceItem::keyPressEvent(QKeyEvent *qtEvent)
530{466{
531 MirEvent mirEvent;467 auto ev = makeMirEvent(qtEvent);
532 if (fillInMirEvent(mirEvent, qtEvent)) {468 m_surface->consume(*ev);
533 m_surface->consume(mirEvent);
534 }
535}469}
536470
537void MirSurfaceItem::keyReleaseEvent(QKeyEvent *qtEvent)471void MirSurfaceItem::keyReleaseEvent(QKeyEvent *qtEvent)
538{472{
539 MirEvent mirEvent;473 auto ev = makeMirEvent(qtEvent);
540 if (fillInMirEvent(mirEvent, qtEvent)) {474 m_surface->consume(*ev);
541 m_surface->consume(mirEvent);
542 }
543}475}
544476
545QString MirSurfaceItem::appId() const477QString MirSurfaceItem::appId() const
@@ -555,8 +487,6 @@
555487
556void MirSurfaceItem::endCurrentTouchSequence(ulong timestamp)488void MirSurfaceItem::endCurrentTouchSequence(ulong timestamp)
557{489{
558 MirEvent mirEvent;
559
560 Q_ASSERT(m_lastTouchEvent);490 Q_ASSERT(m_lastTouchEvent);
561 Q_ASSERT(m_lastTouchEvent->type != QEvent::TouchEnd);491 Q_ASSERT(m_lastTouchEvent->type != QEvent::TouchEnd);
562 Q_ASSERT(m_lastTouchEvent->touchPoints.count() > 0);492 Q_ASSERT(m_lastTouchEvent->touchPoints.count() > 0);
@@ -580,10 +510,10 @@
580510
581 touchEvent.updateTouchPointStatesAndType();511 touchEvent.updateTouchPointStatesAndType();
582512
583 if (fillInMirEvent(mirEvent, touchEvent.touchPoints,513 auto ev = makeMirEvent(touchEvent.modifiers, touchEvent.touchPoints,
584 touchEvent.touchPointStates, touchEvent.timestamp)) {514 touchEvent.touchPointStates, touchEvent.timestamp);
585 m_surface->consume(mirEvent);515 m_surface->consume(*ev);
586 }516
587 *m_lastTouchEvent = touchEvent;517 *m_lastTouchEvent = touchEvent;
588518
589 touchEvent.touchPoints.removeAt(0);519 touchEvent.touchPoints.removeAt(0);
@@ -592,11 +522,10 @@
592522
593void MirSurfaceItem::validateAndDeliverTouchEvent(int eventType,523void MirSurfaceItem::validateAndDeliverTouchEvent(int eventType,
594 ulong timestamp,524 ulong timestamp,
525 Qt::KeyboardModifiers mods,
595 const QList<QTouchEvent::TouchPoint> &touchPoints,526 const QList<QTouchEvent::TouchPoint> &touchPoints,
596 Qt::TouchPointStates touchPointStates)527 Qt::TouchPointStates touchPointStates)
597{528{
598 MirEvent mirEvent;
599
600 if (eventType == QEvent::TouchBegin && m_lastTouchEvent && m_lastTouchEvent->type != QEvent::TouchEnd) {529 if (eventType == QEvent::TouchBegin && m_lastTouchEvent && m_lastTouchEvent->type != QEvent::TouchEnd) {
601 qCWarning(QTMIR_SURFACES) << qPrintable(QString("MirSurfaceItem(%1) - Got a QEvent::TouchBegin while "530 qCWarning(QTMIR_SURFACES) << qPrintable(QString("MirSurfaceItem(%1) - Got a QEvent::TouchBegin while "
602 "there's still an active/unfinished touch sequence.").arg(appId()));531 "there's still an active/unfinished touch sequence.").arg(appId()));
@@ -604,9 +533,8 @@
604 endCurrentTouchSequence(timestamp);533 endCurrentTouchSequence(timestamp);
605 }534 }
606535
607 if (fillInMirEvent(mirEvent, touchPoints, touchPointStates, timestamp)) {536 auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp);
608 m_surface->consume(mirEvent);537 m_surface->consume(*ev);
609 }
610538
611 if (!m_lastTouchEvent) {539 if (!m_lastTouchEvent) {
612 m_lastTouchEvent = new TouchEvent;540 m_lastTouchEvent = new TouchEvent;
@@ -621,6 +549,7 @@
621{549{
622 bool accepted = processTouchEvent(event->type(),550 bool accepted = processTouchEvent(event->type(),
623 event->timestamp(),551 event->timestamp(),
552 event->modifiers(),
624 event->touchPoints(),553 event->touchPoints(),
625 event->touchPointStates());554 event->touchPointStates());
626 event->setAccepted(accepted);555 event->setAccepted(accepted);
@@ -629,6 +558,7 @@
629bool MirSurfaceItem::processTouchEvent(558bool MirSurfaceItem::processTouchEvent(
630 int eventType,559 int eventType,
631 ulong timestamp,560 ulong timestamp,
561 Qt::KeyboardModifiers mods,
632 const QList<QTouchEvent::TouchPoint> &touchPoints,562 const QList<QTouchEvent::TouchPoint> &touchPoints,
633 Qt::TouchPointStates touchPointStates)563 Qt::TouchPointStates touchPointStates)
634{564{
@@ -636,7 +566,7 @@
636 if (type() == InputMethod && eventType == QEvent::TouchBegin) {566 if (type() == InputMethod && eventType == QEvent::TouchBegin) {
637 // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place.567 // FIXME: Hack to get the VKB use case working while we don't have the proper solution in place.
638 if (hasTouchInsideUbuntuKeyboard(touchPoints)) {568 if (hasTouchInsideUbuntuKeyboard(touchPoints)) {
639 validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates);569 validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates);
640 } else {570 } else {
641 accepted = false;571 accepted = false;
642 }572 }
@@ -644,7 +574,7 @@
644 } else {574 } else {
645 // NB: If we are getting QEvent::TouchUpdate or QEvent::TouchEnd it's because we've575 // NB: If we are getting QEvent::TouchUpdate or QEvent::TouchEnd it's because we've
646 // previously accepted the corresponding QEvent::TouchBegin576 // previously accepted the corresponding QEvent::TouchBegin
647 validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates);577 validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates);
648 }578 }
649 return accepted;579 return accepted;
650}580}
@@ -747,18 +677,17 @@
747{677{
748 QMutexLocker locker(&m_mutex);678 QMutexLocker locker(&m_mutex);
749679
750 std::unique_ptr<mg::Renderable> renderable =680 const void* const user_id = (void*)123; // TODO: Multimonitor support
751 m_surface->compositor_snapshot((void*)123/*user_id*/);
752681
753 while (renderable->buffers_ready_for_compositor() > 0) {682 while (m_surface->buffers_ready_for_compositor(user_id) > 0) {
754 // The line below looks like an innocent, effect-less, getter. But as this683 // The line below looks like an innocent, effect-less, getter. But as this
755 // method returns a unique_pointer, not holding its reference causes the684 // method returns a unique_pointer, not holding its reference causes the
756 // buffer to be destroyed/released straight away.685 // buffer to be destroyed/released straight away.
757 m_surface->compositor_snapshot((void*)123/*user_id*/)->buffer();686 m_surface->compositor_snapshot(user_id)->buffer();
758 qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::dropPendingBuffers()"687 qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::dropPendingBuffers()"
759 << "surface =" << this688 << "surface =" << this
760 << "buffer dropped."689 << "buffer dropped."
761 << renderable->buffers_ready_for_compositor()690 << m_surface->buffers_ready_for_compositor(user_id)
762 << "left.";691 << "left.";
763 }692 }
764}693}
765694
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
--- src/modules/Unity/Application/mirsurfaceitem.h 2015-01-14 08:24:29 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.h 2015-02-05 10:26:37 +0000
@@ -47,12 +47,17 @@
47 Q_OBJECT47 Q_OBJECT
48 Q_ENUMS(Type)48 Q_ENUMS(Type)
49 Q_ENUMS(State)49 Q_ENUMS(State)
50 Q_ENUMS(OrientationAngle)
5051
51 Q_PROPERTY(Type type READ type NOTIFY typeChanged)52 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
52 Q_PROPERTY(State state READ state NOTIFY stateChanged)53 Q_PROPERTY(State state READ state NOTIFY stateChanged)
53 Q_PROPERTY(QString name READ name NOTIFY nameChanged)54 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
54 Q_PROPERTY(bool live READ live NOTIFY liveChanged)55 Q_PROPERTY(bool live READ live NOTIFY liveChanged)
55 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false)56
57 // How many degrees, clockwise, the UI in the surface has to rotate to match with the
58 // shell UI orientation
59 Q_PROPERTY(OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
60 NOTIFY orientationAngleChanged DESIGNABLE false)
5661
57public:62public:
58 explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,63 explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
@@ -81,12 +86,18 @@
81 Fullscreen = mir_surface_state_fullscreen,86 Fullscreen = mir_surface_state_fullscreen,
82 };87 };
8388
89 enum OrientationAngle {
90 Angle0 = 0,
91 Angle90 = 90,
92 Angle180 = 180,
93 Angle270 = 270
94 };
95
84 //getters96 //getters
85 Type type() const;97 Type type() const;
86 State state() const;98 State state() const;
87 QString name() const;99 QString name() const;
88 bool live() const;100 bool live() const;
89 Qt::ScreenOrientation orientation() const;
90 SessionInterface *session() const;101 SessionInterface *session() const;
91102
92 Q_INVOKABLE void release();103 Q_INVOKABLE void release();
@@ -100,12 +111,15 @@
100111
101 bool isFirstFrameDrawn() const { return m_firstFrameDrawn; }112 bool isFirstFrameDrawn() const { return m_firstFrameDrawn; }
102113
103 void setOrientation(const Qt::ScreenOrientation orientation);114 OrientationAngle orientationAngle() const;
115 void setOrientationAngle(OrientationAngle angle);
116
104 void setSession(SessionInterface *app);117 void setSession(SessionInterface *app);
105118
106 // to allow easy touch event injection from tests119 // to allow easy touch event injection from tests
107 bool processTouchEvent(int eventType,120 bool processTouchEvent(int eventType,
108 ulong timestamp,121 ulong timestamp,
122 Qt::KeyboardModifiers modifiers,
109 const QList<QTouchEvent::TouchPoint> &touchPoints,123 const QList<QTouchEvent::TouchPoint> &touchPoints,
110 Qt::TouchPointStates touchPointStates);124 Qt::TouchPointStates touchPointStates);
111125
@@ -113,7 +127,7 @@
113 void typeChanged();127 void typeChanged();
114 void stateChanged();128 void stateChanged();
115 void nameChanged();129 void nameChanged();
116 void orientationChanged();130 void orientationAngleChanged(OrientationAngle angle);
117 void liveChanged(bool live);131 void liveChanged(bool live);
118 void firstFrameDrawn(MirSurfaceItem *item);132 void firstFrameDrawn(MirSurfaceItem *item);
119133
@@ -164,6 +178,7 @@
164 void endCurrentTouchSequence(ulong timestamp);178 void endCurrentTouchSequence(ulong timestamp);
165 void validateAndDeliverTouchEvent(int eventType,179 void validateAndDeliverTouchEvent(int eventType,
166 ulong timestamp,180 ulong timestamp,
181 Qt::KeyboardModifiers modifiers,
167 const QList<QTouchEvent::TouchPoint> &touchPoints,182 const QList<QTouchEvent::TouchPoint> &touchPoints,
168 Qt::TouchPointStates touchPointStates);183 Qt::TouchPointStates touchPointStates);
169184
@@ -173,7 +188,9 @@
173 QPointer<SessionInterface> m_session;188 QPointer<SessionInterface> m_session;
174 bool m_firstFrameDrawn;189 bool m_firstFrameDrawn;
175 bool m_live;190 bool m_live;
176 Qt::ScreenOrientation m_orientation; //FIXME - have to save the state as Mir has no getter for it (bug:1357429)191
192 //FIXME - have to save the state as Mir has no getter for it (bug:1357429)
193 OrientationAngle m_orientationAngle;
177194
178 QMirSurfaceTextureProvider *m_textureProvider;195 QMirSurfaceTextureProvider *m_textureProvider;
179196
@@ -188,6 +205,7 @@
188 TouchEvent &operator= (const QTouchEvent &qtEvent) {205 TouchEvent &operator= (const QTouchEvent &qtEvent) {
189 type = qtEvent.type();206 type = qtEvent.type();
190 timestamp = qtEvent.timestamp();207 timestamp = qtEvent.timestamp();
208 modifiers = qtEvent.modifiers();
191 touchPoints = qtEvent.touchPoints();209 touchPoints = qtEvent.touchPoints();
192 touchPointStates = qtEvent.touchPointStates();210 touchPointStates = qtEvent.touchPointStates();
193 return *this;211 return *this;
@@ -197,6 +215,7 @@
197215
198 int type;216 int type;
199 ulong timestamp;217 ulong timestamp;
218 Qt::KeyboardModifiers modifiers;
200 QList<QTouchEvent::TouchPoint> touchPoints;219 QList<QTouchEvent::TouchPoint> touchPoints;
201 Qt::TouchPointStates touchPointStates;220 Qt::TouchPointStates touchPointStates;
202 } *m_lastTouchEvent;221 } *m_lastTouchEvent;
@@ -207,5 +226,6 @@
207} // namespace qtmir226} // namespace qtmir
208227
209Q_DECLARE_METATYPE(qtmir::MirSurfaceItem*)228Q_DECLARE_METATYPE(qtmir::MirSurfaceItem*)
229Q_DECLARE_METATYPE(qtmir::MirSurfaceItem::OrientationAngle)
210230
211#endif // MIRSURFACEITEM_H231#endif // MIRSURFACEITEM_H
212232
=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
--- src/modules/Unity/Application/mirsurfacemanager.cpp 2014-12-16 15:55:29 +0000
+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2015-02-05 10:26:37 +0000
@@ -31,7 +31,7 @@
31#include "nativeinterface.h"31#include "nativeinterface.h"
32#include "mirserver.h"32#include "mirserver.h"
33#include "sessionlistener.h"33#include "sessionlistener.h"
34#include "surfaceconfigurator.h"34#include "mirshell.h"
35#include "logging.h"35#include "logging.h"
3636
37Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")37Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")
@@ -51,9 +51,9 @@
51 manager, &MirSurfaceManager::onSessionDestroyingSurface);51 manager, &MirSurfaceManager::onSessionDestroyingSurface);
52}52}
5353
54void connectToSurfaceConfigurator(MirSurfaceManager *manager, SurfaceConfigurator *surfaceConfigurator)54void connectToShell(MirSurfaceManager *manager, MirShell *shell)
55{55{
56 QObject::connect(surfaceConfigurator, &SurfaceConfigurator::surfaceAttributeChanged,56 QObject::connect(shell, &MirShell::surfaceAttributeChanged,
57 manager, &MirSurfaceManager::onSurfaceAttributeChanged);57 manager, &MirSurfaceManager::onSurfaceAttributeChanged);
58}58}
5959
@@ -70,12 +70,12 @@
70 }70 }
7171
72 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));72 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));
73 SurfaceConfigurator *surfaceConfigurator = static_cast<SurfaceConfigurator*>(nativeInterface->nativeResourceForIntegration("SessionConfigurator"));73 MirShell *shell = static_cast<MirShell*>(nativeInterface->nativeResourceForIntegration("Shell"));
7474
75 the_surface_manager = new MirSurfaceManager(nativeInterface->m_mirServer, SessionManager::singleton());75 the_surface_manager = new MirSurfaceManager(nativeInterface->m_mirServer, SessionManager::singleton());
7676
77 connectToSessionListener(the_surface_manager, sessionListener);77 connectToSessionListener(the_surface_manager, sessionListener);
78 connectToSurfaceConfigurator(the_surface_manager, surfaceConfigurator);78 connectToShell(the_surface_manager, shell);
79 }79 }
80 return the_surface_manager;80 return the_surface_manager;
81}81}
8282
=== modified file 'src/modules/Unity/Application/plugin.cpp'
--- src/modules/Unity/Application/plugin.cpp 2014-10-06 11:37:56 +0000
+++ src/modules/Unity/Application/plugin.cpp 2015-02-05 10:26:37 +0000
@@ -78,6 +78,7 @@
78 qRegisterMetaType<qtmir::Session*>("Session*");78 qRegisterMetaType<qtmir::Session*>("Session*");
79 qRegisterMetaType<qtmir::SessionInterface*>("SessionInterface*");79 qRegisterMetaType<qtmir::SessionInterface*>("SessionInterface*");
80 qRegisterMetaType<qtmir::SessionModel*>("SessionModel*");80 qRegisterMetaType<qtmir::SessionModel*>("SessionModel*");
81 qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib");
8182
82 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(83 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(
83 uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");84 uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
8485
=== modified file 'src/modules/Unity/Application/sessionmanager.cpp'
--- src/modules/Unity/Application/sessionmanager.cpp 2014-12-01 11:05:01 +0000
+++ src/modules/Unity/Application/sessionmanager.cpp 2015-02-05 10:26:37 +0000
@@ -26,7 +26,7 @@
26#include "nativeinterface.h"26#include "nativeinterface.h"
27#include "mirserver.h"27#include "mirserver.h"
28#include "sessionlistener.h"28#include "sessionlistener.h"
29#include "surfaceconfigurator.h"29#include "mirshell.h"
30#include "logging.h"30#include "logging.h"
31#include "promptsessionlistener.h"31#include "promptsessionlistener.h"
3232
3333
=== modified file 'src/platforms/mirserver/CMakeLists.txt'
--- src/platforms/mirserver/CMakeLists.txt 2014-12-12 15:15:06 +0000
+++ src/platforms/mirserver/CMakeLists.txt 2015-02-05 10:26:37 +0000
@@ -38,16 +38,14 @@
3838
39set(MIRSERVER_QPA_PLUGIN_SRC39set(MIRSERVER_QPA_PLUGIN_SRC
40 ../../common/debughelpers.cpp40 ../../common/debughelpers.cpp
41 focussetter.cpp41 mirshell.cpp
42 qteventfeeder.cpp42 qteventfeeder.cpp
43 plugin.cpp43 plugin.cpp
44 qmirserver.cpp44 qmirserver.cpp
45 sessionauthorizer.cpp45 sessionauthorizer.cpp
46 sessionlistener.cpp46 sessionlistener.cpp
47 surfaceconfigurator.cpp
48 surfaceobserver.cpp47 surfaceobserver.cpp
49 promptsessionlistener.cpp48 promptsessionlistener.cpp
50 mirplacementstrategy.cpp
51 mirserver.cpp49 mirserver.cpp
52 mirserverstatuslistener.cpp50 mirserverstatuslistener.cpp
53 display.cpp51 display.cpp
5452
=== removed file 'src/platforms/mirserver/focussetter.cpp'
--- src/platforms/mirserver/focussetter.cpp 2014-07-02 11:06:22 +0000
+++ src/platforms/mirserver/focussetter.cpp 1970-01-01 00:00:00 +0000
@@ -1,24 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#include "focussetter.h"
18
19void FocusSetter::set_focus_to(std::shared_ptr<mir::scene::Session> const&)
20{
21 // no-op
22 // The focus concept live entirely inside the shell qml scene. Therefore
23 // we don't want anything in mir to intervene with it
24}
250
=== removed file 'src/platforms/mirserver/focussetter.h'
--- src/platforms/mirserver/focussetter.h 2014-07-02 11:06:22 +0000
+++ src/platforms/mirserver/focussetter.h 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#ifndef QPAMIRSERVER_FOCUS_SETTER_H
18#define QPAMIRSERVER_FOCUS_SETTER_H
19
20#include <mir/shell/focus_setter.h>
21
22class FocusSetter : public mir::shell::FocusSetter
23{
24public:
25 void set_focus_to(std::shared_ptr<mir::scene::Session> const& new_focus) override;
26};
27
28#endif // QPAMIRSERVER_FOCUS_SETTER_H
290
=== removed file 'src/platforms/mirserver/mirplacementstrategy.cpp'
--- src/platforms/mirserver/mirplacementstrategy.cpp 2014-09-22 18:06:58 +0000
+++ src/platforms/mirserver/mirplacementstrategy.cpp 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#include "mirplacementstrategy.h"
18#include "logging.h"
19#include "tracepoints.h" // generated from tracepoints.tp
20
21#include <mir/geometry/rectangle.h>
22#include <mir/shell/display_layout.h>
23#include <mir/scene/surface_creation_parameters.h>
24
25namespace ms = mir::scene;
26namespace msh = mir::shell;
27
28MirPlacementStrategy::MirPlacementStrategy(
29 std::shared_ptr<msh::DisplayLayout> const& display_layout)
30 : m_displayLayout(display_layout)
31{
32 qCDebug(QTMIR_MIR_MESSAGES) << "MirPlacementStrategy::MirPlacementStrategy";
33}
34
35ms::SurfaceCreationParameters
36MirPlacementStrategy::place(ms::Session const& /*session*/,
37 ms::SurfaceCreationParameters const& requestParameters)
38{
39 tracepoint(qtmirserver, surfacePlacementStart);
40
41 // TODO: Callback unity8 so that it can make a decision on that.
42 // unity8 must bear in mind that the called function will be on a Mir thread though.
43 // The QPA shouldn't be deciding for itself on such things.
44
45 ms::SurfaceCreationParameters placedParameters = requestParameters;
46
47 // Just make it fullscreen for now
48 mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
49 m_displayLayout->size_to_output(rect);
50 placedParameters.size = rect.size;
51
52 qCDebug(QTMIR_MIR_MESSAGES) << "MirPlacementStrategy: requested ("
53 << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and returned ("
54 << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";
55
56 tracepoint(qtmirserver, surfacePlacementEnd);
57
58 return placedParameters;
59}
600
=== removed file 'src/platforms/mirserver/mirplacementstrategy.h'
--- src/platforms/mirserver/mirplacementstrategy.h 2014-04-17 22:25:39 +0000
+++ src/platforms/mirserver/mirplacementstrategy.h 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#ifndef MIRSERVERQPA_MIR_PLACEMENT_STRATEGY_H
18#define MIRSERVERQPA_MIR_PLACEMENT_STRATEGY_H
19
20#include <mir/scene/placement_strategy.h>
21
22#include <memory>
23
24namespace mir {
25 namespace shell {
26 class DisplayLayout;
27 }
28}
29
30class MirPlacementStrategy : public mir::scene::PlacementStrategy
31{
32public:
33 MirPlacementStrategy(std::shared_ptr<mir::shell::DisplayLayout> const& display_layout);
34
35 mir::scene::SurfaceCreationParameters place(mir::scene::Session const& session,
36 mir::scene::SurfaceCreationParameters const& request_parameters) override;
37
38private:
39 std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
40};
41
42#endif // MIRSERVERQPA_MIR_PLACEMENT_STRATEGY_H
430
=== modified file 'src/platforms/mirserver/mirserver.cpp'
--- src/platforms/mirserver/mirserver.cpp 2014-12-03 12:06:30 +0000
+++ src/platforms/mirserver/mirserver.cpp 2015-02-05 10:26:37 +0000
@@ -19,13 +19,11 @@
19#include "mirserver.h"19#include "mirserver.h"
2020
21// local21// local
22#include "focussetter.h"22#include "mirshell.h"
23#include "mirglconfig.h"23#include "mirglconfig.h"
24#include "mirplacementstrategy.h"
25#include "mirserverstatuslistener.h"24#include "mirserverstatuslistener.h"
26#include "promptsessionlistener.h"25#include "promptsessionlistener.h"
27#include "sessionlistener.h"26#include "sessionlistener.h"
28#include "surfaceconfigurator.h"
29#include "sessionauthorizer.h"27#include "sessionauthorizer.h"
30#include "qtcompositor.h"28#include "qtcompositor.h"
31#include "qteventfeeder.h"29#include "qteventfeeder.h"
@@ -53,11 +51,6 @@
53 set_command_line_handler(&ignore_unparsed_arguments);51 set_command_line_handler(&ignore_unparsed_arguments);
54 set_command_line(argc, argv);52 set_command_line(argc, argv);
5553
56 override_the_placement_strategy([this]
57 {
58 return std::make_shared<MirPlacementStrategy>(the_shell_display_layout());
59 });
60
61 override_the_session_listener([]54 override_the_session_listener([]
62 {55 {
63 return std::make_shared<SessionListener>();56 return std::make_shared<SessionListener>();
@@ -68,11 +61,6 @@
68 return std::make_shared<PromptSessionListener>();61 return std::make_shared<PromptSessionListener>();
69 });62 });
7063
71 override_the_surface_configurator([]
72 {
73 return std::make_shared<SurfaceConfigurator>();
74 });
75
76 override_the_session_authorizer([]64 override_the_session_authorizer([]
77 {65 {
78 return std::make_shared<SessionAuthorizer>();66 return std::make_shared<SessionAuthorizer>();
@@ -102,9 +90,17 @@
102 return std::make_shared<MirServerStatusListener>();90 return std::make_shared<MirServerStatusListener>();
103 });91 });
10492
105 override_the_shell_focus_setter([]93 override_the_shell([this]
106 {94 {
107 return std::make_shared<FocusSetter>();95 auto const shell = std::make_shared<MirShell>(
96 the_input_targeter(),
97 the_surface_coordinator(),
98 the_session_coordinator(),
99 the_prompt_session_manager(),
100 the_shell_display_layout());
101
102 m_shell = shell;
103 return shell;
108 });104 });
109105
110 set_terminator([&](int)106 set_terminator([&](int)
@@ -157,10 +153,7 @@
157 return static_cast<PromptSessionListener*>(sharedPtr.get());153 return static_cast<PromptSessionListener*>(sharedPtr.get());
158}154}
159155
160SurfaceConfigurator *MirServer::surfaceConfigurator()156MirShell *MirServer::shell()
161{157{
162 auto sharedPtr = the_surface_configurator();158 return m_shell.lock().get();
163 if (sharedPtr.unique()) return 0;
164
165 return static_cast<SurfaceConfigurator*>(sharedPtr.get());
166}159}
167160
=== modified file 'src/platforms/mirserver/mirserver.h'
--- src/platforms/mirserver/mirserver.h 2014-12-02 14:55:17 +0000
+++ src/platforms/mirserver/mirserver.h 2015-02-05 10:26:37 +0000
@@ -23,7 +23,7 @@
23class QtEventFeeder;23class QtEventFeeder;
24class SessionListener;24class SessionListener;
25class SessionAuthorizer;25class SessionAuthorizer;
26class SurfaceConfigurator;26class MirShell;
27class PromptSessionListener;27class PromptSessionListener;
2828
29// We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing)29// We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing)
@@ -34,7 +34,7 @@
3434
35 Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT)35 Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT)
36 Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT)36 Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT)
37 Q_PROPERTY(SurfaceConfigurator* surfaceConfigurator READ surfaceConfigurator CONSTANT)37 Q_PROPERTY(MirShell* shell READ shell CONSTANT)
38 Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT)38 Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT)
3939
40public:40public:
@@ -58,10 +58,11 @@
58 SessionAuthorizer *sessionAuthorizer();58 SessionAuthorizer *sessionAuthorizer();
59 SessionListener *sessionListener();59 SessionListener *sessionListener();
60 PromptSessionListener *promptSessionListener();60 PromptSessionListener *promptSessionListener();
61 SurfaceConfigurator *surfaceConfigurator();61 MirShell *shell();
6262
63private:63private:
64 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;64 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;
65 std::weak_ptr<MirShell> m_shell;
65};66};
6667
67#endif // MIRSERVER_H68#endif // MIRSERVER_H
6869
=== added file 'src/platforms/mirserver/mirshell.cpp'
--- src/platforms/mirserver/mirshell.cpp 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/mirshell.cpp 2015-02-05 10:26:37 +0000
@@ -0,0 +1,75 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#include "mirshell.h"
18#include "logging.h"
19#include "tracepoints.h" // generated from tracepoints.tp
20
21#include <mir/geometry/rectangle.h>
22#include <mir/scene/session.h>
23#include <mir/scene/surface_creation_parameters.h>
24#include <mir/shell/display_layout.h>
25
26namespace ms = mir::scene;
27using mir::shell::AbstractShell;
28
29MirShell::MirShell(
30 std::shared_ptr<mir::shell::InputTargeter> const& input_targeter,
31 std::shared_ptr<mir::scene::SurfaceCoordinator> const& surface_coordinator,
32 std::shared_ptr<mir::scene::SessionCoordinator> const& session_coordinator,
33 std::shared_ptr<mir::scene::PromptSessionManager> const& prompt_session_manager,
34 std::shared_ptr<mir::shell::DisplayLayout> const& display_layout) :
35 AbstractShell(input_targeter, surface_coordinator, session_coordinator, prompt_session_manager),
36 m_displayLayout{display_layout}
37{
38 qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::MirShell";
39}
40
41mir::frontend::SurfaceId MirShell::create_surface(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& requestParameters)
42{
43 tracepoint(qtmirserver, surfacePlacementStart);
44
45 // TODO: Callback unity8 so that it can make a decision on that.
46 // unity8 must bear in mind that the called function will be on a Mir thread though.
47 // The QPA shouldn't be deciding for itself on such things.
48
49 ms::SurfaceCreationParameters placedParameters = requestParameters;
50
51 // Just make it fullscreen for now
52 mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
53 m_displayLayout->size_to_output(rect);
54 placedParameters.size = rect.size;
55
56 qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::create_surface(): size requested ("
57 << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("
58 << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";
59
60 tracepoint(qtmirserver, surfacePlacementEnd);
61
62 return AbstractShell::create_surface(session, placedParameters);
63}
64
65int MirShell::set_surface_attribute(
66 std::shared_ptr<mir::scene::Session> const& session,
67 std::shared_ptr<mir::scene::Surface> const& surface,
68 MirSurfaceAttrib attrib,
69 int value)
70{
71 auto const result = AbstractShell::set_surface_attribute(session, surface, attrib, value);
72 Q_EMIT surfaceAttributeChanged(surface.get(), attrib, result);
73
74 return result;
75}
076
=== added file 'src/platforms/mirserver/mirshell.h'
--- src/platforms/mirserver/mirshell.h 1970-01-01 00:00:00 +0000
+++ src/platforms/mirserver/mirshell.h 2015-02-05 10:26:37 +0000
@@ -0,0 +1,56 @@
1/*
2 * Copyright © 2015 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#ifndef QPAMIRSERVER_SHELL_H
18#define QPAMIRSERVER_SHELL_H
19
20#include <mir/shell/abstract_shell.h>
21#include <QObject>
22
23namespace mir {
24 namespace shell {
25 class DisplayLayout;
26 }
27}
28
29class MirShell : public QObject, public mir::shell::AbstractShell
30{
31 Q_OBJECT
32
33public:
34 MirShell(
35 std::shared_ptr<mir::shell::InputTargeter> const& input_targeter,
36 std::shared_ptr<mir::scene::SurfaceCoordinator> const& surface_coordinator,
37 std::shared_ptr<mir::scene::SessionCoordinator> const& session_coordinator,
38 std::shared_ptr<mir::scene::PromptSessionManager> const& prompt_session_manager,
39 std::shared_ptr<mir::shell::DisplayLayout> const& display_layout);
40
41 virtual mir::frontend::SurfaceId create_surface(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params);
42
43 int set_surface_attribute(
44 std::shared_ptr<mir::scene::Session> const& session,
45 std::shared_ptr<mir::scene::Surface> const& surface,
46 MirSurfaceAttrib attrib,
47 int value) override;
48
49Q_SIGNALS:
50 void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int);
51
52private:
53 std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
54};
55
56#endif /* QPAMIRSERVER_SHELL_H */
057
=== modified file 'src/platforms/mirserver/nativeinterface.cpp'
--- src/platforms/mirserver/nativeinterface.cpp 2014-12-01 11:05:01 +0000
+++ src/platforms/mirserver/nativeinterface.cpp 2015-02-05 10:26:37 +0000
@@ -29,8 +29,8 @@
2929
30 if (resource == "SessionAuthorizer")30 if (resource == "SessionAuthorizer")
31 result = m_mirServer->sessionAuthorizer();31 result = m_mirServer->sessionAuthorizer();
32 else if (resource == "SessionConfigurator")32 else if (resource == "Shell")
33 result = m_mirServer->surfaceConfigurator();33 result = m_mirServer->shell();
34 else if (resource == "SessionListener")34 else if (resource == "SessionListener")
35 result = m_mirServer->sessionListener();35 result = m_mirServer->sessionListener();
36 else if (resource == "PromptSessionListener")36 else if (resource == "PromptSessionListener")
3737
=== modified file 'src/platforms/mirserver/qteventfeeder.cpp'
--- src/platforms/mirserver/qteventfeeder.cpp 2015-01-05 21:42:31 +0000
+++ src/platforms/mirserver/qteventfeeder.cpp 2015-02-05 10:26:37 +0000
@@ -33,11 +33,6 @@
33Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input")33Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input")
3434
35// from android-input AMOTION_EVENT_ACTION_*, hidden inside mir bowels35// from android-input AMOTION_EVENT_ACTION_*, hidden inside mir bowels
36// mir headers should define them
37const int QtEventFeeder::MirEventActionMask = 0xff;
38const int QtEventFeeder::MirEventActionPointerIndexMask = 0xff00;
39const int QtEventFeeder::MirEventActionPointerIndexShift = 8;
40
4136
42// XKB Keysyms which do not map directly to Qt types (i.e. Unicode points)37// XKB Keysyms which do not map directly to Qt types (i.e. Unicode points)
43static const uint32_t KeyTable[] = {38static const uint32_t KeyTable[] = {
@@ -182,6 +177,15 @@
182 Q_ASSERT(!mTopLevelWindow.isNull());177 Q_ASSERT(!mTopLevelWindow.isNull());
183 QWindowSystemInterface::handleTouchEvent(mTopLevelWindow.data(), timestamp, device, points, mods);178 QWindowSystemInterface::handleTouchEvent(mTopLevelWindow.data(), timestamp, device, points, mods);
184 }179 }
180
181 void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) override
182 {
183 Q_ASSERT(!mTopLevelWindow.isNull());
184 QWindowSystemInterface::handleMouseEvent(mTopLevelWindow.data(), timestamp, point, point, // local and global point are the same
185 buttons, modifiers);
186 }
187
188
185private:189private:
186 QPointer<QWindow> mTopLevelWindow;190 QPointer<QWindow> mTopLevelWindow;
187};191};
@@ -216,55 +220,109 @@
216220
217void QtEventFeeder::dispatch(MirEvent const& event)221void QtEventFeeder::dispatch(MirEvent const& event)
218{222{
219 switch (event.type) {223 auto type = mir_event_get_type(&event);
220 case mir_event_type_key:224 if (type != mir_event_type_input)
221 dispatchKey(event.key);225 return;
222 break;226 auto iev = mir_event_get_input_event(&event);
223 case mir_event_type_motion:227
224 dispatchMotion(event.motion);228 switch (mir_input_event_get_type(iev)) {
225 break;229 case mir_input_event_type_key:
226 case mir_event_type_surface:230 dispatchKey(iev);
227 // Just ignore these events: it doesn't make sense to pass them on.231 break;
228 break;232 case mir_input_event_type_touch:
233 dispatchTouch(iev);
234 break;
235 case mir_input_event_type_pointer:
236 dispatchPointer(iev);
229 default:237 default:
230 // mir_event_type_surface and mir_event_type_resize events go through
231 // mir's own protobuf channel instead of the android_input one. The latter
232 // being the one we're dealing with here.
233 qFatal("QtEventFeeder got unsupported event type from mir");
234 break;238 break;
235 }239 }
236}240}
237241
238void QtEventFeeder::dispatchKey(MirKeyEvent const& event)242namespace
239{243{
240 if (!mQtWindowSystem->hasTargetWindow())244
241 return;245Qt::KeyboardModifiers qt_modifiers_from_mir(MirInputEventModifiers modifiers)
242246{
243 ulong timestamp = event.event_time / 1000000;247 int q_modifiers = Qt::NoModifier;
244 xkb_keysym_t xk_sym = static_cast<xkb_keysym_t>(event.key_code);248 if (modifiers & mir_input_event_modifier_shift) {
249 q_modifiers |= Qt::ShiftModifier;
250 }
251 if (modifiers & mir_input_event_modifier_ctrl) {
252 q_modifiers |= Qt::ControlModifier;
253 }
254 if (modifiers & mir_input_event_modifier_alt) {
255 q_modifiers |= Qt::AltModifier;
256 }
257 if (modifiers & mir_input_event_modifier_meta) {
258 q_modifiers |= Qt::MetaModifier;
259 }
260 return static_cast<Qt::KeyboardModifiers>(q_modifiers);
261}
262
263Qt::MouseButton extract_buttons(MirPointerInputEvent const* pev)
264{
265 int buttons = Qt::NoButton;
266 if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_primary))
267 buttons |= Qt::LeftButton;
268 if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_secondary))
269 buttons |= Qt::RightButton;
270 if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_tertiary))
271 buttons |= Qt::MidButton;
272
273 // TODO: Should mir back and forward buttons exist?
274 // should they be Qt::X button 1 and 2?
275 return static_cast<Qt::MouseButton>(buttons);
276}
277}
278
279void QtEventFeeder::dispatchPointer(MirInputEvent const* ev)
280{
281 if (!mQtWindowSystem->hasTargetWindow())
282 return;
283
284 auto timestamp = mir_input_event_get_event_time(ev) / 1000000;
285
286 auto pev = mir_input_event_get_pointer_input_event(ev);
287 auto modifiers = qt_modifiers_from_mir(mir_pointer_input_event_get_modifiers(pev));
288 auto buttons = extract_buttons(pev);
289
290 auto local_point = QPointF(mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_x),
291 mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_y));
292
293 mQtWindowSystem->handleMouseEvent(timestamp, local_point,
294 buttons, modifiers);
295}
296
297void QtEventFeeder::dispatchKey(MirInputEvent const* event)
298{
299 if (!mQtWindowSystem->hasTargetWindow())
300 return;
301
302 ulong timestamp = mir_input_event_get_event_time(event) / 1000000;
303
304 auto kev = mir_input_event_get_key_input_event(event);
305 xkb_keysym_t xk_sym = mir_key_input_event_get_key_code(kev);
245306
246 // Key modifier and unicode index mapping.307 // Key modifier and unicode index mapping.
247 const int kEventModifiers = event.modifiers;308 auto modifiers = qt_modifiers_from_mir(mir_key_input_event_get_modifiers(kev));
248 Qt::KeyboardModifiers modifiers = Qt::NoModifier;
249 if (kEventModifiers & mir_key_modifier_shift) {
250 modifiers |= Qt::ShiftModifier;
251 }
252 if (kEventModifiers & mir_key_modifier_ctrl) {
253 modifiers |= Qt::ControlModifier;
254 }
255 if (kEventModifiers & mir_key_modifier_alt) {
256 modifiers |= Qt::AltModifier;
257 }
258 if (kEventModifiers & mir_key_modifier_meta) {
259 modifiers |= Qt::MetaModifier;
260 }
261309
262 // Key action310 // Key action
263 QEvent::Type keyType;311 QEvent::Type keyType = QEvent::KeyRelease;
264 if (event.action == mir_key_action_down) {312 bool is_auto_rep = false;
313
314 switch (mir_key_input_event_get_action(kev))
315 {
316 case mir_key_input_event_action_repeat:
317 is_auto_rep = true; // fall-through
318 case mir_key_input_event_action_down:
265 keyType = QEvent::KeyPress;319 keyType = QEvent::KeyPress;
266 } else {320 break;
321 case mir_key_input_event_action_up:
267 keyType = QEvent::KeyRelease;322 keyType = QEvent::KeyRelease;
323 break;
324 default:
325 break;
268 }326 }
269327
270 // Key event propagation.328 // Key event propagation.
@@ -272,13 +330,13 @@
272 int keyCode = translateKeysym(xk_sym, s, sizeof(s));330 int keyCode = translateKeysym(xk_sym, s, sizeof(s));
273 QString text = QString::fromLatin1(s);331 QString text = QString::fromLatin1(s);
274 332
275 bool is_auto_rep = event.repeat_count > 0;
276
277 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();333 QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext();
278 if (context) {334 if (context) {
279 // TODO: consider event.repeat_count335 // TODO: consider event.repeat_count
280 QKeyEvent qKeyEvent(keyType, keyCode, modifiers,336 QKeyEvent qKeyEvent(keyType, keyCode, modifiers,
281 event.scan_code, event.key_code, event.modifiers,337 mir_key_input_event_get_scan_code(kev),
338 mir_key_input_event_get_key_code(kev),
339 mir_key_input_event_get_modifiers(kev),
282 text, is_auto_rep);340 text, is_auto_rep);
283 qKeyEvent.setTimestamp(timestamp);341 qKeyEvent.setTimestamp(timestamp);
284 if (context->filterEvent(&qKeyEvent)) {342 if (context->filterEvent(&qKeyEvent)) {
@@ -288,27 +346,17 @@
288 }346 }
289347
290 mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers,348 mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers,
291 event.scan_code, event.key_code, event.modifiers, text, is_auto_rep);349 mir_key_input_event_get_scan_code(kev),
350 mir_key_input_event_get_key_code(kev),
351 mir_key_input_event_get_modifiers(kev), text, is_auto_rep);
292}352}
293353
294void QtEventFeeder::dispatchMotion(MirMotionEvent const& event)354void QtEventFeeder::dispatchTouch(MirInputEvent const* event)
295{355{
296 if (!mQtWindowSystem->hasTargetWindow())356 if (!mQtWindowSystem->hasTargetWindow())
297 return;357 return;
298358
299 const int mirMotionAction = event.action & MirEventActionMask;359 auto tev = mir_input_event_get_touch_input_event(event);
300
301 // Ignore the events that do not interest us (or that we currently don't support or know
302 // how to translate into Qt events)
303 if (mirMotionAction != mir_motion_action_move
304 && mirMotionAction != mir_motion_action_down
305 && mirMotionAction != mir_motion_action_up
306 && mirMotionAction != mir_motion_action_pointer_down
307 && mirMotionAction != mir_motion_action_pointer_up
308 && mirMotionAction != mir_motion_action_cancel) {
309 return;
310 }
311
312360
313 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That361 // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That
314 // needs to be fixed as soon as the compat input lib adds query support.362 // needs to be fixed as soon as the compat input lib adds query support.
@@ -318,72 +366,48 @@
318366
319 // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left367 // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left
320 // as Qt::TouchPointMoved368 // as Qt::TouchPointMoved
321 const int kPointerCount = (int) event.pointer_count;369 const int kPointerCount = mir_touch_input_event_get_touch_count(tev);
322 for (int i = 0; i < kPointerCount; ++i) {370 for (int i = 0; i < kPointerCount; ++i) {
323 QWindowSystemInterface::TouchPoint touchPoint;371 QWindowSystemInterface::TouchPoint touchPoint;
324372
325 const float kX = event.pointer_coordinates[i].x;373 const float kX = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_x);
326 const float kY = event.pointer_coordinates[i].y;374 const float kY = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_y);
327 const float kW = event.pointer_coordinates[i].touch_major;375 const float kW = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_touch_major);
328 const float kH = event.pointer_coordinates[i].touch_minor;376 const float kH = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_touch_minor);
329 const float kP = event.pointer_coordinates[i].pressure;377 const float kP = mir_touch_input_event_get_touch_axis_value(tev, i, mir_touch_input_axis_pressure);
330 touchPoint.id = event.pointer_coordinates[i].id;378 touchPoint.id = mir_touch_input_event_get_touch_id(tev, i);
379
331 touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height());380 touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height());
332 touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH);381 touchPoint.area = QRectF(kX - (kW / 2.0), kY - (kH / 2.0), kW, kH);
333 touchPoint.pressure = kP / kMaxPressure;382 touchPoint.pressure = kP / kMaxPressure;
334 touchPoint.state = Qt::TouchPointMoved;383 switch (mir_touch_input_event_get_touch_action(tev, i))
384 {
385 case mir_touch_input_event_action_up:
386 touchPoint.state = Qt::TouchPointReleased;
387 break;
388 case mir_touch_input_event_action_down:
389 touchPoint.state = Qt::TouchPointPressed;
390 break;
391 case mir_touch_input_event_action_change:
392 touchPoint.state = Qt::TouchPointMoved;
393 break;
394 default:
395 break;
396 }
335397
336 touchPoints.append(touchPoint);398 touchPoints.append(touchPoint);
337 }399 }
338400
339 switch (mirMotionAction) {
340 case mir_motion_action_move:
341 // No extra work needed.
342 break;
343
344 case mir_motion_action_down:
345 // NB: hardcoded index 0 because there's only a single touch point in this case
346 touchPoints[0].state = Qt::TouchPointPressed;
347 break;
348
349 case mir_motion_action_up:
350 touchPoints[0].state = Qt::TouchPointReleased;
351 break;
352
353 case mir_motion_action_pointer_down: {
354 const int index = (event.action & MirEventActionPointerIndexMask) >>
355 MirEventActionPointerIndexShift;
356 touchPoints[index].state = Qt::TouchPointPressed;
357 break;
358 }
359
360 case mir_motion_action_cancel:
361 case mir_motion_action_pointer_up: {
362 const int index = (event.action & MirEventActionPointerIndexMask) >>
363 MirEventActionPointerIndexShift;
364 touchPoints[index].state = Qt::TouchPointReleased;
365 break;
366 }
367
368 case mir_motion_action_outside:
369 case mir_motion_action_hover_move:
370 case mir_motion_action_scroll:
371 case mir_motion_action_hover_enter:
372 case mir_motion_action_hover_exit:
373 default:
374 // Should never reach this point. If so, it's a programming error.
375 qFatal("Trying to handle unsupported motion event action");
376 }
377
378 // Qt needs a happy, sane stream of touch events. So let's make sure we're not forwarding401 // Qt needs a happy, sane stream of touch events. So let's make sure we're not forwarding
379 // any insanity.402 // any insanity.
380 validateTouches(touchPoints);403 validateTouches(touchPoints);
381404
382 // Touch event propagation.405 // Touch event propagation.
383 mQtWindowSystem->handleTouchEvent(406 mQtWindowSystem->handleTouchEvent(
384 event.event_time / 1000000, //scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable407 //scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable
385 mTouchDevice,408 mir_input_event_get_event_time(event) / 1000000,
386 touchPoints);409 mTouchDevice,
410 touchPoints);
387}411}
388412
389void QtEventFeeder::start()413void QtEventFeeder::start()
@@ -396,12 +420,12 @@
396 // not used420 // not used
397}421}
398422
399void QtEventFeeder::configuration_changed(nsecs_t when)423void QtEventFeeder::configuration_changed(std::chrono::nanoseconds when)
400{424{
401 Q_UNUSED(when);425 Q_UNUSED(when);
402}426}
403427
404void QtEventFeeder::device_reset(int32_t device_id, nsecs_t when)428void QtEventFeeder::device_reset(int32_t device_id, std::chrono::nanoseconds when)
405{429{
406 Q_UNUSED(device_id);430 Q_UNUSED(device_id);
407 Q_UNUSED(when);431 Q_UNUSED(when);
408432
=== modified file 'src/platforms/mirserver/qteventfeeder.h'
--- src/platforms/mirserver/qteventfeeder.h 2014-08-28 12:22:55 +0000
+++ src/platforms/mirserver/qteventfeeder.h 2015-02-05 10:26:37 +0000
@@ -51,6 +51,7 @@
51 virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device,51 virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device,
52 const QList<struct QWindowSystemInterface::TouchPoint> &points,52 const QList<struct QWindowSystemInterface::TouchPoint> &points,
53 Qt::KeyboardModifiers mods = Qt::NoModifier) = 0;53 Qt::KeyboardModifiers mods = Qt::NoModifier) = 0;
54 virtual void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) = 0;
54 };55 };
5556
56 QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr);57 QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr);
@@ -60,15 +61,16 @@
60 static const int MirEventActionPointerIndexMask;61 static const int MirEventActionPointerIndexMask;
61 static const int MirEventActionPointerIndexShift;62 static const int MirEventActionPointerIndexShift;
6263
63 void configuration_changed(nsecs_t when) override;64 void configuration_changed(std::chrono::nanoseconds when) override;
64 void device_reset(int32_t device_id, nsecs_t when) override;65 void device_reset(int32_t device_id, std::chrono::nanoseconds when) override;
65 void dispatch(MirEvent const& event) override;66 void dispatch(MirEvent const& event) override;
66 void start() override;67 void start() override;
67 void stop() override;68 void stop() override;
6869
69private:70private:
70 void dispatchKey(MirKeyEvent const& event);71 void dispatchKey(MirInputEvent const* event);
71 void dispatchMotion(MirMotionEvent const& event);72 void dispatchTouch(MirInputEvent const* event);
73 void dispatchPointer(MirInputEvent const* event);
72 void validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints);74 void validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints);
73 bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint);75 bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint);
7476
7577
=== removed file 'src/platforms/mirserver/surfaceconfigurator.cpp'
--- src/platforms/mirserver/surfaceconfigurator.cpp 2014-04-02 16:10:34 +0000
+++ src/platforms/mirserver/surfaceconfigurator.cpp 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1/*
2 * Copyright (C) 2013,2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#include "surfaceconfigurator.h"
18
19namespace ms = mir::scene;
20
21SurfaceConfigurator::SurfaceConfigurator()
22{
23 qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib");
24}
25
26int SurfaceConfigurator::select_attribute_value(ms::Surface const&, MirSurfaceAttrib, int requested_value)
27{
28 return requested_value;
29}
30
31void SurfaceConfigurator::attribute_set(ms::Surface const& surface, MirSurfaceAttrib attrib, int value)
32{
33 Q_EMIT surfaceAttributeChanged(&surface, attrib, value);
34}
350
=== removed file 'src/platforms/mirserver/surfaceconfigurator.h'
--- src/platforms/mirserver/surfaceconfigurator.h 2014-04-02 16:10:34 +0000
+++ src/platforms/mirserver/surfaceconfigurator.h 1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
1/*
2 * Copyright (C) 2013,2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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
17#ifndef SURFACECONFIGURATOR_H
18#define SURFACECONFIGURATOR_H
19
20#include <QObject>
21
22#include <mir/scene/surface_configurator.h>
23#include <mir_toolkit/common.h>
24
25namespace mir { namespace scene { class Surface; }}
26
27class SurfaceConfigurator : public QObject, public mir::scene::SurfaceConfigurator
28{
29 Q_OBJECT
30
31public:
32 SurfaceConfigurator();
33
34 int select_attribute_value(mir::scene::Surface const&, MirSurfaceAttrib, int) override;
35 void attribute_set(mir::scene::Surface const&, MirSurfaceAttrib, int) override;
36
37Q_SIGNALS:
38 void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int);
39};
40
41#endif // SURFACECONFIGURATOR_H
420
=== modified file 'tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h'
--- tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2014-08-28 12:20:13 +0000
+++ tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2015-02-05 10:26:37 +0000
@@ -34,6 +34,7 @@
34 MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device,34 MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device,
35 const QList<struct QWindowSystemInterface::TouchPoint> &points,35 const QList<struct QWindowSystemInterface::TouchPoint> &points,
36 Qt::KeyboardModifiers mods));36 Qt::KeyboardModifiers mods));
37 MOCK_METHOD4(handleMouseEvent, void(ulong, QPointF, Qt::MouseButton, Qt::KeyboardModifiers));
37};38};
3839
39namespace testing40namespace testing
4041
=== modified file 'tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp'
--- tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2014-08-28 13:12:30 +0000
+++ tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2015-02-05 10:26:37 +0000
@@ -15,6 +15,8 @@
15 *15 *
16 */16 */
1717
18#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
19
18#include <gmock/gmock.h>20#include <gmock/gmock.h>
19#include <gtest/gtest.h>21#include <gtest/gtest.h>
2022
@@ -191,34 +193,3 @@
191 ASSERT_TRUE(Mock::VerifyAndClearExpectations(mockWindowSystem));193 ASSERT_TRUE(Mock::VerifyAndClearExpectations(mockWindowSystem));
192}194}
193195
194TEST_F(QtEventFeederTest, IgnoreHovering)
195{
196 setIrrelevantMockWindowSystemExpectations();
197 EXPECT_CALL(*mockWindowSystem, handleTouchEvent(_,_,_,_)).Times(0);
198
199 MirEvent mirEvent;
200 mirEvent.type = mir_event_type_motion;
201 mirEvent.motion.pointer_count = 1;
202 mirEvent.motion.pointer_coordinates[0].id = 0;
203 mirEvent.motion.pointer_coordinates[0].x = 10;
204 mirEvent.motion.pointer_coordinates[0].y = 10;
205 mirEvent.motion.pointer_coordinates[0].touch_major = 1;
206 mirEvent.motion.pointer_coordinates[0].touch_minor = 1;
207 mirEvent.motion.pointer_coordinates[0].pressure = 10;
208 mirEvent.motion.action = mir_motion_action_hover_enter;
209 mirEvent.motion.event_time = 123 * 1000000;
210
211 qtEventFeeder->dispatch(mirEvent);
212
213 mirEvent.motion.pointer_coordinates[0].x = 20;
214 mirEvent.motion.pointer_coordinates[0].y = 20;
215 mirEvent.motion.action = mir_motion_action_hover_move;
216 mirEvent.motion.event_time = 125 * 1000000;
217
218 qtEventFeeder->dispatch(mirEvent);
219
220 mirEvent.motion.action = mir_motion_action_hover_exit;
221 mirEvent.motion.event_time = 127 * 1000000;
222
223 qtEventFeeder->dispatch(mirEvent);
224}
225196
=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
--- tests/modules/ApplicationManager/application_manager_test.cpp 2014-11-13 16:26:03 +0000
+++ tests/modules/ApplicationManager/application_manager_test.cpp 2015-02-05 10:26:37 +0000
@@ -15,6 +15,8 @@
15 *15 *
16 */16 */
1717
18#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
19
18#include <thread>20#include <thread>
19#include <condition_variable>21#include <condition_variable>
20#include <QSignalSpy>22#include <QSignalSpy>
@@ -2135,3 +2137,100 @@
2135 cv.wait(lk, [&] { return done; } );2137 cv.wait(lk, [&] { return done; } );
2136 }2138 }
2137}2139}
2140
2141/*
2142 1 - launch and focus a main stage app
2143 * main stage app is running and focused
2144 2 - launch and focus a side stage app
2145 * main stage app is running but is not focused
2146 * side stage app is running and has focus
2147 3 - focus the main stage app
2148 * main stage app is running and has focus
2149 * side stage app is running but is not focused
2150
2151 This is a regression test for the bug where on step 3, the main stage app was momentarily
2152 suspended and then resumed again.
2153 */
2154TEST_F(ApplicationManagerTests, focusMainStageAfterSideStage)
2155{
2156 using namespace testing;
2157
2158 QString webbrowserAppId("webbrowser-app");
2159 quint64 webbrowserPID = 123;
2160 std::shared_ptr<mir::scene::Surface> webbrowserSurface(nullptr);
2161
2162 QString dialerAppId("dialer-app");
2163 quint64 dialerPID = 456;
2164 std::shared_ptr<mir::scene::Surface> dialerSurface(nullptr);
2165
2166 /*** Start webbrowser-app (main stage) ***/
2167
2168 ON_CALL(appController,appIdHasProcessId(webbrowserPID, webbrowserAppId)).WillByDefault(Return(true));
2169
2170 {
2171 auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(webbrowserAppId, QFileInfo());
2172 ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
2173 ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(webbrowserAppId));
2174 ON_CALL(*mockDesktopFileReader, stageHint()).WillByDefault(Return("MainStage"));
2175
2176 ON_CALL(desktopFileReaderFactory, createInstance(webbrowserAppId, _))
2177 .WillByDefault(Return(mockDesktopFileReader));
2178 }
2179
2180 EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(webbrowserAppId, _))
2181 .Times(1)
2182 .WillOnce(Return(true));
2183
2184 /*auto application =*/ applicationManager.startApplication(webbrowserAppId, ApplicationManager::NoFlag);
2185 applicationManager.onProcessStarting(webbrowserAppId);
2186
2187 {
2188 bool authed = false;
2189 applicationManager.authorizeSession(webbrowserPID, authed);
2190 EXPECT_EQ(authed, true);
2191 }
2192
2193 auto webbrowserSession = std::make_shared<mir::scene::MockSession>(webbrowserAppId.toStdString(), webbrowserPID);
2194 sessionManager.onSessionStarting(webbrowserSession);
2195 applicationManager.focusApplication(webbrowserAppId);
2196 applicationManager.onSessionCreatedSurface(webbrowserSession.get(), webbrowserSurface);
2197
2198 /*** Start dialer-app (side stage) ***/
2199
2200 ON_CALL(appController, appIdHasProcessId(dialerPID, dialerAppId)).WillByDefault(Return(true));
2201
2202 {
2203 auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(dialerAppId, QFileInfo());
2204 ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
2205 ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(dialerAppId));
2206 ON_CALL(*mockDesktopFileReader, stageHint()).WillByDefault(Return("SideStage"));
2207
2208 ON_CALL(desktopFileReaderFactory, createInstance(dialerAppId, _))
2209 .WillByDefault(Return(mockDesktopFileReader));
2210 }
2211
2212 EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(dialerAppId, _))
2213 .Times(1)
2214 .WillOnce(Return(true));
2215
2216 /*auto application =*/ applicationManager.startApplication(dialerAppId, ApplicationManager::NoFlag);
2217 applicationManager.onProcessStarting(dialerAppId);
2218
2219 {
2220 bool authed = false;
2221 applicationManager.authorizeSession(dialerPID, authed);
2222 EXPECT_EQ(authed, true);
2223 }
2224
2225 auto dialerSession = std::make_shared<mir::scene::MockSession>(dialerAppId.toStdString(), dialerPID);
2226 sessionManager.onSessionStarting(dialerSession);
2227 applicationManager.focusApplication(dialerAppId);
2228 applicationManager.onSessionCreatedSurface(dialerSession.get(), dialerSurface);
2229
2230 /*** Focus webbrowser ***/
2231
2232 // Nothing should happen as it's already the running main stage app
2233 EXPECT_CALL(*webbrowserSession.get(), set_lifecycle_state(_))
2234 .Times(0);
2235 applicationManager.focusApplication(webbrowserAppId);
2236}
21382237
=== modified file 'tests/modules/DesktopFileReader/desktopfilereader_test.cpp'
--- tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2014-10-14 23:15:46 +0000
+++ tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2015-02-05 10:26:37 +0000
@@ -126,3 +126,73 @@
126 EXPECT_EQ(reader->comment(), "Ubuntu 简易计算器");126 EXPECT_EQ(reader->comment(), "Ubuntu 简易计算器");
127 EXPECT_EQ(reader->splashTitle(), "计算器 2.0");127 EXPECT_EQ(reader->splashTitle(), "计算器 2.0");
128}128}
129
130TEST(DesktopFileReader, parseOrientations)
131{
132 using namespace ::testing;
133
134 const Qt::ScreenOrientations defaultOrientations = Qt::PortraitOrientation | Qt::LandscapeOrientation
135 | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation;
136 bool ok;
137 Qt::ScreenOrientations orientations;
138
139 ok = DesktopFileReader::parseOrientations(QString(), orientations);
140 ASSERT_TRUE(ok);
141 EXPECT_EQ(defaultOrientations, orientations);
142
143 ok = DesktopFileReader::parseOrientations("An invalid string!", orientations);
144 ASSERT_FALSE(ok);
145 EXPECT_EQ(defaultOrientations, orientations);
146
147 ok = DesktopFileReader::parseOrientations("landscape", orientations);
148 ASSERT_TRUE(ok);
149 EXPECT_EQ(Qt::LandscapeOrientation, orientations);
150
151 ok = DesktopFileReader::parseOrientations(" InvertedPortrait , Portrait ", orientations);
152 ASSERT_TRUE(ok);
153 EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::PortraitOrientation, orientations);
154
155 ok = DesktopFileReader::parseOrientations(",inverted-landscape, inverted_portrait, ", orientations);
156 ASSERT_TRUE(ok);
157 EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation, orientations);
158
159 ok = DesktopFileReader::parseOrientations(",inverted-landscape, some-invalid-text, ", orientations);
160 ASSERT_FALSE(ok);
161 EXPECT_EQ(defaultOrientations, orientations);
162
163 ok = DesktopFileReader::parseOrientations("landscape;portrait", orientations);
164 ASSERT_TRUE(ok);
165 EXPECT_EQ(Qt::PortraitOrientation | Qt::LandscapeOrientation, orientations);
166
167 ok = DesktopFileReader::parseOrientations("primary", orientations);
168 ASSERT_TRUE(ok);
169 EXPECT_EQ(Qt::PrimaryOrientation, orientations);
170
171 ok = DesktopFileReader::parseOrientations("landscpe,primary", orientations);
172 ASSERT_FALSE(ok);
173 EXPECT_EQ(defaultOrientations, orientations);
174}
175
176TEST(DesktopFileReader, parseBoolean)
177{
178 using namespace ::testing;
179
180 bool ok;
181 bool boolean;
182
183 ok = DesktopFileReader::parseBoolean(QString(), boolean);
184 ASSERT_TRUE(ok);
185 EXPECT_EQ(false, boolean);
186
187 ok = DesktopFileReader::parseBoolean(" Yes ", boolean);
188 ASSERT_TRUE(ok);
189 EXPECT_EQ(true, boolean);
190
191 ok = DesktopFileReader::parseBoolean("False", boolean);
192 ASSERT_TRUE(ok);
193 EXPECT_EQ(false, boolean);
194
195 ok = DesktopFileReader::parseBoolean("Hello World!", boolean);
196 ASSERT_FALSE(ok);
197 EXPECT_EQ(false, boolean);
198}
129199
=== modified file 'tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp'
--- tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 2014-12-12 15:15:06 +0000
+++ tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 2015-02-05 10:26:37 +0000
@@ -15,6 +15,8 @@
15 *15 *
16 */16 */
1717
18#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
19
18#include <gtest/gtest.h>20#include <gtest/gtest.h>
1921
20#include <QLoggingCategory>22#include <QLoggingCategory>
@@ -60,29 +62,43 @@
60 EXPECT_CALL(*mockSurface, type()).Times(AnyNumber()).WillRepeatedly(Return(mir_surface_type_normal));62 EXPECT_CALL(*mockSurface, type()).Times(AnyNumber()).WillRepeatedly(Return(mir_surface_type_normal));
61 EXPECT_CALL(*mockSession, setSurface(_)).Times(AnyNumber());63 EXPECT_CALL(*mockSession, setSurface(_)).Times(AnyNumber());
6264
65 auto get_touch_event = [](MirEvent const& event) -> MirTouchInputEvent const*
66 {
67 if (mir_event_get_type(&event) != mir_event_type_input)
68 return nullptr;
69 auto const* input_event = mir_event_get_input_event(&event);
70 if (mir_input_event_get_type(input_event) != mir_input_event_type_touch)
71 return nullptr;
72 return mir_input_event_get_touch_input_event(input_event);
73 };
74
75 auto event_matches = [&](MirEvent const& event,
76 int touch_count,
77 MirTouchInputEventTouchAction action,
78 MirTouchInputEventTouchId touch_id) ->void
79 {
80 auto const* touch_event = get_touch_event(event);
81 ASSERT_NE(touch_event, nullptr);
82 ASSERT_EQ(touch_count, mir_touch_input_event_get_touch_count(touch_event));
83 ASSERT_EQ(action, mir_touch_input_event_get_touch_action(touch_event,0));
84 ASSERT_EQ(touch_id, mir_touch_input_event_get_touch_id(touch_event,0));
85 };
86
63 // The touch event sequence we expect mir::input::surface to receive from MirSurfaceItem.87 // The touch event sequence we expect mir::input::surface to receive from MirSurfaceItem.
64 // It should properly finish the sequence for touch 0 ('down', 'move' and 'up') before starting88 // It should properly finish the sequence for touch 0 ('down', 'move' and 'up') before starting
65 // the sequence for touch 1.89 // the sequence for touch 1.
66 EXPECT_CALL(*mockSurface, consume(_))90 EXPECT_CALL(*mockSurface, consume(_))
67 .WillOnce(Invoke([] (MirEvent const& mirEvent) {91 .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
68 ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action);92 event_matches(mirEvent, 1, mir_touch_input_event_action_down, 0);
69 ASSERT_EQ(1, mirEvent.motion.pointer_count);93 }))
70 ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);94 .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
71 }))95 event_matches(mirEvent, 1, mir_touch_input_event_action_change, 0);
72 .WillOnce(Invoke([] (MirEvent const& mirEvent) {96 }))
73 ASSERT_EQ(mir_motion_action_move, mirEvent.motion.action);97 .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
74 ASSERT_EQ(1, mirEvent.motion.pointer_count);98 event_matches(mirEvent, 1, mir_touch_input_event_action_up, 0);
75 ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);99 }))
76 }))100 .WillOnce(Invoke([&] (MirEvent const& mirEvent) {
77 .WillOnce(Invoke([] (MirEvent const& mirEvent) {101 event_matches(mirEvent, 1, mir_touch_input_event_action_down, 1);
78 ASSERT_EQ(mir_motion_action_up, mirEvent.motion.action);
79 ASSERT_EQ(1, mirEvent.motion.pointer_count);
80 ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id);
81 }))
82 .WillOnce(Invoke([] (MirEvent const& mirEvent) {
83 ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action);
84 ASSERT_EQ(1, mirEvent.motion.pointer_count);
85 ASSERT_EQ(1, mirEvent.motion.pointer_coordinates[0].id);
86 }));102 }));
87103
88104
@@ -95,18 +111,18 @@
95 touchPoints[0].setId(0);111 touchPoints[0].setId(0);
96 touchPoints[0].setState(Qt::TouchPointPressed);112 touchPoints[0].setState(Qt::TouchPointPressed);
97 surfaceItem->processTouchEvent(QEvent::TouchBegin,113 surfaceItem->processTouchEvent(QEvent::TouchBegin,
98 timestamp, touchPoints, touchPoints[0].state());114 timestamp, Qt::NoModifier, touchPoints, touchPoints[0].state());
99115
100 touchPoints[0].setState(Qt::TouchPointMoved);116 touchPoints[0].setState(Qt::TouchPointMoved);
101 surfaceItem->processTouchEvent(QEvent::TouchUpdate,117 surfaceItem->processTouchEvent(QEvent::TouchUpdate,
102 timestamp + 10, touchPoints, touchPoints[0].state());118 timestamp + 10, Qt::NoModifier, touchPoints, touchPoints[0].state());
103119
104 // Starting a new touch sequence (with touch 1) without ending the current one120 // Starting a new touch sequence (with touch 1) without ending the current one
105 // (wich has touch 0).121 // (wich has touch 0).
106 touchPoints[0].setId(1);122 touchPoints[0].setId(1);
107 touchPoints[0].setState(Qt::TouchPointPressed);123 touchPoints[0].setState(Qt::TouchPointPressed);
108 surfaceItem->processTouchEvent(QEvent::TouchBegin,124 surfaceItem->processTouchEvent(QEvent::TouchBegin,
109 timestamp + 20, touchPoints, touchPoints[0].state());125 timestamp + 20, Qt::NoModifier, touchPoints, touchPoints[0].state());
110 126
111 delete surfaceItem;127 delete surfaceItem;
112 delete mockSession;128 delete mockSession;
113129
=== removed file 'tests/modules/common/mock_focus_controller.h'
--- tests/modules/common/mock_focus_controller.h 2014-09-11 16:18:40 +0000
+++ tests/modules/common/mock_focus_controller.h 1970-01-01 00:00:00 +0000
@@ -1,40 +0,0 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * 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 */
17
18#ifndef MOCK_MIR_SHELL_FOCUS_CONTROLLER_H
19#define MOCK_MIR_SHELL_FOCUS_CONTROLLER_H
20
21#include <mir/shell/focus_controller.h>
22#include <gmock/gmock.h>
23
24#include <string>
25
26namespace mir {
27namespace shell {
28
29class MockFocusController : public FocusController
30{
31public:
32 MOCK_METHOD0(focus_next, void());
33 MOCK_CONST_METHOD0(focussed_application, std::weak_ptr<scene::Session>());
34 MOCK_METHOD1(set_focus_to, void(std::shared_ptr<scene::Session>const&));
35};
36
37} // namespace shell
38} // namespace mir
39
40#endif // MOCK_MIR_SHELL_FOCUS_CONTROLLER_H_
410
=== modified file 'tests/modules/common/mock_mir_session.h'
--- tests/modules/common/mock_mir_session.h 2015-01-07 15:35:29 +0000
+++ tests/modules/common/mock_mir_session.h 2015-02-05 10:26:37 +0000
@@ -49,6 +49,7 @@
4949
50 MOCK_CONST_METHOD0(default_surface, std::shared_ptr<Surface>());50 MOCK_CONST_METHOD0(default_surface, std::shared_ptr<Surface>());
51 MOCK_CONST_METHOD1(get_surface, std::shared_ptr<frontend::Surface>(frontend::SurfaceId));51 MOCK_CONST_METHOD1(get_surface, std::shared_ptr<frontend::Surface>(frontend::SurfaceId));
52 MOCK_CONST_METHOD1(surface, std::shared_ptr<scene::Surface>(frontend::SurfaceId));
5253
53 MOCK_METHOD1(take_snapshot, void(SnapshotCallback const&));54 MOCK_METHOD1(take_snapshot, void(SnapshotCallback const&));
54 MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState));55 MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState));
5556
=== modified file 'tests/modules/common/mock_renderable.h'
--- tests/modules/common/mock_renderable.h 2014-09-11 16:18:40 +0000
+++ tests/modules/common/mock_renderable.h 2015-02-05 10:26:37 +0000
@@ -34,9 +34,7 @@
34 MOCK_CONST_METHOD0(screen_position, geometry::Rectangle());34 MOCK_CONST_METHOD0(screen_position, geometry::Rectangle());
35 MOCK_CONST_METHOD0(alpha, float() );35 MOCK_CONST_METHOD0(alpha, float() );
36 MOCK_CONST_METHOD0(transformation, glm::mat4());36 MOCK_CONST_METHOD0(transformation, glm::mat4());
37 MOCK_CONST_METHOD0(visible, bool());
38 MOCK_CONST_METHOD0(shaped, bool());37 MOCK_CONST_METHOD0(shaped, bool());
39 MOCK_CONST_METHOD0(buffers_ready_for_compositor, int());
40};38};
4139
42} // namespace graphics40} // namespace graphics
4341
=== modified file 'tests/modules/common/mock_surface.h'
--- tests/modules/common/mock_surface.h 2015-01-06 17:28:52 +0000
+++ tests/modules/common/mock_surface.h 2015-02-05 10:26:37 +0000
@@ -36,6 +36,7 @@
36 MOCK_CONST_METHOD0(input_bounds, geometry::Rectangle());36 MOCK_CONST_METHOD0(input_bounds, geometry::Rectangle());
37 MOCK_CONST_METHOD0(top_left, geometry::Point());37 MOCK_CONST_METHOD0(top_left, geometry::Point());
38 MOCK_CONST_METHOD0(size, geometry::Size());38 MOCK_CONST_METHOD0(size, geometry::Size());
39 MOCK_CONST_METHOD0(parent, std::shared_ptr<Surface>());
3940
40 std::unique_ptr<graphics::Renderable> compositor_snapshot(void const* /*compositor_id*/) const41 std::unique_ptr<graphics::Renderable> compositor_snapshot(void const* /*compositor_id*/) const
41 {42 {
@@ -64,6 +65,7 @@
64 MOCK_CONST_METHOD0(input_channel, std::shared_ptr<input::InputChannel>());65 MOCK_CONST_METHOD0(input_channel, std::shared_ptr<input::InputChannel>());
65 MOCK_METHOD1(set_reception_mode, void(input::InputReceptionMode mode));66 MOCK_METHOD1(set_reception_mode, void(input::InputReceptionMode mode));
66 MOCK_METHOD0(request_client_surface_close, void());67 MOCK_METHOD0(request_client_surface_close, void());
68 MOCK_CONST_METHOD1(buffers_ready_for_compositor, int(void const*));
6769
68 // from mir::input::surface70 // from mir::input::surface
69 MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point));71 MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point));
7072
=== modified file 'tests/modules/common/qtmir_test.h'
--- tests/modules/common/qtmir_test.h 2015-01-09 11:24:44 +0000
+++ tests/modules/common/qtmir_test.h 2015-02-05 10:26:37 +0000
@@ -33,7 +33,6 @@
33#include "mock_desktop_file_reader.h"33#include "mock_desktop_file_reader.h"
34#include "mock_proc_info.h"34#include "mock_proc_info.h"
35#include "mock_mir_session.h"35#include "mock_mir_session.h"
36#include "mock_focus_controller.h"
37#include "mock_prompt_session_manager.h"36#include "mock_prompt_session_manager.h"
38#include "mock_prompt_session.h"37#include "mock_prompt_session.h"
39#include "mock_shared_wakelock.h"38#include "mock_shared_wakelock.h"

Subscribers

People subscribed via source and target branches