Merge lp:~mir-team/qtmir/port-to-msh-shell-and-mirevent2 into lp:qtmir
- port-to-msh-shell-and-mirevent2
- Merge into trunk
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 |
Related bugs: |
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
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2014-12-09 14:12:57 +0000 | |||
3 | +++ CMakeLists.txt 2015-02-05 10:26:37 +0000 | |||
4 | @@ -78,6 +78,7 @@ | |||
5 | 78 | pkg_check_modules(GIO_UNIX gio-unix-2.0) | 78 | pkg_check_modules(GIO_UNIX gio-unix-2.0) |
6 | 79 | pkg_check_modules(LTTNG lttng-ust) | 79 | pkg_check_modules(LTTNG lttng-ust) |
7 | 80 | 80 | ||
8 | 81 | add_definitions(-DMIR_REQUIRE_DEPRECATED_EVENT_OPT_IN=1) | ||
9 | 81 | 82 | ||
10 | 82 | # We expect this to be set via debian/rules for GLES builds | 83 | # We expect this to be set via debian/rules for GLES builds |
11 | 83 | if ("${USE_OPENGLES}" STREQUAL 1) | 84 | if ("${USE_OPENGLES}" STREQUAL 1) |
12 | 84 | 85 | ||
13 | === modified file 'debian/changelog' | |||
14 | --- debian/changelog 2015-01-15 15:19:46 +0000 | |||
15 | +++ debian/changelog 2015-02-05 10:26:37 +0000 | |||
16 | @@ -1,3 +1,9 @@ | |||
17 | 1 | qtmir (0.4.5) UNRELEASED; urgency=medium | ||
18 | 2 | |||
19 | 3 | * Add X-Ubuntu-Supported-Orientations desktop file entry | ||
20 | 4 | |||
21 | 5 | -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 31 Oct 2014 10:17:42 -0200 | ||
22 | 6 | |||
23 | 1 | qtmir (0.4.4+15.04.20150115-0ubuntu1) vivid; urgency=low | 7 | qtmir (0.4.4+15.04.20150115-0ubuntu1) vivid; urgency=low |
24 | 2 | 8 | ||
25 | 3 | [ Gerry Boland ] | 9 | [ Gerry Boland ] |
26 | 4 | 10 | ||
27 | === modified file 'debian/control' | |||
28 | --- debian/control 2015-01-14 09:07:31 +0000 | |||
29 | +++ debian/control 2015-02-05 10:26:37 +0000 | |||
30 | @@ -10,7 +10,7 @@ | |||
31 | 10 | # version. To allow cross-compiling to work, we also must | 10 | # version. To allow cross-compiling to work, we also must |
32 | 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++ |
33 | 12 | # on an x86 CPU for example, when cross-compiling. | 12 | # on an x86 CPU for example, when cross-compiling. |
35 | 13 | g++-4.9:native, | 13 | g++-4.9, |
36 | 14 | google-mock (>= 1.6.0+svn437), | 14 | google-mock (>= 1.6.0+svn437), |
37 | 15 | libboost-system-dev, | 15 | libboost-system-dev, |
38 | 16 | libfontconfig1-dev, | 16 | libfontconfig1-dev, |
39 | @@ -26,7 +26,7 @@ | |||
40 | 26 | libubuntu-app-launch2-dev, | 26 | libubuntu-app-launch2-dev, |
41 | 27 | libubuntu-application-api-dev (>= 2.1.0), | 27 | libubuntu-application-api-dev (>= 2.1.0), |
42 | 28 | libudev-dev, | 28 | libudev-dev, |
44 | 29 | libunity-api-dev (>= 7.92), | 29 | libunity-api-dev (>= 7.94), |
45 | 30 | liburl-dispatcher1-dev, | 30 | liburl-dispatcher1-dev, |
46 | 31 | libxkbcommon-dev, | 31 | libxkbcommon-dev, |
47 | 32 | libxrender-dev, | 32 | libxrender-dev, |
48 | @@ -96,7 +96,7 @@ | |||
49 | 96 | Conflicts: libqtmir, | 96 | Conflicts: libqtmir, |
50 | 97 | libunity-mir1, | 97 | libunity-mir1, |
51 | 98 | Provides: unity-application-impl, | 98 | Provides: unity-application-impl, |
53 | 99 | unity-application-impl-4, | 99 | unity-application-impl-5, |
54 | 100 | Description: Qt plugin for Unity specific Mir APIs | 100 | Description: Qt plugin for Unity specific Mir APIs |
55 | 101 | QtMir provides Qt/QML bindings for Mir features that are exposed through the | 101 | QtMir provides Qt/QML bindings for Mir features that are exposed through the |
56 | 102 | qtmir-desktop or qtmir-android QPA plugin such as Application management | 102 | qtmir-desktop or qtmir-android QPA plugin such as Application management |
57 | 103 | 103 | ||
58 | === modified file 'src/common/debughelpers.cpp' | |||
59 | --- src/common/debughelpers.cpp 2014-08-27 11:51:28 +0000 | |||
60 | +++ src/common/debughelpers.cpp 2015-02-05 10:26:37 +0000 | |||
61 | @@ -176,31 +176,15 @@ | |||
62 | 176 | } | 176 | } |
63 | 177 | } | 177 | } |
64 | 178 | 178 | ||
66 | 179 | const char *mirMotionActionToStr(int value) | 179 | const char *mirTouchActionToStr(MirTouchInputEventTouchAction action) |
67 | 180 | { | 180 | { |
72 | 181 | switch (value) { | 181 | switch (action) { |
73 | 182 | case mir_motion_action_move: | 182 | case mir_touch_input_event_action_up: |
74 | 183 | return "move"; | 183 | return "up"; |
75 | 184 | case mir_motion_action_down: | 184 | case mir_touch_input_event_action_down: |
76 | 185 | return "down"; | 185 | return "down"; |
95 | 186 | case mir_motion_action_up: | 186 | case mir_touch_input_event_action_change: |
96 | 187 | return "up"; | 187 | return "change"; |
79 | 188 | case mir_motion_action_pointer_down: | ||
80 | 189 | return "pointer_down"; | ||
81 | 190 | case mir_motion_action_cancel: | ||
82 | 191 | return "cancel"; | ||
83 | 192 | case mir_motion_action_pointer_up: | ||
84 | 193 | return "pointer_up"; | ||
85 | 194 | case mir_motion_action_outside: | ||
86 | 195 | return "outside"; | ||
87 | 196 | case mir_motion_action_hover_move: | ||
88 | 197 | return "hover_move"; | ||
89 | 198 | case mir_motion_action_scroll: | ||
90 | 199 | return "scroll"; | ||
91 | 200 | case mir_motion_action_hover_enter: | ||
92 | 201 | return "hover_enter"; | ||
93 | 202 | case mir_motion_action_hover_exit: | ||
94 | 203 | return "hover_exit"; | ||
97 | 204 | default: | 188 | default: |
98 | 205 | return "???"; | 189 | return "???"; |
99 | 206 | } | 190 | } |
100 | 207 | 191 | ||
101 | === modified file 'src/modules/Unity/Application/application.cpp' | |||
102 | --- src/modules/Unity/Application/application.cpp 2015-01-08 12:35:41 +0000 | |||
103 | +++ src/modules/Unity/Application/application.cpp 2015-02-05 10:26:37 +0000 | |||
104 | @@ -60,12 +60,9 @@ | |||
105 | 60 | // FIXME(greyback) need to save long appId internally until ubuntu-app-launch can hide it from us | 60 | // FIXME(greyback) need to save long appId internally until ubuntu-app-launch can hide it from us |
106 | 61 | m_longAppId = desktopFileReader->file().remove(QRegExp(".desktop$")).split('/').last(); | 61 | m_longAppId = desktopFileReader->file().remove(QRegExp(".desktop$")).split('/').last(); |
107 | 62 | 62 | ||
114 | 63 | // FIXME: This is a hack. Remove once we have a real implementation for knowing the supported | 63 | m_supportedOrientations = m_desktopData->supportedOrientations(); |
115 | 64 | // orientations of an app | 64 | |
116 | 65 | m_supportedOrientations = PortraitOrientation | 65 | m_rotatesWindowContents = m_desktopData->rotatesWindowContents(); |
111 | 66 | | LandscapeOrientation | ||
112 | 67 | | InvertedPortraitOrientation | ||
113 | 68 | | InvertedLandscapeOrientation; | ||
117 | 69 | } | 66 | } |
118 | 70 | 67 | ||
119 | 71 | Application::~Application() | 68 | Application::~Application() |
120 | @@ -353,11 +350,16 @@ | |||
121 | 353 | return m_longAppId; | 350 | return m_longAppId; |
122 | 354 | } | 351 | } |
123 | 355 | 352 | ||
125 | 356 | Application::SupportedOrientations Application::supportedOrientations() const | 353 | Qt::ScreenOrientations Application::supportedOrientations() const |
126 | 357 | { | 354 | { |
127 | 358 | return m_supportedOrientations; | 355 | return m_supportedOrientations; |
128 | 359 | } | 356 | } |
129 | 360 | 357 | ||
130 | 358 | bool Application::rotatesWindowContents() const | ||
131 | 359 | { | ||
132 | 360 | return m_rotatesWindowContents; | ||
133 | 361 | } | ||
134 | 362 | |||
135 | 361 | Session* Application::session() const | 363 | Session* Application::session() const |
136 | 362 | { | 364 | { |
137 | 363 | return m_session; | 365 | return m_session; |
138 | 364 | 366 | ||
139 | === modified file 'src/modules/Unity/Application/application.h' | |||
140 | --- src/modules/Unity/Application/application.h 2015-01-08 12:35:41 +0000 | |||
141 | +++ src/modules/Unity/Application/application.h 2015-02-05 10:26:37 +0000 | |||
142 | @@ -47,27 +47,15 @@ | |||
143 | 47 | { | 47 | { |
144 | 48 | Q_OBJECT | 48 | Q_OBJECT |
145 | 49 | 49 | ||
146 | 50 | Q_FLAGS(Orientation SupportedOrientations) | ||
147 | 51 | |||
148 | 52 | Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT) | 50 | Q_PROPERTY(QString desktopFile READ desktopFile CONSTANT) |
149 | 53 | Q_PROPERTY(QString exec READ exec CONSTANT) | 51 | Q_PROPERTY(QString exec READ exec CONSTANT) |
150 | 54 | Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) | 52 | Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged) |
151 | 55 | Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged) | 53 | Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged) |
152 | 56 | Q_PROPERTY(SupportedOrientations supportedOrientations READ supportedOrientations CONSTANT) | ||
153 | 57 | Q_PROPERTY(Session* session READ session NOTIFY sessionChanged DESIGNABLE false) | 54 | Q_PROPERTY(Session* session READ session NOTIFY sessionChanged DESIGNABLE false) |
154 | 58 | 55 | ||
155 | 59 | public: | 56 | public: |
156 | 60 | Q_DECLARE_FLAGS(Stages, Stage) | 57 | Q_DECLARE_FLAGS(Stages, Stage) |
157 | 61 | 58 | ||
158 | 62 | // Matching Qt::ScreenOrientation values for convenience | ||
159 | 63 | enum Orientation { | ||
160 | 64 | PortraitOrientation = 0x1, | ||
161 | 65 | LandscapeOrientation = 0x2, | ||
162 | 66 | InvertedPortraitOrientation = 0x4, | ||
163 | 67 | InvertedLandscapeOrientation = 0x8 | ||
164 | 68 | }; | ||
165 | 69 | Q_DECLARE_FLAGS(SupportedOrientations, Orientation) | ||
166 | 70 | |||
167 | 71 | Application(const QSharedPointer<TaskController>& taskController, | 59 | Application(const QSharedPointer<TaskController>& taskController, |
168 | 72 | const QSharedPointer<SharedWakelock>& sharedWakelock, | 60 | const QSharedPointer<SharedWakelock>& sharedWakelock, |
169 | 73 | DesktopFileReader *desktopFileReader, | 61 | DesktopFileReader *desktopFileReader, |
170 | @@ -90,6 +78,8 @@ | |||
171 | 90 | QColor splashColor() const override; | 78 | QColor splashColor() const override; |
172 | 91 | QColor splashColorHeader() const override; | 79 | QColor splashColorHeader() const override; |
173 | 92 | QColor splashColorFooter() const override; | 80 | QColor splashColorFooter() const override; |
174 | 81 | Qt::ScreenOrientations supportedOrientations() const override; | ||
175 | 82 | bool rotatesWindowContents() const override; | ||
176 | 93 | 83 | ||
177 | 94 | void setStage(Stage stage); | 84 | void setStage(Stage stage); |
178 | 95 | void setState(State state); | 85 | void setState(State state); |
179 | @@ -105,7 +95,6 @@ | |||
180 | 105 | bool fullscreen() const; | 95 | bool fullscreen() const; |
181 | 106 | 96 | ||
182 | 107 | Stages supportedStages() const; | 97 | Stages supportedStages() const; |
183 | 108 | SupportedOrientations supportedOrientations() const; | ||
184 | 109 | 98 | ||
185 | 110 | pid_t pid() const; | 99 | pid_t pid() const; |
186 | 111 | 100 | ||
187 | @@ -140,7 +129,8 @@ | |||
188 | 140 | bool m_focused; | 129 | bool m_focused; |
189 | 141 | bool m_canBeResumed; | 130 | bool m_canBeResumed; |
190 | 142 | QStringList m_arguments; | 131 | QStringList m_arguments; |
192 | 143 | SupportedOrientations m_supportedOrientations; | 132 | Qt::ScreenOrientations m_supportedOrientations; |
193 | 133 | bool m_rotatesWindowContents; | ||
194 | 144 | Session *m_session; | 134 | Session *m_session; |
195 | 145 | 135 | ||
196 | 146 | friend class ApplicationManager; | 136 | friend class ApplicationManager; |
197 | @@ -151,6 +141,5 @@ | |||
198 | 151 | } // namespace qtmir | 141 | } // namespace qtmir |
199 | 152 | 142 | ||
200 | 153 | Q_DECLARE_METATYPE(qtmir::Application*) | 143 | Q_DECLARE_METATYPE(qtmir::Application*) |
201 | 154 | Q_DECLARE_OPERATORS_FOR_FLAGS(qtmir::Application::SupportedOrientations) | ||
202 | 155 | 144 | ||
203 | 156 | #endif // APPLICATION_H | 145 | #endif // APPLICATION_H |
204 | 157 | 146 | ||
205 | === modified file 'src/modules/Unity/Application/application_manager.cpp' | |||
206 | --- src/modules/Unity/Application/application_manager.cpp 2015-01-07 17:56:07 +0000 | |||
207 | +++ src/modules/Unity/Application/application_manager.cpp 2015-02-05 10:26:37 +0000 | |||
208 | @@ -61,33 +61,6 @@ | |||
209 | 61 | 61 | ||
210 | 62 | namespace { | 62 | namespace { |
211 | 63 | 63 | ||
212 | 64 | // FIXME: AppManager should not implement policy based on display geometry, shell should do that | ||
213 | 65 | bool forceAllAppsIntoMainStage(const QSharedPointer<MirServer> &mirServer) | ||
214 | 66 | { | ||
215 | 67 | const int tabletModeMinimimWithGU = 100; | ||
216 | 68 | |||
217 | 69 | // Obtain display size | ||
218 | 70 | mir::geometry::Rectangles view_area; | ||
219 | 71 | mirServer->the_display()->for_each_display_buffer( | ||
220 | 72 | [&view_area](const mir::graphics::DisplayBuffer & db) | ||
221 | 73 | { | ||
222 | 74 | view_area.add(db.view_area()); | ||
223 | 75 | }); | ||
224 | 76 | |||
225 | 77 | // Get current Grid Unit value | ||
226 | 78 | int gridUnitPx = 8; | ||
227 | 79 | QByteArray gridUnitString = qgetenv("GRID_UNIT_PX"); | ||
228 | 80 | if (!gridUnitString.isEmpty()) { | ||
229 | 81 | bool ok; | ||
230 | 82 | int value = gridUnitString.toInt(&ok); | ||
231 | 83 | if (ok) { | ||
232 | 84 | gridUnitPx = value; | ||
233 | 85 | } | ||
234 | 86 | } | ||
235 | 87 | |||
236 | 88 | return (view_area.bounding_rectangle().size.width.as_int() < tabletModeMinimimWithGU * gridUnitPx); | ||
237 | 89 | } | ||
238 | 90 | |||
239 | 91 | // FIXME: To be removed once shell has fully adopted short appIds!! | 64 | // FIXME: To be removed once shell has fully adopted short appIds!! |
240 | 92 | QString toShortAppIdIfPossible(const QString &appId) { | 65 | QString toShortAppIdIfPossible(const QString &appId) { |
241 | 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.+:~-]*"); |
242 | @@ -413,7 +386,9 @@ | |||
243 | 413 | if (m_focusedApplication) { | 386 | if (m_focusedApplication) { |
244 | 414 | m_focusedApplication->setFocused(false); | 387 | m_focusedApplication->setFocused(false); |
245 | 415 | Application *lastApplication = applicationForStage(application->stage()); | 388 | Application *lastApplication = applicationForStage(application->stage()); |
247 | 416 | suspendApplication(lastApplication); | 389 | if (lastApplication != application) { |
248 | 390 | suspendApplication(lastApplication); | ||
249 | 391 | } | ||
250 | 417 | } | 392 | } |
251 | 418 | 393 | ||
252 | 419 | if (application->stage() == Application::MainStage) { | 394 | if (application->stage() == Application::MainStage) { |
253 | @@ -539,10 +514,6 @@ | |||
254 | 539 | return; | 514 | return; |
255 | 540 | } | 515 | } |
256 | 541 | 516 | ||
257 | 542 | // override stage if necessary (i.e. side stage invalid on phone) | ||
258 | 543 | if (application->stage() == Application::SideStage && forceAllAppsIntoMainStage(m_mirServer)) | ||
259 | 544 | application->setStage(Application::MainStage); | ||
260 | 545 | |||
261 | 546 | add(application); | 517 | add(application); |
262 | 547 | Q_EMIT focusRequested(appId); | 518 | Q_EMIT focusRequested(appId); |
263 | 548 | } | 519 | } |
264 | 549 | 520 | ||
265 | === modified file 'src/modules/Unity/Application/desktopfilereader.cpp' | |||
266 | --- src/modules/Unity/Application/desktopfilereader.cpp 2014-10-07 13:43:17 +0000 | |||
267 | +++ src/modules/Unity/Application/desktopfilereader.cpp 2015-02-05 10:26:37 +0000 | |||
268 | @@ -68,6 +68,8 @@ | |||
269 | 68 | : d_ptr(new DesktopFileReaderPrivate(this)) | 68 | : d_ptr(new DesktopFileReaderPrivate(this)) |
270 | 69 | { | 69 | { |
271 | 70 | Q_D(DesktopFileReader); | 70 | Q_D(DesktopFileReader); |
272 | 71 | qCDebug(QTMIR_APPLICATIONS) << "Loading desktop file" << desktopFile.absoluteFilePath() | ||
273 | 72 | << "for appId" << appId; | ||
274 | 71 | 73 | ||
275 | 72 | d->appId = appId; | 74 | d->appId = appId; |
276 | 73 | d->file = desktopFile.absoluteFilePath(); | 75 | d->file = desktopFile.absoluteFilePath(); |
277 | @@ -202,6 +204,100 @@ | |||
278 | 202 | return d->getKey("X-Ubuntu-Splash-Color-Footer"); | 204 | return d->getKey("X-Ubuntu-Splash-Color-Footer"); |
279 | 203 | } | 205 | } |
280 | 204 | 206 | ||
281 | 207 | Qt::ScreenOrientations DesktopFileReader::supportedOrientations() const | ||
282 | 208 | { | ||
283 | 209 | Q_D(const DesktopFileReader); | ||
284 | 210 | Qt::ScreenOrientations result; | ||
285 | 211 | |||
286 | 212 | if (!parseOrientations(d->getKey("X-Ubuntu-Supported-Orientations"), result)) { | ||
287 | 213 | qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Supported-Orientations entry."; | ||
288 | 214 | } | ||
289 | 215 | |||
290 | 216 | return result; | ||
291 | 217 | } | ||
292 | 218 | |||
293 | 219 | bool DesktopFileReader::rotatesWindowContents() const | ||
294 | 220 | { | ||
295 | 221 | Q_D(const DesktopFileReader); | ||
296 | 222 | bool result; | ||
297 | 223 | |||
298 | 224 | if (!parseBoolean(d->getKey("X-Ubuntu-Rotates-Window-Contents"), result)) { | ||
299 | 225 | qCWarning(QTMIR_APPLICATIONS) << d->file << "has an invalid X-Ubuntu-Rotates-Window-Contents entry."; | ||
300 | 226 | } | ||
301 | 227 | |||
302 | 228 | return result; | ||
303 | 229 | } | ||
304 | 230 | |||
305 | 231 | bool DesktopFileReader::parseOrientations(const QString &rawString, Qt::ScreenOrientations &result) | ||
306 | 232 | { | ||
307 | 233 | // Default to all orientations | ||
308 | 234 | result = Qt::PortraitOrientation | Qt::LandscapeOrientation | ||
309 | 235 | | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation; | ||
310 | 236 | |||
311 | 237 | if (rawString.isEmpty()) { | ||
312 | 238 | return true; | ||
313 | 239 | } | ||
314 | 240 | |||
315 | 241 | Qt::ScreenOrientations parsedOrientations = 0; | ||
316 | 242 | bool ok = true; | ||
317 | 243 | |||
318 | 244 | QStringList orientationsList = rawString | ||
319 | 245 | .simplified() | ||
320 | 246 | .replace(QChar(','), ";") | ||
321 | 247 | .remove(QChar(' ')) | ||
322 | 248 | .remove(QChar('-')) | ||
323 | 249 | .remove(QChar('_')) | ||
324 | 250 | .toLower() | ||
325 | 251 | .split(";"); | ||
326 | 252 | |||
327 | 253 | for (int i = 0; i < orientationsList.count() && ok; ++i) { | ||
328 | 254 | const QString &orientationString = orientationsList.at(i); | ||
329 | 255 | if (orientationString.isEmpty()) { | ||
330 | 256 | // skip it | ||
331 | 257 | continue; | ||
332 | 258 | } | ||
333 | 259 | |||
334 | 260 | if (orientationString == "portrait") { | ||
335 | 261 | parsedOrientations |= Qt::PortraitOrientation; | ||
336 | 262 | } else if (orientationString == "landscape") { | ||
337 | 263 | parsedOrientations |= Qt::LandscapeOrientation; | ||
338 | 264 | } else if (orientationString == "invertedportrait") { | ||
339 | 265 | parsedOrientations |= Qt::InvertedPortraitOrientation; | ||
340 | 266 | } else if (orientationString == "invertedlandscape") { | ||
341 | 267 | parsedOrientations |= Qt::InvertedLandscapeOrientation; | ||
342 | 268 | } else if (orientationsList.count() == 1 && orientationString == "primary") { | ||
343 | 269 | // Special case: primary orientation must be alone | ||
344 | 270 | // There's no sense in supporting primary orientation + other orientations | ||
345 | 271 | // like "primary,landscape" | ||
346 | 272 | parsedOrientations = Qt::PrimaryOrientation; | ||
347 | 273 | } else { | ||
348 | 274 | ok = false; | ||
349 | 275 | } | ||
350 | 276 | } | ||
351 | 277 | |||
352 | 278 | if (ok) { | ||
353 | 279 | result = parsedOrientations; | ||
354 | 280 | } | ||
355 | 281 | |||
356 | 282 | return ok; | ||
357 | 283 | } | ||
358 | 284 | |||
359 | 285 | bool DesktopFileReader::parseBoolean(const QString &rawString, bool &result) | ||
360 | 286 | { | ||
361 | 287 | QString cookedString = rawString.trimmed().toLower(); | ||
362 | 288 | |||
363 | 289 | result = cookedString == "y" | ||
364 | 290 | || cookedString == "1" | ||
365 | 291 | || cookedString == "yes" | ||
366 | 292 | || cookedString == "true"; | ||
367 | 293 | |||
368 | 294 | return result || rawString.isEmpty() | ||
369 | 295 | || cookedString == "n" | ||
370 | 296 | || cookedString == "0" | ||
371 | 297 | || cookedString == "no" | ||
372 | 298 | || cookedString == "false"; | ||
373 | 299 | } | ||
374 | 300 | |||
375 | 205 | bool DesktopFileReader::loaded() const | 301 | bool DesktopFileReader::loaded() const |
376 | 206 | { | 302 | { |
377 | 207 | Q_D(const DesktopFileReader); | 303 | Q_D(const DesktopFileReader); |
378 | 208 | 304 | ||
379 | === modified file 'src/modules/Unity/Application/desktopfilereader.h' | |||
380 | --- src/modules/Unity/Application/desktopfilereader.h 2014-10-14 19:39:43 +0000 | |||
381 | +++ src/modules/Unity/Application/desktopfilereader.h 2015-02-05 10:26:37 +0000 | |||
382 | @@ -55,8 +55,13 @@ | |||
383 | 55 | virtual QString splashColor() const; | 55 | virtual QString splashColor() const; |
384 | 56 | virtual QString splashColorHeader() const; | 56 | virtual QString splashColorHeader() const; |
385 | 57 | virtual QString splashColorFooter() const; | 57 | virtual QString splashColorFooter() const; |
386 | 58 | virtual Qt::ScreenOrientations supportedOrientations() const; | ||
387 | 59 | virtual bool rotatesWindowContents() const; | ||
388 | 58 | virtual bool loaded() const; | 60 | virtual bool loaded() const; |
389 | 59 | 61 | ||
390 | 62 | static bool parseOrientations(const QString &rawString, Qt::ScreenOrientations &result); | ||
391 | 63 | static bool parseBoolean(const QString &rawString, bool &result); | ||
392 | 64 | |||
393 | 60 | protected: | 65 | protected: |
394 | 61 | DesktopFileReader(const QString &appId, const QFileInfo &desktopFile); | 66 | DesktopFileReader(const QString &appId, const QFileInfo &desktopFile); |
395 | 62 | 67 | ||
396 | 63 | 68 | ||
397 | === modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp' | |||
398 | --- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-01-14 09:07:41 +0000 | |||
399 | +++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-02-05 10:26:37 +0000 | |||
400 | @@ -44,6 +44,7 @@ | |||
401 | 44 | 44 | ||
402 | 45 | // Mir | 45 | // Mir |
403 | 46 | #include <mir/geometry/rectangle.h> | 46 | #include <mir/geometry/rectangle.h> |
404 | 47 | #include <mir/events/event_builders.h> | ||
405 | 47 | #include <mir_toolkit/event.h> | 48 | #include <mir_toolkit/event.h> |
406 | 48 | 49 | ||
407 | 49 | namespace mg = mir::graphics; | 50 | namespace mg = mir::graphics; |
408 | @@ -52,160 +53,99 @@ | |||
409 | 52 | 53 | ||
410 | 53 | namespace { | 54 | namespace { |
411 | 54 | 55 | ||
512 | 55 | bool fillInMirEvent(MirEvent &mirEvent, QKeyEvent *qtEvent) | 56 | // Would be better if QMouseEvent had nativeModifiers |
513 | 56 | { | 57 | MirInputEventModifiers |
514 | 57 | mirEvent.type = mir_event_type_key; | 58 | mir_modifiers_from_qt(Qt::KeyboardModifiers mods) |
515 | 58 | 59 | { | |
516 | 59 | // don't care | 60 | MirInputEventModifiers m_mods = mir_input_event_modifier_none; |
517 | 60 | mirEvent.key.device_id = 0; | 61 | if (mods & Qt::ShiftModifier) |
518 | 61 | mirEvent.key.source_id = 0; | 62 | m_mods |= mir_input_event_modifier_shift; |
519 | 62 | 63 | if (mods & Qt::ControlModifier) | |
520 | 63 | switch (qtEvent->type()) { | 64 | m_mods |= mir_input_event_modifier_ctrl; |
521 | 64 | case QEvent::KeyPress: | 65 | if (mods & Qt::AltModifier) |
522 | 65 | mirEvent.key.action = mir_key_action_down; | 66 | m_mods |= mir_input_event_modifier_alt; |
523 | 66 | break; | 67 | if (mods & Qt::MetaModifier) |
524 | 67 | case QEvent::KeyRelease: | 68 | m_mods |= mir_input_event_modifier_meta; |
525 | 68 | mirEvent.key.action = mir_key_action_up; | 69 | |
526 | 69 | break; | 70 | return m_mods; |
527 | 70 | default: | 71 | } |
528 | 71 | return false; | 72 | |
529 | 72 | } | 73 | mir::EventUPtr makeMirEvent(QMouseEvent *qtEvent, MirPointerInputEventAction action) |
530 | 73 | 74 | { | |
531 | 74 | // don't care | 75 | auto timestamp = qtEvent->timestamp() * 1000000; |
532 | 75 | mirEvent.key.flags = (MirKeyFlag)0; | 76 | auto modifiers = mir_modifiers_from_qt(qtEvent->modifiers()); |
533 | 76 | 77 | ||
534 | 77 | mirEvent.key.modifiers = qtEvent->nativeModifiers(); | 78 | std::vector<MirPointerInputEventButton> buttons; |
535 | 78 | mirEvent.key.key_code = qtEvent->nativeVirtualKey(); | 79 | if (qtEvent->buttons() & Qt::LeftButton) |
536 | 79 | mirEvent.key.scan_code = qtEvent->nativeScanCode(); | 80 | buttons.push_back(mir_pointer_input_button_primary); |
537 | 80 | 81 | if (qtEvent->buttons() & Qt::RightButton) | |
538 | 81 | // TODO: It's not the best that we lose the actual repeat count from | 82 | buttons.push_back(mir_pointer_input_button_secondary); |
539 | 82 | // the original mir event (pre QtEventFeeder)...of course it will | 83 | if (qtEvent->buttons() & Qt::MidButton) |
540 | 83 | // not matter for Qt clients...so this is an improvement for now. | 84 | buttons.push_back(mir_pointer_input_button_tertiary); |
541 | 84 | mirEvent.key.repeat_count = qtEvent->isAutoRepeat() ? 1 : 0; | 85 | |
542 | 85 | 86 | return mir::events::make_event(0 /*DeviceID */, timestamp, modifiers, action, | |
543 | 86 | // Don't care | 87 | buttons, qtEvent->x(), qtEvent->y(), 0, 0); |
544 | 87 | mirEvent.key.down_time = 0; | 88 | } |
545 | 88 | 89 | ||
546 | 89 | mirEvent.key.event_time = qtEvent->timestamp() * 1000000; | 90 | mir::EventUPtr makeMirEvent(QKeyEvent *qtEvent) |
547 | 90 | 91 | { | |
548 | 91 | // Don't care | 92 | MirKeyInputEventAction action = mir_key_input_event_action_down; |
549 | 92 | mirEvent.key.is_system_key = 0; | 93 | switch (qtEvent->type()) |
550 | 93 | 94 | { | |
551 | 94 | return true; | 95 | case QEvent::KeyPress: |
552 | 95 | } | 96 | action = mir_key_input_event_action_down; |
553 | 96 | 97 | break; | |
554 | 97 | bool fillInMirEvent(MirEvent &mirEvent, | 98 | case QEvent::KeyRelease: |
555 | 98 | const QList<QTouchEvent::TouchPoint> &qtTouchPoints, | 99 | action = mir_key_input_event_action_up; |
556 | 99 | Qt::TouchPointStates qtTouchPointStates, | 100 | break; |
557 | 100 | ulong qtTimestamp) | 101 | default: |
558 | 101 | { | 102 | break; |
559 | 102 | mirEvent.type = mir_event_type_motion; | 103 | } |
560 | 103 | 104 | if (qtEvent->isAutoRepeat()) | |
561 | 104 | // Hardcoding it for now | 105 | action = mir_key_input_event_action_repeat; |
562 | 105 | // TODO: Gather this info from a QTouchDevice-derived class created by QtEventFeeder | 106 | |
563 | 106 | mirEvent.motion.device_id = 0; | 107 | return mir::events::make_event(0 /* DeviceID */, qtEvent->timestamp() * 1000000, |
564 | 107 | mirEvent.motion.source_id = 0x00001002; // AINPUT_SOURCE_TOUCHSCREEN; https://bugs.launchpad.net/bugs/1311687 | 108 | action, qtEvent->nativeVirtualKey(), |
565 | 108 | 109 | qtEvent->nativeScanCode(), | |
566 | 109 | // NB: it's assumed that touch points are pressed and released | 110 | qtEvent->nativeModifiers()); |
567 | 110 | // one at a time. | 111 | } |
568 | 111 | 112 | ||
569 | 112 | if (qtTouchPointStates.testFlag(Qt::TouchPointPressed)) { | 113 | mir::EventUPtr makeMirEvent(Qt::KeyboardModifiers qmods, |
570 | 113 | if (qtTouchPoints.count() > 1) { | 114 | const QList<QTouchEvent::TouchPoint> &qtTouchPoints, |
571 | 114 | mirEvent.motion.action = mir_motion_action_pointer_down; | 115 | Qt::TouchPointStates /* qtTouchPointStates */, |
572 | 115 | } else { | 116 | ulong qtTimestamp) |
573 | 116 | mirEvent.motion.action = mir_motion_action_down; | 117 | { |
574 | 117 | } | 118 | auto modifiers = mir_modifiers_from_qt(qmods); |
575 | 118 | } else if (qtTouchPointStates.testFlag(Qt::TouchPointReleased)) { | 119 | auto ev = mir::events::make_event(0, static_cast<int64_t>(qtTimestamp) * 1000000, |
576 | 119 | if (qtTouchPoints.count() > 1) { | 120 | modifiers); |
577 | 120 | mirEvent.motion.action = mir_motion_action_pointer_up; | 121 | |
478 | 121 | } else { | ||
479 | 122 | mirEvent.motion.action = mir_motion_action_up; | ||
480 | 123 | } | ||
481 | 124 | } else { | ||
482 | 125 | mirEvent.motion.action = mir_motion_action_move; | ||
483 | 126 | } | ||
484 | 127 | |||
485 | 128 | // not used | ||
486 | 129 | mirEvent.motion.flags = (MirMotionFlag) 0; | ||
487 | 130 | |||
488 | 131 | // TODO: map QInputEvent::modifiers() | ||
489 | 132 | mirEvent.motion.modifiers = 0; | ||
490 | 133 | |||
491 | 134 | // not used | ||
492 | 135 | mirEvent.motion.edge_flags = 0; | ||
493 | 136 | |||
494 | 137 | // TODO | ||
495 | 138 | mirEvent.motion.button_state = (MirMotionButton) 0; | ||
496 | 139 | |||
497 | 140 | // Does it matter? | ||
498 | 141 | mirEvent.motion.x_offset = 0.; | ||
499 | 142 | mirEvent.motion.y_offset = 0.; | ||
500 | 143 | mirEvent.motion.x_precision = 0.1; | ||
501 | 144 | mirEvent.motion.y_precision = 0.1; | ||
502 | 145 | |||
503 | 146 | // TODO. Not useful to Qt at least... | ||
504 | 147 | mirEvent.motion.down_time = 0; | ||
505 | 148 | |||
506 | 149 | // Note: QtEventFeeder scales the event time down, scale it back up - precision is | ||
507 | 150 | // lost but the time difference should still be accurate to milliseconds | ||
508 | 151 | mirEvent.motion.event_time = static_cast<nsecs_t>(qtTimestamp) * 1000000; | ||
509 | 152 | |||
510 | 153 | mirEvent.motion.pointer_count = qtTouchPoints.count(); | ||
511 | 154 | |||
578 | 155 | for (int i = 0; i < qtTouchPoints.count(); ++i) { | 122 | for (int i = 0; i < qtTouchPoints.count(); ++i) { |
579 | 156 | auto touchPoint = qtTouchPoints.at(i); | 123 | auto touchPoint = qtTouchPoints.at(i); |
625 | 157 | auto &pointer = mirEvent.motion.pointer_coordinates[i]; | 124 | auto id = touchPoint.id(); |
626 | 158 | 125 | ||
627 | 159 | // FIXME: https://bugs.launchpad.net/mir/+bug/1311699 | 126 | MirTouchInputEventTouchAction action = mir_touch_input_event_action_change; |
628 | 160 | // When multiple touch points are transmitted with a MirEvent | 127 | if (touchPoint.state() == Qt::TouchPointReleased) |
629 | 161 | // and one of them (only one is allowed) indicates a presse | 128 | { |
630 | 162 | // state change the index is encoded in the second byte of the | 129 | action = mir_touch_input_event_action_up; |
631 | 163 | // action value. | 130 | } |
632 | 164 | const int mir_motion_event_pointer_index_shift = 8; | 131 | if (touchPoint.state() == Qt::TouchPointPressed) |
633 | 165 | if (mirEvent.motion.action == mir_motion_action_pointer_up && | 132 | { |
634 | 166 | touchPoint.state() == Qt::TouchPointReleased) | 133 | action = mir_touch_input_event_action_down; |
635 | 167 | { | 134 | } |
636 | 168 | mirEvent.motion.action |= i << mir_motion_event_pointer_index_shift; | 135 | |
637 | 169 | } | 136 | MirTouchInputEventTouchTooltype tooltype = mir_touch_input_tool_type_finger; |
593 | 170 | if (mirEvent.motion.action == mir_motion_action_pointer_down && | ||
594 | 171 | touchPoint.state() == Qt::TouchPointPressed) | ||
595 | 172 | { | ||
596 | 173 | mirEvent.motion.action |= i << mir_motion_event_pointer_index_shift; | ||
597 | 174 | } | ||
598 | 175 | |||
599 | 176 | |||
600 | 177 | pointer.id = touchPoint.id(); | ||
601 | 178 | pointer.x = touchPoint.pos().x(); | ||
602 | 179 | pointer.y = touchPoint.pos().y(); | ||
603 | 180 | |||
604 | 181 | // FIXME: https://bugs.launchpad.net/mir/+bug/1311809 | ||
605 | 182 | |||
606 | 183 | if (touchPoint.rawScreenPositions().isEmpty()) { | ||
607 | 184 | pointer.raw_x = 0.; | ||
608 | 185 | pointer.raw_y = 0.; | ||
609 | 186 | } else { | ||
610 | 187 | pointer.raw_x = touchPoint.rawScreenPositions().at(0).x(); | ||
611 | 188 | pointer.raw_y = touchPoint.rawScreenPositions().at(0).y(); | ||
612 | 189 | } | ||
613 | 190 | |||
614 | 191 | pointer.touch_major = touchPoint.rect().width(); | ||
615 | 192 | pointer.touch_minor = touchPoint.rect().height(); | ||
616 | 193 | pointer.size = 0.; | ||
617 | 194 | pointer.pressure = touchPoint.pressure(); | ||
618 | 195 | pointer.orientation = 0.; | ||
619 | 196 | pointer.vscroll = 0.; | ||
620 | 197 | pointer.hscroll = 0.; | ||
621 | 198 | |||
622 | 199 | // TODO: Mir supports a wider set of tool types (finger, stylus, mouse, eraser, unknown). | ||
623 | 200 | // so just because we are not TouchPoint::Pen does not mean we are motion_tool_type_finger... | ||
624 | 201 | // however this is the best we can do with the QtEventFeeder approach. | ||
638 | 202 | if (touchPoint.flags() & QTouchEvent::TouchPoint::Pen) | 137 | if (touchPoint.flags() & QTouchEvent::TouchPoint::Pen) |
642 | 203 | pointer.tool_type = mir_motion_tool_type_stylus; | 138 | tooltype = mir_touch_input_tool_type_stylus; |
643 | 204 | else | 139 | |
644 | 205 | pointer.tool_type = mir_motion_tool_type_finger; | 140 | mir::events::add_touch(*ev, id, action, tooltype, |
645 | 141 | touchPoint.pos().x(), touchPoint.pos().y(), | ||
646 | 142 | touchPoint.pressure(), | ||
647 | 143 | touchPoint.rect().width(), | ||
648 | 144 | touchPoint.rect().height(), | ||
649 | 145 | 0 /* size */); | ||
650 | 206 | } | 146 | } |
651 | 207 | 147 | ||
653 | 208 | return true; | 148 | return ev; |
654 | 209 | } | 149 | } |
655 | 210 | 150 | ||
656 | 211 | } // namespace { | 151 | } // namespace { |
657 | @@ -243,7 +183,7 @@ | |||
658 | 243 | , m_session(session) | 183 | , m_session(session) |
659 | 244 | , m_firstFrameDrawn(false) | 184 | , m_firstFrameDrawn(false) |
660 | 245 | , m_live(true) | 185 | , m_live(true) |
662 | 246 | , m_orientation(Qt::PortraitOrientation) | 186 | , m_orientationAngle(Angle0) |
663 | 247 | , m_textureProvider(nullptr) | 187 | , m_textureProvider(nullptr) |
664 | 248 | , m_lastTouchEvent(nullptr) | 188 | , m_lastTouchEvent(nullptr) |
665 | 249 | { | 189 | { |
666 | @@ -352,49 +292,42 @@ | |||
667 | 352 | return static_cast<MirSurfaceItem::State>(m_surface->state()); | 292 | return static_cast<MirSurfaceItem::State>(m_surface->state()); |
668 | 353 | } | 293 | } |
669 | 354 | 294 | ||
671 | 355 | Qt::ScreenOrientation MirSurfaceItem::orientation() const | 295 | MirSurfaceItem::OrientationAngle MirSurfaceItem::orientationAngle() const |
672 | 356 | { | 296 | { |
674 | 357 | return m_orientation; | 297 | return m_orientationAngle; |
675 | 358 | } | 298 | } |
676 | 359 | 299 | ||
678 | 360 | void MirSurfaceItem::setOrientation(const Qt::ScreenOrientation orientation) | 300 | void MirSurfaceItem::setOrientationAngle(MirSurfaceItem::OrientationAngle angle) |
679 | 361 | { | 301 | { |
681 | 362 | qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::setOrientation - orientation=" << orientation; | 302 | qCDebug(QTMIR_SURFACES, "MirSurfaceItem::setOrientationAngle(%d)", angle); |
682 | 363 | 303 | ||
684 | 364 | if (m_orientation == orientation) | 304 | if (m_orientationAngle == angle) |
685 | 365 | return; | 305 | return; |
686 | 366 | 306 | ||
687 | 367 | MirOrientation mirOrientation; | 307 | MirOrientation mirOrientation; |
708 | 368 | Qt::ScreenOrientation nativeOrientation = QGuiApplication::primaryScreen()->nativeOrientation(); | 308 | |
709 | 369 | const bool landscapeNativeOrientation = (nativeOrientation == Qt::LandscapeOrientation); | 309 | switch (angle) { |
710 | 370 | 310 | case Angle0: | |
711 | 371 | Qt::ScreenOrientation requestedOrientation = orientation; | 311 | mirOrientation = mir_orientation_normal; |
712 | 372 | if (orientation == Qt::PrimaryOrientation) { // means orientation equals native orientation, set it as such | 312 | break; |
713 | 373 | requestedOrientation = nativeOrientation; | 313 | case Angle90: |
714 | 374 | } | 314 | mirOrientation = mir_orientation_right; |
715 | 375 | 315 | break; | |
716 | 376 | switch(requestedOrientation) { | 316 | case Angle180: |
717 | 377 | case Qt::PortraitOrientation: | 317 | mirOrientation = mir_orientation_inverted; |
718 | 378 | mirOrientation = (landscapeNativeOrientation) ? mir_orientation_right : mir_orientation_normal; | 318 | break; |
719 | 379 | break; | 319 | case Angle270: |
720 | 380 | case Qt::LandscapeOrientation: | 320 | mirOrientation = mir_orientation_left; |
701 | 381 | mirOrientation = (landscapeNativeOrientation) ? mir_orientation_normal : mir_orientation_left; | ||
702 | 382 | break; | ||
703 | 383 | case Qt::InvertedPortraitOrientation: | ||
704 | 384 | mirOrientation = (landscapeNativeOrientation) ? mir_orientation_left : mir_orientation_inverted; | ||
705 | 385 | break; | ||
706 | 386 | case Qt::InvertedLandscapeOrientation: | ||
707 | 387 | mirOrientation = (landscapeNativeOrientation) ? mir_orientation_inverted : mir_orientation_right; | ||
721 | 388 | break; | 321 | break; |
722 | 389 | default: | 322 | default: |
724 | 390 | qWarning("Unrecognized Qt::ScreenOrientation!"); | 323 | qCWarning(QTMIR_SURFACES, "Unsupported orientation angle: %d", angle); |
725 | 391 | return; | 324 | return; |
726 | 392 | } | 325 | } |
727 | 393 | 326 | ||
728 | 394 | m_surface->set_orientation(mirOrientation); | 327 | m_surface->set_orientation(mirOrientation); |
729 | 395 | 328 | ||
732 | 396 | m_orientation = orientation; | 329 | m_orientationAngle = angle; |
733 | 397 | Q_EMIT orientationChanged(); | 330 | Q_EMIT orientationAngleChanged(angle); |
734 | 398 | } | 331 | } |
735 | 399 | 332 | ||
736 | 400 | QString MirSurfaceItem::name() const | 333 | QString MirSurfaceItem::name() const |
737 | @@ -440,10 +373,11 @@ | |||
738 | 440 | ensureProvider(); | 373 | ensureProvider(); |
739 | 441 | bool textureUpdated = false; | 374 | bool textureUpdated = false; |
740 | 442 | 375 | ||
741 | 376 | const void* const user_id = (void*)123; | ||
742 | 443 | std::unique_ptr<mg::Renderable> renderable = | 377 | std::unique_ptr<mg::Renderable> renderable = |
744 | 444 | m_surface->compositor_snapshot((void*)123/*user_id*/); | 378 | m_surface->compositor_snapshot(user_id); |
745 | 445 | 379 | ||
747 | 446 | if (renderable->buffers_ready_for_compositor() > 0) { | 380 | if (m_surface->buffers_ready_for_compositor(user_id) > 0) { |
748 | 447 | if (!m_textureProvider->t) { | 381 | if (!m_textureProvider->t) { |
749 | 448 | m_textureProvider->t = new MirBufferSGTexture(renderable->buffer()); | 382 | m_textureProvider->t = new MirBufferSGTexture(renderable->buffer()); |
750 | 449 | } else { | 383 | } else { |
751 | @@ -455,7 +389,7 @@ | |||
752 | 455 | textureUpdated = true; | 389 | textureUpdated = true; |
753 | 456 | } | 390 | } |
754 | 457 | 391 | ||
756 | 458 | if (renderable->buffers_ready_for_compositor() > 0) { | 392 | if (m_surface->buffers_ready_for_compositor(user_id) > 0) { |
757 | 459 | QTimer::singleShot(0, this, SLOT(update())); | 393 | QTimer::singleShot(0, this, SLOT(update())); |
758 | 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. |
759 | 461 | m_frameDropperTimer.start(); | 395 | m_frameDropperTimer.start(); |
760 | @@ -507,18 +441,20 @@ | |||
761 | 507 | 441 | ||
762 | 508 | void MirSurfaceItem::mousePressEvent(QMouseEvent *event) | 442 | void MirSurfaceItem::mousePressEvent(QMouseEvent *event) |
763 | 509 | { | 443 | { |
766 | 510 | // TODO: Implement for desktop support | 444 | auto ev = makeMirEvent(event, mir_pointer_input_event_action_button_down); |
767 | 511 | event->ignore(); | 445 | m_surface->consume(*ev); |
768 | 512 | } | 446 | } |
769 | 513 | 447 | ||
770 | 514 | void MirSurfaceItem::mouseMoveEvent(QMouseEvent *event) | 448 | void MirSurfaceItem::mouseMoveEvent(QMouseEvent *event) |
771 | 515 | { | 449 | { |
773 | 516 | Q_UNUSED(event); | 450 | auto ev = makeMirEvent(event, mir_pointer_input_event_action_motion); |
774 | 451 | m_surface->consume(*ev); | ||
775 | 517 | } | 452 | } |
776 | 518 | 453 | ||
777 | 519 | void MirSurfaceItem::mouseReleaseEvent(QMouseEvent *event) | 454 | void MirSurfaceItem::mouseReleaseEvent(QMouseEvent *event) |
778 | 520 | { | 455 | { |
780 | 521 | Q_UNUSED(event); | 456 | auto ev = makeMirEvent(event, mir_pointer_input_event_action_button_up); |
781 | 457 | m_surface->consume(*ev); | ||
782 | 522 | } | 458 | } |
783 | 523 | 459 | ||
784 | 524 | void MirSurfaceItem::wheelEvent(QWheelEvent *event) | 460 | void MirSurfaceItem::wheelEvent(QWheelEvent *event) |
785 | @@ -528,18 +464,14 @@ | |||
786 | 528 | 464 | ||
787 | 529 | void MirSurfaceItem::keyPressEvent(QKeyEvent *qtEvent) | 465 | void MirSurfaceItem::keyPressEvent(QKeyEvent *qtEvent) |
788 | 530 | { | 466 | { |
793 | 531 | MirEvent mirEvent; | 467 | auto ev = makeMirEvent(qtEvent); |
794 | 532 | if (fillInMirEvent(mirEvent, qtEvent)) { | 468 | m_surface->consume(*ev); |
791 | 533 | m_surface->consume(mirEvent); | ||
792 | 534 | } | ||
795 | 535 | } | 469 | } |
796 | 536 | 470 | ||
797 | 537 | void MirSurfaceItem::keyReleaseEvent(QKeyEvent *qtEvent) | 471 | void MirSurfaceItem::keyReleaseEvent(QKeyEvent *qtEvent) |
798 | 538 | { | 472 | { |
803 | 539 | MirEvent mirEvent; | 473 | auto ev = makeMirEvent(qtEvent); |
804 | 540 | if (fillInMirEvent(mirEvent, qtEvent)) { | 474 | m_surface->consume(*ev); |
801 | 541 | m_surface->consume(mirEvent); | ||
802 | 542 | } | ||
805 | 543 | } | 475 | } |
806 | 544 | 476 | ||
807 | 545 | QString MirSurfaceItem::appId() const | 477 | QString MirSurfaceItem::appId() const |
808 | @@ -555,8 +487,6 @@ | |||
809 | 555 | 487 | ||
810 | 556 | void MirSurfaceItem::endCurrentTouchSequence(ulong timestamp) | 488 | void MirSurfaceItem::endCurrentTouchSequence(ulong timestamp) |
811 | 557 | { | 489 | { |
812 | 558 | MirEvent mirEvent; | ||
813 | 559 | |||
814 | 560 | Q_ASSERT(m_lastTouchEvent); | 490 | Q_ASSERT(m_lastTouchEvent); |
815 | 561 | Q_ASSERT(m_lastTouchEvent->type != QEvent::TouchEnd); | 491 | Q_ASSERT(m_lastTouchEvent->type != QEvent::TouchEnd); |
816 | 562 | Q_ASSERT(m_lastTouchEvent->touchPoints.count() > 0); | 492 | Q_ASSERT(m_lastTouchEvent->touchPoints.count() > 0); |
817 | @@ -580,10 +510,10 @@ | |||
818 | 580 | 510 | ||
819 | 581 | touchEvent.updateTouchPointStatesAndType(); | 511 | touchEvent.updateTouchPointStatesAndType(); |
820 | 582 | 512 | ||
825 | 583 | if (fillInMirEvent(mirEvent, touchEvent.touchPoints, | 513 | auto ev = makeMirEvent(touchEvent.modifiers, touchEvent.touchPoints, |
826 | 584 | touchEvent.touchPointStates, touchEvent.timestamp)) { | 514 | touchEvent.touchPointStates, touchEvent.timestamp); |
827 | 585 | m_surface->consume(mirEvent); | 515 | m_surface->consume(*ev); |
828 | 586 | } | 516 | |
829 | 587 | *m_lastTouchEvent = touchEvent; | 517 | *m_lastTouchEvent = touchEvent; |
830 | 588 | 518 | ||
831 | 589 | touchEvent.touchPoints.removeAt(0); | 519 | touchEvent.touchPoints.removeAt(0); |
832 | @@ -592,11 +522,10 @@ | |||
833 | 592 | 522 | ||
834 | 593 | void MirSurfaceItem::validateAndDeliverTouchEvent(int eventType, | 523 | void MirSurfaceItem::validateAndDeliverTouchEvent(int eventType, |
835 | 594 | ulong timestamp, | 524 | ulong timestamp, |
836 | 525 | Qt::KeyboardModifiers mods, | ||
837 | 595 | const QList<QTouchEvent::TouchPoint> &touchPoints, | 526 | const QList<QTouchEvent::TouchPoint> &touchPoints, |
838 | 596 | Qt::TouchPointStates touchPointStates) | 527 | Qt::TouchPointStates touchPointStates) |
839 | 597 | { | 528 | { |
840 | 598 | MirEvent mirEvent; | ||
841 | 599 | |||
842 | 600 | if (eventType == QEvent::TouchBegin && m_lastTouchEvent && m_lastTouchEvent->type != QEvent::TouchEnd) { | 529 | if (eventType == QEvent::TouchBegin && m_lastTouchEvent && m_lastTouchEvent->type != QEvent::TouchEnd) { |
843 | 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 " |
844 | 602 | "there's still an active/unfinished touch sequence.").arg(appId())); | 531 | "there's still an active/unfinished touch sequence.").arg(appId())); |
845 | @@ -604,9 +533,8 @@ | |||
846 | 604 | endCurrentTouchSequence(timestamp); | 533 | endCurrentTouchSequence(timestamp); |
847 | 605 | } | 534 | } |
848 | 606 | 535 | ||
852 | 607 | if (fillInMirEvent(mirEvent, touchPoints, touchPointStates, timestamp)) { | 536 | auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp); |
853 | 608 | m_surface->consume(mirEvent); | 537 | m_surface->consume(*ev); |
851 | 609 | } | ||
854 | 610 | 538 | ||
855 | 611 | if (!m_lastTouchEvent) { | 539 | if (!m_lastTouchEvent) { |
856 | 612 | m_lastTouchEvent = new TouchEvent; | 540 | m_lastTouchEvent = new TouchEvent; |
857 | @@ -621,6 +549,7 @@ | |||
858 | 621 | { | 549 | { |
859 | 622 | bool accepted = processTouchEvent(event->type(), | 550 | bool accepted = processTouchEvent(event->type(), |
860 | 623 | event->timestamp(), | 551 | event->timestamp(), |
861 | 552 | event->modifiers(), | ||
862 | 624 | event->touchPoints(), | 553 | event->touchPoints(), |
863 | 625 | event->touchPointStates()); | 554 | event->touchPointStates()); |
864 | 626 | event->setAccepted(accepted); | 555 | event->setAccepted(accepted); |
865 | @@ -629,6 +558,7 @@ | |||
866 | 629 | bool MirSurfaceItem::processTouchEvent( | 558 | bool MirSurfaceItem::processTouchEvent( |
867 | 630 | int eventType, | 559 | int eventType, |
868 | 631 | ulong timestamp, | 560 | ulong timestamp, |
869 | 561 | Qt::KeyboardModifiers mods, | ||
870 | 632 | const QList<QTouchEvent::TouchPoint> &touchPoints, | 562 | const QList<QTouchEvent::TouchPoint> &touchPoints, |
871 | 633 | Qt::TouchPointStates touchPointStates) | 563 | Qt::TouchPointStates touchPointStates) |
872 | 634 | { | 564 | { |
873 | @@ -636,7 +566,7 @@ | |||
874 | 636 | if (type() == InputMethod && eventType == QEvent::TouchBegin) { | 566 | if (type() == InputMethod && eventType == QEvent::TouchBegin) { |
875 | 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. |
876 | 638 | if (hasTouchInsideUbuntuKeyboard(touchPoints)) { | 568 | if (hasTouchInsideUbuntuKeyboard(touchPoints)) { |
878 | 639 | validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates); | 569 | validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates); |
879 | 640 | } else { | 570 | } else { |
880 | 641 | accepted = false; | 571 | accepted = false; |
881 | 642 | } | 572 | } |
882 | @@ -644,7 +574,7 @@ | |||
883 | 644 | } else { | 574 | } else { |
884 | 645 | // NB: If we are getting QEvent::TouchUpdate or QEvent::TouchEnd it's because we've | 575 | // NB: If we are getting QEvent::TouchUpdate or QEvent::TouchEnd it's because we've |
885 | 646 | // previously accepted the corresponding QEvent::TouchBegin | 576 | // previously accepted the corresponding QEvent::TouchBegin |
887 | 647 | validateAndDeliverTouchEvent(eventType, timestamp, touchPoints, touchPointStates); | 577 | validateAndDeliverTouchEvent(eventType, timestamp, mods, touchPoints, touchPointStates); |
888 | 648 | } | 578 | } |
889 | 649 | return accepted; | 579 | return accepted; |
890 | 650 | } | 580 | } |
891 | @@ -747,18 +677,17 @@ | |||
892 | 747 | { | 677 | { |
893 | 748 | QMutexLocker locker(&m_mutex); | 678 | QMutexLocker locker(&m_mutex); |
894 | 749 | 679 | ||
897 | 750 | std::unique_ptr<mg::Renderable> renderable = | 680 | const void* const user_id = (void*)123; // TODO: Multimonitor support |
896 | 751 | m_surface->compositor_snapshot((void*)123/*user_id*/); | ||
898 | 752 | 681 | ||
900 | 753 | while (renderable->buffers_ready_for_compositor() > 0) { | 682 | while (m_surface->buffers_ready_for_compositor(user_id) > 0) { |
901 | 754 | // The line below looks like an innocent, effect-less, getter. But as this | 683 | // The line below looks like an innocent, effect-less, getter. But as this |
902 | 755 | // method returns a unique_pointer, not holding its reference causes the | 684 | // method returns a unique_pointer, not holding its reference causes the |
903 | 756 | // buffer to be destroyed/released straight away. | 685 | // buffer to be destroyed/released straight away. |
905 | 757 | m_surface->compositor_snapshot((void*)123/*user_id*/)->buffer(); | 686 | m_surface->compositor_snapshot(user_id)->buffer(); |
906 | 758 | qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::dropPendingBuffers()" | 687 | qCDebug(QTMIR_SURFACES) << "MirSurfaceItem::dropPendingBuffers()" |
907 | 759 | << "surface =" << this | 688 | << "surface =" << this |
908 | 760 | << "buffer dropped." | 689 | << "buffer dropped." |
910 | 761 | << renderable->buffers_ready_for_compositor() | 690 | << m_surface->buffers_ready_for_compositor(user_id) |
911 | 762 | << "left."; | 691 | << "left."; |
912 | 763 | } | 692 | } |
913 | 764 | } | 693 | } |
914 | 765 | 694 | ||
915 | === modified file 'src/modules/Unity/Application/mirsurfaceitem.h' | |||
916 | --- src/modules/Unity/Application/mirsurfaceitem.h 2015-01-14 08:24:29 +0000 | |||
917 | +++ src/modules/Unity/Application/mirsurfaceitem.h 2015-02-05 10:26:37 +0000 | |||
918 | @@ -47,12 +47,17 @@ | |||
919 | 47 | Q_OBJECT | 47 | Q_OBJECT |
920 | 48 | Q_ENUMS(Type) | 48 | Q_ENUMS(Type) |
921 | 49 | Q_ENUMS(State) | 49 | Q_ENUMS(State) |
922 | 50 | Q_ENUMS(OrientationAngle) | ||
923 | 50 | 51 | ||
924 | 51 | Q_PROPERTY(Type type READ type NOTIFY typeChanged) | 52 | Q_PROPERTY(Type type READ type NOTIFY typeChanged) |
925 | 52 | Q_PROPERTY(State state READ state NOTIFY stateChanged) | 53 | Q_PROPERTY(State state READ state NOTIFY stateChanged) |
926 | 53 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) | 54 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) |
927 | 54 | Q_PROPERTY(bool live READ live NOTIFY liveChanged) | 55 | Q_PROPERTY(bool live READ live NOTIFY liveChanged) |
929 | 55 | Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false) | 56 | |
930 | 57 | // How many degrees, clockwise, the UI in the surface has to rotate to match with the | ||
931 | 58 | // shell UI orientation | ||
932 | 59 | Q_PROPERTY(OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle | ||
933 | 60 | NOTIFY orientationAngleChanged DESIGNABLE false) | ||
934 | 56 | 61 | ||
935 | 57 | public: | 62 | public: |
936 | 58 | explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface, | 63 | explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface, |
937 | @@ -81,12 +86,18 @@ | |||
938 | 81 | Fullscreen = mir_surface_state_fullscreen, | 86 | Fullscreen = mir_surface_state_fullscreen, |
939 | 82 | }; | 87 | }; |
940 | 83 | 88 | ||
941 | 89 | enum OrientationAngle { | ||
942 | 90 | Angle0 = 0, | ||
943 | 91 | Angle90 = 90, | ||
944 | 92 | Angle180 = 180, | ||
945 | 93 | Angle270 = 270 | ||
946 | 94 | }; | ||
947 | 95 | |||
948 | 84 | //getters | 96 | //getters |
949 | 85 | Type type() const; | 97 | Type type() const; |
950 | 86 | State state() const; | 98 | State state() const; |
951 | 87 | QString name() const; | 99 | QString name() const; |
952 | 88 | bool live() const; | 100 | bool live() const; |
953 | 89 | Qt::ScreenOrientation orientation() const; | ||
954 | 90 | SessionInterface *session() const; | 101 | SessionInterface *session() const; |
955 | 91 | 102 | ||
956 | 92 | Q_INVOKABLE void release(); | 103 | Q_INVOKABLE void release(); |
957 | @@ -100,12 +111,15 @@ | |||
958 | 100 | 111 | ||
959 | 101 | bool isFirstFrameDrawn() const { return m_firstFrameDrawn; } | 112 | bool isFirstFrameDrawn() const { return m_firstFrameDrawn; } |
960 | 102 | 113 | ||
962 | 103 | void setOrientation(const Qt::ScreenOrientation orientation); | 114 | OrientationAngle orientationAngle() const; |
963 | 115 | void setOrientationAngle(OrientationAngle angle); | ||
964 | 116 | |||
965 | 104 | void setSession(SessionInterface *app); | 117 | void setSession(SessionInterface *app); |
966 | 105 | 118 | ||
967 | 106 | // to allow easy touch event injection from tests | 119 | // to allow easy touch event injection from tests |
968 | 107 | bool processTouchEvent(int eventType, | 120 | bool processTouchEvent(int eventType, |
969 | 108 | ulong timestamp, | 121 | ulong timestamp, |
970 | 122 | Qt::KeyboardModifiers modifiers, | ||
971 | 109 | const QList<QTouchEvent::TouchPoint> &touchPoints, | 123 | const QList<QTouchEvent::TouchPoint> &touchPoints, |
972 | 110 | Qt::TouchPointStates touchPointStates); | 124 | Qt::TouchPointStates touchPointStates); |
973 | 111 | 125 | ||
974 | @@ -113,7 +127,7 @@ | |||
975 | 113 | void typeChanged(); | 127 | void typeChanged(); |
976 | 114 | void stateChanged(); | 128 | void stateChanged(); |
977 | 115 | void nameChanged(); | 129 | void nameChanged(); |
979 | 116 | void orientationChanged(); | 130 | void orientationAngleChanged(OrientationAngle angle); |
980 | 117 | void liveChanged(bool live); | 131 | void liveChanged(bool live); |
981 | 118 | void firstFrameDrawn(MirSurfaceItem *item); | 132 | void firstFrameDrawn(MirSurfaceItem *item); |
982 | 119 | 133 | ||
983 | @@ -164,6 +178,7 @@ | |||
984 | 164 | void endCurrentTouchSequence(ulong timestamp); | 178 | void endCurrentTouchSequence(ulong timestamp); |
985 | 165 | void validateAndDeliverTouchEvent(int eventType, | 179 | void validateAndDeliverTouchEvent(int eventType, |
986 | 166 | ulong timestamp, | 180 | ulong timestamp, |
987 | 181 | Qt::KeyboardModifiers modifiers, | ||
988 | 167 | const QList<QTouchEvent::TouchPoint> &touchPoints, | 182 | const QList<QTouchEvent::TouchPoint> &touchPoints, |
989 | 168 | Qt::TouchPointStates touchPointStates); | 183 | Qt::TouchPointStates touchPointStates); |
990 | 169 | 184 | ||
991 | @@ -173,7 +188,9 @@ | |||
992 | 173 | QPointer<SessionInterface> m_session; | 188 | QPointer<SessionInterface> m_session; |
993 | 174 | bool m_firstFrameDrawn; | 189 | bool m_firstFrameDrawn; |
994 | 175 | bool m_live; | 190 | bool m_live; |
996 | 176 | Qt::ScreenOrientation m_orientation; //FIXME - have to save the state as Mir has no getter for it (bug:1357429) | 191 | |
997 | 192 | //FIXME - have to save the state as Mir has no getter for it (bug:1357429) | ||
998 | 193 | OrientationAngle m_orientationAngle; | ||
999 | 177 | 194 | ||
1000 | 178 | QMirSurfaceTextureProvider *m_textureProvider; | 195 | QMirSurfaceTextureProvider *m_textureProvider; |
1001 | 179 | 196 | ||
1002 | @@ -188,6 +205,7 @@ | |||
1003 | 188 | TouchEvent &operator= (const QTouchEvent &qtEvent) { | 205 | TouchEvent &operator= (const QTouchEvent &qtEvent) { |
1004 | 189 | type = qtEvent.type(); | 206 | type = qtEvent.type(); |
1005 | 190 | timestamp = qtEvent.timestamp(); | 207 | timestamp = qtEvent.timestamp(); |
1006 | 208 | modifiers = qtEvent.modifiers(); | ||
1007 | 191 | touchPoints = qtEvent.touchPoints(); | 209 | touchPoints = qtEvent.touchPoints(); |
1008 | 192 | touchPointStates = qtEvent.touchPointStates(); | 210 | touchPointStates = qtEvent.touchPointStates(); |
1009 | 193 | return *this; | 211 | return *this; |
1010 | @@ -197,6 +215,7 @@ | |||
1011 | 197 | 215 | ||
1012 | 198 | int type; | 216 | int type; |
1013 | 199 | ulong timestamp; | 217 | ulong timestamp; |
1014 | 218 | Qt::KeyboardModifiers modifiers; | ||
1015 | 200 | QList<QTouchEvent::TouchPoint> touchPoints; | 219 | QList<QTouchEvent::TouchPoint> touchPoints; |
1016 | 201 | Qt::TouchPointStates touchPointStates; | 220 | Qt::TouchPointStates touchPointStates; |
1017 | 202 | } *m_lastTouchEvent; | 221 | } *m_lastTouchEvent; |
1018 | @@ -207,5 +226,6 @@ | |||
1019 | 207 | } // namespace qtmir | 226 | } // namespace qtmir |
1020 | 208 | 227 | ||
1021 | 209 | Q_DECLARE_METATYPE(qtmir::MirSurfaceItem*) | 228 | Q_DECLARE_METATYPE(qtmir::MirSurfaceItem*) |
1022 | 229 | Q_DECLARE_METATYPE(qtmir::MirSurfaceItem::OrientationAngle) | ||
1023 | 210 | 230 | ||
1024 | 211 | #endif // MIRSURFACEITEM_H | 231 | #endif // MIRSURFACEITEM_H |
1025 | 212 | 232 | ||
1026 | === modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp' | |||
1027 | --- src/modules/Unity/Application/mirsurfacemanager.cpp 2014-12-16 15:55:29 +0000 | |||
1028 | +++ src/modules/Unity/Application/mirsurfacemanager.cpp 2015-02-05 10:26:37 +0000 | |||
1029 | @@ -31,7 +31,7 @@ | |||
1030 | 31 | #include "nativeinterface.h" | 31 | #include "nativeinterface.h" |
1031 | 32 | #include "mirserver.h" | 32 | #include "mirserver.h" |
1032 | 33 | #include "sessionlistener.h" | 33 | #include "sessionlistener.h" |
1034 | 34 | #include "surfaceconfigurator.h" | 34 | #include "mirshell.h" |
1035 | 35 | #include "logging.h" | 35 | #include "logging.h" |
1036 | 36 | 36 | ||
1037 | 37 | Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces") | 37 | Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces") |
1038 | @@ -51,9 +51,9 @@ | |||
1039 | 51 | manager, &MirSurfaceManager::onSessionDestroyingSurface); | 51 | manager, &MirSurfaceManager::onSessionDestroyingSurface); |
1040 | 52 | } | 52 | } |
1041 | 53 | 53 | ||
1043 | 54 | void connectToSurfaceConfigurator(MirSurfaceManager *manager, SurfaceConfigurator *surfaceConfigurator) | 54 | void connectToShell(MirSurfaceManager *manager, MirShell *shell) |
1044 | 55 | { | 55 | { |
1046 | 56 | QObject::connect(surfaceConfigurator, &SurfaceConfigurator::surfaceAttributeChanged, | 56 | QObject::connect(shell, &MirShell::surfaceAttributeChanged, |
1047 | 57 | manager, &MirSurfaceManager::onSurfaceAttributeChanged); | 57 | manager, &MirSurfaceManager::onSurfaceAttributeChanged); |
1048 | 58 | } | 58 | } |
1049 | 59 | 59 | ||
1050 | @@ -70,12 +70,12 @@ | |||
1051 | 70 | } | 70 | } |
1052 | 71 | 71 | ||
1053 | 72 | SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener")); | 72 | SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener")); |
1055 | 73 | SurfaceConfigurator *surfaceConfigurator = static_cast<SurfaceConfigurator*>(nativeInterface->nativeResourceForIntegration("SessionConfigurator")); | 73 | MirShell *shell = static_cast<MirShell*>(nativeInterface->nativeResourceForIntegration("Shell")); |
1056 | 74 | 74 | ||
1057 | 75 | the_surface_manager = new MirSurfaceManager(nativeInterface->m_mirServer, SessionManager::singleton()); | 75 | the_surface_manager = new MirSurfaceManager(nativeInterface->m_mirServer, SessionManager::singleton()); |
1058 | 76 | 76 | ||
1059 | 77 | connectToSessionListener(the_surface_manager, sessionListener); | 77 | connectToSessionListener(the_surface_manager, sessionListener); |
1061 | 78 | connectToSurfaceConfigurator(the_surface_manager, surfaceConfigurator); | 78 | connectToShell(the_surface_manager, shell); |
1062 | 79 | } | 79 | } |
1063 | 80 | return the_surface_manager; | 80 | return the_surface_manager; |
1064 | 81 | } | 81 | } |
1065 | 82 | 82 | ||
1066 | === modified file 'src/modules/Unity/Application/plugin.cpp' | |||
1067 | --- src/modules/Unity/Application/plugin.cpp 2014-10-06 11:37:56 +0000 | |||
1068 | +++ src/modules/Unity/Application/plugin.cpp 2015-02-05 10:26:37 +0000 | |||
1069 | @@ -78,6 +78,7 @@ | |||
1070 | 78 | qRegisterMetaType<qtmir::Session*>("Session*"); | 78 | qRegisterMetaType<qtmir::Session*>("Session*"); |
1071 | 79 | qRegisterMetaType<qtmir::SessionInterface*>("SessionInterface*"); | 79 | qRegisterMetaType<qtmir::SessionInterface*>("SessionInterface*"); |
1072 | 80 | qRegisterMetaType<qtmir::SessionModel*>("SessionModel*"); | 80 | qRegisterMetaType<qtmir::SessionModel*>("SessionModel*"); |
1073 | 81 | qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib"); | ||
1074 | 81 | 82 | ||
1075 | 82 | qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>( | 83 | qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>( |
1076 | 83 | uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML"); | 84 | uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML"); |
1077 | 84 | 85 | ||
1078 | === modified file 'src/modules/Unity/Application/sessionmanager.cpp' | |||
1079 | --- src/modules/Unity/Application/sessionmanager.cpp 2014-12-01 11:05:01 +0000 | |||
1080 | +++ src/modules/Unity/Application/sessionmanager.cpp 2015-02-05 10:26:37 +0000 | |||
1081 | @@ -26,7 +26,7 @@ | |||
1082 | 26 | #include "nativeinterface.h" | 26 | #include "nativeinterface.h" |
1083 | 27 | #include "mirserver.h" | 27 | #include "mirserver.h" |
1084 | 28 | #include "sessionlistener.h" | 28 | #include "sessionlistener.h" |
1086 | 29 | #include "surfaceconfigurator.h" | 29 | #include "mirshell.h" |
1087 | 30 | #include "logging.h" | 30 | #include "logging.h" |
1088 | 31 | #include "promptsessionlistener.h" | 31 | #include "promptsessionlistener.h" |
1089 | 32 | 32 | ||
1090 | 33 | 33 | ||
1091 | === modified file 'src/platforms/mirserver/CMakeLists.txt' | |||
1092 | --- src/platforms/mirserver/CMakeLists.txt 2014-12-12 15:15:06 +0000 | |||
1093 | +++ src/platforms/mirserver/CMakeLists.txt 2015-02-05 10:26:37 +0000 | |||
1094 | @@ -38,16 +38,14 @@ | |||
1095 | 38 | 38 | ||
1096 | 39 | set(MIRSERVER_QPA_PLUGIN_SRC | 39 | set(MIRSERVER_QPA_PLUGIN_SRC |
1097 | 40 | ../../common/debughelpers.cpp | 40 | ../../common/debughelpers.cpp |
1099 | 41 | focussetter.cpp | 41 | mirshell.cpp |
1100 | 42 | qteventfeeder.cpp | 42 | qteventfeeder.cpp |
1101 | 43 | plugin.cpp | 43 | plugin.cpp |
1102 | 44 | qmirserver.cpp | 44 | qmirserver.cpp |
1103 | 45 | sessionauthorizer.cpp | 45 | sessionauthorizer.cpp |
1104 | 46 | sessionlistener.cpp | 46 | sessionlistener.cpp |
1105 | 47 | surfaceconfigurator.cpp | ||
1106 | 48 | surfaceobserver.cpp | 47 | surfaceobserver.cpp |
1107 | 49 | promptsessionlistener.cpp | 48 | promptsessionlistener.cpp |
1108 | 50 | mirplacementstrategy.cpp | ||
1109 | 51 | mirserver.cpp | 49 | mirserver.cpp |
1110 | 52 | mirserverstatuslistener.cpp | 50 | mirserverstatuslistener.cpp |
1111 | 53 | display.cpp | 51 | display.cpp |
1112 | 54 | 52 | ||
1113 | === removed file 'src/platforms/mirserver/focussetter.cpp' | |||
1114 | --- src/platforms/mirserver/focussetter.cpp 2014-07-02 11:06:22 +0000 | |||
1115 | +++ src/platforms/mirserver/focussetter.cpp 1970-01-01 00:00:00 +0000 | |||
1116 | @@ -1,24 +0,0 @@ | |||
1117 | 1 | /* | ||
1118 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
1119 | 3 | * | ||
1120 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1121 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1122 | 6 | * the Free Software Foundation. | ||
1123 | 7 | * | ||
1124 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1125 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1126 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1127 | 11 | * Lesser General Public License for more details. | ||
1128 | 12 | * | ||
1129 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1130 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1131 | 15 | */ | ||
1132 | 16 | |||
1133 | 17 | #include "focussetter.h" | ||
1134 | 18 | |||
1135 | 19 | void FocusSetter::set_focus_to(std::shared_ptr<mir::scene::Session> const&) | ||
1136 | 20 | { | ||
1137 | 21 | // no-op | ||
1138 | 22 | // The focus concept live entirely inside the shell qml scene. Therefore | ||
1139 | 23 | // we don't want anything in mir to intervene with it | ||
1140 | 24 | } | ||
1141 | 25 | 0 | ||
1142 | === removed file 'src/platforms/mirserver/focussetter.h' | |||
1143 | --- src/platforms/mirserver/focussetter.h 2014-07-02 11:06:22 +0000 | |||
1144 | +++ src/platforms/mirserver/focussetter.h 1970-01-01 00:00:00 +0000 | |||
1145 | @@ -1,28 +0,0 @@ | |||
1146 | 1 | /* | ||
1147 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
1148 | 3 | * | ||
1149 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1150 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1151 | 6 | * the Free Software Foundation. | ||
1152 | 7 | * | ||
1153 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1154 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1155 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1156 | 11 | * Lesser General Public License for more details. | ||
1157 | 12 | * | ||
1158 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1159 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1160 | 15 | */ | ||
1161 | 16 | |||
1162 | 17 | #ifndef QPAMIRSERVER_FOCUS_SETTER_H | ||
1163 | 18 | #define QPAMIRSERVER_FOCUS_SETTER_H | ||
1164 | 19 | |||
1165 | 20 | #include <mir/shell/focus_setter.h> | ||
1166 | 21 | |||
1167 | 22 | class FocusSetter : public mir::shell::FocusSetter | ||
1168 | 23 | { | ||
1169 | 24 | public: | ||
1170 | 25 | void set_focus_to(std::shared_ptr<mir::scene::Session> const& new_focus) override; | ||
1171 | 26 | }; | ||
1172 | 27 | |||
1173 | 28 | #endif // QPAMIRSERVER_FOCUS_SETTER_H | ||
1174 | 29 | 0 | ||
1175 | === removed file 'src/platforms/mirserver/mirplacementstrategy.cpp' | |||
1176 | --- src/platforms/mirserver/mirplacementstrategy.cpp 2014-09-22 18:06:58 +0000 | |||
1177 | +++ src/platforms/mirserver/mirplacementstrategy.cpp 1970-01-01 00:00:00 +0000 | |||
1178 | @@ -1,59 +0,0 @@ | |||
1179 | 1 | /* | ||
1180 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
1181 | 3 | * | ||
1182 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1183 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1184 | 6 | * the Free Software Foundation. | ||
1185 | 7 | * | ||
1186 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1187 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1188 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1189 | 11 | * Lesser General Public License for more details. | ||
1190 | 12 | * | ||
1191 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1192 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1193 | 15 | */ | ||
1194 | 16 | |||
1195 | 17 | #include "mirplacementstrategy.h" | ||
1196 | 18 | #include "logging.h" | ||
1197 | 19 | #include "tracepoints.h" // generated from tracepoints.tp | ||
1198 | 20 | |||
1199 | 21 | #include <mir/geometry/rectangle.h> | ||
1200 | 22 | #include <mir/shell/display_layout.h> | ||
1201 | 23 | #include <mir/scene/surface_creation_parameters.h> | ||
1202 | 24 | |||
1203 | 25 | namespace ms = mir::scene; | ||
1204 | 26 | namespace msh = mir::shell; | ||
1205 | 27 | |||
1206 | 28 | MirPlacementStrategy::MirPlacementStrategy( | ||
1207 | 29 | std::shared_ptr<msh::DisplayLayout> const& display_layout) | ||
1208 | 30 | : m_displayLayout(display_layout) | ||
1209 | 31 | { | ||
1210 | 32 | qCDebug(QTMIR_MIR_MESSAGES) << "MirPlacementStrategy::MirPlacementStrategy"; | ||
1211 | 33 | } | ||
1212 | 34 | |||
1213 | 35 | ms::SurfaceCreationParameters | ||
1214 | 36 | MirPlacementStrategy::place(ms::Session const& /*session*/, | ||
1215 | 37 | ms::SurfaceCreationParameters const& requestParameters) | ||
1216 | 38 | { | ||
1217 | 39 | tracepoint(qtmirserver, surfacePlacementStart); | ||
1218 | 40 | |||
1219 | 41 | // TODO: Callback unity8 so that it can make a decision on that. | ||
1220 | 42 | // unity8 must bear in mind that the called function will be on a Mir thread though. | ||
1221 | 43 | // The QPA shouldn't be deciding for itself on such things. | ||
1222 | 44 | |||
1223 | 45 | ms::SurfaceCreationParameters placedParameters = requestParameters; | ||
1224 | 46 | |||
1225 | 47 | // Just make it fullscreen for now | ||
1226 | 48 | mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size}; | ||
1227 | 49 | m_displayLayout->size_to_output(rect); | ||
1228 | 50 | placedParameters.size = rect.size; | ||
1229 | 51 | |||
1230 | 52 | qCDebug(QTMIR_MIR_MESSAGES) << "MirPlacementStrategy: requested (" | ||
1231 | 53 | << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and returned (" | ||
1232 | 54 | << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")"; | ||
1233 | 55 | |||
1234 | 56 | tracepoint(qtmirserver, surfacePlacementEnd); | ||
1235 | 57 | |||
1236 | 58 | return placedParameters; | ||
1237 | 59 | } | ||
1238 | 60 | 0 | ||
1239 | === removed file 'src/platforms/mirserver/mirplacementstrategy.h' | |||
1240 | --- src/platforms/mirserver/mirplacementstrategy.h 2014-04-17 22:25:39 +0000 | |||
1241 | +++ src/platforms/mirserver/mirplacementstrategy.h 1970-01-01 00:00:00 +0000 | |||
1242 | @@ -1,42 +0,0 @@ | |||
1243 | 1 | /* | ||
1244 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
1245 | 3 | * | ||
1246 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1247 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1248 | 6 | * the Free Software Foundation. | ||
1249 | 7 | * | ||
1250 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1251 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1252 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1253 | 11 | * Lesser General Public License for more details. | ||
1254 | 12 | * | ||
1255 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1256 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1257 | 15 | */ | ||
1258 | 16 | |||
1259 | 17 | #ifndef MIRSERVERQPA_MIR_PLACEMENT_STRATEGY_H | ||
1260 | 18 | #define MIRSERVERQPA_MIR_PLACEMENT_STRATEGY_H | ||
1261 | 19 | |||
1262 | 20 | #include <mir/scene/placement_strategy.h> | ||
1263 | 21 | |||
1264 | 22 | #include <memory> | ||
1265 | 23 | |||
1266 | 24 | namespace mir { | ||
1267 | 25 | namespace shell { | ||
1268 | 26 | class DisplayLayout; | ||
1269 | 27 | } | ||
1270 | 28 | } | ||
1271 | 29 | |||
1272 | 30 | class MirPlacementStrategy : public mir::scene::PlacementStrategy | ||
1273 | 31 | { | ||
1274 | 32 | public: | ||
1275 | 33 | MirPlacementStrategy(std::shared_ptr<mir::shell::DisplayLayout> const& display_layout); | ||
1276 | 34 | |||
1277 | 35 | mir::scene::SurfaceCreationParameters place(mir::scene::Session const& session, | ||
1278 | 36 | mir::scene::SurfaceCreationParameters const& request_parameters) override; | ||
1279 | 37 | |||
1280 | 38 | private: | ||
1281 | 39 | std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout; | ||
1282 | 40 | }; | ||
1283 | 41 | |||
1284 | 42 | #endif // MIRSERVERQPA_MIR_PLACEMENT_STRATEGY_H | ||
1285 | 43 | 0 | ||
1286 | === modified file 'src/platforms/mirserver/mirserver.cpp' | |||
1287 | --- src/platforms/mirserver/mirserver.cpp 2014-12-03 12:06:30 +0000 | |||
1288 | +++ src/platforms/mirserver/mirserver.cpp 2015-02-05 10:26:37 +0000 | |||
1289 | @@ -19,13 +19,11 @@ | |||
1290 | 19 | #include "mirserver.h" | 19 | #include "mirserver.h" |
1291 | 20 | 20 | ||
1292 | 21 | // local | 21 | // local |
1294 | 22 | #include "focussetter.h" | 22 | #include "mirshell.h" |
1295 | 23 | #include "mirglconfig.h" | 23 | #include "mirglconfig.h" |
1296 | 24 | #include "mirplacementstrategy.h" | ||
1297 | 25 | #include "mirserverstatuslistener.h" | 24 | #include "mirserverstatuslistener.h" |
1298 | 26 | #include "promptsessionlistener.h" | 25 | #include "promptsessionlistener.h" |
1299 | 27 | #include "sessionlistener.h" | 26 | #include "sessionlistener.h" |
1300 | 28 | #include "surfaceconfigurator.h" | ||
1301 | 29 | #include "sessionauthorizer.h" | 27 | #include "sessionauthorizer.h" |
1302 | 30 | #include "qtcompositor.h" | 28 | #include "qtcompositor.h" |
1303 | 31 | #include "qteventfeeder.h" | 29 | #include "qteventfeeder.h" |
1304 | @@ -53,11 +51,6 @@ | |||
1305 | 53 | set_command_line_handler(&ignore_unparsed_arguments); | 51 | set_command_line_handler(&ignore_unparsed_arguments); |
1306 | 54 | set_command_line(argc, argv); | 52 | set_command_line(argc, argv); |
1307 | 55 | 53 | ||
1308 | 56 | override_the_placement_strategy([this] | ||
1309 | 57 | { | ||
1310 | 58 | return std::make_shared<MirPlacementStrategy>(the_shell_display_layout()); | ||
1311 | 59 | }); | ||
1312 | 60 | |||
1313 | 61 | override_the_session_listener([] | 54 | override_the_session_listener([] |
1314 | 62 | { | 55 | { |
1315 | 63 | return std::make_shared<SessionListener>(); | 56 | return std::make_shared<SessionListener>(); |
1316 | @@ -68,11 +61,6 @@ | |||
1317 | 68 | return std::make_shared<PromptSessionListener>(); | 61 | return std::make_shared<PromptSessionListener>(); |
1318 | 69 | }); | 62 | }); |
1319 | 70 | 63 | ||
1320 | 71 | override_the_surface_configurator([] | ||
1321 | 72 | { | ||
1322 | 73 | return std::make_shared<SurfaceConfigurator>(); | ||
1323 | 74 | }); | ||
1324 | 75 | |||
1325 | 76 | override_the_session_authorizer([] | 64 | override_the_session_authorizer([] |
1326 | 77 | { | 65 | { |
1327 | 78 | return std::make_shared<SessionAuthorizer>(); | 66 | return std::make_shared<SessionAuthorizer>(); |
1328 | @@ -102,9 +90,17 @@ | |||
1329 | 102 | return std::make_shared<MirServerStatusListener>(); | 90 | return std::make_shared<MirServerStatusListener>(); |
1330 | 103 | }); | 91 | }); |
1331 | 104 | 92 | ||
1333 | 105 | override_the_shell_focus_setter([] | 93 | override_the_shell([this] |
1334 | 106 | { | 94 | { |
1336 | 107 | return std::make_shared<FocusSetter>(); | 95 | auto const shell = std::make_shared<MirShell>( |
1337 | 96 | the_input_targeter(), | ||
1338 | 97 | the_surface_coordinator(), | ||
1339 | 98 | the_session_coordinator(), | ||
1340 | 99 | the_prompt_session_manager(), | ||
1341 | 100 | the_shell_display_layout()); | ||
1342 | 101 | |||
1343 | 102 | m_shell = shell; | ||
1344 | 103 | return shell; | ||
1345 | 108 | }); | 104 | }); |
1346 | 109 | 105 | ||
1347 | 110 | set_terminator([&](int) | 106 | set_terminator([&](int) |
1348 | @@ -157,10 +153,7 @@ | |||
1349 | 157 | return static_cast<PromptSessionListener*>(sharedPtr.get()); | 153 | return static_cast<PromptSessionListener*>(sharedPtr.get()); |
1350 | 158 | } | 154 | } |
1351 | 159 | 155 | ||
1353 | 160 | SurfaceConfigurator *MirServer::surfaceConfigurator() | 156 | MirShell *MirServer::shell() |
1354 | 161 | { | 157 | { |
1359 | 162 | auto sharedPtr = the_surface_configurator(); | 158 | return m_shell.lock().get(); |
1356 | 163 | if (sharedPtr.unique()) return 0; | ||
1357 | 164 | |||
1358 | 165 | return static_cast<SurfaceConfigurator*>(sharedPtr.get()); | ||
1360 | 166 | } | 159 | } |
1361 | 167 | 160 | ||
1362 | === modified file 'src/platforms/mirserver/mirserver.h' | |||
1363 | --- src/platforms/mirserver/mirserver.h 2014-12-02 14:55:17 +0000 | |||
1364 | +++ src/platforms/mirserver/mirserver.h 2015-02-05 10:26:37 +0000 | |||
1365 | @@ -23,7 +23,7 @@ | |||
1366 | 23 | class QtEventFeeder; | 23 | class QtEventFeeder; |
1367 | 24 | class SessionListener; | 24 | class SessionListener; |
1368 | 25 | class SessionAuthorizer; | 25 | class SessionAuthorizer; |
1370 | 26 | class SurfaceConfigurator; | 26 | class MirShell; |
1371 | 27 | class PromptSessionListener; | 27 | class PromptSessionListener; |
1372 | 28 | 28 | ||
1373 | 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) |
1374 | @@ -34,7 +34,7 @@ | |||
1375 | 34 | 34 | ||
1376 | 35 | Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT) | 35 | Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT) |
1377 | 36 | Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT) | 36 | Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT) |
1379 | 37 | Q_PROPERTY(SurfaceConfigurator* surfaceConfigurator READ surfaceConfigurator CONSTANT) | 37 | Q_PROPERTY(MirShell* shell READ shell CONSTANT) |
1380 | 38 | Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT) | 38 | Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT) |
1381 | 39 | 39 | ||
1382 | 40 | public: | 40 | public: |
1383 | @@ -58,10 +58,11 @@ | |||
1384 | 58 | SessionAuthorizer *sessionAuthorizer(); | 58 | SessionAuthorizer *sessionAuthorizer(); |
1385 | 59 | SessionListener *sessionListener(); | 59 | SessionListener *sessionListener(); |
1386 | 60 | PromptSessionListener *promptSessionListener(); | 60 | PromptSessionListener *promptSessionListener(); |
1388 | 61 | SurfaceConfigurator *surfaceConfigurator(); | 61 | MirShell *shell(); |
1389 | 62 | 62 | ||
1390 | 63 | private: | 63 | private: |
1391 | 64 | std::shared_ptr<QtEventFeeder> m_qtEventFeeder; | 64 | std::shared_ptr<QtEventFeeder> m_qtEventFeeder; |
1392 | 65 | std::weak_ptr<MirShell> m_shell; | ||
1393 | 65 | }; | 66 | }; |
1394 | 66 | 67 | ||
1395 | 67 | #endif // MIRSERVER_H | 68 | #endif // MIRSERVER_H |
1396 | 68 | 69 | ||
1397 | === added file 'src/platforms/mirserver/mirshell.cpp' | |||
1398 | --- src/platforms/mirserver/mirshell.cpp 1970-01-01 00:00:00 +0000 | |||
1399 | +++ src/platforms/mirserver/mirshell.cpp 2015-02-05 10:26:37 +0000 | |||
1400 | @@ -0,0 +1,75 @@ | |||
1401 | 1 | /* | ||
1402 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1403 | 3 | * | ||
1404 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1405 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1406 | 6 | * the Free Software Foundation. | ||
1407 | 7 | * | ||
1408 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1409 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1410 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1411 | 11 | * Lesser General Public License for more details. | ||
1412 | 12 | * | ||
1413 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1414 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1415 | 15 | */ | ||
1416 | 16 | |||
1417 | 17 | #include "mirshell.h" | ||
1418 | 18 | #include "logging.h" | ||
1419 | 19 | #include "tracepoints.h" // generated from tracepoints.tp | ||
1420 | 20 | |||
1421 | 21 | #include <mir/geometry/rectangle.h> | ||
1422 | 22 | #include <mir/scene/session.h> | ||
1423 | 23 | #include <mir/scene/surface_creation_parameters.h> | ||
1424 | 24 | #include <mir/shell/display_layout.h> | ||
1425 | 25 | |||
1426 | 26 | namespace ms = mir::scene; | ||
1427 | 27 | using mir::shell::AbstractShell; | ||
1428 | 28 | |||
1429 | 29 | MirShell::MirShell( | ||
1430 | 30 | std::shared_ptr<mir::shell::InputTargeter> const& input_targeter, | ||
1431 | 31 | std::shared_ptr<mir::scene::SurfaceCoordinator> const& surface_coordinator, | ||
1432 | 32 | std::shared_ptr<mir::scene::SessionCoordinator> const& session_coordinator, | ||
1433 | 33 | std::shared_ptr<mir::scene::PromptSessionManager> const& prompt_session_manager, | ||
1434 | 34 | std::shared_ptr<mir::shell::DisplayLayout> const& display_layout) : | ||
1435 | 35 | AbstractShell(input_targeter, surface_coordinator, session_coordinator, prompt_session_manager), | ||
1436 | 36 | m_displayLayout{display_layout} | ||
1437 | 37 | { | ||
1438 | 38 | qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::MirShell"; | ||
1439 | 39 | } | ||
1440 | 40 | |||
1441 | 41 | mir::frontend::SurfaceId MirShell::create_surface(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& requestParameters) | ||
1442 | 42 | { | ||
1443 | 43 | tracepoint(qtmirserver, surfacePlacementStart); | ||
1444 | 44 | |||
1445 | 45 | // TODO: Callback unity8 so that it can make a decision on that. | ||
1446 | 46 | // unity8 must bear in mind that the called function will be on a Mir thread though. | ||
1447 | 47 | // The QPA shouldn't be deciding for itself on such things. | ||
1448 | 48 | |||
1449 | 49 | ms::SurfaceCreationParameters placedParameters = requestParameters; | ||
1450 | 50 | |||
1451 | 51 | // Just make it fullscreen for now | ||
1452 | 52 | mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size}; | ||
1453 | 53 | m_displayLayout->size_to_output(rect); | ||
1454 | 54 | placedParameters.size = rect.size; | ||
1455 | 55 | |||
1456 | 56 | qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::create_surface(): size requested (" | ||
1457 | 57 | << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed (" | ||
1458 | 58 | << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")"; | ||
1459 | 59 | |||
1460 | 60 | tracepoint(qtmirserver, surfacePlacementEnd); | ||
1461 | 61 | |||
1462 | 62 | return AbstractShell::create_surface(session, placedParameters); | ||
1463 | 63 | } | ||
1464 | 64 | |||
1465 | 65 | int MirShell::set_surface_attribute( | ||
1466 | 66 | std::shared_ptr<mir::scene::Session> const& session, | ||
1467 | 67 | std::shared_ptr<mir::scene::Surface> const& surface, | ||
1468 | 68 | MirSurfaceAttrib attrib, | ||
1469 | 69 | int value) | ||
1470 | 70 | { | ||
1471 | 71 | auto const result = AbstractShell::set_surface_attribute(session, surface, attrib, value); | ||
1472 | 72 | Q_EMIT surfaceAttributeChanged(surface.get(), attrib, result); | ||
1473 | 73 | |||
1474 | 74 | return result; | ||
1475 | 75 | } | ||
1476 | 0 | 76 | ||
1477 | === added file 'src/platforms/mirserver/mirshell.h' | |||
1478 | --- src/platforms/mirserver/mirshell.h 1970-01-01 00:00:00 +0000 | |||
1479 | +++ src/platforms/mirserver/mirshell.h 2015-02-05 10:26:37 +0000 | |||
1480 | @@ -0,0 +1,56 @@ | |||
1481 | 1 | /* | ||
1482 | 2 | * Copyright © 2015 Canonical Ltd. | ||
1483 | 3 | * | ||
1484 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1485 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1486 | 6 | * the Free Software Foundation. | ||
1487 | 7 | * | ||
1488 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1489 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1490 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1491 | 11 | * Lesser General Public License for more details. | ||
1492 | 12 | * | ||
1493 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1494 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1495 | 15 | */ | ||
1496 | 16 | |||
1497 | 17 | #ifndef QPAMIRSERVER_SHELL_H | ||
1498 | 18 | #define QPAMIRSERVER_SHELL_H | ||
1499 | 19 | |||
1500 | 20 | #include <mir/shell/abstract_shell.h> | ||
1501 | 21 | #include <QObject> | ||
1502 | 22 | |||
1503 | 23 | namespace mir { | ||
1504 | 24 | namespace shell { | ||
1505 | 25 | class DisplayLayout; | ||
1506 | 26 | } | ||
1507 | 27 | } | ||
1508 | 28 | |||
1509 | 29 | class MirShell : public QObject, public mir::shell::AbstractShell | ||
1510 | 30 | { | ||
1511 | 31 | Q_OBJECT | ||
1512 | 32 | |||
1513 | 33 | public: | ||
1514 | 34 | MirShell( | ||
1515 | 35 | std::shared_ptr<mir::shell::InputTargeter> const& input_targeter, | ||
1516 | 36 | std::shared_ptr<mir::scene::SurfaceCoordinator> const& surface_coordinator, | ||
1517 | 37 | std::shared_ptr<mir::scene::SessionCoordinator> const& session_coordinator, | ||
1518 | 38 | std::shared_ptr<mir::scene::PromptSessionManager> const& prompt_session_manager, | ||
1519 | 39 | std::shared_ptr<mir::shell::DisplayLayout> const& display_layout); | ||
1520 | 40 | |||
1521 | 41 | virtual mir::frontend::SurfaceId create_surface(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params); | ||
1522 | 42 | |||
1523 | 43 | int set_surface_attribute( | ||
1524 | 44 | std::shared_ptr<mir::scene::Session> const& session, | ||
1525 | 45 | std::shared_ptr<mir::scene::Surface> const& surface, | ||
1526 | 46 | MirSurfaceAttrib attrib, | ||
1527 | 47 | int value) override; | ||
1528 | 48 | |||
1529 | 49 | Q_SIGNALS: | ||
1530 | 50 | void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int); | ||
1531 | 51 | |||
1532 | 52 | private: | ||
1533 | 53 | std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout; | ||
1534 | 54 | }; | ||
1535 | 55 | |||
1536 | 56 | #endif /* QPAMIRSERVER_SHELL_H */ | ||
1537 | 0 | 57 | ||
1538 | === modified file 'src/platforms/mirserver/nativeinterface.cpp' | |||
1539 | --- src/platforms/mirserver/nativeinterface.cpp 2014-12-01 11:05:01 +0000 | |||
1540 | +++ src/platforms/mirserver/nativeinterface.cpp 2015-02-05 10:26:37 +0000 | |||
1541 | @@ -29,8 +29,8 @@ | |||
1542 | 29 | 29 | ||
1543 | 30 | if (resource == "SessionAuthorizer") | 30 | if (resource == "SessionAuthorizer") |
1544 | 31 | result = m_mirServer->sessionAuthorizer(); | 31 | result = m_mirServer->sessionAuthorizer(); |
1547 | 32 | else if (resource == "SessionConfigurator") | 32 | else if (resource == "Shell") |
1548 | 33 | result = m_mirServer->surfaceConfigurator(); | 33 | result = m_mirServer->shell(); |
1549 | 34 | else if (resource == "SessionListener") | 34 | else if (resource == "SessionListener") |
1550 | 35 | result = m_mirServer->sessionListener(); | 35 | result = m_mirServer->sessionListener(); |
1551 | 36 | else if (resource == "PromptSessionListener") | 36 | else if (resource == "PromptSessionListener") |
1552 | 37 | 37 | ||
1553 | === modified file 'src/platforms/mirserver/qteventfeeder.cpp' | |||
1554 | --- src/platforms/mirserver/qteventfeeder.cpp 2015-01-05 21:42:31 +0000 | |||
1555 | +++ src/platforms/mirserver/qteventfeeder.cpp 2015-02-05 10:26:37 +0000 | |||
1556 | @@ -33,11 +33,6 @@ | |||
1557 | 33 | Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input") | 33 | Q_LOGGING_CATEGORY(QTMIR_MIR_INPUT, "qtmir.mir.input") |
1558 | 34 | 34 | ||
1559 | 35 | // from android-input AMOTION_EVENT_ACTION_*, hidden inside mir bowels | 35 | // from android-input AMOTION_EVENT_ACTION_*, hidden inside mir bowels |
1560 | 36 | // mir headers should define them | ||
1561 | 37 | const int QtEventFeeder::MirEventActionMask = 0xff; | ||
1562 | 38 | const int QtEventFeeder::MirEventActionPointerIndexMask = 0xff00; | ||
1563 | 39 | const int QtEventFeeder::MirEventActionPointerIndexShift = 8; | ||
1564 | 40 | |||
1565 | 41 | 36 | ||
1566 | 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) |
1567 | 43 | static const uint32_t KeyTable[] = { | 38 | static const uint32_t KeyTable[] = { |
1568 | @@ -182,6 +177,15 @@ | |||
1569 | 182 | Q_ASSERT(!mTopLevelWindow.isNull()); | 177 | Q_ASSERT(!mTopLevelWindow.isNull()); |
1570 | 183 | QWindowSystemInterface::handleTouchEvent(mTopLevelWindow.data(), timestamp, device, points, mods); | 178 | QWindowSystemInterface::handleTouchEvent(mTopLevelWindow.data(), timestamp, device, points, mods); |
1571 | 184 | } | 179 | } |
1572 | 180 | |||
1573 | 181 | void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) override | ||
1574 | 182 | { | ||
1575 | 183 | Q_ASSERT(!mTopLevelWindow.isNull()); | ||
1576 | 184 | QWindowSystemInterface::handleMouseEvent(mTopLevelWindow.data(), timestamp, point, point, // local and global point are the same | ||
1577 | 185 | buttons, modifiers); | ||
1578 | 186 | } | ||
1579 | 187 | |||
1580 | 188 | |||
1581 | 185 | private: | 189 | private: |
1582 | 186 | QPointer<QWindow> mTopLevelWindow; | 190 | QPointer<QWindow> mTopLevelWindow; |
1583 | 187 | }; | 191 | }; |
1584 | @@ -216,55 +220,109 @@ | |||
1585 | 216 | 220 | ||
1586 | 217 | void QtEventFeeder::dispatch(MirEvent const& event) | 221 | void QtEventFeeder::dispatch(MirEvent const& event) |
1587 | 218 | { | 222 | { |
1598 | 219 | switch (event.type) { | 223 | auto type = mir_event_get_type(&event); |
1599 | 220 | case mir_event_type_key: | 224 | if (type != mir_event_type_input) |
1600 | 221 | dispatchKey(event.key); | 225 | return; |
1601 | 222 | break; | 226 | auto iev = mir_event_get_input_event(&event); |
1602 | 223 | case mir_event_type_motion: | 227 | |
1603 | 224 | dispatchMotion(event.motion); | 228 | switch (mir_input_event_get_type(iev)) { |
1604 | 225 | break; | 229 | case mir_input_event_type_key: |
1605 | 226 | case mir_event_type_surface: | 230 | dispatchKey(iev); |
1606 | 227 | // Just ignore these events: it doesn't make sense to pass them on. | 231 | break; |
1607 | 228 | break; | 232 | case mir_input_event_type_touch: |
1608 | 233 | dispatchTouch(iev); | ||
1609 | 234 | break; | ||
1610 | 235 | case mir_input_event_type_pointer: | ||
1611 | 236 | dispatchPointer(iev); | ||
1612 | 229 | default: | 237 | default: |
1613 | 230 | // mir_event_type_surface and mir_event_type_resize events go through | ||
1614 | 231 | // mir's own protobuf channel instead of the android_input one. The latter | ||
1615 | 232 | // being the one we're dealing with here. | ||
1616 | 233 | qFatal("QtEventFeeder got unsupported event type from mir"); | ||
1617 | 234 | break; | 238 | break; |
1618 | 235 | } | 239 | } |
1619 | 236 | } | 240 | } |
1620 | 237 | 241 | ||
1628 | 238 | void QtEventFeeder::dispatchKey(MirKeyEvent const& event) | 242 | namespace |
1629 | 239 | { | 243 | { |
1630 | 240 | if (!mQtWindowSystem->hasTargetWindow()) | 244 | |
1631 | 241 | return; | 245 | Qt::KeyboardModifiers qt_modifiers_from_mir(MirInputEventModifiers modifiers) |
1632 | 242 | 246 | { | |
1633 | 243 | ulong timestamp = event.event_time / 1000000; | 247 | int q_modifiers = Qt::NoModifier; |
1634 | 244 | xkb_keysym_t xk_sym = static_cast<xkb_keysym_t>(event.key_code); | 248 | if (modifiers & mir_input_event_modifier_shift) { |
1635 | 249 | q_modifiers |= Qt::ShiftModifier; | ||
1636 | 250 | } | ||
1637 | 251 | if (modifiers & mir_input_event_modifier_ctrl) { | ||
1638 | 252 | q_modifiers |= Qt::ControlModifier; | ||
1639 | 253 | } | ||
1640 | 254 | if (modifiers & mir_input_event_modifier_alt) { | ||
1641 | 255 | q_modifiers |= Qt::AltModifier; | ||
1642 | 256 | } | ||
1643 | 257 | if (modifiers & mir_input_event_modifier_meta) { | ||
1644 | 258 | q_modifiers |= Qt::MetaModifier; | ||
1645 | 259 | } | ||
1646 | 260 | return static_cast<Qt::KeyboardModifiers>(q_modifiers); | ||
1647 | 261 | } | ||
1648 | 262 | |||
1649 | 263 | Qt::MouseButton extract_buttons(MirPointerInputEvent const* pev) | ||
1650 | 264 | { | ||
1651 | 265 | int buttons = Qt::NoButton; | ||
1652 | 266 | if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_primary)) | ||
1653 | 267 | buttons |= Qt::LeftButton; | ||
1654 | 268 | if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_secondary)) | ||
1655 | 269 | buttons |= Qt::RightButton; | ||
1656 | 270 | if (mir_pointer_input_event_get_button_state(pev, mir_pointer_input_button_tertiary)) | ||
1657 | 271 | buttons |= Qt::MidButton; | ||
1658 | 272 | |||
1659 | 273 | // TODO: Should mir back and forward buttons exist? | ||
1660 | 274 | // should they be Qt::X button 1 and 2? | ||
1661 | 275 | return static_cast<Qt::MouseButton>(buttons); | ||
1662 | 276 | } | ||
1663 | 277 | } | ||
1664 | 278 | |||
1665 | 279 | void QtEventFeeder::dispatchPointer(MirInputEvent const* ev) | ||
1666 | 280 | { | ||
1667 | 281 | if (!mQtWindowSystem->hasTargetWindow()) | ||
1668 | 282 | return; | ||
1669 | 283 | |||
1670 | 284 | auto timestamp = mir_input_event_get_event_time(ev) / 1000000; | ||
1671 | 285 | |||
1672 | 286 | auto pev = mir_input_event_get_pointer_input_event(ev); | ||
1673 | 287 | auto modifiers = qt_modifiers_from_mir(mir_pointer_input_event_get_modifiers(pev)); | ||
1674 | 288 | auto buttons = extract_buttons(pev); | ||
1675 | 289 | |||
1676 | 290 | auto local_point = QPointF(mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_x), | ||
1677 | 291 | mir_pointer_input_event_get_axis_value(pev, mir_pointer_input_axis_y)); | ||
1678 | 292 | |||
1679 | 293 | mQtWindowSystem->handleMouseEvent(timestamp, local_point, | ||
1680 | 294 | buttons, modifiers); | ||
1681 | 295 | } | ||
1682 | 296 | |||
1683 | 297 | void QtEventFeeder::dispatchKey(MirInputEvent const* event) | ||
1684 | 298 | { | ||
1685 | 299 | if (!mQtWindowSystem->hasTargetWindow()) | ||
1686 | 300 | return; | ||
1687 | 301 | |||
1688 | 302 | ulong timestamp = mir_input_event_get_event_time(event) / 1000000; | ||
1689 | 303 | |||
1690 | 304 | auto kev = mir_input_event_get_key_input_event(event); | ||
1691 | 305 | xkb_keysym_t xk_sym = mir_key_input_event_get_key_code(kev); | ||
1692 | 245 | 306 | ||
1693 | 246 | // Key modifier and unicode index mapping. | 307 | // Key modifier and unicode index mapping. |
1708 | 247 | const int kEventModifiers = event.modifiers; | 308 | auto modifiers = qt_modifiers_from_mir(mir_key_input_event_get_modifiers(kev)); |
1695 | 248 | Qt::KeyboardModifiers modifiers = Qt::NoModifier; | ||
1696 | 249 | if (kEventModifiers & mir_key_modifier_shift) { | ||
1697 | 250 | modifiers |= Qt::ShiftModifier; | ||
1698 | 251 | } | ||
1699 | 252 | if (kEventModifiers & mir_key_modifier_ctrl) { | ||
1700 | 253 | modifiers |= Qt::ControlModifier; | ||
1701 | 254 | } | ||
1702 | 255 | if (kEventModifiers & mir_key_modifier_alt) { | ||
1703 | 256 | modifiers |= Qt::AltModifier; | ||
1704 | 257 | } | ||
1705 | 258 | if (kEventModifiers & mir_key_modifier_meta) { | ||
1706 | 259 | modifiers |= Qt::MetaModifier; | ||
1707 | 260 | } | ||
1709 | 261 | 309 | ||
1710 | 262 | // Key action | 310 | // Key action |
1713 | 263 | QEvent::Type keyType; | 311 | QEvent::Type keyType = QEvent::KeyRelease; |
1714 | 264 | if (event.action == mir_key_action_down) { | 312 | bool is_auto_rep = false; |
1715 | 313 | |||
1716 | 314 | switch (mir_key_input_event_get_action(kev)) | ||
1717 | 315 | { | ||
1718 | 316 | case mir_key_input_event_action_repeat: | ||
1719 | 317 | is_auto_rep = true; // fall-through | ||
1720 | 318 | case mir_key_input_event_action_down: | ||
1721 | 265 | keyType = QEvent::KeyPress; | 319 | keyType = QEvent::KeyPress; |
1723 | 266 | } else { | 320 | break; |
1724 | 321 | case mir_key_input_event_action_up: | ||
1725 | 267 | keyType = QEvent::KeyRelease; | 322 | keyType = QEvent::KeyRelease; |
1726 | 323 | break; | ||
1727 | 324 | default: | ||
1728 | 325 | break; | ||
1729 | 268 | } | 326 | } |
1730 | 269 | 327 | ||
1731 | 270 | // Key event propagation. | 328 | // Key event propagation. |
1732 | @@ -272,13 +330,13 @@ | |||
1733 | 272 | int keyCode = translateKeysym(xk_sym, s, sizeof(s)); | 330 | int keyCode = translateKeysym(xk_sym, s, sizeof(s)); |
1734 | 273 | QString text = QString::fromLatin1(s); | 331 | QString text = QString::fromLatin1(s); |
1735 | 274 | 332 | ||
1736 | 275 | bool is_auto_rep = event.repeat_count > 0; | ||
1737 | 276 | |||
1738 | 277 | QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext(); | 333 | QPlatformInputContext* context = QGuiApplicationPrivate::platformIntegration()->inputContext(); |
1739 | 278 | if (context) { | 334 | if (context) { |
1740 | 279 | // TODO: consider event.repeat_count | 335 | // TODO: consider event.repeat_count |
1741 | 280 | QKeyEvent qKeyEvent(keyType, keyCode, modifiers, | 336 | QKeyEvent qKeyEvent(keyType, keyCode, modifiers, |
1743 | 281 | event.scan_code, event.key_code, event.modifiers, | 337 | mir_key_input_event_get_scan_code(kev), |
1744 | 338 | mir_key_input_event_get_key_code(kev), | ||
1745 | 339 | mir_key_input_event_get_modifiers(kev), | ||
1746 | 282 | text, is_auto_rep); | 340 | text, is_auto_rep); |
1747 | 283 | qKeyEvent.setTimestamp(timestamp); | 341 | qKeyEvent.setTimestamp(timestamp); |
1748 | 284 | if (context->filterEvent(&qKeyEvent)) { | 342 | if (context->filterEvent(&qKeyEvent)) { |
1749 | @@ -288,27 +346,17 @@ | |||
1750 | 288 | } | 346 | } |
1751 | 289 | 347 | ||
1752 | 290 | mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers, | 348 | mQtWindowSystem->handleExtendedKeyEvent(timestamp, keyType, keyCode, modifiers, |
1754 | 291 | event.scan_code, event.key_code, event.modifiers, text, is_auto_rep); | 349 | mir_key_input_event_get_scan_code(kev), |
1755 | 350 | mir_key_input_event_get_key_code(kev), | ||
1756 | 351 | mir_key_input_event_get_modifiers(kev), text, is_auto_rep); | ||
1757 | 292 | } | 352 | } |
1758 | 293 | 353 | ||
1760 | 294 | void QtEventFeeder::dispatchMotion(MirMotionEvent const& event) | 354 | void QtEventFeeder::dispatchTouch(MirInputEvent const* event) |
1761 | 295 | { | 355 | { |
1762 | 296 | if (!mQtWindowSystem->hasTargetWindow()) | 356 | if (!mQtWindowSystem->hasTargetWindow()) |
1763 | 297 | return; | 357 | return; |
1764 | 298 | 358 | ||
1778 | 299 | const int mirMotionAction = event.action & MirEventActionMask; | 359 | auto tev = mir_input_event_get_touch_input_event(event); |
1766 | 300 | |||
1767 | 301 | // Ignore the events that do not interest us (or that we currently don't support or know | ||
1768 | 302 | // how to translate into Qt events) | ||
1769 | 303 | if (mirMotionAction != mir_motion_action_move | ||
1770 | 304 | && mirMotionAction != mir_motion_action_down | ||
1771 | 305 | && mirMotionAction != mir_motion_action_up | ||
1772 | 306 | && mirMotionAction != mir_motion_action_pointer_down | ||
1773 | 307 | && mirMotionAction != mir_motion_action_pointer_up | ||
1774 | 308 | && mirMotionAction != mir_motion_action_cancel) { | ||
1775 | 309 | return; | ||
1776 | 310 | } | ||
1777 | 311 | |||
1779 | 312 | 360 | ||
1780 | 313 | // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That | 361 | // FIXME(loicm) Max pressure is device specific. That one is for the Samsung Galaxy Nexus. That |
1781 | 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. |
1782 | @@ -318,72 +366,48 @@ | |||
1783 | 318 | 366 | ||
1784 | 319 | // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left | 367 | // TODO: Is it worth setting the Qt::TouchPointStationary ones? Currently they are left |
1785 | 320 | // as Qt::TouchPointMoved | 368 | // as Qt::TouchPointMoved |
1787 | 321 | const int kPointerCount = (int) event.pointer_count; | 369 | const int kPointerCount = mir_touch_input_event_get_touch_count(tev); |
1788 | 322 | for (int i = 0; i < kPointerCount; ++i) { | 370 | for (int i = 0; i < kPointerCount; ++i) { |
1789 | 323 | QWindowSystemInterface::TouchPoint touchPoint; | 371 | QWindowSystemInterface::TouchPoint touchPoint; |
1790 | 324 | 372 | ||
1797 | 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); |
1798 | 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); |
1799 | 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); |
1800 | 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); |
1801 | 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); |
1802 | 330 | touchPoint.id = event.pointer_coordinates[i].id; | 378 | touchPoint.id = mir_touch_input_event_get_touch_id(tev, i); |
1803 | 379 | |||
1804 | 331 | touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height()); | 380 | touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height()); |
1805 | 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); |
1806 | 333 | touchPoint.pressure = kP / kMaxPressure; | 382 | touchPoint.pressure = kP / kMaxPressure; |
1808 | 334 | touchPoint.state = Qt::TouchPointMoved; | 383 | switch (mir_touch_input_event_get_touch_action(tev, i)) |
1809 | 384 | { | ||
1810 | 385 | case mir_touch_input_event_action_up: | ||
1811 | 386 | touchPoint.state = Qt::TouchPointReleased; | ||
1812 | 387 | break; | ||
1813 | 388 | case mir_touch_input_event_action_down: | ||
1814 | 389 | touchPoint.state = Qt::TouchPointPressed; | ||
1815 | 390 | break; | ||
1816 | 391 | case mir_touch_input_event_action_change: | ||
1817 | 392 | touchPoint.state = Qt::TouchPointMoved; | ||
1818 | 393 | break; | ||
1819 | 394 | default: | ||
1820 | 395 | break; | ||
1821 | 396 | } | ||
1822 | 335 | 397 | ||
1823 | 336 | touchPoints.append(touchPoint); | 398 | touchPoints.append(touchPoint); |
1824 | 337 | } | 399 | } |
1825 | 338 | 400 | ||
1826 | 339 | switch (mirMotionAction) { | ||
1827 | 340 | case mir_motion_action_move: | ||
1828 | 341 | // No extra work needed. | ||
1829 | 342 | break; | ||
1830 | 343 | |||
1831 | 344 | case mir_motion_action_down: | ||
1832 | 345 | // NB: hardcoded index 0 because there's only a single touch point in this case | ||
1833 | 346 | touchPoints[0].state = Qt::TouchPointPressed; | ||
1834 | 347 | break; | ||
1835 | 348 | |||
1836 | 349 | case mir_motion_action_up: | ||
1837 | 350 | touchPoints[0].state = Qt::TouchPointReleased; | ||
1838 | 351 | break; | ||
1839 | 352 | |||
1840 | 353 | case mir_motion_action_pointer_down: { | ||
1841 | 354 | const int index = (event.action & MirEventActionPointerIndexMask) >> | ||
1842 | 355 | MirEventActionPointerIndexShift; | ||
1843 | 356 | touchPoints[index].state = Qt::TouchPointPressed; | ||
1844 | 357 | break; | ||
1845 | 358 | } | ||
1846 | 359 | |||
1847 | 360 | case mir_motion_action_cancel: | ||
1848 | 361 | case mir_motion_action_pointer_up: { | ||
1849 | 362 | const int index = (event.action & MirEventActionPointerIndexMask) >> | ||
1850 | 363 | MirEventActionPointerIndexShift; | ||
1851 | 364 | touchPoints[index].state = Qt::TouchPointReleased; | ||
1852 | 365 | break; | ||
1853 | 366 | } | ||
1854 | 367 | |||
1855 | 368 | case mir_motion_action_outside: | ||
1856 | 369 | case mir_motion_action_hover_move: | ||
1857 | 370 | case mir_motion_action_scroll: | ||
1858 | 371 | case mir_motion_action_hover_enter: | ||
1859 | 372 | case mir_motion_action_hover_exit: | ||
1860 | 373 | default: | ||
1861 | 374 | // Should never reach this point. If so, it's a programming error. | ||
1862 | 375 | qFatal("Trying to handle unsupported motion event action"); | ||
1863 | 376 | } | ||
1864 | 377 | |||
1865 | 378 | // Qt needs a happy, sane stream of touch events. So let's make sure we're not forwarding | 401 | // Qt needs a happy, sane stream of touch events. So let's make sure we're not forwarding |
1866 | 379 | // any insanity. | 402 | // any insanity. |
1867 | 380 | validateTouches(touchPoints); | 403 | validateTouches(touchPoints); |
1868 | 381 | 404 | ||
1869 | 382 | // Touch event propagation. | 405 | // Touch event propagation. |
1870 | 383 | mQtWindowSystem->handleTouchEvent( | 406 | mQtWindowSystem->handleTouchEvent( |
1874 | 384 | event.event_time / 1000000, //scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable | 407 | //scales down the nsec_t (int64) to fit a ulong, precision lost but time difference suitable |
1875 | 385 | mTouchDevice, | 408 | mir_input_event_get_event_time(event) / 1000000, |
1876 | 386 | touchPoints); | 409 | mTouchDevice, |
1877 | 410 | touchPoints); | ||
1878 | 387 | } | 411 | } |
1879 | 388 | 412 | ||
1880 | 389 | void QtEventFeeder::start() | 413 | void QtEventFeeder::start() |
1881 | @@ -396,12 +420,12 @@ | |||
1882 | 396 | // not used | 420 | // not used |
1883 | 397 | } | 421 | } |
1884 | 398 | 422 | ||
1886 | 399 | void QtEventFeeder::configuration_changed(nsecs_t when) | 423 | void QtEventFeeder::configuration_changed(std::chrono::nanoseconds when) |
1887 | 400 | { | 424 | { |
1888 | 401 | Q_UNUSED(when); | 425 | Q_UNUSED(when); |
1889 | 402 | } | 426 | } |
1890 | 403 | 427 | ||
1892 | 404 | void QtEventFeeder::device_reset(int32_t device_id, nsecs_t when) | 428 | void QtEventFeeder::device_reset(int32_t device_id, std::chrono::nanoseconds when) |
1893 | 405 | { | 429 | { |
1894 | 406 | Q_UNUSED(device_id); | 430 | Q_UNUSED(device_id); |
1895 | 407 | Q_UNUSED(when); | 431 | Q_UNUSED(when); |
1896 | 408 | 432 | ||
1897 | === modified file 'src/platforms/mirserver/qteventfeeder.h' | |||
1898 | --- src/platforms/mirserver/qteventfeeder.h 2014-08-28 12:22:55 +0000 | |||
1899 | +++ src/platforms/mirserver/qteventfeeder.h 2015-02-05 10:26:37 +0000 | |||
1900 | @@ -51,6 +51,7 @@ | |||
1901 | 51 | virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device, | 51 | virtual void handleTouchEvent(ulong timestamp, QTouchDevice *device, |
1902 | 52 | const QList<struct QWindowSystemInterface::TouchPoint> &points, | 52 | const QList<struct QWindowSystemInterface::TouchPoint> &points, |
1903 | 53 | Qt::KeyboardModifiers mods = Qt::NoModifier) = 0; | 53 | Qt::KeyboardModifiers mods = Qt::NoModifier) = 0; |
1904 | 54 | virtual void handleMouseEvent(ulong timestamp, QPointF point, Qt::MouseButton buttons, Qt::KeyboardModifiers modifiers) = 0; | ||
1905 | 54 | }; | 55 | }; |
1906 | 55 | 56 | ||
1907 | 56 | QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr); | 57 | QtEventFeeder(QtWindowSystemInterface *windowSystem = nullptr); |
1908 | @@ -60,15 +61,16 @@ | |||
1909 | 60 | static const int MirEventActionPointerIndexMask; | 61 | static const int MirEventActionPointerIndexMask; |
1910 | 61 | static const int MirEventActionPointerIndexShift; | 62 | static const int MirEventActionPointerIndexShift; |
1911 | 62 | 63 | ||
1914 | 63 | void configuration_changed(nsecs_t when) override; | 64 | void configuration_changed(std::chrono::nanoseconds when) override; |
1915 | 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; |
1916 | 65 | void dispatch(MirEvent const& event) override; | 66 | void dispatch(MirEvent const& event) override; |
1917 | 66 | void start() override; | 67 | void start() override; |
1918 | 67 | void stop() override; | 68 | void stop() override; |
1919 | 68 | 69 | ||
1920 | 69 | private: | 70 | private: |
1923 | 70 | void dispatchKey(MirKeyEvent const& event); | 71 | void dispatchKey(MirInputEvent const* event); |
1924 | 71 | void dispatchMotion(MirMotionEvent const& event); | 72 | void dispatchTouch(MirInputEvent const* event); |
1925 | 73 | void dispatchPointer(MirInputEvent const* event); | ||
1926 | 72 | void validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints); | 74 | void validateTouches(QList<QWindowSystemInterface::TouchPoint> &touchPoints); |
1927 | 73 | bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint); | 75 | bool validateTouch(QWindowSystemInterface::TouchPoint &touchPoint); |
1928 | 74 | 76 | ||
1929 | 75 | 77 | ||
1930 | === removed file 'src/platforms/mirserver/surfaceconfigurator.cpp' | |||
1931 | --- src/platforms/mirserver/surfaceconfigurator.cpp 2014-04-02 16:10:34 +0000 | |||
1932 | +++ src/platforms/mirserver/surfaceconfigurator.cpp 1970-01-01 00:00:00 +0000 | |||
1933 | @@ -1,34 +0,0 @@ | |||
1934 | 1 | /* | ||
1935 | 2 | * Copyright (C) 2013,2014 Canonical, Ltd. | ||
1936 | 3 | * | ||
1937 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1938 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1939 | 6 | * the Free Software Foundation. | ||
1940 | 7 | * | ||
1941 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1942 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1943 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1944 | 11 | * Lesser General Public License for more details. | ||
1945 | 12 | * | ||
1946 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1947 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1948 | 15 | */ | ||
1949 | 16 | |||
1950 | 17 | #include "surfaceconfigurator.h" | ||
1951 | 18 | |||
1952 | 19 | namespace ms = mir::scene; | ||
1953 | 20 | |||
1954 | 21 | SurfaceConfigurator::SurfaceConfigurator() | ||
1955 | 22 | { | ||
1956 | 23 | qRegisterMetaType<MirSurfaceAttrib>("MirSurfaceAttrib"); | ||
1957 | 24 | } | ||
1958 | 25 | |||
1959 | 26 | int SurfaceConfigurator::select_attribute_value(ms::Surface const&, MirSurfaceAttrib, int requested_value) | ||
1960 | 27 | { | ||
1961 | 28 | return requested_value; | ||
1962 | 29 | } | ||
1963 | 30 | |||
1964 | 31 | void SurfaceConfigurator::attribute_set(ms::Surface const& surface, MirSurfaceAttrib attrib, int value) | ||
1965 | 32 | { | ||
1966 | 33 | Q_EMIT surfaceAttributeChanged(&surface, attrib, value); | ||
1967 | 34 | } | ||
1968 | 35 | 0 | ||
1969 | === removed file 'src/platforms/mirserver/surfaceconfigurator.h' | |||
1970 | --- src/platforms/mirserver/surfaceconfigurator.h 2014-04-02 16:10:34 +0000 | |||
1971 | +++ src/platforms/mirserver/surfaceconfigurator.h 1970-01-01 00:00:00 +0000 | |||
1972 | @@ -1,41 +0,0 @@ | |||
1973 | 1 | /* | ||
1974 | 2 | * Copyright (C) 2013,2014 Canonical, Ltd. | ||
1975 | 3 | * | ||
1976 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
1977 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
1978 | 6 | * the Free Software Foundation. | ||
1979 | 7 | * | ||
1980 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
1981 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
1982 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1983 | 11 | * Lesser General Public License for more details. | ||
1984 | 12 | * | ||
1985 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
1986 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1987 | 15 | */ | ||
1988 | 16 | |||
1989 | 17 | #ifndef SURFACECONFIGURATOR_H | ||
1990 | 18 | #define SURFACECONFIGURATOR_H | ||
1991 | 19 | |||
1992 | 20 | #include <QObject> | ||
1993 | 21 | |||
1994 | 22 | #include <mir/scene/surface_configurator.h> | ||
1995 | 23 | #include <mir_toolkit/common.h> | ||
1996 | 24 | |||
1997 | 25 | namespace mir { namespace scene { class Surface; }} | ||
1998 | 26 | |||
1999 | 27 | class SurfaceConfigurator : public QObject, public mir::scene::SurfaceConfigurator | ||
2000 | 28 | { | ||
2001 | 29 | Q_OBJECT | ||
2002 | 30 | |||
2003 | 31 | public: | ||
2004 | 32 | SurfaceConfigurator(); | ||
2005 | 33 | |||
2006 | 34 | int select_attribute_value(mir::scene::Surface const&, MirSurfaceAttrib, int) override; | ||
2007 | 35 | void attribute_set(mir::scene::Surface const&, MirSurfaceAttrib, int) override; | ||
2008 | 36 | |||
2009 | 37 | Q_SIGNALS: | ||
2010 | 38 | void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int); | ||
2011 | 39 | }; | ||
2012 | 40 | |||
2013 | 41 | #endif // SURFACECONFIGURATOR_H | ||
2014 | 42 | 0 | ||
2015 | === modified file 'tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h' | |||
2016 | --- tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2014-08-28 12:20:13 +0000 | |||
2017 | +++ tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2015-02-05 10:26:37 +0000 | |||
2018 | @@ -34,6 +34,7 @@ | |||
2019 | 34 | MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device, | 34 | MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device, |
2020 | 35 | const QList<struct QWindowSystemInterface::TouchPoint> &points, | 35 | const QList<struct QWindowSystemInterface::TouchPoint> &points, |
2021 | 36 | Qt::KeyboardModifiers mods)); | 36 | Qt::KeyboardModifiers mods)); |
2022 | 37 | MOCK_METHOD4(handleMouseEvent, void(ulong, QPointF, Qt::MouseButton, Qt::KeyboardModifiers)); | ||
2023 | 37 | }; | 38 | }; |
2024 | 38 | 39 | ||
2025 | 39 | namespace testing | 40 | namespace testing |
2026 | 40 | 41 | ||
2027 | === modified file 'tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp' | |||
2028 | --- tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2014-08-28 13:12:30 +0000 | |||
2029 | +++ tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2015-02-05 10:26:37 +0000 | |||
2030 | @@ -15,6 +15,8 @@ | |||
2031 | 15 | * | 15 | * |
2032 | 16 | */ | 16 | */ |
2033 | 17 | 17 | ||
2034 | 18 | #define MIR_INCLUDE_DEPRECATED_EVENT_HEADER | ||
2035 | 19 | |||
2036 | 18 | #include <gmock/gmock.h> | 20 | #include <gmock/gmock.h> |
2037 | 19 | #include <gtest/gtest.h> | 21 | #include <gtest/gtest.h> |
2038 | 20 | 22 | ||
2039 | @@ -191,34 +193,3 @@ | |||
2040 | 191 | ASSERT_TRUE(Mock::VerifyAndClearExpectations(mockWindowSystem)); | 193 | ASSERT_TRUE(Mock::VerifyAndClearExpectations(mockWindowSystem)); |
2041 | 192 | } | 194 | } |
2042 | 193 | 195 | ||
2043 | 194 | TEST_F(QtEventFeederTest, IgnoreHovering) | ||
2044 | 195 | { | ||
2045 | 196 | setIrrelevantMockWindowSystemExpectations(); | ||
2046 | 197 | EXPECT_CALL(*mockWindowSystem, handleTouchEvent(_,_,_,_)).Times(0); | ||
2047 | 198 | |||
2048 | 199 | MirEvent mirEvent; | ||
2049 | 200 | mirEvent.type = mir_event_type_motion; | ||
2050 | 201 | mirEvent.motion.pointer_count = 1; | ||
2051 | 202 | mirEvent.motion.pointer_coordinates[0].id = 0; | ||
2052 | 203 | mirEvent.motion.pointer_coordinates[0].x = 10; | ||
2053 | 204 | mirEvent.motion.pointer_coordinates[0].y = 10; | ||
2054 | 205 | mirEvent.motion.pointer_coordinates[0].touch_major = 1; | ||
2055 | 206 | mirEvent.motion.pointer_coordinates[0].touch_minor = 1; | ||
2056 | 207 | mirEvent.motion.pointer_coordinates[0].pressure = 10; | ||
2057 | 208 | mirEvent.motion.action = mir_motion_action_hover_enter; | ||
2058 | 209 | mirEvent.motion.event_time = 123 * 1000000; | ||
2059 | 210 | |||
2060 | 211 | qtEventFeeder->dispatch(mirEvent); | ||
2061 | 212 | |||
2062 | 213 | mirEvent.motion.pointer_coordinates[0].x = 20; | ||
2063 | 214 | mirEvent.motion.pointer_coordinates[0].y = 20; | ||
2064 | 215 | mirEvent.motion.action = mir_motion_action_hover_move; | ||
2065 | 216 | mirEvent.motion.event_time = 125 * 1000000; | ||
2066 | 217 | |||
2067 | 218 | qtEventFeeder->dispatch(mirEvent); | ||
2068 | 219 | |||
2069 | 220 | mirEvent.motion.action = mir_motion_action_hover_exit; | ||
2070 | 221 | mirEvent.motion.event_time = 127 * 1000000; | ||
2071 | 222 | |||
2072 | 223 | qtEventFeeder->dispatch(mirEvent); | ||
2073 | 224 | } | ||
2074 | 225 | 196 | ||
2075 | === modified file 'tests/modules/ApplicationManager/application_manager_test.cpp' | |||
2076 | --- tests/modules/ApplicationManager/application_manager_test.cpp 2014-11-13 16:26:03 +0000 | |||
2077 | +++ tests/modules/ApplicationManager/application_manager_test.cpp 2015-02-05 10:26:37 +0000 | |||
2078 | @@ -15,6 +15,8 @@ | |||
2079 | 15 | * | 15 | * |
2080 | 16 | */ | 16 | */ |
2081 | 17 | 17 | ||
2082 | 18 | #define MIR_INCLUDE_DEPRECATED_EVENT_HEADER | ||
2083 | 19 | |||
2084 | 18 | #include <thread> | 20 | #include <thread> |
2085 | 19 | #include <condition_variable> | 21 | #include <condition_variable> |
2086 | 20 | #include <QSignalSpy> | 22 | #include <QSignalSpy> |
2087 | @@ -2135,3 +2137,100 @@ | |||
2088 | 2135 | cv.wait(lk, [&] { return done; } ); | 2137 | cv.wait(lk, [&] { return done; } ); |
2089 | 2136 | } | 2138 | } |
2090 | 2137 | } | 2139 | } |
2091 | 2140 | |||
2092 | 2141 | /* | ||
2093 | 2142 | 1 - launch and focus a main stage app | ||
2094 | 2143 | * main stage app is running and focused | ||
2095 | 2144 | 2 - launch and focus a side stage app | ||
2096 | 2145 | * main stage app is running but is not focused | ||
2097 | 2146 | * side stage app is running and has focus | ||
2098 | 2147 | 3 - focus the main stage app | ||
2099 | 2148 | * main stage app is running and has focus | ||
2100 | 2149 | * side stage app is running but is not focused | ||
2101 | 2150 | |||
2102 | 2151 | This is a regression test for the bug where on step 3, the main stage app was momentarily | ||
2103 | 2152 | suspended and then resumed again. | ||
2104 | 2153 | */ | ||
2105 | 2154 | TEST_F(ApplicationManagerTests, focusMainStageAfterSideStage) | ||
2106 | 2155 | { | ||
2107 | 2156 | using namespace testing; | ||
2108 | 2157 | |||
2109 | 2158 | QString webbrowserAppId("webbrowser-app"); | ||
2110 | 2159 | quint64 webbrowserPID = 123; | ||
2111 | 2160 | std::shared_ptr<mir::scene::Surface> webbrowserSurface(nullptr); | ||
2112 | 2161 | |||
2113 | 2162 | QString dialerAppId("dialer-app"); | ||
2114 | 2163 | quint64 dialerPID = 456; | ||
2115 | 2164 | std::shared_ptr<mir::scene::Surface> dialerSurface(nullptr); | ||
2116 | 2165 | |||
2117 | 2166 | /*** Start webbrowser-app (main stage) ***/ | ||
2118 | 2167 | |||
2119 | 2168 | ON_CALL(appController,appIdHasProcessId(webbrowserPID, webbrowserAppId)).WillByDefault(Return(true)); | ||
2120 | 2169 | |||
2121 | 2170 | { | ||
2122 | 2171 | auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(webbrowserAppId, QFileInfo()); | ||
2123 | 2172 | ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); | ||
2124 | 2173 | ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(webbrowserAppId)); | ||
2125 | 2174 | ON_CALL(*mockDesktopFileReader, stageHint()).WillByDefault(Return("MainStage")); | ||
2126 | 2175 | |||
2127 | 2176 | ON_CALL(desktopFileReaderFactory, createInstance(webbrowserAppId, _)) | ||
2128 | 2177 | .WillByDefault(Return(mockDesktopFileReader)); | ||
2129 | 2178 | } | ||
2130 | 2179 | |||
2131 | 2180 | EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(webbrowserAppId, _)) | ||
2132 | 2181 | .Times(1) | ||
2133 | 2182 | .WillOnce(Return(true)); | ||
2134 | 2183 | |||
2135 | 2184 | /*auto application =*/ applicationManager.startApplication(webbrowserAppId, ApplicationManager::NoFlag); | ||
2136 | 2185 | applicationManager.onProcessStarting(webbrowserAppId); | ||
2137 | 2186 | |||
2138 | 2187 | { | ||
2139 | 2188 | bool authed = false; | ||
2140 | 2189 | applicationManager.authorizeSession(webbrowserPID, authed); | ||
2141 | 2190 | EXPECT_EQ(authed, true); | ||
2142 | 2191 | } | ||
2143 | 2192 | |||
2144 | 2193 | auto webbrowserSession = std::make_shared<mir::scene::MockSession>(webbrowserAppId.toStdString(), webbrowserPID); | ||
2145 | 2194 | sessionManager.onSessionStarting(webbrowserSession); | ||
2146 | 2195 | applicationManager.focusApplication(webbrowserAppId); | ||
2147 | 2196 | applicationManager.onSessionCreatedSurface(webbrowserSession.get(), webbrowserSurface); | ||
2148 | 2197 | |||
2149 | 2198 | /*** Start dialer-app (side stage) ***/ | ||
2150 | 2199 | |||
2151 | 2200 | ON_CALL(appController, appIdHasProcessId(dialerPID, dialerAppId)).WillByDefault(Return(true)); | ||
2152 | 2201 | |||
2153 | 2202 | { | ||
2154 | 2203 | auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(dialerAppId, QFileInfo()); | ||
2155 | 2204 | ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); | ||
2156 | 2205 | ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(dialerAppId)); | ||
2157 | 2206 | ON_CALL(*mockDesktopFileReader, stageHint()).WillByDefault(Return("SideStage")); | ||
2158 | 2207 | |||
2159 | 2208 | ON_CALL(desktopFileReaderFactory, createInstance(dialerAppId, _)) | ||
2160 | 2209 | .WillByDefault(Return(mockDesktopFileReader)); | ||
2161 | 2210 | } | ||
2162 | 2211 | |||
2163 | 2212 | EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(dialerAppId, _)) | ||
2164 | 2213 | .Times(1) | ||
2165 | 2214 | .WillOnce(Return(true)); | ||
2166 | 2215 | |||
2167 | 2216 | /*auto application =*/ applicationManager.startApplication(dialerAppId, ApplicationManager::NoFlag); | ||
2168 | 2217 | applicationManager.onProcessStarting(dialerAppId); | ||
2169 | 2218 | |||
2170 | 2219 | { | ||
2171 | 2220 | bool authed = false; | ||
2172 | 2221 | applicationManager.authorizeSession(dialerPID, authed); | ||
2173 | 2222 | EXPECT_EQ(authed, true); | ||
2174 | 2223 | } | ||
2175 | 2224 | |||
2176 | 2225 | auto dialerSession = std::make_shared<mir::scene::MockSession>(dialerAppId.toStdString(), dialerPID); | ||
2177 | 2226 | sessionManager.onSessionStarting(dialerSession); | ||
2178 | 2227 | applicationManager.focusApplication(dialerAppId); | ||
2179 | 2228 | applicationManager.onSessionCreatedSurface(dialerSession.get(), dialerSurface); | ||
2180 | 2229 | |||
2181 | 2230 | /*** Focus webbrowser ***/ | ||
2182 | 2231 | |||
2183 | 2232 | // Nothing should happen as it's already the running main stage app | ||
2184 | 2233 | EXPECT_CALL(*webbrowserSession.get(), set_lifecycle_state(_)) | ||
2185 | 2234 | .Times(0); | ||
2186 | 2235 | applicationManager.focusApplication(webbrowserAppId); | ||
2187 | 2236 | } | ||
2188 | 2138 | 2237 | ||
2189 | === modified file 'tests/modules/DesktopFileReader/desktopfilereader_test.cpp' | |||
2190 | --- tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2014-10-14 23:15:46 +0000 | |||
2191 | +++ tests/modules/DesktopFileReader/desktopfilereader_test.cpp 2015-02-05 10:26:37 +0000 | |||
2192 | @@ -126,3 +126,73 @@ | |||
2193 | 126 | EXPECT_EQ(reader->comment(), "Ubuntu 简易计算器"); | 126 | EXPECT_EQ(reader->comment(), "Ubuntu 简易计算器"); |
2194 | 127 | EXPECT_EQ(reader->splashTitle(), "计算器 2.0"); | 127 | EXPECT_EQ(reader->splashTitle(), "计算器 2.0"); |
2195 | 128 | } | 128 | } |
2196 | 129 | |||
2197 | 130 | TEST(DesktopFileReader, parseOrientations) | ||
2198 | 131 | { | ||
2199 | 132 | using namespace ::testing; | ||
2200 | 133 | |||
2201 | 134 | const Qt::ScreenOrientations defaultOrientations = Qt::PortraitOrientation | Qt::LandscapeOrientation | ||
2202 | 135 | | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation; | ||
2203 | 136 | bool ok; | ||
2204 | 137 | Qt::ScreenOrientations orientations; | ||
2205 | 138 | |||
2206 | 139 | ok = DesktopFileReader::parseOrientations(QString(), orientations); | ||
2207 | 140 | ASSERT_TRUE(ok); | ||
2208 | 141 | EXPECT_EQ(defaultOrientations, orientations); | ||
2209 | 142 | |||
2210 | 143 | ok = DesktopFileReader::parseOrientations("An invalid string!", orientations); | ||
2211 | 144 | ASSERT_FALSE(ok); | ||
2212 | 145 | EXPECT_EQ(defaultOrientations, orientations); | ||
2213 | 146 | |||
2214 | 147 | ok = DesktopFileReader::parseOrientations("landscape", orientations); | ||
2215 | 148 | ASSERT_TRUE(ok); | ||
2216 | 149 | EXPECT_EQ(Qt::LandscapeOrientation, orientations); | ||
2217 | 150 | |||
2218 | 151 | ok = DesktopFileReader::parseOrientations(" InvertedPortrait , Portrait ", orientations); | ||
2219 | 152 | ASSERT_TRUE(ok); | ||
2220 | 153 | EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::PortraitOrientation, orientations); | ||
2221 | 154 | |||
2222 | 155 | ok = DesktopFileReader::parseOrientations(",inverted-landscape, inverted_portrait, ", orientations); | ||
2223 | 156 | ASSERT_TRUE(ok); | ||
2224 | 157 | EXPECT_EQ(Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation, orientations); | ||
2225 | 158 | |||
2226 | 159 | ok = DesktopFileReader::parseOrientations(",inverted-landscape, some-invalid-text, ", orientations); | ||
2227 | 160 | ASSERT_FALSE(ok); | ||
2228 | 161 | EXPECT_EQ(defaultOrientations, orientations); | ||
2229 | 162 | |||
2230 | 163 | ok = DesktopFileReader::parseOrientations("landscape;portrait", orientations); | ||
2231 | 164 | ASSERT_TRUE(ok); | ||
2232 | 165 | EXPECT_EQ(Qt::PortraitOrientation | Qt::LandscapeOrientation, orientations); | ||
2233 | 166 | |||
2234 | 167 | ok = DesktopFileReader::parseOrientations("primary", orientations); | ||
2235 | 168 | ASSERT_TRUE(ok); | ||
2236 | 169 | EXPECT_EQ(Qt::PrimaryOrientation, orientations); | ||
2237 | 170 | |||
2238 | 171 | ok = DesktopFileReader::parseOrientations("landscpe,primary", orientations); | ||
2239 | 172 | ASSERT_FALSE(ok); | ||
2240 | 173 | EXPECT_EQ(defaultOrientations, orientations); | ||
2241 | 174 | } | ||
2242 | 175 | |||
2243 | 176 | TEST(DesktopFileReader, parseBoolean) | ||
2244 | 177 | { | ||
2245 | 178 | using namespace ::testing; | ||
2246 | 179 | |||
2247 | 180 | bool ok; | ||
2248 | 181 | bool boolean; | ||
2249 | 182 | |||
2250 | 183 | ok = DesktopFileReader::parseBoolean(QString(), boolean); | ||
2251 | 184 | ASSERT_TRUE(ok); | ||
2252 | 185 | EXPECT_EQ(false, boolean); | ||
2253 | 186 | |||
2254 | 187 | ok = DesktopFileReader::parseBoolean(" Yes ", boolean); | ||
2255 | 188 | ASSERT_TRUE(ok); | ||
2256 | 189 | EXPECT_EQ(true, boolean); | ||
2257 | 190 | |||
2258 | 191 | ok = DesktopFileReader::parseBoolean("False", boolean); | ||
2259 | 192 | ASSERT_TRUE(ok); | ||
2260 | 193 | EXPECT_EQ(false, boolean); | ||
2261 | 194 | |||
2262 | 195 | ok = DesktopFileReader::parseBoolean("Hello World!", boolean); | ||
2263 | 196 | ASSERT_FALSE(ok); | ||
2264 | 197 | EXPECT_EQ(false, boolean); | ||
2265 | 198 | } | ||
2266 | 129 | 199 | ||
2267 | === modified file 'tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp' | |||
2268 | --- tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 2014-12-12 15:15:06 +0000 | |||
2269 | +++ tests/modules/MirSurfaceItem/mirsurfaceitem_test.cpp 2015-02-05 10:26:37 +0000 | |||
2270 | @@ -15,6 +15,8 @@ | |||
2271 | 15 | * | 15 | * |
2272 | 16 | */ | 16 | */ |
2273 | 17 | 17 | ||
2274 | 18 | #define MIR_INCLUDE_DEPRECATED_EVENT_HEADER | ||
2275 | 19 | |||
2276 | 18 | #include <gtest/gtest.h> | 20 | #include <gtest/gtest.h> |
2277 | 19 | 21 | ||
2278 | 20 | #include <QLoggingCategory> | 22 | #include <QLoggingCategory> |
2279 | @@ -60,29 +62,43 @@ | |||
2280 | 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)); |
2281 | 61 | EXPECT_CALL(*mockSession, setSurface(_)).Times(AnyNumber()); | 63 | EXPECT_CALL(*mockSession, setSurface(_)).Times(AnyNumber()); |
2282 | 62 | 64 | ||
2283 | 65 | auto get_touch_event = [](MirEvent const& event) -> MirTouchInputEvent const* | ||
2284 | 66 | { | ||
2285 | 67 | if (mir_event_get_type(&event) != mir_event_type_input) | ||
2286 | 68 | return nullptr; | ||
2287 | 69 | auto const* input_event = mir_event_get_input_event(&event); | ||
2288 | 70 | if (mir_input_event_get_type(input_event) != mir_input_event_type_touch) | ||
2289 | 71 | return nullptr; | ||
2290 | 72 | return mir_input_event_get_touch_input_event(input_event); | ||
2291 | 73 | }; | ||
2292 | 74 | |||
2293 | 75 | auto event_matches = [&](MirEvent const& event, | ||
2294 | 76 | int touch_count, | ||
2295 | 77 | MirTouchInputEventTouchAction action, | ||
2296 | 78 | MirTouchInputEventTouchId touch_id) ->void | ||
2297 | 79 | { | ||
2298 | 80 | auto const* touch_event = get_touch_event(event); | ||
2299 | 81 | ASSERT_NE(touch_event, nullptr); | ||
2300 | 82 | ASSERT_EQ(touch_count, mir_touch_input_event_get_touch_count(touch_event)); | ||
2301 | 83 | ASSERT_EQ(action, mir_touch_input_event_get_touch_action(touch_event,0)); | ||
2302 | 84 | ASSERT_EQ(touch_id, mir_touch_input_event_get_touch_id(touch_event,0)); | ||
2303 | 85 | }; | ||
2304 | 86 | |||
2305 | 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. |
2306 | 64 | // It should properly finish the sequence for touch 0 ('down', 'move' and 'up') before starting | 88 | // It should properly finish the sequence for touch 0 ('down', 'move' and 'up') before starting |
2307 | 65 | // the sequence for touch 1. | 89 | // the sequence for touch 1. |
2308 | 66 | EXPECT_CALL(*mockSurface, consume(_)) | 90 | EXPECT_CALL(*mockSurface, consume(_)) |
2328 | 67 | .WillOnce(Invoke([] (MirEvent const& mirEvent) { | 91 | .WillOnce(Invoke([&] (MirEvent const& mirEvent) { |
2329 | 68 | ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action); | 92 | event_matches(mirEvent, 1, mir_touch_input_event_action_down, 0); |
2330 | 69 | ASSERT_EQ(1, mirEvent.motion.pointer_count); | 93 | })) |
2331 | 70 | ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id); | 94 | .WillOnce(Invoke([&] (MirEvent const& mirEvent) { |
2332 | 71 | })) | 95 | event_matches(mirEvent, 1, mir_touch_input_event_action_change, 0); |
2333 | 72 | .WillOnce(Invoke([] (MirEvent const& mirEvent) { | 96 | })) |
2334 | 73 | ASSERT_EQ(mir_motion_action_move, mirEvent.motion.action); | 97 | .WillOnce(Invoke([&] (MirEvent const& mirEvent) { |
2335 | 74 | ASSERT_EQ(1, mirEvent.motion.pointer_count); | 98 | event_matches(mirEvent, 1, mir_touch_input_event_action_up, 0); |
2336 | 75 | ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id); | 99 | })) |
2337 | 76 | })) | 100 | .WillOnce(Invoke([&] (MirEvent const& mirEvent) { |
2338 | 77 | .WillOnce(Invoke([] (MirEvent const& mirEvent) { | 101 | event_matches(mirEvent, 1, mir_touch_input_event_action_down, 1); |
2320 | 78 | ASSERT_EQ(mir_motion_action_up, mirEvent.motion.action); | ||
2321 | 79 | ASSERT_EQ(1, mirEvent.motion.pointer_count); | ||
2322 | 80 | ASSERT_EQ(0, mirEvent.motion.pointer_coordinates[0].id); | ||
2323 | 81 | })) | ||
2324 | 82 | .WillOnce(Invoke([] (MirEvent const& mirEvent) { | ||
2325 | 83 | ASSERT_EQ(mir_motion_action_down, mirEvent.motion.action); | ||
2326 | 84 | ASSERT_EQ(1, mirEvent.motion.pointer_count); | ||
2327 | 85 | ASSERT_EQ(1, mirEvent.motion.pointer_coordinates[0].id); | ||
2339 | 86 | })); | 102 | })); |
2340 | 87 | 103 | ||
2341 | 88 | 104 | ||
2342 | @@ -95,18 +111,18 @@ | |||
2343 | 95 | touchPoints[0].setId(0); | 111 | touchPoints[0].setId(0); |
2344 | 96 | touchPoints[0].setState(Qt::TouchPointPressed); | 112 | touchPoints[0].setState(Qt::TouchPointPressed); |
2345 | 97 | surfaceItem->processTouchEvent(QEvent::TouchBegin, | 113 | surfaceItem->processTouchEvent(QEvent::TouchBegin, |
2347 | 98 | timestamp, touchPoints, touchPoints[0].state()); | 114 | timestamp, Qt::NoModifier, touchPoints, touchPoints[0].state()); |
2348 | 99 | 115 | ||
2349 | 100 | touchPoints[0].setState(Qt::TouchPointMoved); | 116 | touchPoints[0].setState(Qt::TouchPointMoved); |
2350 | 101 | surfaceItem->processTouchEvent(QEvent::TouchUpdate, | 117 | surfaceItem->processTouchEvent(QEvent::TouchUpdate, |
2352 | 102 | timestamp + 10, touchPoints, touchPoints[0].state()); | 118 | timestamp + 10, Qt::NoModifier, touchPoints, touchPoints[0].state()); |
2353 | 103 | 119 | ||
2354 | 104 | // Starting a new touch sequence (with touch 1) without ending the current one | 120 | // Starting a new touch sequence (with touch 1) without ending the current one |
2355 | 105 | // (wich has touch 0). | 121 | // (wich has touch 0). |
2356 | 106 | touchPoints[0].setId(1); | 122 | touchPoints[0].setId(1); |
2357 | 107 | touchPoints[0].setState(Qt::TouchPointPressed); | 123 | touchPoints[0].setState(Qt::TouchPointPressed); |
2358 | 108 | surfaceItem->processTouchEvent(QEvent::TouchBegin, | 124 | surfaceItem->processTouchEvent(QEvent::TouchBegin, |
2360 | 109 | timestamp + 20, touchPoints, touchPoints[0].state()); | 125 | timestamp + 20, Qt::NoModifier, touchPoints, touchPoints[0].state()); |
2361 | 110 | 126 | ||
2362 | 111 | delete surfaceItem; | 127 | delete surfaceItem; |
2363 | 112 | delete mockSession; | 128 | delete mockSession; |
2364 | 113 | 129 | ||
2365 | === removed file 'tests/modules/common/mock_focus_controller.h' | |||
2366 | --- tests/modules/common/mock_focus_controller.h 2014-09-11 16:18:40 +0000 | |||
2367 | +++ tests/modules/common/mock_focus_controller.h 1970-01-01 00:00:00 +0000 | |||
2368 | @@ -1,40 +0,0 @@ | |||
2369 | 1 | /* | ||
2370 | 2 | * Copyright (C) 2014 Canonical, Ltd. | ||
2371 | 3 | * | ||
2372 | 4 | * This program is free software: you can redistribute it and/or modify it under | ||
2373 | 5 | * the terms of the GNU Lesser General Public License version 3, as published by | ||
2374 | 6 | * the Free Software Foundation. | ||
2375 | 7 | * | ||
2376 | 8 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
2377 | 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | ||
2378 | 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
2379 | 11 | * Lesser General Public License for more details. | ||
2380 | 12 | * | ||
2381 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
2382 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2383 | 15 | * | ||
2384 | 16 | */ | ||
2385 | 17 | |||
2386 | 18 | #ifndef MOCK_MIR_SHELL_FOCUS_CONTROLLER_H | ||
2387 | 19 | #define MOCK_MIR_SHELL_FOCUS_CONTROLLER_H | ||
2388 | 20 | |||
2389 | 21 | #include <mir/shell/focus_controller.h> | ||
2390 | 22 | #include <gmock/gmock.h> | ||
2391 | 23 | |||
2392 | 24 | #include <string> | ||
2393 | 25 | |||
2394 | 26 | namespace mir { | ||
2395 | 27 | namespace shell { | ||
2396 | 28 | |||
2397 | 29 | class MockFocusController : public FocusController | ||
2398 | 30 | { | ||
2399 | 31 | public: | ||
2400 | 32 | MOCK_METHOD0(focus_next, void()); | ||
2401 | 33 | MOCK_CONST_METHOD0(focussed_application, std::weak_ptr<scene::Session>()); | ||
2402 | 34 | MOCK_METHOD1(set_focus_to, void(std::shared_ptr<scene::Session>const&)); | ||
2403 | 35 | }; | ||
2404 | 36 | |||
2405 | 37 | } // namespace shell | ||
2406 | 38 | } // namespace mir | ||
2407 | 39 | |||
2408 | 40 | #endif // MOCK_MIR_SHELL_FOCUS_CONTROLLER_H_ | ||
2409 | 41 | 0 | ||
2410 | === modified file 'tests/modules/common/mock_mir_session.h' | |||
2411 | --- tests/modules/common/mock_mir_session.h 2015-01-07 15:35:29 +0000 | |||
2412 | +++ tests/modules/common/mock_mir_session.h 2015-02-05 10:26:37 +0000 | |||
2413 | @@ -49,6 +49,7 @@ | |||
2414 | 49 | 49 | ||
2415 | 50 | MOCK_CONST_METHOD0(default_surface, std::shared_ptr<Surface>()); | 50 | MOCK_CONST_METHOD0(default_surface, std::shared_ptr<Surface>()); |
2416 | 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)); |
2417 | 52 | MOCK_CONST_METHOD1(surface, std::shared_ptr<scene::Surface>(frontend::SurfaceId)); | ||
2418 | 52 | 53 | ||
2419 | 53 | MOCK_METHOD1(take_snapshot, void(SnapshotCallback const&)); | 54 | MOCK_METHOD1(take_snapshot, void(SnapshotCallback const&)); |
2420 | 54 | MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState)); | 55 | MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState)); |
2421 | 55 | 56 | ||
2422 | === modified file 'tests/modules/common/mock_renderable.h' | |||
2423 | --- tests/modules/common/mock_renderable.h 2014-09-11 16:18:40 +0000 | |||
2424 | +++ tests/modules/common/mock_renderable.h 2015-02-05 10:26:37 +0000 | |||
2425 | @@ -34,9 +34,7 @@ | |||
2426 | 34 | MOCK_CONST_METHOD0(screen_position, geometry::Rectangle()); | 34 | MOCK_CONST_METHOD0(screen_position, geometry::Rectangle()); |
2427 | 35 | MOCK_CONST_METHOD0(alpha, float() ); | 35 | MOCK_CONST_METHOD0(alpha, float() ); |
2428 | 36 | MOCK_CONST_METHOD0(transformation, glm::mat4()); | 36 | MOCK_CONST_METHOD0(transformation, glm::mat4()); |
2429 | 37 | MOCK_CONST_METHOD0(visible, bool()); | ||
2430 | 38 | MOCK_CONST_METHOD0(shaped, bool()); | 37 | MOCK_CONST_METHOD0(shaped, bool()); |
2431 | 39 | MOCK_CONST_METHOD0(buffers_ready_for_compositor, int()); | ||
2432 | 40 | }; | 38 | }; |
2433 | 41 | 39 | ||
2434 | 42 | } // namespace graphics | 40 | } // namespace graphics |
2435 | 43 | 41 | ||
2436 | === modified file 'tests/modules/common/mock_surface.h' | |||
2437 | --- tests/modules/common/mock_surface.h 2015-01-06 17:28:52 +0000 | |||
2438 | +++ tests/modules/common/mock_surface.h 2015-02-05 10:26:37 +0000 | |||
2439 | @@ -36,6 +36,7 @@ | |||
2440 | 36 | MOCK_CONST_METHOD0(input_bounds, geometry::Rectangle()); | 36 | MOCK_CONST_METHOD0(input_bounds, geometry::Rectangle()); |
2441 | 37 | MOCK_CONST_METHOD0(top_left, geometry::Point()); | 37 | MOCK_CONST_METHOD0(top_left, geometry::Point()); |
2442 | 38 | MOCK_CONST_METHOD0(size, geometry::Size()); | 38 | MOCK_CONST_METHOD0(size, geometry::Size()); |
2443 | 39 | MOCK_CONST_METHOD0(parent, std::shared_ptr<Surface>()); | ||
2444 | 39 | 40 | ||
2445 | 40 | std::unique_ptr<graphics::Renderable> compositor_snapshot(void const* /*compositor_id*/) const | 41 | std::unique_ptr<graphics::Renderable> compositor_snapshot(void const* /*compositor_id*/) const |
2446 | 41 | { | 42 | { |
2447 | @@ -64,6 +65,7 @@ | |||
2448 | 64 | MOCK_CONST_METHOD0(input_channel, std::shared_ptr<input::InputChannel>()); | 65 | MOCK_CONST_METHOD0(input_channel, std::shared_ptr<input::InputChannel>()); |
2449 | 65 | MOCK_METHOD1(set_reception_mode, void(input::InputReceptionMode mode)); | 66 | MOCK_METHOD1(set_reception_mode, void(input::InputReceptionMode mode)); |
2450 | 66 | MOCK_METHOD0(request_client_surface_close, void()); | 67 | MOCK_METHOD0(request_client_surface_close, void()); |
2451 | 68 | MOCK_CONST_METHOD1(buffers_ready_for_compositor, int(void const*)); | ||
2452 | 67 | 69 | ||
2453 | 68 | // from mir::input::surface | 70 | // from mir::input::surface |
2454 | 69 | MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point)); | 71 | MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point)); |
2455 | 70 | 72 | ||
2456 | === modified file 'tests/modules/common/qtmir_test.h' | |||
2457 | --- tests/modules/common/qtmir_test.h 2015-01-09 11:24:44 +0000 | |||
2458 | +++ tests/modules/common/qtmir_test.h 2015-02-05 10:26:37 +0000 | |||
2459 | @@ -33,7 +33,6 @@ | |||
2460 | 33 | #include "mock_desktop_file_reader.h" | 33 | #include "mock_desktop_file_reader.h" |
2461 | 34 | #include "mock_proc_info.h" | 34 | #include "mock_proc_info.h" |
2462 | 35 | #include "mock_mir_session.h" | 35 | #include "mock_mir_session.h" |
2463 | 36 | #include "mock_focus_controller.h" | ||
2464 | 37 | #include "mock_prompt_session_manager.h" | 36 | #include "mock_prompt_session_manager.h" |
2465 | 38 | #include "mock_prompt_session.h" | 37 | #include "mock_prompt_session.h" |
2466 | 39 | #include "mock_shared_wakelock.h" | 38 | #include "mock_shared_wakelock.h" |