Merge lp:~gerboland/qtmir/decouple-qteventfeeder-screensmodel into lp:qtmir
- decouple-qteventfeeder-screensmodel
- Merge into trunk
Status: | Approved |
---|---|
Approved by: | Daniel d'Andrada |
Approved revision: | 639 |
Proposed branch: | lp:~gerboland/qtmir/decouple-qteventfeeder-screensmodel |
Merge into: | lp:qtmir |
Diff against target: |
362 lines (+43/-69) 9 files modified
src/platforms/mirserver/qmirserver_p.cpp (+1/-1) src/platforms/mirserver/qteventfeeder.cpp (+24/-20) src/platforms/mirserver/qteventfeeder.h (+3/-6) src/platforms/mirserver/screensmodel.cpp (+5/-22) src/platforms/mirserver/screensmodel.h (+1/-4) src/platforms/mirserver/windowmanagementpolicy.cpp (+4/-6) src/platforms/mirserver/windowmanagementpolicy.h (+2/-5) tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h (+1/-2) tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp (+2/-3) |
To merge this branch: | bzr merge lp:~gerboland/qtmir/decouple-qteventfeeder-screensmodel |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity8 CI Bot (community) | continuous-integration | Approve | |
Daniel d'Andrada (community) | Approve | ||
Review via email: mp+321443@code.launchpad.net |
Commit message
Decouple QtEventFeeder and ScreensModel, event feeder can rely on qGuiApp::screens()
Description of the change
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:626
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel d'Andrada (dandrader) wrote : | # |
"""
const auto screens = qGuiApp->screens();
"""
I think s/auto/
Daniel d'Andrada (dandrader) wrote : | # |
> Please update copyright header of modified files.
Other than that, code looks good.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:629
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Daniel d'Andrada (dandrader) wrote : | # |
* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes
* Did CI run pass? If not, please explain why.
Yes
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:629
https:/
Executed test runs:
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
Albert Astals Cid (aacid) wrote : | # |
Needs merging.
Was top approved.
Unity8 CI Bot (unity8-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:639
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Unmerged revisions
- 639. By Gerry Boland
-
A lil less auto-mation, a lil more action please
- 638. By Gerry Boland
-
Remove unneeded header file
- 637. By Gerry Boland
-
Update copyrights
- 636. By Gerry Boland
-
Decouple QtEventFeeder and ScreensModel, event feeder can rely on qGuiApp::screens()
Preview Diff
1 | === modified file 'src/platforms/mirserver/qmirserver_p.cpp' |
2 | --- src/platforms/mirserver/qmirserver_p.cpp 2017-03-28 17:13:24 +0000 |
3 | +++ src/platforms/mirserver/qmirserver_p.cpp 2017-03-31 16:46:34 +0000 |
4 | @@ -134,7 +134,7 @@ |
5 | m_openGLContextFactory, |
6 | m_mirServerHooks, |
7 | miral::set_window_management_policy<WindowManagementPolicy>(m_windowModelNotifier, m_windowController, |
8 | - m_appNotifier, screensModel), |
9 | + m_appNotifier), |
10 | addInitCallback, |
11 | qtmir::SetQtCompositor{screensModel}, |
12 | setTerminator, |
13 | |
14 | === modified file 'src/platforms/mirserver/qteventfeeder.cpp' |
15 | --- src/platforms/mirserver/qteventfeeder.cpp 2017-03-03 10:39:24 +0000 |
16 | +++ src/platforms/mirserver/qteventfeeder.cpp 2017-03-31 16:46:34 +0000 |
17 | @@ -20,8 +20,7 @@ |
18 | #include "logging.h" |
19 | #include "timestamp.h" |
20 | #include "tracepoints.h" // generated from tracepoints.tp |
21 | -#include "screen.h" // NEEDED? |
22 | -#include "screensmodel.h" |
23 | +#include "screen.h" |
24 | |
25 | #include <qpa/qplatforminputcontext.h> |
26 | #include <qpa/qplatformintegration.h> |
27 | @@ -387,11 +386,6 @@ |
28 | qRegisterMetaType<Qt::MouseButtons>("Qt::MouseButtons"); |
29 | } |
30 | |
31 | - void setScreensModel(const QSharedPointer<ScreensModel> &sc) override |
32 | - { |
33 | - m_screensModel = sc; |
34 | - } |
35 | - |
36 | virtual QWindow* focusedWindow() override |
37 | { |
38 | return QGuiApplication::focusWindow(); |
39 | @@ -399,7 +393,20 @@ |
40 | |
41 | QWindow* getWindowForTouchPoint(const QPoint &point) override //FIXME: not efficient, not updating focused window |
42 | { |
43 | - return m_screensModel->getWindowForPoint(point); |
44 | + const QWindowList windowList = qGuiApp->topLevelWindows(); |
45 | + |
46 | + // This is a part optimization, and a part work-around for AP generated input events occasionally |
47 | + // appearing outside the screen borders: https://bugs.launchpad.net/qtmir/+bug/1508415 |
48 | + if (windowList.length() == 1) { |
49 | + return windowList.first(); |
50 | + } |
51 | + |
52 | + Q_FOREACH (QWindow *window, windowList) { |
53 | + if (window->geometry().contains(point)) { |
54 | + return window; |
55 | + } |
56 | + } |
57 | + return nullptr; |
58 | } |
59 | |
60 | void registerTouchDevice(QTouchDevice *device) override |
61 | @@ -462,11 +469,12 @@ |
62 | // This will probably come once we implement the feature of having the mouse pointer |
63 | // crossing adjacent screens. |
64 | |
65 | - QList<Screen*> screens = m_screensModel->screens(); |
66 | + const QList<QScreen *> screens = qGuiApp->screens(); |
67 | bool eventHandled = false; |
68 | int i = 0; |
69 | while (i < screens.count() && !eventHandled) { |
70 | - auto platformCursor = static_cast<qtmir::Cursor*>(screens[i]->cursor()); |
71 | + auto screenWindow = static_cast<Screen*>(screens[i]->handle()); |
72 | + auto platformCursor = static_cast<qtmir::Cursor*>(screenWindow->cursor()); |
73 | eventHandled = platformCursor->handleMouseEvent(timestamp, relative, buttons, modifiers); |
74 | ++i; |
75 | } |
76 | @@ -483,11 +491,12 @@ |
77 | // This will probably come once we implement the feature of having the mouse pointer |
78 | // crossing adjacent screens. |
79 | |
80 | - QList<Screen*> screens = m_screensModel->screens(); |
81 | + const QList<QScreen *> screens = qGuiApp->screens(); |
82 | bool eventHandled = false; |
83 | int i = 0; |
84 | while (i < screens.count() && !eventHandled) { |
85 | - auto platformCursor = static_cast<qtmir::Cursor*>(screens.at(i)->cursor()); |
86 | + auto screenWindow = static_cast<Screen*>(screens[i]->handle()); |
87 | + auto platformCursor = static_cast<qtmir::Cursor*>(screenWindow->cursor()); |
88 | eventHandled = platformCursor->handleWheelEvent(timestamp, angleDelta, modifiers); |
89 | ++i; |
90 | } |
91 | @@ -496,20 +505,16 @@ |
92 | QPoint(), angleDelta, modifiers, Qt::ScrollUpdate); |
93 | } |
94 | } |
95 | - |
96 | -private: |
97 | - QSharedPointer<ScreensModel> m_screensModel; |
98 | }; |
99 | |
100 | } // anonymous namespace |
101 | |
102 | -QtEventFeeder::QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel) |
103 | - : QtEventFeeder(screensModel, new QtWindowSystem) |
104 | +QtEventFeeder::QtEventFeeder() |
105 | + : QtEventFeeder(new QtWindowSystem) |
106 | { |
107 | } |
108 | |
109 | -QtEventFeeder::QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel, |
110 | - QtEventFeeder::QtWindowSystemInterface *windowSystem) |
111 | +QtEventFeeder::QtEventFeeder(QtEventFeeder::QtWindowSystemInterface *windowSystem) |
112 | : mQtWindowSystem(windowSystem) |
113 | { |
114 | // Initialize touch device. Hardcoded just like in qtubuntu |
115 | @@ -521,7 +526,6 @@ |
116 | mTouchDevice->setCapabilities( |
117 | QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::Pressure | |
118 | QTouchDevice::NormalizedPosition); |
119 | - mQtWindowSystem->setScreensModel(screensModel); |
120 | mQtWindowSystem->registerTouchDevice(mTouchDevice); |
121 | } |
122 | |
123 | |
124 | === modified file 'src/platforms/mirserver/qteventfeeder.h' |
125 | --- src/platforms/mirserver/qteventfeeder.h 2016-11-03 20:17:46 +0000 |
126 | +++ src/platforms/mirserver/qteventfeeder.h 2017-03-31 16:46:34 +0000 |
127 | @@ -1,5 +1,5 @@ |
128 | /* |
129 | - * Copyright (C) 2013-2016 Canonical, Ltd. |
130 | + * Copyright (C) 2013-2017 Canonical, Ltd. |
131 | * |
132 | * This program is free software: you can redistribute it and/or modify it under |
133 | * the terms of the GNU Lesser General Public License version 3, as published by |
134 | @@ -22,7 +22,6 @@ |
135 | #include <qpa/qwindowsysteminterface.h> |
136 | |
137 | class QTouchDevice; |
138 | -class ScreensModel; |
139 | |
140 | /* |
141 | Fills Qt's event loop with input events from Mir |
142 | @@ -36,7 +35,6 @@ |
143 | class QtWindowSystemInterface { |
144 | public: |
145 | virtual ~QtWindowSystemInterface() {} |
146 | - virtual void setScreensModel(const QSharedPointer<ScreensModel> &sc) = 0; |
147 | virtual QWindow* getWindowForTouchPoint(const QPoint &point) = 0; |
148 | virtual QWindow* focusedWindow() = 0; |
149 | virtual void registerTouchDevice(QTouchDevice *device) = 0; |
150 | @@ -55,9 +53,8 @@ |
151 | Qt::KeyboardModifiers modifiers) = 0; |
152 | }; |
153 | |
154 | - QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel); |
155 | - QtEventFeeder(const QSharedPointer<ScreensModel> &screensModel, |
156 | - QtWindowSystemInterface *windowSystem); |
157 | + QtEventFeeder(); |
158 | + QtEventFeeder(QtWindowSystemInterface *windowSystem); |
159 | virtual ~QtEventFeeder(); |
160 | |
161 | void dispatchKey(MirKeyboardEvent const* event); |
162 | |
163 | === modified file 'src/platforms/mirserver/screensmodel.cpp' |
164 | --- src/platforms/mirserver/screensmodel.cpp 2017-01-18 18:30:14 +0000 |
165 | +++ src/platforms/mirserver/screensmodel.cpp 2017-03-31 16:46:34 +0000 |
166 | @@ -1,5 +1,5 @@ |
167 | /* |
168 | - * Copyright (C) 2015-2016 Canonical, Ltd. |
169 | + * Copyright (C) 2015-2017 Canonical, Ltd. |
170 | * |
171 | * This program is free software: you can redistribute it and/or modify it under |
172 | * the terms of the GNU Lesser General Public License version 3, as published by |
173 | @@ -16,12 +16,12 @@ |
174 | |
175 | #include "screensmodel.h" |
176 | |
177 | -#include "screenwindow.h" |
178 | -#include "qtcompositor.h" |
179 | #include "logging.h" |
180 | +#include "mirqtconversion.h" |
181 | #include "mirserverintegration.h" |
182 | +#include "qtcompositor.h" |
183 | #include "screen.h" |
184 | -#include "mirqtconversion.h" |
185 | +#include "screenwindow.h" |
186 | |
187 | // Mir |
188 | #include <mir/graphics/display.h> |
189 | @@ -30,9 +30,8 @@ |
190 | |
191 | // Qt |
192 | #include <QScreen> |
193 | -#include <QQuickWindow> |
194 | +#include <QGuiApplication> // for qApp |
195 | #include <qpa/qwindowsysteminterface.h> |
196 | -#include <QGuiApplication> // for qApp |
197 | |
198 | // std |
199 | #include <memory> |
200 | @@ -266,19 +265,3 @@ |
201 | } |
202 | return nullptr; |
203 | } |
204 | - |
205 | -QWindow* ScreensModel::getWindowForPoint(QPoint point) //FIXME - not thread safe & not efficient |
206 | -{ |
207 | - // This is a part optimization, and a part work-around for AP generated input events occasionally |
208 | - // appearing outside the screen borders: https://bugs.launchpad.net/qtmir/+bug/1508415 |
209 | - if (m_screenList.length() == 1 && m_screenList.first()->window()) { |
210 | - return m_screenList.first()->window()->window(); |
211 | - } |
212 | - |
213 | - Q_FOREACH (Screen *screen, m_screenList) { |
214 | - if (screen->window() && screen->geometry().contains(point)) { |
215 | - return screen->window()->window(); |
216 | - } |
217 | - } |
218 | - return nullptr; |
219 | -} |
220 | |
221 | === modified file 'src/platforms/mirserver/screensmodel.h' |
222 | --- src/platforms/mirserver/screensmodel.h 2017-01-18 18:30:14 +0000 |
223 | +++ src/platforms/mirserver/screensmodel.h 2017-03-31 16:46:34 +0000 |
224 | @@ -1,5 +1,5 @@ |
225 | /* |
226 | - * Copyright (C) 2015-2016 Canonical, Ltd. |
227 | + * Copyright (C) 2015-2017 Canonical, Ltd. |
228 | * |
229 | * This program is free software: you can redistribute it and/or modify it under |
230 | * the terms of the GNU Lesser General Public License version 3, as published by |
231 | @@ -31,7 +31,6 @@ |
232 | namespace compositor { class DisplayListener; } |
233 | } |
234 | class Screen; |
235 | -class QWindow; |
236 | class QtCompositor; |
237 | |
238 | /* |
239 | @@ -63,8 +62,6 @@ |
240 | QList<Screen*> screens() const { return m_screenList; } |
241 | bool compositing() const { return m_compositing; } |
242 | |
243 | - QWindow* getWindowForPoint(QPoint point); |
244 | - |
245 | Q_SIGNALS: |
246 | void screenAdded(Screen *screen); |
247 | void screenRemoved(Screen *screen); |
248 | |
249 | === modified file 'src/platforms/mirserver/windowmanagementpolicy.cpp' |
250 | --- src/platforms/mirserver/windowmanagementpolicy.cpp 2017-03-24 11:29:56 +0000 |
251 | +++ src/platforms/mirserver/windowmanagementpolicy.cpp 2017-03-31 16:46:34 +0000 |
252 | @@ -38,13 +38,11 @@ |
253 | WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools, |
254 | qtmir::WindowModelNotifier &windowModel, |
255 | qtmir::WindowController &windowController, |
256 | - qtmir::AppNotifier &appNotifier, |
257 | - const QSharedPointer<ScreensModel> screensModel) |
258 | + qtmir::AppNotifier &appNotifier) |
259 | : CanonicalWindowManagerPolicy(tools) |
260 | , m_tools(tools) |
261 | , m_windowModel(windowModel) |
262 | , m_appNotifier(appNotifier) |
263 | - , m_eventFeeder(new QtEventFeeder(screensModel)) |
264 | { |
265 | qRegisterMetaType<qtmir::NewWindow>(); |
266 | qRegisterMetaType<std::vector<miral::Window>>(); |
267 | @@ -116,19 +114,19 @@ |
268 | /* Handle input events - here just inject them into Qt event loop for later processing */ |
269 | bool WindowManagementPolicy::handle_keyboard_event(const MirKeyboardEvent *event) |
270 | { |
271 | - m_eventFeeder->dispatchKey(event); |
272 | + m_eventFeeder.dispatchKey(event); |
273 | return true; |
274 | } |
275 | |
276 | bool WindowManagementPolicy::handle_touch_event(const MirTouchEvent *event) |
277 | { |
278 | - m_eventFeeder->dispatchTouch(event); |
279 | + m_eventFeeder.dispatchTouch(event); |
280 | return true; |
281 | } |
282 | |
283 | bool WindowManagementPolicy::handle_pointer_event(const MirPointerEvent *event) |
284 | { |
285 | - m_eventFeeder->dispatchPointer(event); |
286 | + m_eventFeeder.dispatchPointer(event); |
287 | return true; |
288 | } |
289 | |
290 | |
291 | === modified file 'src/platforms/mirserver/windowmanagementpolicy.h' |
292 | --- src/platforms/mirserver/windowmanagementpolicy.h 2017-03-22 14:04:23 +0000 |
293 | +++ src/platforms/mirserver/windowmanagementpolicy.h 2017-03-31 16:46:34 +0000 |
294 | @@ -28,16 +28,13 @@ |
295 | |
296 | using namespace mir::geometry; |
297 | |
298 | -class ScreensModel; |
299 | - |
300 | class WindowManagementPolicy : public miral::CanonicalWindowManagerPolicy |
301 | { |
302 | public: |
303 | WindowManagementPolicy(const miral::WindowManagerTools &tools, |
304 | qtmir::WindowModelNotifier &windowModel, |
305 | qtmir::WindowController &windowController, |
306 | - qtmir::AppNotifier &appNotifier, |
307 | - const QSharedPointer<ScreensModel> screensModel); |
308 | + qtmir::AppNotifier &appNotifier); |
309 | |
310 | // From WindowManagementPolicy |
311 | auto place_new_window(const miral::ApplicationInfo &app_info, |
312 | @@ -96,7 +93,7 @@ |
313 | miral::WindowManagerTools m_tools; |
314 | qtmir::WindowModelNotifier &m_windowModel; |
315 | qtmir::AppNotifier &m_appNotifier; |
316 | - const QScopedPointer<QtEventFeeder> m_eventFeeder; |
317 | + QtEventFeeder m_eventFeeder; |
318 | QVector<QRect> m_confinementRegions; |
319 | QMargins m_windowMargins[mir_window_types]; |
320 | }; |
321 | |
322 | === modified file 'tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h' |
323 | --- tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2016-11-23 22:01:22 +0000 |
324 | +++ tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h 2017-03-31 16:46:34 +0000 |
325 | @@ -1,5 +1,5 @@ |
326 | /* |
327 | - * Copyright (C) 2014-2015 Canonical, Ltd. |
328 | + * Copyright (C) 2014-2017 Canonical, Ltd. |
329 | * |
330 | * This program is free software: you can redistribute it and/or modify it under |
331 | * the terms of the GNU Lesser General Public License version 3, as published by |
332 | @@ -24,7 +24,6 @@ |
333 | class MockQtWindowSystem : public QtEventFeeder::QtWindowSystemInterface { |
334 | public: |
335 | MOCK_CONST_METHOD0(ready, bool()); |
336 | - MOCK_METHOD1(setScreensModel, void(const QSharedPointer<ScreensModel> &)); |
337 | MOCK_METHOD1(getWindowForTouchPoint, QWindow*(const QPoint &point)); |
338 | MOCK_METHOD0(lastWindow, QWindow*()); |
339 | MOCK_METHOD0(focusedWindow, QWindow*()); |
340 | |
341 | === modified file 'tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp' |
342 | --- tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2016-11-23 22:01:22 +0000 |
343 | +++ tests/mirserver/QtEventFeeder/qteventfeeder_test.cpp 2017-03-31 16:46:34 +0000 |
344 | @@ -1,5 +1,5 @@ |
345 | /* |
346 | - * Copyright (C) 2014-2016 Canonical, Ltd. |
347 | + * Copyright (C) 2014-2017 Canonical, Ltd. |
348 | * |
349 | * This program is free software: you can redistribute it and/or modify it under |
350 | * the terms of the GNU Lesser General Public License version 3, as published by |
351 | @@ -79,11 +79,10 @@ |
352 | void QtEventFeederTest::SetUp() |
353 | { |
354 | mockWindowSystem = new MockQtWindowSystem; |
355 | - auto screens = QSharedPointer<ScreensModel>(); |
356 | |
357 | ASSERT_TRUE(mockWindowSystem->m_devices.count() == 0); |
358 | |
359 | - qtEventFeeder = new QtEventFeeder(screens, mockWindowSystem); |
360 | + qtEventFeeder = new QtEventFeeder(mockWindowSystem); |
361 | |
362 | ASSERT_TRUE(mockWindowSystem->m_devices.count() == 1); |
363 |
Please update copyright header of modified files.