Merge lp:~gerboland/miral/qt-fix-qt-rendering into lp:miral

Proposed by Gerry Boland
Status: Superseded
Proposed branch: lp:~gerboland/miral/qt-fix-qt-rendering
Merge into: lp:miral
Diff against target: 1853 lines (+371/-560)
14 files modified
include/miral/window_info.h (+1/-0)
miral-qt/src/common/windowmodelnotifier.h (+36/-17)
miral-qt/src/common/windowmodelnotifierinterface.h (+0/-107)
miral-qt/src/modules/Unity/Application/mirsurface.cpp (+42/-40)
miral-qt/src/modules/Unity/Application/mirsurface.h (+4/-5)
miral-qt/src/modules/Unity/Application/windowmodel.cpp (+89/-59)
miral-qt/src/modules/Unity/Application/windowmodel.h (+19/-19)
miral-qt/src/platforms/mirserver/CMakeLists.txt (+1/-2)
miral-qt/src/platforms/mirserver/qmirserver_p.h (+1/-1)
miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp (+13/-7)
miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp (+0/-152)
miral-qt/tests/modules/WindowManager/mirsurface_test.cpp (+1/-2)
miral-qt/tests/modules/WindowManager/windowmodel_test.cpp (+151/-149)
miral/window_info.cpp (+13/-0)
To merge this branch: bzr merge lp:~gerboland/miral/qt-fix-qt-rendering
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+305594@code.launchpad.net

Commit message

[miral-qt] Add workaround to get Qt clients rendering - manually set visibility

To post a comment you must log in.

Unmerged revisions

327. By Gerry Boland

Add workaround to get Qt apps rendering

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/miral/window_info.h'
2--- include/miral/window_info.h 2016-08-03 16:50:37 +0000
3+++ include/miral/window_info.h 2016-09-13 12:26:41 +0000
4@@ -31,6 +31,7 @@
5 {
6 using AspectRatio = WindowSpecification::AspectRatio;
7
8+ WindowInfo();
9 WindowInfo(Window const& window, WindowSpecification const& params);
10 ~WindowInfo();
11 WindowInfo(WindowInfo const& that);
12
13=== renamed file 'miral-qt/src/platforms/mirserver/windowmodelnotifier.h' => 'miral-qt/src/common/windowmodelnotifier.h'
14--- miral-qt/src/platforms/mirserver/windowmodelnotifier.h 2016-09-07 14:11:13 +0000
15+++ miral-qt/src/common/windowmodelnotifier.h 2016-09-13 12:26:41 +0000
16@@ -17,35 +17,54 @@
17 #ifndef WINDOWMODELNOTIFIER_H
18 #define WINDOWMODELNOTIFIER_H
19
20-#include "windowmodelnotifierinterface.h"
21+#include <QObject>
22+#include <QPoint>
23+#include <QSize>
24
25 #include "miral/window_info.h"
26
27-#include <QPair>
28-
29 namespace qtmir {
30
31-class WindowModelNotifier : public WindowModelNotifierInterface
32+class NewWindow {
33+public:
34+ NewWindow() = default;
35+ NewWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId = "")
36+ : windowInfo(windowInfo)
37+ , persistentId(persistentId)
38+ , surface(windowInfo.window())
39+ {}
40+
41+ miral::WindowInfo windowInfo;
42+ std::string persistentId;
43+
44+ // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface
45+ // but MirSurface needs to share ownership of the Surface with Mir
46+ std::shared_ptr<mir::scene::Surface> surface;
47+};
48+
49+
50+class WindowModelNotifier : public QObject
51 {
52 Q_OBJECT
53 public:
54- WindowModelNotifier();
55- virtual ~WindowModelNotifier();
56-
57- void addWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId = "");
58- void removeWindow(const miral::WindowInfo &windowInfo);
59-
60- void moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft);
61- void resizeWindow(const miral::WindowInfo &windowInfo, mir::geometry::Size newSize);
62-
63- void focusWindow(const miral::WindowInfo &windowInfo, const bool focus);
64- void raiseWindows(const std::vector<miral::Window> &windows); //window?? Not WindowInfo??
65+ WindowModelNotifier() = default;
66+
67+Q_SIGNALS: // **Must used Queued Connection or else events will be out of order**
68+ void windowAdded(const qtmir::NewWindow &window);
69+ void windowRemoved(const miral::WindowInfo &window);
70+ void windowMoved(const miral::WindowInfo &window, const QPoint topLeft);
71+ void windowResized(const miral::WindowInfo &window, const QSize size);
72+ void windowFocusChanged(const miral::WindowInfo &window, bool focused);
73+ void windowsRaised(const std::vector<miral::Window> &windows); // results in deep copy when passed over Queued connection:(
74
75 private:
76- QVector<miral::Window> m_windowStack;
77- int m_focusedWindowIndex;
78+ Q_DISABLE_COPY(WindowModelNotifier)
79 };
80
81 } // namespace qtmir
82
83+Q_DECLARE_METATYPE(qtmir::NewWindow)
84+Q_DECLARE_METATYPE(miral::WindowInfo)
85+Q_DECLARE_METATYPE(std::vector<miral::Window>)
86+
87 #endif // WINDOWMODELNOTIFIER_H
88
89=== removed file 'miral-qt/src/common/windowmodelnotifierinterface.h'
90--- miral-qt/src/common/windowmodelnotifierinterface.h 2016-09-08 23:29:34 +0000
91+++ miral-qt/src/common/windowmodelnotifierinterface.h 1970-01-01 00:00:00 +0000
92@@ -1,107 +0,0 @@
93-/*
94- * Copyright (C) 2016 Canonical, Ltd.
95- *
96- * This program is free software: you can redistribute it and/or modify it under
97- * the terms of the GNU Lesser General Public License version 3, as published by
98- * the Free Software Foundation.
99- *
100- * This program is distributed in the hope that it will be useful, but WITHOUT
101- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
102- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
103- * Lesser General Public License for more details.
104- *
105- * You should have received a copy of the GNU Lesser General Public License
106- * along with this program. If not, see <http://www.gnu.org/licenses/>.
107- */
108-
109-#ifndef WINDOWMODELNOTIFIERINTERFACE_H
110-#define WINDOWMODELNOTIFIERINTERFACE_H
111-
112-#include <QObject>
113-#include <QSize>
114-#include <QPoint>
115-#include <QVector>
116-
117-#include "miral/window_info.h"
118-
119-namespace qtmir {
120-
121-// miral::WindowInfo missing a default constructor, needed by MOC. Need to wrap it instead
122-class WindowInfo {
123-public:
124- WindowInfo() = default;
125- WindowInfo(const miral::WindowInfo &windowInfo)
126- : name(windowInfo.name())
127- , type(windowInfo.type())
128- , state(windowInfo.state())
129- , restoreRect(windowInfo.restore_rect())
130- , parent(windowInfo.parent())
131- , children(windowInfo.children())
132- , minWidth(windowInfo.min_width())
133- , minHeight(windowInfo.min_height())
134- , maxWidth(windowInfo.max_width())
135- , maxHeight(windowInfo.max_height())
136- {}
137-
138- mir::optional_value<std::string> name;
139- MirSurfaceType type;
140- MirSurfaceState state;
141- mir::geometry::Rectangle restoreRect;
142- miral::Window parent;
143- std::vector<miral::Window> children;
144- mir::geometry::Width minWidth;
145- mir::geometry::Height minHeight;
146- mir::geometry::Width maxWidth;
147- mir::geometry::Height maxHeight;
148-};
149-
150-class NewWindow {
151-public:
152- NewWindow() = default;
153- NewWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId = "")
154- : window(windowInfo.window())
155- , windowInfo(windowInfo)
156- , persistentId(persistentId)
157- , surface(windowInfo.window())
158- {}
159-
160- miral::Window window;
161- WindowInfo windowInfo;
162- std::string persistentId;
163-
164- // hold copy of Surface shared pointer, as miral::Window has just a weak pointer to the Surface
165- // but MirSurface needs to share ownership of the Surface with Mir
166- std::shared_ptr<mir::scene::Surface> surface;
167-};
168-
169-
170-class WindowModelNotifierInterface : public QObject
171-{
172- Q_OBJECT
173-public:
174- WindowModelNotifierInterface() = default;
175- virtual ~WindowModelNotifierInterface() = default;
176-
177-Q_SIGNALS:
178- void windowAdded(const qtmir::NewWindow, const int index);
179- void windowRemoved(const int index);
180- void windowMoved(const QPoint topLeft, const int index);
181- void windowResized(const QSize size, const int index);
182- void windowFocused(const int index);
183- void windowInfoChanged(const qtmir::WindowInfo, const int index);
184- void windowsRaised(const QVector<int> indices);
185-
186- // Assuming only 1 input method surface for now
187- void inputMethodWindowAdded(const qtmir::NewWindow);
188- void inputMethodWindowRemoved();
189-
190-private:
191- Q_DISABLE_COPY(WindowModelNotifierInterface)
192-};
193-
194-} // namespace qtmir
195-
196-Q_DECLARE_METATYPE(qtmir::NewWindow)
197-Q_DECLARE_METATYPE(qtmir::WindowInfo)
198-
199-#endif // WINDOWMODELNOTIFIERINTERFACE_H
200
201=== modified file 'miral-qt/src/modules/Unity/Application/mirsurface.cpp'
202--- miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-09-09 19:27:28 +0000
203+++ miral-qt/src/modules/Unity/Application/mirsurface.cpp 2016-09-13 12:26:41 +0000
204@@ -198,7 +198,6 @@
205 MirSurface::MirSurface(NewWindow newWindowInfo,
206 WindowControllerInterface* controller)
207 : MirSurfaceInterface()
208- , m_window(newWindowInfo.window)
209 , m_windowInfo(newWindowInfo.windowInfo)
210 , m_surface(newWindowInfo.surface)
211 , m_controller(controller)
212@@ -209,8 +208,8 @@
213 , m_currentFrameNumber(0)
214 , m_live(true)
215 , m_surfaceObserver(std::make_shared<SurfaceObserver>())
216- , m_position(toQPoint(m_window.top_left()))
217- , m_size(toQSize(m_window.size()))
218+ , m_position(toQPoint(m_windowInfo.window().top_left()))
219+ , m_size(toQSize(m_windowInfo.window().size()))
220 , m_shellChrome(Mir::NormalChrome)
221 {
222 DEBUG_MSG << "()";
223@@ -303,7 +302,7 @@
224
225 Mir::Type MirSurface::type() const
226 {
227- switch (m_windowInfo.type) {
228+ switch (m_windowInfo.type()) {
229 case mir_surface_type_normal:
230 return Mir::NormalType;
231
232@@ -484,10 +483,10 @@
233
234 if (m_activelyFocusedViews.isEmpty()) {
235 DEBUG_MSG << "() unfocused";
236- m_controller->setActiveFocus(m_window, false);
237+ m_controller->setActiveFocus(m_windowInfo.window(), false);
238 } else {
239 DEBUG_MSG << "() focused";
240- m_controller->setActiveFocus(m_window, true);
241+ m_controller->setActiveFocus(m_windowInfo.window(), true);
242 }
243
244 m_neverSetSurfaceFocus = false;
245@@ -505,19 +504,17 @@
246 Q_EMIT closeRequested();
247 m_closeTimer->start();
248
249- if (m_window) {
250+ if (m_surface) {
251 m_surface->request_client_surface_close();
252 }
253 }
254
255 void MirSurface::resize(int width, int height)
256 {
257- auto const &window = m_window;
258-
259 bool mirSizeIsDifferent = width != m_size.width() || height != m_size.height();
260
261 if (clientIsRunning() && mirSizeIsDifferent) {
262- m_controller->resize(window, QSize(width, height));
263+ m_controller->resize(m_windowInfo.window(), QSize(width, height));
264 DEBUG_MSG << " old (" << m_size.width() << "," << m_size.height() << ")"
265 << ", new (" << width << "," << height << ")";
266 }
267@@ -538,7 +535,7 @@
268
269 void MirSurface::requestPosition(const QPoint newPosition)
270 {
271- m_controller->move(m_window, newPosition);
272+ m_controller->move(m_windowInfo.window(), newPosition);
273 }
274
275 void MirSurface::setSize(const QSize newSize)
276@@ -556,7 +553,7 @@
277
278 Mir::State MirSurface::state() const
279 {
280- switch (m_windowInfo.state) {
281+ switch (m_windowInfo.state()) {
282 case mir_surface_state_unknown:
283 return Mir::UnknownState;
284 case mir_surface_state_restored:
285@@ -620,10 +617,10 @@
286
287 QString MirSurface::name() const
288 {
289- if (!m_windowInfo.name.is_set()) {
290+ if (!m_windowInfo.has_name()) {
291 return QStringLiteral();
292 }
293- return QString::fromStdString(m_windowInfo.name.value());
294+ return QString::fromStdString(m_windowInfo.name());
295 }
296
297 QString MirSurface::persistentId() const
298@@ -670,7 +667,7 @@
299 break;
300 }
301
302- m_controller->setState(m_window, mirState);
303+ m_controller->setState(m_windowInfo.window(), mirState);
304 }
305
306 void MirSurface::setLive(bool value)
307@@ -699,7 +696,7 @@
308 {
309 auto ev = makeMirEvent(event, mir_pointer_action_button_down);
310 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
311- m_controller->deliverPointerEvent(m_window, ev1);
312+ m_controller->deliverPointerEvent(m_windowInfo.window(), ev1);
313 event->accept();
314 }
315
316@@ -707,7 +704,7 @@
317 {
318 auto ev = makeMirEvent(event, mir_pointer_action_motion);
319 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
320- m_controller->deliverPointerEvent(m_window, ev1);
321+ m_controller->deliverPointerEvent(m_windowInfo.window(), ev1);
322 event->accept();
323 }
324
325@@ -715,7 +712,7 @@
326 {
327 auto ev = makeMirEvent(event, mir_pointer_action_button_up);
328 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
329- m_controller->deliverPointerEvent(m_window, ev1);
330+ m_controller->deliverPointerEvent(m_windowInfo.window(), ev1);
331 event->accept();
332 }
333
334@@ -723,7 +720,7 @@
335 {
336 auto ev = makeMirEvent(event, mir_pointer_action_enter);
337 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
338- m_controller->deliverPointerEvent(m_window, ev1);
339+ m_controller->deliverPointerEvent(m_windowInfo.window(), ev1);
340 event->accept();
341 }
342
343@@ -731,7 +728,7 @@
344 {
345 auto ev = makeMirEvent(event, mir_pointer_action_leave);
346 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
347- m_controller->deliverPointerEvent(m_window, ev1);
348+ m_controller->deliverPointerEvent(m_windowInfo.window(), ev1);
349 event->accept();
350 }
351
352@@ -739,7 +736,7 @@
353 {
354 auto ev = makeMirEvent(event, mir_pointer_action_motion);
355 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
356- m_controller->deliverPointerEvent(m_window, ev1);
357+ m_controller->deliverPointerEvent(m_windowInfo.window(), ev1);
358 event->accept();
359 }
360
361@@ -747,7 +744,7 @@
362 {
363 auto ev = makeMirEvent(event);
364 auto ev1 = reinterpret_cast<MirPointerEvent const*>(ev.get());
365- m_controller->deliverPointerEvent(m_window, ev1);
366+ m_controller->deliverPointerEvent(m_windowInfo.window(), ev1);
367 event->accept();
368 }
369
370@@ -755,7 +752,7 @@
371 {
372 auto ev = makeMirEvent(qtEvent);
373 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());
374- m_controller->deliverKeyboardEvent(m_window, ev1);
375+ m_controller->deliverKeyboardEvent(m_windowInfo.window(), ev1);
376 qtEvent->accept();
377 }
378
379@@ -763,7 +760,7 @@
380 {
381 auto ev = makeMirEvent(qtEvent);
382 auto ev1 = reinterpret_cast<MirKeyboardEvent const*>(ev.get());
383- m_controller->deliverKeyboardEvent(m_window, ev1);
384+ m_controller->deliverKeyboardEvent(m_windowInfo.window(), ev1);
385 qtEvent->accept();
386 }
387
388@@ -774,7 +771,7 @@
389 {
390 auto ev = makeMirEvent(mods, touchPoints, touchPointStates, timestamp);
391 auto ev1 = reinterpret_cast<MirTouchEvent const*>(ev.get());
392- m_controller->deliverTouchEvent(m_window, ev1);
393+ m_controller->deliverTouchEvent(m_windowInfo.window(), ev1);
394 }
395
396 bool MirSurface::clientIsRunning() const
397@@ -796,6 +793,9 @@
398 m_views.insert(viewId, MirSurface::View{false});
399 DEBUG_MSG << "(" << viewId << ")" << " after=" << m_views.count();
400 if (m_views.count() == 1) {
401+ // FIXME: Mir has internal RenderingTracker which sets surface visibility. I think is is interfering
402+ // QtMir's rendering. So manually inform client of its visibility.
403+ m_surface->configure(mir_surface_attrib_visibility, mir_surface_visibility_exposed);
404 Q_EMIT isBeingDisplayedChanged();
405 }
406 }
407@@ -807,6 +807,8 @@
408 if (m_views.count() == 0) {
409 Q_EMIT isBeingDisplayedChanged();
410 if (m_session.isNull() || !m_live) {
411+ // FIXME: see above
412+ m_surface->configure(mir_surface_attrib_visibility, mir_surface_visibility_occluded);
413 deleteLater();
414 }
415 }
416@@ -944,33 +946,33 @@
417 return result;
418 }
419
420-void MirSurface::updateWindowInfo(const WindowInfo &windowInfo)
421+void MirSurface::updateWindowInfo(const miral::WindowInfo &windowInfo)
422 {
423 qDebug() << "MirSurface::updateWindowInfo";
424 // Need to compare the new windowInfo instance with the existing one to figure out what changed
425 DirtyStates dirt = DirtyState::Clean;
426
427- if (windowInfo.name != m_windowInfo.name) {
428+ if (windowInfo.name() != m_windowInfo.name()) {
429 dirt &= DirtyState::Name; qDebug("Name changed");
430 }
431- if (windowInfo.type != m_windowInfo.type) {
432+ if (windowInfo.type() != m_windowInfo.type()) {
433 dirt &= DirtyState::Type; qDebug("Type changed");
434 }
435- if (windowInfo.state != m_windowInfo.state) {
436+ if (windowInfo.state() != m_windowInfo.state()) {
437 dirt &= DirtyState::State; qDebug("State changed");
438 }
439- if (windowInfo.restoreRect != m_windowInfo.restoreRect) {
440+ if (windowInfo.restore_rect() != m_windowInfo.restore_rect()) {
441 dirt &= DirtyState::RestoreRect; qDebug("RestoreRect changed");
442 }
443- if (windowInfo.children != m_windowInfo.children) {
444+ if (windowInfo.children() != m_windowInfo.children()) {
445 dirt &= DirtyState::Children; qDebug("Children changed");
446 }
447- if (windowInfo.minWidth != m_windowInfo.minWidth
448- && windowInfo.minHeight != m_windowInfo.minHeight) {
449+ if (windowInfo.min_width() != m_windowInfo.min_width()
450+ && windowInfo.min_height() != m_windowInfo.min_height()) {
451 dirt &= DirtyState::MinSize; qDebug("MinSize changed");
452 }
453- if (windowInfo.maxWidth != m_windowInfo.maxWidth
454- && windowInfo.maxHeight != m_windowInfo.maxHeight) {
455+ if (windowInfo.max_width() != m_windowInfo.max_width()
456+ && windowInfo.max_height() != m_windowInfo.max_height()) {
457 dirt &= DirtyState::MaxSize; qDebug("MaxHeight changed");
458 }
459
460@@ -1000,22 +1002,22 @@
461
462 int MirSurface::minimumWidth() const
463 {
464- return m_windowInfo.minWidth.as_int();
465+ return m_windowInfo.min_width().as_int();
466 }
467
468 int MirSurface::minimumHeight() const
469 {
470- return m_windowInfo.minHeight.as_int();
471+ return m_windowInfo.min_height().as_int();
472 }
473
474 int MirSurface::maximumWidth() const
475 {
476- return m_windowInfo.maxWidth.as_int();
477+ return m_windowInfo.max_width().as_int();
478 }
479
480 int MirSurface::maximumHeight() const
481 {
482- return m_windowInfo.maxHeight.as_int();
483+ return m_windowInfo.max_height().as_int();
484 }
485
486 int MirSurface::widthIncrement() const
487@@ -1058,7 +1060,7 @@
488
489 m_closingState = CloseOverdue;
490
491- m_controller->requestClose(m_window);
492+ m_controller->requestClose(m_windowInfo.window());
493 }
494
495 void MirSurface::setCloseTimer(AbstractTimer *timer)
496
497=== modified file 'miral-qt/src/modules/Unity/Application/mirsurface.h'
498--- miral-qt/src/modules/Unity/Application/mirsurface.h 2016-09-08 14:00:59 +0000
499+++ miral-qt/src/modules/Unity/Application/mirsurface.h 2016-09-13 12:26:41 +0000
500@@ -32,7 +32,7 @@
501 #include "mirbuffersgtexture.h"
502 #include "session.h"
503 #include "windowcontrollerinterface.h"
504-#include "windowmodelnotifierinterface.h"
505+#include "windowmodelnotifier.h"
506
507 // mir
508 #include <mir_toolkit/common.h>
509@@ -155,12 +155,12 @@
510 // Own API
511 void setPosition(const QPoint newPosition);
512 void setSize(const QSize newSize);
513- void updateWindowInfo(const WindowInfo &windowInfo);
514+ void updateWindowInfo(const miral::WindowInfo &windowInfo);
515
516 // useful for tests
517 void setCloseTimer(AbstractTimer *timer);
518 std::shared_ptr<SurfaceObserver> surfaceObserver() const;
519- miral::Window window() const { return m_window; }
520+ miral::Window window() const { return m_windowInfo.window(); }
521
522 public Q_SLOTS:
523 void onCompositorSwappedBuffers() override;
524@@ -184,8 +184,7 @@
525 void applyKeymap();
526 void updateActiveFocus();
527
528- miral::Window m_window;
529- WindowInfo m_windowInfo;
530+ miral::WindowInfo m_windowInfo;
531 std::shared_ptr<mir::scene::Surface> m_surface; // keep copy of the Surface for lifecycle
532 QPointer<SessionInterface> m_session;
533 WindowControllerInterface *const m_controller;
534
535=== modified file 'miral-qt/src/modules/Unity/Application/windowmodel.cpp'
536--- miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-09-08 23:29:34 +0000
537+++ miral-qt/src/modules/Unity/Application/windowmodel.cpp 2016-09-13 12:26:41 +0000
538@@ -39,30 +39,25 @@
539
540 m_windowController = static_cast<WindowControllerInterface*>(nativeInterface->nativeResourceForIntegration("WindowController"));
541
542- auto windowModel = static_cast<WindowModelNotifierInterface*>(nativeInterface->nativeResourceForIntegration("WindowModelNotifier"));
543+ auto windowModel = static_cast<WindowModelNotifier*>(nativeInterface->nativeResourceForIntegration("WindowModelNotifier"));
544 connectToWindowModelNotifier(windowModel);
545 }
546
547-WindowModel::WindowModel(WindowModelNotifierInterface *notifier,
548+WindowModel::WindowModel(WindowModelNotifier *notifier,
549 WindowControllerInterface *controller)
550 : m_windowController(controller)
551 {
552 connectToWindowModelNotifier(notifier);
553 }
554
555-void WindowModel::connectToWindowModelNotifier(WindowModelNotifierInterface *notifier)
556+void WindowModel::connectToWindowModelNotifier(WindowModelNotifier *notifier)
557 {
558- connect(notifier, &WindowModelNotifierInterface::windowAdded, this, &WindowModel::onWindowAdded, Qt::QueuedConnection);
559- connect(notifier, &WindowModelNotifierInterface::windowRemoved, this, &WindowModel::onWindowRemoved, Qt::QueuedConnection);
560- connect(notifier, &WindowModelNotifierInterface::windowMoved, this, &WindowModel::onWindowMoved, Qt::QueuedConnection);
561- connect(notifier, &WindowModelNotifierInterface::windowResized, this, &WindowModel::onWindowResized, Qt::QueuedConnection);
562- connect(notifier, &WindowModelNotifierInterface::windowFocused, this, &WindowModel::onWindowFocused, Qt::QueuedConnection);
563- connect(notifier, &WindowModelNotifierInterface::windowInfoChanged, this, &WindowModel::onWindowInfoChanged, Qt::QueuedConnection);
564- connect(notifier, &WindowModelNotifierInterface::windowsRaised, this, &WindowModel::onWindowsRaised, Qt::QueuedConnection);
565- connect(notifier, &WindowModelNotifierInterface::inputMethodWindowAdded,
566- this, &WindowModel::onInputMethodWindowAdded, Qt::QueuedConnection);
567- connect(notifier, &WindowModelNotifierInterface::inputMethodWindowRemoved,
568- this, &WindowModel::onInputMethodWindowRemoved, Qt::QueuedConnection);
569+ connect(notifier, &WindowModelNotifier::windowAdded, this, &WindowModel::onWindowAdded, Qt::QueuedConnection);
570+ connect(notifier, &WindowModelNotifier::windowRemoved, this, &WindowModel::onWindowRemoved, Qt::QueuedConnection);
571+ connect(notifier, &WindowModelNotifier::windowMoved, this, &WindowModel::onWindowMoved, Qt::QueuedConnection);
572+ connect(notifier, &WindowModelNotifier::windowResized, this, &WindowModel::onWindowResized, Qt::QueuedConnection);
573+ connect(notifier, &WindowModelNotifier::windowFocusChanged, this, &WindowModel::onWindowFocusChanged, Qt::QueuedConnection);
574+ connect(notifier, &WindowModelNotifier::windowsRaised, this, &WindowModel::onWindowsRaised, Qt::QueuedConnection);
575 }
576
577 QHash<int, QByteArray> WindowModel::roleNames() const
578@@ -72,58 +67,66 @@
579 return roleNames;
580 }
581
582-void WindowModel::onWindowAdded(const NewWindow windowInfo, const int index)
583+void WindowModel::onWindowAdded(const NewWindow &window)
584 {
585- auto mirSurface = new MirSurface(windowInfo, m_windowController);
586+ if (window.windowInfo.type() == mir_surface_type_inputmethod) {
587+ addInputMethodWindow(window);
588+ return;
589+ }
590+
591+ const int index = m_windowModel.count();
592 beginInsertRows(QModelIndex(), index, index);
593- m_windowModel.insert(index, mirSurface);
594+ m_windowModel.append(new MirSurface(window, m_windowController));
595 endInsertRows();
596 Q_EMIT countChanged();
597 }
598
599-void WindowModel::onWindowRemoved(const int index)
600+void WindowModel::onWindowRemoved(const miral::WindowInfo &windowInfo)
601 {
602+ if (windowInfo.type() == mir_surface_type_inputmethod) {
603+ removeInputMethodWindow();
604+ return;
605+ }
606+
607+ const int index = findIndexOf(windowInfo.window());
608+
609 beginRemoveRows(QModelIndex(), index, index);
610- auto window = m_windowModel.takeAt(index);
611- if (window == m_focusedWindow) {
612- m_focusedWindow = nullptr;
613- }
614+ m_windowModel.takeAt(index);
615 endRemoveRows();
616 Q_EMIT countChanged();
617 }
618
619-void WindowModel::onWindowMoved(const QPoint topLeft, const int index)
620-{
621- auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(index));
622- mirSurface->setPosition(topLeft);
623-}
624-
625-void WindowModel::onWindowResized(const QSize size, const int index)
626-{
627- auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(index));
628- mirSurface->setSize(size);
629-}
630-
631-void WindowModel::onWindowFocused(const int index)
632-{
633- auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(index));
634- if (m_focusedWindow && m_focusedWindow != mirSurface) {
635- m_focusedWindow->setFocused(false);
636- }
637- mirSurface->setFocused(true);
638- m_focusedWindow = mirSurface;
639-}
640-
641-void WindowModel::onWindowInfoChanged(const WindowInfo windowInfo, const int pos)
642-{
643- auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(pos));
644- mirSurface->updateWindowInfo(windowInfo);
645-
646- QModelIndex row = index(pos);
647- Q_EMIT dataChanged(row, row, QVector<int>() << SurfaceRole);
648-}
649-
650-void WindowModel::onInputMethodWindowAdded(const NewWindow windowInfo)
651+void WindowModel::onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft)
652+{
653+ if (auto mirSurface = find(windowInfo)) {
654+ mirSurface->setPosition(topLeft);
655+ }
656+}
657+
658+void WindowModel::onWindowResized(const miral::WindowInfo &windowInfo, const QSize size)
659+{
660+ if (auto mirSurface = find(windowInfo)) {
661+ mirSurface->setSize(size);
662+ }
663+}
664+
665+void WindowModel::onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused)
666+{
667+ if (auto mirSurface = find(windowInfo)) {
668+ mirSurface->setFocused(focused);
669+ }
670+}
671+
672+//void WindowModel::onWindowInfoChanged(const WindowInfo windowInfo, const int pos)
673+//{
674+// auto mirSurface = static_cast<MirSurface *>(m_windowModel.value(pos));
675+// mirSurface->updateWindowInfo(windowInfo);
676+
677+// QModelIndex row = index(pos);
678+// Q_EMIT dataChanged(row, row, QVector<int>() << SurfaceRole);
679+//}
680+
681+void WindowModel::addInputMethodWindow(const NewWindow &windowInfo)
682 {
683 if (m_inputMethodSurface) {
684 qDebug("Multiple Input Method Surfaces created, removing the old one!");
685@@ -133,7 +136,7 @@
686 Q_EMIT inputMethodSurfaceChanged(m_inputMethodSurface);
687 }
688
689-void WindowModel::onInputMethodWindowRemoved()
690+void WindowModel::removeInputMethodWindow()
691 {
692 if (m_inputMethodSurface) {
693 delete m_inputMethodSurface;
694@@ -142,10 +145,17 @@
695 }
696 }
697
698-void WindowModel::onWindowsRaised(QVector<int> indices)
699+void WindowModel::onWindowsRaised(const std::vector<miral::Window> &windows)
700 {
701 const int modelCount = m_windowModel.count();
702
703+ QVector<int> indices;
704+ for (const auto window: windows) {
705+ int index = findIndexOf(window);
706+ if (index >= 0) {
707+ indices.append(index);
708+ }
709+ }
710 // Assumption: no NO-OPs are in this list - Qt will crash on endMoveRows() if you try NO-OPs!!!
711 // A NO-OP is if
712 // 1. "indices" is an empty list
713@@ -181,7 +191,7 @@
714 beginMoveRows(parent, move, move, parent, modelCount);
715
716 // QVector missing a move method in Qt5.4
717- const auto window = m_windowModel.takeAt(move);
718+ const auto &window = m_windowModel.takeAt(move);
719 m_windowModel.push_back(window);
720
721 endMoveRows();
722@@ -199,10 +209,30 @@
723 return QVariant();
724
725 if (role == SurfaceRole) {
726- MirSurfaceInterface *surface = m_windowModel.at(index.row());
727- return QVariant::fromValue(static_cast<MirSurfaceInterface*>(surface));
728+ auto &surface = m_windowModel.at(index.row());
729+ return QVariant::fromValue(surface);
730 } else {
731 return QVariant();
732 }
733 }
734
735+MirSurface *WindowModel::find(const miral::WindowInfo &needle) const
736+{
737+ auto window = needle.window();
738+ Q_FOREACH(const auto mirSurface, m_windowModel) {
739+ if (mirSurface->window() == window) {
740+ return mirSurface;
741+ }
742+ }
743+ return nullptr;
744+}
745+
746+int WindowModel::findIndexOf(const miral::Window &needle) const
747+{
748+ for (int i=0; i<m_windowModel.count(); i++) {
749+ if (m_windowModel[i]->window() == needle) {
750+ return i;
751+ }
752+ }
753+ return -1;
754+}
755
756=== modified file 'miral-qt/src/modules/Unity/Application/windowmodel.h'
757--- miral-qt/src/modules/Unity/Application/windowmodel.h 2016-09-08 23:29:34 +0000
758+++ miral-qt/src/modules/Unity/Application/windowmodel.h 2016-09-13 12:26:41 +0000
759@@ -19,8 +19,8 @@
760
761 #include <QAbstractListModel>
762
763-#include "mirsurfaceinterface.h"
764-#include "windowmodelnotifierinterface.h"
765+#include "mirsurface.h"
766+#include "windowmodelnotifier.h"
767
768 namespace qtmir {
769
770@@ -40,7 +40,7 @@
771 };
772
773 WindowModel();
774- explicit WindowModel(WindowModelNotifierInterface *notifier,
775+ explicit WindowModel(WindowModelNotifier *notifier,
776 WindowControllerInterface *controller); // For testing
777
778 // QAbstractItemModel methods
779@@ -51,31 +51,31 @@
780
781 int count() const { return rowCount(); }
782
783- MirSurfaceInterface* inputMethodSurface() const { return m_inputMethodSurface; }
784+ MirSurface* inputMethodSurface() const { return m_inputMethodSurface; }
785
786 Q_SIGNALS:
787 void countChanged();
788 void inputMethodSurfaceChanged(MirSurfaceInterface* inputMethodSurface);
789
790 private Q_SLOTS:
791- void onWindowAdded(const NewWindow windowInfo, const int index);
792- void onWindowRemoved(const int index);
793- void onWindowMoved(const QPoint topLeft, const int index);
794- void onWindowResized(const QSize size, const int index);
795- void onWindowFocused(const int index);
796- void onWindowInfoChanged(const WindowInfo windowInfo, const int index);
797- void onWindowsRaised(const QVector<int> indices);
798-
799- void onInputMethodWindowAdded(const NewWindow windowInfo);
800- void onInputMethodWindowRemoved();
801+ void onWindowAdded(const qtmir::NewWindow &windowInfo);
802+ void onWindowRemoved(const miral::WindowInfo &window);
803+ void onWindowMoved(const miral::WindowInfo &window, const QPoint topLeft);
804+ void onWindowResized(const miral::WindowInfo &window, const QSize size);
805+ void onWindowFocusChanged(const miral::WindowInfo &window, bool focused);
806+ void onWindowsRaised(const std::vector<miral::Window> &windows);
807
808 private:
809- void connectToWindowModelNotifier(WindowModelNotifierInterface *notifier);
810-
811- QVector<MirSurfaceInterface *> m_windowModel;
812+ void connectToWindowModelNotifier(WindowModelNotifier *notifier);
813+
814+ void addInputMethodWindow(const NewWindow &windowInfo);
815+ void removeInputMethodWindow();
816+ MirSurface* find(const miral::WindowInfo &needle) const;
817+ int findIndexOf(const miral::Window &needle) const;
818+
819+ QVector<MirSurface*> m_windowModel;
820 WindowControllerInterface *m_windowController;
821- MirSurfaceInterface* m_focusedWindow{nullptr};
822- MirSurfaceInterface* m_inputMethodSurface{nullptr};
823+ MirSurface* m_inputMethodSurface{nullptr};
824 };
825
826 } // namespace qtmir
827
828=== modified file 'miral-qt/src/platforms/mirserver/CMakeLists.txt'
829--- miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-08-19 16:41:10 +0000
830+++ miral-qt/src/platforms/mirserver/CMakeLists.txt 2016-09-13 12:26:41 +0000
831@@ -79,7 +79,6 @@
832 creationhints.cpp
833 windowcontroller.cpp
834 windowmanagementpolicy.cpp
835- windowmodelnotifier.cpp
836 tracepoints.c
837 mirserverhooks.cpp mirserverhooks.h
838 openglcontextfactory.cpp openglcontextfactory.h
839@@ -88,7 +87,7 @@
840 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
841 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h
842 ${MIRAL_QT_SOURCE_DIR}/src/common/windowcontrollerinterface.h
843- ${MIRAL_QT_SOURCE_DIR}/src/common/windowmodelnotifierinterface.h
844+ ${MIRAL_QT_SOURCE_DIR}/src/common/windowmodelnotifier.h
845 )
846
847 add_library(qpa-mirserver SHARED
848
849=== modified file 'miral-qt/src/platforms/mirserver/qmirserver_p.h'
850--- miral-qt/src/platforms/mirserver/qmirserver_p.h 2016-08-22 14:33:59 +0000
851+++ miral-qt/src/platforms/mirserver/qmirserver_p.h 2016-09-13 12:26:41 +0000
852@@ -65,7 +65,7 @@
853 std::shared_ptr<SessionAuthorizer> theApplicationAuthorizer() const
854 { return m_sessionAuthorizer.the_custom_application_authorizer(); }
855
856- qtmir::WindowModelNotifierInterface *windowModelNotifier() const
857+ qtmir::WindowModelNotifier *windowModelNotifier() const
858 { return &m_windowModelNotifier; }
859
860 qtmir::WindowControllerInterface *windowController() const
861
862=== modified file 'miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp'
863--- miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-09-07 20:33:52 +0000
864+++ miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-09-13 12:26:41 +0000
865@@ -21,9 +21,13 @@
866 #include "miral/window_manager_tools.h"
867 #include "miral/window_specification.h"
868
869+#include "mirqtconversion.h"
870+
871 #include <mir/scene/surface.h>
872 #include <QDebug>
873
874+using namespace qtmir;
875+
876 WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools,
877 qtmir::WindowModelNotifier &windowModel,
878 qtmir::WindowController &windowController,
879@@ -33,6 +37,8 @@
880 , m_windowModel(windowModel)
881 , m_eventFeeder(new QtEventFeeder(screensModel))
882 {
883+ qRegisterMetaType<qtmir::NewWindow>();
884+ qRegisterMetaType<std::vector<miral::Window>>();
885 windowController.setPolicy(this);
886 }
887
888@@ -90,17 +96,17 @@
889 // TODO: attach surface observer here
890 std::string persistentId = m_tools.id_for_window(windowInfo.window());
891
892- m_windowModel.addWindow(windowInfo, persistentId);
893+ Q_EMIT m_windowModel.windowAdded(NewWindow{windowInfo, persistentId});
894 }
895
896 void WindowManagementPolicy::advise_delete_window(const miral::WindowInfo &windowInfo)
897 {
898- m_windowModel.removeWindow(windowInfo);
899+ Q_EMIT m_windowModel.windowRemoved(windowInfo);
900 }
901
902 void WindowManagementPolicy::advise_raise(const std::vector<miral::Window> &windows)
903 {
904- m_windowModel.raiseWindows(windows);
905+ Q_EMIT m_windowModel.windowsRaised(windows);
906 }
907
908 void WindowManagementPolicy::advise_new_app(miral::ApplicationInfo &/*application*/)
909@@ -121,24 +127,24 @@
910 void WindowManagementPolicy::advise_move_to(const miral::WindowInfo &windowInfo, Point topLeft)
911 {
912 qDebug("Window Moved to (%d, %d)", topLeft.x.as_int(), topLeft.y.as_int());
913- m_windowModel.moveWindow(windowInfo, topLeft);
914+ Q_EMIT m_windowModel.windowMoved(windowInfo, toQPoint(topLeft));
915 }
916
917 void WindowManagementPolicy::advise_resize(const miral::WindowInfo &windowInfo, const Size &newSize)
918 {
919 qDebug("Window Resized to %dx%d", newSize.width.as_int(), newSize.height.as_int());
920- m_windowModel.resizeWindow(windowInfo, newSize);
921+ Q_EMIT m_windowModel.windowResized(windowInfo, toQSize(newSize));
922 }
923
924 void WindowManagementPolicy::advise_focus_lost(const miral::WindowInfo &windowInfo)
925 {
926- m_windowModel.focusWindow(windowInfo, false);
927+ Q_EMIT m_windowModel.windowFocusChanged(windowInfo, false);
928 }
929
930 void WindowManagementPolicy::advise_focus_gained(const miral::WindowInfo &windowInfo)
931 {
932 // update Qt model ASAP, before applying Mir policy
933- m_windowModel.focusWindow(windowInfo, true);
934+ Q_EMIT m_windowModel.windowFocusChanged(windowInfo, true);
935
936 CanonicalWindowManagerPolicy::advise_focus_gained(windowInfo);
937 }
938
939=== removed file 'miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp'
940--- miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp 2016-09-08 23:29:34 +0000
941+++ miral-qt/src/platforms/mirserver/windowmodelnotifier.cpp 1970-01-01 00:00:00 +0000
942@@ -1,152 +0,0 @@
943-/*
944- * Copyright (C) 2016 Canonical, Ltd.
945- *
946- * This program is free software: you can redistribute it and/or modify it under
947- * the terms of the GNU Lesser General Public License version 3, as published by
948- * the Free Software Foundation.
949- *
950- * This program is distributed in the hope that it will be useful, but WITHOUT
951- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
952- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
953- * Lesser General Public License for more details.
954- *
955- * You should have received a copy of the GNU Lesser General Public License
956- * along with this program. If not, see <http://www.gnu.org/licenses/>.
957- */
958-
959-#include "windowmodelnotifier.h"
960-
961-#include "mirqtconversion.h"
962-#include <QDebug>
963-
964-/*
965- * WindowModelNotifier - tracks Mir Window Manager operations and duplicates the window stack
966- * that Mir has created internally. Any changes to this model are emitted as notify
967- * signals to the Qt GUI thread which will effectively duplicate this model again.
968- *
969- * Use a window ID as a shared identifier between this Mir-side model and the Qt-side model
970- */
971-
972-using namespace qtmir;
973-
974-WindowModelNotifier::WindowModelNotifier()
975-{
976- qRegisterMetaType<qtmir::NewWindow>();
977- qRegisterMetaType<qtmir::WindowInfo>();
978- qRegisterMetaType<QVector<int>>();
979-}
980-
981-WindowModelNotifier::~WindowModelNotifier()
982-{
983-
984-}
985-
986-void WindowModelNotifier::addWindow(const miral::WindowInfo &windowInfo, const std::string &persistentId)
987-{
988- if (windowInfo.type() == mir_surface_type_inputmethod) {
989- NewWindow newWindowInfo{windowInfo};
990- Q_EMIT inputMethodWindowAdded(newWindowInfo);
991- return;
992- }
993-
994- auto stackPosition = m_windowStack.count();
995- m_windowStack.push_back(windowInfo.window()); // ASSUMPTION: Mir should tell us where in stack
996-
997- NewWindow newWindowInfo{windowInfo, persistentId};
998- Q_EMIT windowAdded(newWindowInfo, stackPosition);
999-}
1000-
1001-void WindowModelNotifier::removeWindow(const miral::WindowInfo &windowInfo)
1002-{
1003- if (windowInfo.type() == mir_surface_type_inputmethod) {
1004- Q_EMIT inputMethodWindowRemoved();
1005- return;
1006- }
1007-
1008- const int pos = m_windowStack.indexOf(windowInfo.window());
1009- if (pos < 0) {
1010- qDebug("Unknown window removed");
1011- return;
1012- }
1013- m_windowStack.removeAt(pos);
1014- Q_EMIT windowRemoved(pos);
1015-}
1016-
1017-void WindowModelNotifier::focusWindow(const miral::WindowInfo &windowInfo, const bool focus)
1018-{
1019- const int pos = m_windowStack.indexOf(windowInfo.window());
1020- if (pos < 0) {
1021- qDebug("Unknown window focused");
1022- return;
1023- }
1024-
1025- if (focus && m_focusedWindowIndex != pos) {
1026- m_focusedWindowIndex = pos;
1027- Q_EMIT windowFocused(pos);
1028- }
1029-}
1030-
1031-void WindowModelNotifier::moveWindow(const miral::WindowInfo &windowInfo, mir::geometry::Point topLeft)
1032-{
1033- const int pos = m_windowStack.indexOf(windowInfo.window());
1034- if (pos < 0) {
1035- qDebug("Unknown window moved");
1036- return;
1037- }
1038-
1039- // Note: windowInfo.window() is in the state before the move
1040- Q_EMIT windowMoved(toQPoint(topLeft), pos);
1041-}
1042-
1043-void WindowModelNotifier::resizeWindow(const miral::WindowInfo &windowInfo, mir::geometry::Size newSize)
1044-{
1045- const int pos = m_windowStack.indexOf(windowInfo.window());
1046- if (pos < 0) {
1047- qDebug("Unknown window resized");
1048- return;
1049- }
1050-
1051- // Note: windowInfo.window() is in the state before the resize
1052- Q_EMIT windowResized(toQSize(newSize), pos);
1053-}
1054-
1055-void WindowModelNotifier::raiseWindows(const std::vector<miral::Window> &windows)
1056-{
1057- QVector<int> indices;
1058- for (auto window: windows) {
1059- const int pos = m_windowStack.indexOf(window);
1060- if (pos < 0) {
1061- qDebug("Unknown window raised");
1062- continue;
1063- }
1064- indices.push_back(pos);
1065- }
1066-
1067- // Filter some NO-OP (raise list of windows which is already raised and in that order)
1068- // A NO-OP is if
1069- // 1. "indices" is an empty list
1070- // 2. "indices" of the form (modelCount - 1, modelCount - 2,...)
1071- {
1072- bool noop = true;
1073- int counter = m_windowStack.count() - 1;
1074- Q_FOREACH(int index, indices) {
1075- if (index != counter) {
1076- noop = false;
1077- break;
1078- }
1079- counter--;
1080- }
1081-
1082- if (noop) {
1083- return;
1084- }
1085- }
1086-
1087- for (int i=indices.count()-1; i>=0; i--) {
1088- // QVector missing a move method in Qt5.4
1089- auto window = m_windowStack.takeAt(indices[i]);
1090- m_windowStack.push_back(window);
1091- }
1092-
1093- Q_EMIT windowsRaised(indices);
1094-}
1095
1096=== modified file 'miral-qt/tests/modules/WindowManager/mirsurface_test.cpp'
1097--- miral-qt/tests/modules/WindowManager/mirsurface_test.cpp 2016-08-23 13:28:03 +0000
1098+++ miral-qt/tests/modules/WindowManager/mirsurface_test.cpp 2016-09-13 12:26:41 +0000
1099@@ -26,7 +26,7 @@
1100 #include <QSignalSpy>
1101
1102 // src/common
1103-#include "windowmodelnotifierinterface.h"
1104+#include "windowmodelnotifier.h"
1105
1106 // the test subject
1107 #include <Unity/Application/mirsurface.h>
1108@@ -86,7 +86,6 @@
1109 miral::Window mockWindow(stubSession, mockSurface);
1110 ms::SurfaceCreationParameters spec;
1111 miral::WindowInfo mockWindowInfo(mockWindow, spec);
1112- QScopedPointer<WindowInfo> windowInfo(new WindowInfo(mockWindowInfo));
1113
1114 EXPECT_CALL(*mockSurface.get(),buffers_ready_for_compositor(_))
1115 .WillRepeatedly(Return(1));
1116
1117=== modified file 'miral-qt/tests/modules/WindowManager/windowmodel_test.cpp'
1118--- miral-qt/tests/modules/WindowManager/windowmodel_test.cpp 2016-09-08 23:44:44 +0000
1119+++ miral-qt/tests/modules/WindowManager/windowmodel_test.cpp 2016-09-13 12:26:41 +0000
1120@@ -57,7 +57,7 @@
1121 QLoggingCategory::setFilterRules(QStringLiteral("qtmir.surfaces=false"));
1122 }
1123
1124- miral::WindowInfo createMirALWindowInfo(QPoint position = {160, 320}, QSize size = {100, 200})
1125+ NewWindow createNewWindow(QPoint position = {160, 320}, QSize size = {100, 200})
1126 {
1127 const miral::Application app{stubSession};
1128 stubSurface->setSize(size);
1129@@ -66,17 +66,19 @@
1130 ms::SurfaceCreationParameters windowSpec;
1131 // windowSpec.of_size(toMirSize(size)); // useless, Window/Surface has the size actually used
1132 windowSpec.of_position(toMirPoint(position));
1133- return miral::WindowInfo{window, windowSpec};
1134+ miral::WindowInfo windowInfo{window, windowSpec};
1135+ return NewWindow{windowInfo, ""};
1136 }
1137
1138- miral::WindowInfo createMirALWindowInfoForInputMethod()
1139+ NewWindow createNewWindowForInputMethod()
1140 {
1141 const miral::Application app{stubSession};
1142 const miral::Window window{app, stubSurface};
1143
1144 ms::SurfaceCreationParameters windowSpec;
1145 windowSpec.of_type(mir_surface_type_inputmethod);
1146- return miral::WindowInfo{window, windowSpec};
1147+ miral::WindowInfo windowInfo{window, windowSpec};
1148+ return NewWindow{windowInfo, ""};
1149 }
1150
1151 MirSurface *getMirSurfaceFromModel(const WindowModel &model, int index)
1152@@ -113,7 +115,7 @@
1153 };
1154
1155 /*
1156- * Test: that the WindowModelNotifier.addWindow causes the Qt-side WindowModel to
1157+ * Test: that the WindowModelNotifier.windowAdded causes the Qt-side WindowModel to
1158 * increment model count
1159 */
1160 TEST_F(WindowModelTest, WhenAddWindowNotifiedModelCountIncrements)
1161@@ -121,16 +123,16 @@
1162 WindowModelNotifier notifier;
1163 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1164
1165- auto mirWindowInfo = createMirALWindowInfo();
1166+ auto newWindow = createNewWindow();
1167
1168- notifier.addWindow(mirWindowInfo);
1169+ notifier.windowAdded(newWindow);
1170 flushEvents();
1171
1172 EXPECT_EQ(1, model.count());
1173 }
1174
1175 /*
1176- * Test: that the WindowModelNotifier.addWindow causes the Qt-side WindowModel to
1177+ * Test: that the WindowModelNotifier.windowAdded causes the Qt-side WindowModel to
1178 * emit the countChanged signal.
1179 */
1180 TEST_F(WindowModelTest, WhenAddWindowNotifiedModelEmitsCountChangedSignal)
1181@@ -138,18 +140,18 @@
1182 WindowModelNotifier notifier;
1183 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1184
1185- auto mirWindowInfo = createMirALWindowInfo();
1186+ auto newWindow = createNewWindow();
1187
1188 QSignalSpy spyCountChanged(&model, SIGNAL(countChanged()));
1189
1190- notifier.addWindow(mirWindowInfo);
1191+ notifier.windowAdded(newWindow);
1192 flushEvents();
1193
1194 EXPECT_EQ(1, spyCountChanged.count());
1195 }
1196
1197 /*
1198- * Test: that the WindowModelNotifier.addWindow causes the Qt-side WindowModel to
1199+ * Test: that the WindowModelNotifier.windowAdded causes the Qt-side WindowModel to
1200 * gain an entry which has the correct miral::Window
1201 */
1202 TEST_F(WindowModelTest, WhenAddWindowNotifiedNewModelEntryHasCorrectWindow)
1203@@ -157,17 +159,17 @@
1204 WindowModelNotifier notifier;
1205 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1206
1207- auto mirWindowInfo = createMirALWindowInfo();
1208+ auto newWindow = createNewWindow();
1209
1210- notifier.addWindow(mirWindowInfo);
1211+ notifier.windowAdded(newWindow);
1212 flushEvents();
1213
1214 auto miralWindow = getMirALWindowFromModel(model, 0);
1215- EXPECT_EQ(mirWindowInfo.window(), miralWindow);
1216+ EXPECT_EQ(newWindow.windowInfo.window(), miralWindow);
1217 }
1218
1219 /*
1220- * Test: that the WindowModelNotifier.removeWindow causes the Qt-side WindowModel to
1221+ * Test: that the WindowModelNotifier.windowRemoved causes the Qt-side WindowModel to
1222 * remove the Window from the model, and emit the countChanged signal.
1223 */
1224 TEST_F(WindowModelTest, WhenRemoveWindowNotifiedModelCountDecrements)
1225@@ -175,18 +177,18 @@
1226 WindowModelNotifier notifier;
1227 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1228
1229- auto mirWindowInfo = createMirALWindowInfo();
1230- notifier.addWindow(mirWindowInfo);
1231+ auto newWindow = createNewWindow();
1232+ notifier.windowAdded(newWindow);
1233
1234 // Test removing the window
1235- notifier.removeWindow(mirWindowInfo);
1236+ notifier.windowRemoved(newWindow.windowInfo);
1237 flushEvents();
1238
1239 EXPECT_EQ(0, model.count());
1240 }
1241
1242 /*
1243- * Test: that the WindowModelNotifier.removeWindow causes the Qt-side WindowModel to
1244+ * Test: that the WindowModelNotifier.windowRemoved causes the Qt-side WindowModel to
1245 * emit the countChanged signal.
1246 */
1247 TEST_F(WindowModelTest, WhenRemoveWindowNotifiedModelEmitsCountChangedSignal)
1248@@ -194,21 +196,21 @@
1249 WindowModelNotifier notifier;
1250 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1251
1252- auto mirWindowInfo = createMirALWindowInfo();
1253- notifier.addWindow(mirWindowInfo);
1254+ auto newWindow = createNewWindow();
1255+ notifier.windowAdded(newWindow);
1256 flushEvents();
1257
1258 // Test removing the window
1259 QSignalSpy spyCountChanged(&model, SIGNAL(countChanged()));
1260
1261- notifier.removeWindow(mirWindowInfo);
1262+ notifier.windowRemoved(newWindow.windowInfo);
1263 flushEvents();
1264
1265 EXPECT_EQ(1, spyCountChanged.count());
1266 }
1267
1268 /*
1269- * Test: that calling WindowModelNotifier.addWindow causes Qt-side WindowModel to
1270+ * Test: that calling WindowModelNotifier.windowAdded causes Qt-side WindowModel to
1271 * have 2 windows in the correct order.
1272 */
1273 TEST_F(WindowModelTest, WhenAddingTwoWindowsModelHasCorrectOrder)
1274@@ -216,18 +218,18 @@
1275 WindowModelNotifier notifier;
1276 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1277
1278- auto mirWindowInfo1 = createMirALWindowInfo();
1279- auto mirWindowInfo2 = createMirALWindowInfo();
1280+ auto newWindow1 = createNewWindow();
1281+ auto newWindow2 = createNewWindow();
1282
1283- notifier.addWindow(mirWindowInfo1);
1284- notifier.addWindow(mirWindowInfo2);
1285+ notifier.windowAdded(newWindow1);
1286+ notifier.windowAdded(newWindow2);
1287 flushEvents();
1288
1289 ASSERT_EQ(2, model.count());
1290 auto miralWindow1 = getMirALWindowFromModel(model, 0);
1291- EXPECT_EQ(mirWindowInfo1.window(), miralWindow1);
1292+ EXPECT_EQ(newWindow1.windowInfo.window(), miralWindow1);
1293 auto miralWindow2 = getMirALWindowFromModel(model, 1);
1294- EXPECT_EQ(mirWindowInfo2.window(), miralWindow2);
1295+ EXPECT_EQ(newWindow2.windowInfo.window(), miralWindow2);
1296 }
1297
1298 /*
1299@@ -238,19 +240,19 @@
1300 WindowModelNotifier notifier;
1301 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1302
1303- auto mirWindowInfo1 = createMirALWindowInfo();
1304- auto mirWindowInfo2 = createMirALWindowInfo();
1305+ auto newWindow1 = createNewWindow();
1306+ auto newWindow2 = createNewWindow();
1307
1308- notifier.addWindow(mirWindowInfo1);
1309- notifier.addWindow(mirWindowInfo2);
1310+ notifier.windowAdded(newWindow1);
1311+ notifier.windowAdded(newWindow2);
1312
1313 // Remove second window
1314- notifier.removeWindow(mirWindowInfo2);
1315+ notifier.windowRemoved(newWindow2.windowInfo);
1316 flushEvents();
1317
1318 ASSERT_EQ(1, model.count());
1319 auto miralWindow = getMirALWindowFromModel(model, 0);
1320- EXPECT_EQ(mirWindowInfo1.window(), miralWindow);
1321+ EXPECT_EQ(newWindow1.windowInfo.window(), miralWindow);
1322 }
1323
1324 /*
1325@@ -261,19 +263,19 @@
1326 WindowModelNotifier notifier;
1327 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1328
1329- auto mirWindowInfo1 = createMirALWindowInfo();
1330- auto mirWindowInfo2 = createMirALWindowInfo();
1331+ auto newWindow1 = createNewWindow();
1332+ auto newWindow2 = createNewWindow();
1333
1334- notifier.addWindow(mirWindowInfo1);
1335- notifier.addWindow(mirWindowInfo2);
1336+ notifier.windowAdded(newWindow1);
1337+ notifier.windowAdded(newWindow2);
1338
1339 // Remove first window
1340- notifier.removeWindow(mirWindowInfo1);
1341+ notifier.windowRemoved(newWindow1.windowInfo);
1342 flushEvents();
1343
1344 ASSERT_EQ(1, model.count());
1345 auto miralWindow = getMirALWindowFromModel(model, 0);
1346- EXPECT_EQ(mirWindowInfo2.window(), miralWindow);
1347+ EXPECT_EQ(newWindow2.windowInfo.window(), miralWindow);
1348 }
1349
1350 /*
1351@@ -284,22 +286,22 @@
1352 WindowModelNotifier notifier;
1353 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1354
1355- auto mirWindowInfo1 = createMirALWindowInfo();
1356- auto mirWindowInfo2 = createMirALWindowInfo();
1357- auto mirWindowInfo3 = createMirALWindowInfo();
1358-
1359- notifier.addWindow(mirWindowInfo1);
1360- notifier.addWindow(mirWindowInfo2);
1361- notifier.removeWindow(mirWindowInfo1);
1362-
1363- notifier.addWindow(mirWindowInfo3);
1364+ auto newWindow1 = createNewWindow();
1365+ auto newWindow2 = createNewWindow();
1366+ auto newWindow3 = createNewWindow();
1367+
1368+ notifier.windowAdded(newWindow1);
1369+ notifier.windowAdded(newWindow2);
1370+ notifier.windowRemoved(newWindow1.windowInfo);
1371+
1372+ notifier.windowAdded(newWindow3);
1373 flushEvents();
1374
1375 ASSERT_EQ(2, model.count());
1376 auto miralWindow2 = getMirALWindowFromModel(model, 0);
1377- EXPECT_EQ(mirWindowInfo2.window(), miralWindow2);
1378+ EXPECT_EQ(newWindow2.windowInfo.window(), miralWindow2);
1379 auto miralWindow3 = getMirALWindowFromModel(model, 1);
1380- EXPECT_EQ(mirWindowInfo3.window(), miralWindow3);
1381+ EXPECT_EQ(newWindow3.windowInfo.window(), miralWindow3);
1382 }
1383
1384 /*
1385@@ -310,22 +312,22 @@
1386 WindowModelNotifier notifier;
1387 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1388
1389- auto mirWindowInfo1 = createMirALWindowInfo();
1390- auto mirWindowInfo2 = createMirALWindowInfo();
1391- auto mirWindowInfo3 = createMirALWindowInfo();
1392-
1393- notifier.addWindow(mirWindowInfo1);
1394- notifier.addWindow(mirWindowInfo2);
1395- notifier.addWindow(mirWindowInfo3);
1396-
1397- notifier.removeWindow(mirWindowInfo2);
1398+ auto newWindow1 = createNewWindow();
1399+ auto newWindow2 = createNewWindow();
1400+ auto newWindow3 = createNewWindow();
1401+
1402+ notifier.windowAdded(newWindow1);
1403+ notifier.windowAdded(newWindow2);
1404+ notifier.windowAdded(newWindow3);
1405+
1406+ notifier.windowRemoved(newWindow2.windowInfo);
1407 flushEvents();
1408
1409 ASSERT_EQ(2, model.count());
1410 auto miralWindow1 = getMirALWindowFromModel(model, 0);
1411- EXPECT_EQ(mirWindowInfo1.window(), miralWindow1);
1412+ EXPECT_EQ(newWindow1.windowInfo.window(), miralWindow1);
1413 auto miralWindow3 = getMirALWindowFromModel(model, 1);
1414- EXPECT_EQ(mirWindowInfo3.window(), miralWindow3);
1415+ EXPECT_EQ(newWindow3.windowInfo.window(), miralWindow3);
1416 }
1417
1418 /*
1419@@ -336,16 +338,16 @@
1420 WindowModelNotifier notifier;
1421 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1422
1423- auto mirWindowInfo1 = createMirALWindowInfo();
1424- notifier.addWindow(mirWindowInfo1);
1425+ auto newWindow1 = createNewWindow();
1426+ notifier.windowAdded(newWindow1);
1427
1428 // Raise first window
1429- notifier.raiseWindows({mirWindowInfo1.window()});
1430+ notifier.windowsRaised({newWindow1.windowInfo.window()});
1431 flushEvents();
1432
1433 ASSERT_EQ(1, model.count());
1434 auto topWindow = getMirALWindowFromModel(model, 0);
1435- EXPECT_EQ(mirWindowInfo1.window(), topWindow);
1436+ EXPECT_EQ(newWindow1.windowInfo.window(), topWindow);
1437 }
1438
1439 /*
1440@@ -356,19 +358,19 @@
1441 WindowModelNotifier notifier;
1442 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1443
1444- auto mirWindowInfo1 = createMirALWindowInfo();
1445- auto mirWindowInfo2 = createMirALWindowInfo();
1446- notifier.addWindow(mirWindowInfo1);
1447- notifier.addWindow(mirWindowInfo2);
1448+ auto newWindow1 = createNewWindow();
1449+ auto newWindow2 = createNewWindow();
1450+ notifier.windowAdded(newWindow1);
1451+ notifier.windowAdded(newWindow2);
1452
1453 // Raise second window (currently on top)
1454- notifier.raiseWindows({mirWindowInfo2.window()});
1455+ notifier.windowsRaised({newWindow2.windowInfo.window()});
1456 flushEvents();
1457
1458 // Check second window still on top
1459 ASSERT_EQ(2, model.count());
1460 auto topWindow = getMirALWindowFromModel(model, 1);
1461- EXPECT_EQ(mirWindowInfo2.window(), topWindow);
1462+ EXPECT_EQ(newWindow2.windowInfo.window(), topWindow);
1463 }
1464
1465 /*
1466@@ -379,19 +381,19 @@
1467 WindowModelNotifier notifier;
1468 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1469
1470- auto mirWindowInfo1 = createMirALWindowInfo();
1471- auto mirWindowInfo2 = createMirALWindowInfo();
1472- notifier.addWindow(mirWindowInfo1);
1473- notifier.addWindow(mirWindowInfo2);
1474+ auto newWindow1 = createNewWindow();
1475+ auto newWindow2 = createNewWindow();
1476+ notifier.windowAdded(newWindow1);
1477+ notifier.windowAdded(newWindow2);
1478
1479 // Raise first window (currently at bottom)
1480- notifier.raiseWindows({mirWindowInfo1.window()});
1481+ notifier.windowsRaised({newWindow1.windowInfo.window()});
1482 flushEvents();
1483
1484 // Check first window now on top
1485 ASSERT_EQ(2, model.count());
1486 auto topWindow = getMirALWindowFromModel(model, 1);
1487- EXPECT_EQ(mirWindowInfo1.window(), topWindow);
1488+ EXPECT_EQ(newWindow1.windowInfo.window(), topWindow);
1489 }
1490
1491 /*
1492@@ -402,12 +404,12 @@
1493 WindowModelNotifier notifier;
1494 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1495
1496- auto mirWindowInfo1 = createMirALWindowInfo();
1497- auto mirWindowInfo2 = createMirALWindowInfo();
1498- auto mirWindowInfo3 = createMirALWindowInfo();
1499- notifier.addWindow(mirWindowInfo1);
1500- notifier.addWindow(mirWindowInfo2);
1501- notifier.addWindow(mirWindowInfo3);
1502+ auto newWindow1 = createNewWindow();
1503+ auto newWindow2 = createNewWindow();
1504+ auto newWindow3 = createNewWindow();
1505+ notifier.windowAdded(newWindow1);
1506+ notifier.windowAdded(newWindow2);
1507+ notifier.windowAdded(newWindow3);
1508
1509 // Current model state
1510 // 2: Window3
1511@@ -415,7 +417,7 @@
1512 // 0: Window1
1513
1514 // Raise windows 1 & 2 (currently at bottom)
1515- notifier.raiseWindows({mirWindowInfo1.window(), mirWindowInfo2.window()});
1516+ notifier.windowsRaised({newWindow1.windowInfo.window(), newWindow2.windowInfo.window()});
1517
1518 // Model should now be like this:
1519 // 2: Window1
1520@@ -425,11 +427,11 @@
1521
1522 ASSERT_EQ(3, model.count());
1523 auto topWindow = getMirALWindowFromModel(model, 2);
1524- EXPECT_EQ(mirWindowInfo1.window(), topWindow);
1525+ EXPECT_EQ(newWindow1.windowInfo.window(), topWindow);
1526 auto middleWindow = getMirALWindowFromModel(model, 1);
1527- EXPECT_EQ(mirWindowInfo2.window(), middleWindow);
1528+ EXPECT_EQ(newWindow2.windowInfo.window(), middleWindow);
1529 auto bottomWindow = getMirALWindowFromModel(model, 0);
1530- EXPECT_EQ(mirWindowInfo3.window(), bottomWindow);
1531+ EXPECT_EQ(newWindow3.windowInfo.window(), bottomWindow);
1532 }
1533
1534 /*
1535@@ -440,17 +442,17 @@
1536 WindowModelNotifier notifier;
1537 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1538
1539- auto mirWindowInfo1 = createMirALWindowInfo();
1540- auto mirWindowInfo2 = createMirALWindowInfo();
1541- notifier.addWindow(mirWindowInfo1);
1542- notifier.addWindow(mirWindowInfo2);
1543+ auto newWindow1 = createNewWindow();
1544+ auto newWindow2 = createNewWindow();
1545+ notifier.windowAdded(newWindow1);
1546+ notifier.windowAdded(newWindow2);
1547
1548 // Current model state
1549 // 1: Window2
1550 // 0: Window1
1551
1552 // Raise windows 1 & 2 (in opposite order)
1553- notifier.raiseWindows({mirWindowInfo1.window(), mirWindowInfo2.window()});
1554+ notifier.windowsRaised({newWindow1.windowInfo.window(), newWindow2.windowInfo.window()});
1555
1556 // Model should now be like this:
1557 // 1: Window1
1558@@ -459,9 +461,9 @@
1559
1560 ASSERT_EQ(2, model.count());
1561 auto topWindow = getMirALWindowFromModel(model, 1);
1562- EXPECT_EQ(mirWindowInfo1.window(), topWindow);
1563+ EXPECT_EQ(newWindow1.windowInfo.window(), topWindow);
1564 auto bottomWindow = getMirALWindowFromModel(model, 0);
1565- EXPECT_EQ(mirWindowInfo2.window(), bottomWindow);
1566+ EXPECT_EQ(newWindow2.windowInfo.window(), bottomWindow);
1567 }
1568
1569 /*
1570@@ -473,12 +475,12 @@
1571 WindowModelNotifier notifier;
1572 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1573
1574- auto mirWindowInfo1 = createMirALWindowInfo();
1575- auto mirWindowInfo2 = createMirALWindowInfo();
1576- auto mirWindowInfo3 = createMirALWindowInfo();
1577- notifier.addWindow(mirWindowInfo1);
1578- notifier.addWindow(mirWindowInfo2);
1579- notifier.addWindow(mirWindowInfo3);
1580+ auto newWindow1 = createNewWindow();
1581+ auto newWindow2 = createNewWindow();
1582+ auto newWindow3 = createNewWindow();
1583+ notifier.windowAdded(newWindow1);
1584+ notifier.windowAdded(newWindow2);
1585+ notifier.windowAdded(newWindow3);
1586
1587 // Current model state
1588 // 2: Window3
1589@@ -486,7 +488,7 @@
1590 // 0: Window1
1591
1592 // Raise windows 2 & 1 (i.e. bottom two, but in opposite order)
1593- notifier.raiseWindows({mirWindowInfo2.window(), mirWindowInfo1.window()});
1594+ notifier.windowsRaised({newWindow2.windowInfo.window(), newWindow1.windowInfo.window()});
1595
1596 // Model should now be like this:
1597 // 2: Window2
1598@@ -496,11 +498,11 @@
1599
1600 ASSERT_EQ(3, model.count());
1601 auto topWindow = getMirALWindowFromModel(model, 2);
1602- EXPECT_EQ(mirWindowInfo2.window(), topWindow);
1603+ EXPECT_EQ(newWindow2.windowInfo.window(), topWindow);
1604 auto middleWindow = getMirALWindowFromModel(model, 1);
1605- EXPECT_EQ(mirWindowInfo1.window(), middleWindow);
1606+ EXPECT_EQ(newWindow1.windowInfo.window(), middleWindow);
1607 auto bottomWindow = getMirALWindowFromModel(model, 0);
1608- EXPECT_EQ(mirWindowInfo3.window(), bottomWindow);
1609+ EXPECT_EQ(newWindow3.windowInfo.window(), bottomWindow);
1610 }
1611
1612 /*
1613@@ -513,8 +515,8 @@
1614
1615 QPoint position(100, 200);
1616
1617- auto mirWindowInfo = createMirALWindowInfo(position);
1618- notifier.addWindow(mirWindowInfo);
1619+ auto newWindow = createNewWindow(position);
1620+ notifier.windowAdded(newWindow);
1621 flushEvents();
1622
1623 auto surface = getMirSurfaceFromModel(model, 0);
1624@@ -532,13 +534,13 @@
1625 QPoint oldPosition(100, 200),
1626 newPosition(150, 220);
1627
1628- auto mirWindowInfo = createMirALWindowInfo(oldPosition);
1629- notifier.addWindow(mirWindowInfo);
1630+ auto newWindow = createNewWindow(oldPosition);
1631+ notifier.windowAdded(newWindow);
1632
1633 auto surface = getMirSurfaceFromModel(model, 0);
1634
1635 // Move window, check new position set
1636- notifier.moveWindow(mirWindowInfo, toMirPoint(newPosition));
1637+ notifier.windowMoved(newWindow.windowInfo, newPosition);
1638 flushEvents();
1639
1640 EXPECT_EQ(newPosition, surface->position());
1641@@ -555,15 +557,15 @@
1642 QPoint oldPosition(100, 200),
1643 newPosition(150, 220);
1644
1645- auto mirWindowInfo1 = createMirALWindowInfo(oldPosition);
1646- auto mirWindowInfo2 = createMirALWindowInfo(QPoint(300, 400));
1647- notifier.addWindow(mirWindowInfo1);
1648- notifier.addWindow(mirWindowInfo2);
1649+ auto newWindow1 = createNewWindow(oldPosition);
1650+ auto newWindow2 = createNewWindow(QPoint(300, 400));
1651+ notifier.windowAdded(newWindow1);
1652+ notifier.windowAdded(newWindow2);
1653
1654- auto surface = getMirSurfaceFromModel(model, 0); // will be MirSurface for mirWindowInfo1
1655+ auto surface = getMirSurfaceFromModel(model, 0); // will be MirSurface for newWindow1
1656
1657 // Move window, check new position set
1658- notifier.moveWindow(mirWindowInfo1, toMirPoint(newPosition));
1659+ notifier.windowMoved(newWindow1.windowInfo, newPosition);
1660 flushEvents();
1661
1662 EXPECT_EQ(newPosition, surface->position());
1663@@ -579,15 +581,15 @@
1664
1665 QPoint fixedPosition(300, 400);
1666
1667- auto mirWindowInfo1 = createMirALWindowInfo(QPoint(100, 200));
1668- auto mirWindowInfo2 = createMirALWindowInfo(fixedPosition);
1669- notifier.addWindow(mirWindowInfo1);
1670- notifier.addWindow(mirWindowInfo2);
1671+ auto newWindow1 = createNewWindow(QPoint(100, 200));
1672+ auto newWindow2 = createNewWindow(fixedPosition);
1673+ notifier.windowAdded(newWindow1);
1674+ notifier.windowAdded(newWindow2);
1675
1676- auto surface = getMirSurfaceFromModel(model, 1); // will be MirSurface for mirWindowInfo2
1677+ auto surface = getMirSurfaceFromModel(model, 1); // will be MirSurface for newWindow2
1678
1679 // Move window, check new position set
1680- notifier.moveWindow(mirWindowInfo1, toMirPoint(QPoint(350, 420)));
1681+ notifier.windowMoved(newWindow1.windowInfo, QPoint(350, 420));
1682 flushEvents();
1683
1684 // Ensure other window untouched
1685@@ -604,8 +606,8 @@
1686
1687 QSize size(300, 200);
1688
1689- auto mirWindowInfo1 = createMirALWindowInfo(QPoint(), size);
1690- notifier.addWindow(mirWindowInfo1);
1691+ auto newWindow1 = createNewWindow(QPoint(), size);
1692+ notifier.windowAdded(newWindow1);
1693 flushEvents();
1694
1695 auto surface = getMirSurfaceFromModel(model, 0);
1696@@ -622,13 +624,13 @@
1697
1698 QSize newSize(150, 220);
1699
1700- auto mirWindowInfo1 = createMirALWindowInfo(QPoint(), QSize(300, 200));
1701- notifier.addWindow(mirWindowInfo1);
1702+ auto newWindow1 = createNewWindow(QPoint(), QSize(300, 200));
1703+ notifier.windowAdded(newWindow1);
1704
1705 auto surface = getMirSurfaceFromModel(model, 0);
1706
1707 // Resize window, check new size set
1708- notifier.resizeWindow(mirWindowInfo1, toMirSize(newSize));
1709+ notifier.windowResized(newWindow1.windowInfo, newSize);
1710 flushEvents();
1711
1712 EXPECT_EQ(newSize, surface->size());
1713@@ -644,15 +646,15 @@
1714
1715 QSize newSize(150, 220);
1716
1717- auto mirWindowInfo1 = createMirALWindowInfo(QPoint(), QSize(100, 200));
1718- auto mirWindowInfo2 = createMirALWindowInfo(QPoint(), QSize(300, 400));
1719- notifier.addWindow(mirWindowInfo1);
1720- notifier.addWindow(mirWindowInfo2);
1721+ auto newWindow1 = createNewWindow(QPoint(), QSize(100, 200));
1722+ auto newWindow2 = createNewWindow(QPoint(), QSize(300, 400));
1723+ notifier.windowAdded(newWindow1);
1724+ notifier.windowAdded(newWindow2);
1725
1726 auto surface = getMirSurfaceFromModel(model, 0);
1727
1728 // Resize window, check new size set
1729- notifier.resizeWindow(mirWindowInfo1, toMirSize(newSize));
1730+ notifier.windowResized(newWindow1.windowInfo, newSize);
1731 flushEvents();
1732
1733 EXPECT_EQ(newSize, surface->size());
1734@@ -668,15 +670,15 @@
1735
1736 QSize fixedSize(300, 400);
1737
1738- auto mirWindowInfo1 = createMirALWindowInfo(QPoint(), QSize(100, 200));
1739- auto mirWindowInfo2 = createMirALWindowInfo(QPoint(), fixedSize);
1740- notifier.addWindow(mirWindowInfo1);
1741- notifier.addWindow(mirWindowInfo2);
1742+ auto newWindow1 = createNewWindow(QPoint(), QSize(100, 200));
1743+ auto newWindow2 = createNewWindow(QPoint(), fixedSize);
1744+ notifier.windowAdded(newWindow1);
1745+ notifier.windowAdded(newWindow2);
1746
1747 auto surface = getMirSurfaceFromModel(model, 1);
1748
1749 // Resize window
1750- notifier.resizeWindow(mirWindowInfo1, toMirSize(QSize(150, 220)));
1751+ notifier.windowResized(newWindow1.windowInfo, QSize(150, 220));
1752 flushEvents();
1753
1754 // Ensure other window untouched
1755@@ -684,7 +686,7 @@
1756 }
1757
1758 /*
1759- * Test: that the WindowModelNotifier.addWindow for an Input Method Window causes
1760+ * Test: that the WindowModelNotifier.windowAdded for an Input Method Window causes
1761 * the Qt-side WindowModel to register the input method surface
1762 */
1763 TEST_F(WindowModelTest, WhenAddInputMethodWindowNotifiedModelEmitsInputMethodChangedSignal)
1764@@ -692,18 +694,18 @@
1765 WindowModelNotifier notifier;
1766 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1767
1768- auto mirWindowInfo = createMirALWindowInfoForInputMethod();
1769+ auto newWindow = createNewWindowForInputMethod();
1770
1771 QSignalSpy spyCountChanged(&model, SIGNAL(inputMethodSurfaceChanged(MirSurfaceInterface*)));
1772
1773- notifier.addWindow(mirWindowInfo);
1774+ notifier.windowAdded(newWindow);
1775 flushEvents();
1776
1777 EXPECT_EQ(1, spyCountChanged.count());
1778 }
1779
1780 /*
1781- * Test: that the WindowModelNotifier.addWindow for an Input Method Window causes
1782+ * Test: that the WindowModelNotifier.windowAdded for an Input Method Window causes
1783 * the Qt-side WindowModel::inputMethodSurface property to be correctly set
1784 */
1785 TEST_F(WindowModelTest, WhenAddInputMethodWindowNotifiedModelPropertyHasCorrectWindow)
1786@@ -711,17 +713,17 @@
1787 WindowModelNotifier notifier;
1788 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1789
1790- auto mirWindowInfo = createMirALWindowInfoForInputMethod();
1791+ auto newWindow = createNewWindowForInputMethod();
1792
1793- notifier.addWindow(mirWindowInfo);
1794+ notifier.windowAdded(newWindow);
1795 flushEvents();
1796
1797 auto miralWindow = static_cast<MirSurface*>(model.inputMethodSurface())->window();
1798- EXPECT_EQ(mirWindowInfo.window(), miralWindow);
1799+ EXPECT_EQ(newWindow.windowInfo.window(), miralWindow);
1800 }
1801
1802 /*
1803- * Test: that the WindowModelNotifier.removeWindow for an Input Method Window causes
1804+ * Test: that the WindowModelNotifier.windowRemoved for an Input Method Window causes
1805 * the Qt-side WindowModel to reset the WindowModel::inputMethodSurface property to null
1806 */
1807 TEST_F(WindowModelTest, WhenRemoveInputMethodWindowNotifiedModelPropertyReset)
1808@@ -729,11 +731,11 @@
1809 WindowModelNotifier notifier;
1810 WindowModel model(&notifier, nullptr); // no need for controller in this testcase
1811
1812- auto mirWindowInfo = createMirALWindowInfoForInputMethod();
1813- notifier.addWindow(mirWindowInfo);
1814+ auto newWindow = createNewWindowForInputMethod();
1815+ notifier.windowAdded(newWindow);
1816
1817 // Test removing the window
1818- notifier.removeWindow(mirWindowInfo);
1819+ notifier.windowRemoved(newWindow.windowInfo);
1820 flushEvents();
1821
1822 EXPECT_EQ(nullptr, model.inputMethodSurface());
1823
1824=== modified file 'miral/window_info.cpp'
1825--- miral/window_info.cpp 2016-08-05 13:38:53 +0000
1826+++ miral/window_info.cpp 2016-09-13 12:26:41 +0000
1827@@ -35,6 +35,7 @@
1828 struct miral::WindowInfo::Self
1829 {
1830 Self(Window window, WindowSpecification const& params);
1831+ Self();
1832
1833 Window window;
1834 mir::optional_value<std::string> name;
1835@@ -77,6 +78,18 @@
1836 output_id = params.output_id().value();
1837 }
1838
1839+miral::WindowInfo::Self::Self() :
1840+ type{mir_surface_type_normal},
1841+ state{mir_surface_state_unknown},
1842+ preferred_orientation{mir_orientation_mode_any}
1843+{
1844+}
1845+
1846+miral::WindowInfo::WindowInfo() :
1847+ self{std::make_unique<Self>()}
1848+{
1849+}
1850+
1851 miral::WindowInfo::WindowInfo(
1852 Window const& window,
1853 WindowSpecification const& params) :

Subscribers

People subscribed via source and target branches