Merge lp:~nick-dedekind/qtmir/screens-api into lp:qtmir

Proposed by Nick Dedekind
Status: Work in progress
Proposed branch: lp:~nick-dedekind/qtmir/screens-api
Merge into: lp:qtmir
Prerequisite: lp:~nick-dedekind/qtmir/multiwindow.configuration
Diff against target: 3924 lines (+1579/-1208)
68 files modified
cmake/modules/UseLttngGenTp.cmake (+1/-1)
debian/changelog (+4/-2)
demos/qml-demo-shell/CMakeLists.txt (+2/-0)
demos/qml-demo-shell/Shell.qml (+0/-171)
demos/qml-demo-shell/main.cpp (+10/-0)
demos/qml-demo-shell/qml-demo-shell.qml (+7/-1)
demos/qml-demo-shell/screens.cpp (+100/-0)
demos/qml-demo-shell/screens.h (+58/-0)
demos/qml-demo-shell/screenwindow.cpp (+47/-0)
demos/qml-demo-shell/screenwindow.h (+49/-0)
include/qtmir/miral/display_configuration_storage.h (+5/-11)
include/qtmir/miral/display_id.h (+23/-0)
include/qtmir/mirserverapplication.h (+12/-1)
include/qtmir/qtmir.h (+14/-0)
include/qtmir/screen.h (+120/-0)
include/qtmir/screens.h (+50/-0)
include/qtmir/types.h (+0/-3)
include/qtmir/windowmanagementpolicy.h (+10/-3)
src/common/windowmodelnotifier.h (+25/-1)
src/common/workspacecontrollerinterface.h (+50/-0)
src/modules/Unity/Application/CMakeLists.txt (+10/-5)
src/modules/Unity/Application/application_manager.cpp (+1/-1)
src/modules/Unity/Application/mirsurface.cpp (+30/-0)
src/modules/Unity/Application/mirsurface.h (+3/-1)
src/modules/Unity/Application/plugin.cpp (+7/-1)
src/modules/Unity/Application/surfacemanager.cpp (+120/-80)
src/modules/Unity/Application/surfacemanager.h (+24/-12)
src/modules/Unity/Application/windowmodel.cpp (+2/-34)
src/modules/Unity/Application/windowmodel.h (+0/-4)
src/modules/Unity/CMakeLists.txt (+0/-1)
src/modules/Unity/Screens/CMakeLists.txt (+0/-35)
src/modules/Unity/Screens/plugin.cpp (+0/-59)
src/modules/Unity/Screens/qmldir (+0/-2)
src/modules/Unity/Screens/qquickscreenwindow.cpp (+0/-62)
src/modules/Unity/Screens/qquickscreenwindow.h (+0/-51)
src/modules/Unity/Screens/screen.cpp (+0/-213)
src/modules/Unity/Screens/screen.h (+0/-99)
src/modules/Unity/Screens/screens.cpp (+0/-140)
src/modules/Unity/Screens/screens.h (+0/-70)
src/modules/Unity/Screens/types.h (+0/-41)
src/platforms/mirserver/CMakeLists.txt (+18/-3)
src/platforms/mirserver/customscreenconfiguration.h (+0/-45)
src/platforms/mirserver/miral/CMakeLists.txt (+1/-0)
src/platforms/mirserver/miral/persist_display_config.cpp (+2/-2)
src/platforms/mirserver/mirserverapplication.cpp (+5/-3)
src/platforms/mirserver/platformscreen.cpp (+13/-4)
src/platforms/mirserver/platformscreen.h (+6/-3)
src/platforms/mirserver/qmirserver.cpp (+2/-0)
src/platforms/mirserver/qmirserver_p.cpp (+1/-0)
src/platforms/mirserver/qmirserver_p.h (+5/-0)
src/platforms/mirserver/qtmir.cpp (+15/-0)
src/platforms/mirserver/screenadaptor.cpp (+175/-0)
src/platforms/mirserver/screenadaptor.h (+66/-0)
src/platforms/mirserver/screenadaptormodel.cpp (+99/-0)
src/platforms/mirserver/screenadaptormodel.h (+45/-0)
src/platforms/mirserver/screenplatformwindow.cpp (+2/-2)
src/platforms/mirserver/screenscontroller.cpp (+8/-9)
src/platforms/mirserver/screenscontroller.h (+5/-5)
src/platforms/mirserver/screensmodel.cpp (+3/-3)
src/platforms/mirserver/screensmodel.h (+3/-3)
src/platforms/mirserver/windowmodelnotifier.cpp (+109/-0)
src/platforms/mirserver/workspacecontroller.cpp (+54/-0)
src/platforms/mirserver/workspacecontroller.h (+49/-0)
src/platforms/mirserver/wrappedwindowmanagementpolicy.cpp (+71/-0)
src/platforms/mirserver/wrappedwindowmanagementpolicy.h (+17/-2)
tests/mirserver/Screen/CMakeLists.txt (+1/-0)
tests/mirserver/ScreensModel/CMakeLists.txt (+1/-0)
tests/modules/SurfaceManager/surface_manager_test.cpp (+19/-19)
To merge this branch: bzr merge lp:~nick-dedekind/qtmir/screens-api
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+317964@code.launchpad.net

Commit message

Screens API

Description of the change

Screens API

To post a comment you must log in.
lp:~nick-dedekind/qtmir/screens-api updated
614. By Nick Dedekind

workspace policy

615. By Nick Dedekind

suface manager singleton

616. By Nick Dedekind

Surfaces track window changes. Better surface tracking

617. By Nick Dedekind

merged with parent

618. By Nick Dedekind

WindowNotifierObserver

619. By Nick Dedekind

signal renaming

620. By Nick Dedekind

const override

621. By Nick Dedekind

reverted to MirSurface create with NewWindow

622. By Nick Dedekind

merged with parent

623. By Nick Dedekind

removed Q_PROPERTY from qtmir::Screen

624. By Nick Dedekind

workspace controller & surface manager api

625. By Nick Dedekind

merged with parent

626. By Nick Dedekind

merged with parent

627. By Nick Dedekind

merged parent

628. By Nick Dedekind

merged with pre-req

629. By Nick Dedekind

better lttng deps

630. By Nick Dedekind

DisplayId

631. By Nick Dedekind

include def

632. By Nick Dedekind

merged with pre-req

633. By Nick Dedekind

merged pre-req

634. By Nick Dedekind

changelog update

635. By Nick Dedekind

changelog

Unmerged revisions

635. By Nick Dedekind

changelog

634. By Nick Dedekind

changelog update

633. By Nick Dedekind

merged pre-req

632. By Nick Dedekind

merged with pre-req

631. By Nick Dedekind

include def

630. By Nick Dedekind

DisplayId

629. By Nick Dedekind

better lttng deps

628. By Nick Dedekind

merged with pre-req

627. By Nick Dedekind

merged parent

626. By Nick Dedekind

merged with parent

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmake/modules/UseLttngGenTp.cmake'
2--- cmake/modules/UseLttngGenTp.cmake 2014-09-18 16:37:42 +0000
3+++ cmake/modules/UseLttngGenTp.cmake 2017-04-06 08:50:29 +0000
4@@ -21,4 +21,4 @@
5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
6 DEPENDS "${arg_NAME}.tp"
7 )
8-endfunction(add_lttng_gen_tp)
9\ No newline at end of file
10+endfunction(add_lttng_gen_tp)
11
12=== modified file 'debian/changelog'
13--- debian/changelog 2017-04-06 08:50:28 +0000
14+++ debian/changelog 2017-04-06 08:50:29 +0000
15@@ -1,12 +1,14 @@
16-qtmir (0.6.0ubuntu3) UNRELEASED; urgency=medium
17+qtmir (0.6.0ubuntu4) UNRELEASED; urgency=medium
18
19 [ Nick Dedekind ]
20 * Introduced QtMir API
21 * Support for multiple compositors per MirSurface
22 * Support multiple screen windows & cursors with qml instantiation
23 * Screen configuration API & implementation
24+ * Removed Unity.Screens
25+ * Support for workspaces
26
27- -- Nick Dedekind <nick.dedekind@canonical.com> Thu, 06 Apr 2017 09:48:21 +0100
28+ -- Nick Dedekind <nick.dedekind@canonical.com> Thu, 06 Apr 2017 09:49:24 +0100
29
30 qtmir (0.5.1+17.04.20170328-0ubuntu1) zesty; urgency=medium
31
32
33=== modified file 'demos/qml-demo-shell/CMakeLists.txt'
34--- demos/qml-demo-shell/CMakeLists.txt 2017-04-06 08:50:28 +0000
35+++ demos/qml-demo-shell/CMakeLists.txt 2017-04-06 08:50:29 +0000
36@@ -15,6 +15,8 @@
37
38 add_executable(${DEMO_SHELL}
39 pointerposition.cpp
40+ screenwindow.cpp
41+ screens.cpp
42 main.cpp
43 )
44
45
46=== removed file 'demos/qml-demo-shell/Shell.qml'
47--- demos/qml-demo-shell/Shell.qml 2017-04-06 08:50:28 +0000
48+++ demos/qml-demo-shell/Shell.qml 1970-01-01 00:00:00 +0000
49@@ -1,171 +0,0 @@
50-import QtQuick 2.4
51-import Unity.Application 0.1
52-import Mir.Pointer 0.1
53-
54-FocusScope {
55- id: root
56- focus: true
57-
58- Image {
59- id: unityLogo
60- source: "UnityLogo.png"
61- fillMode: Image.PreserveAspectFit
62- anchors.centerIn: parent
63- width: 600
64- height: 600
65-
66- RotationAnimation {
67- id: logoAnimation
68- target: unityLogo
69- from: 0
70- to: 359
71- duration: 3000
72- easing.type: Easing.Linear
73- loops: Animation.Infinite
74- }
75-
76- MultiPointTouchArea {
77- anchors.fill: parent
78- minimumTouchPoints:1
79- maximumTouchPoints:1
80- onPressed: {
81- if (logoAnimation.paused) {
82- logoAnimation.resume();
83- } else if (logoAnimation.running) {
84- logoAnimation.pause();
85- } else {
86- logoAnimation.start();
87- }
88- }
89- }
90- }
91-
92-
93- WindowModel {
94- id: windowModel;
95- }
96-
97- Item {
98- id: windowViewContainer
99- anchors.fill: parent
100-
101- Repeater {
102- model: windowModel
103-
104- delegate: MirSurfaceItem {
105- id: surfaceItem
106- surface: model.surface
107- consumesInput: true // QUESTION: why is this non-default?
108- x: surface.position.x
109- y: surface.position.y
110- width: surface.size.width
111- height: surface.size.height
112- focus: surface.focused
113- visible: surface.visible
114-
115- Rectangle {
116- anchors { top: parent.bottom; right: parent.right }
117- width: childrenRect.width
118- height: childrenRect.height
119- color: surface.focused ? "red" : "lightsteelblue"
120- opacity: 0.8
121- Text {
122- text: surface.position.x + "," + surface.position.y + " " + surface.size.width + "x" + surface.size.height
123- font.pixelSize: 10
124- }
125- }
126-
127- Rectangle { anchors.fill: parent; z: -1; color: "black"; opacity: 0.3 }
128- }
129- }
130- }
131-
132- Button {
133- anchors { right: parent.right; top: parent.top }
134- height: 30
135- width: 80
136- text: "Quit"
137- onClicked: Qt.quit()
138- }
139-
140- WindowModelDebugView {
141- anchors { right: parent.right; bottom: parent.bottom }
142- model: windowModel
143- }
144-
145- Text {
146- anchors { left: parent.left; bottom: parent.bottom }
147- text: "Move window: Ctrl+click\n
148-Resize window: Ctrl+Right click"
149- }
150-
151- Rectangle {
152- id: mousePointer
153- color: "black"
154- width: 6
155- height: 10
156- x: PointerPosition.x - window.screen.position.x
157- y: PointerPosition.y - window.screen.position.y
158- }
159-
160- MouseArea {
161- anchors.fill: parent
162- acceptedButtons: Qt.LeftButton | Qt.RightButton
163- hoverEnabled: false
164- property variant window: null
165- property int initialWindowXPosition
166- property int initialWindowYPosition
167- property int initialWindowWidth
168- property int initialWindowHeight
169- property int initialMouseXPosition
170- property int initialMouseYPosition
171- property var action
172-
173- function moveWindowBy(window, delta) {
174- window.surface.requestedPosition = Qt.point(initialWindowXPosition + delta.x,
175- initialWindowYPosition + delta.y);
176- }
177- function resizeWindowBy(window, delta) {
178- window.surface.resize(Qt.size(initialWindowWidth + delta.x,
179- initialWindowHeight + delta.y))
180- }
181-
182- onPressed: {
183- if (mouse.modifiers & Qt.ControlModifier) {
184- window = windowViewContainer.childAt(mouse.x, mouse.y)
185- if (!window) return;
186-
187- if (mouse.button == Qt.LeftButton) {
188- initialWindowXPosition = window.surface.position.x
189- initialWindowYPosition = window.surface.position.y
190- action = moveWindowBy
191- } else if (mouse.button == Qt.RightButton) {
192- initialWindowHeight = window.surface.size.height
193- initialWindowWidth = window.surface.size.width
194- action = resizeWindowBy
195- }
196- initialMouseXPosition = mouse.x
197- initialMouseYPosition = mouse.y
198- } else {
199- mouse.accepted = false
200- }
201- }
202-
203- onPositionChanged: {
204- if (!window) {
205- mouse.accepted = false
206- return
207- }
208- action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition))
209- }
210-
211- onReleased: {
212- if (!window) {
213- mouse.accepted = false
214- return
215- }
216- action(window, Qt.point(mouse.x - initialMouseXPosition, mouse.y - initialMouseYPosition))
217- window = null;
218- }
219- }
220-}
221
222=== modified file 'demos/qml-demo-shell/main.cpp'
223--- demos/qml-demo-shell/main.cpp 2017-04-06 08:50:28 +0000
224+++ demos/qml-demo-shell/main.cpp 2017-04-06 08:50:29 +0000
225@@ -25,6 +25,8 @@
226 #include <libintl.h>
227 #include "../paths.h"
228 #include "pointerposition.h"
229+#include "screenwindow.h"
230+#include "screens.h"
231
232 #include <qtmir/mirserverapplication.h>
233 #include <qtmir/displayconfigurationpolicy.h>
234@@ -191,6 +193,14 @@
235 qmlRegisterSingletonType<PointerPosition>("Mir.Pointer", 0, 1, "PointerPosition",
236 [](QQmlEngine*, QJSEngine*) -> QObject* { return PointerPosition::instance(); });
237
238+ qmlRegisterType<ScreenWindow>("QtMir", 0, 1, "ScreenWindow");
239+ qmlRegisterSingletonType<Screens>("QtMir", 0, 1, "Screens",
240+ [](QQmlEngine*, QJSEngine*) -> QObject* {
241+ static Screens* screens = new Screens();
242+ return screens;
243+ });
244+ qmlRegisterUncreatableType<qtmir::ScreenMode>("QtMir", 0, 1, "ScreenMode", "ScreenMode is not creatable.");
245+
246 qmlEngine->load(::qmlDirectory() + "qml-demo-shell/qml-demo-shell.qml");
247
248 int result = application->exec();
249
250=== modified file 'demos/qml-demo-shell/qml-demo-shell.qml'
251--- demos/qml-demo-shell/qml-demo-shell.qml 2017-04-06 08:50:28 +0000
252+++ demos/qml-demo-shell/qml-demo-shell.qml 2017-04-06 08:50:29 +0000
253@@ -1,5 +1,5 @@
254 import QtQuick 2.5
255-import Unity.Screens 0.1
256+import QtMir 0.1
257
258 Instantiator {
259 id: root
260@@ -11,6 +11,12 @@
261 visible: true
262 screen: model.screen
263
264+ Binding {
265+ target: model.screen
266+ property: "active"
267+ value: index == 0
268+ }
269+
270 Row {
271 x: 10
272 y: 10
273
274=== added file 'demos/qml-demo-shell/screens.cpp'
275--- demos/qml-demo-shell/screens.cpp 1970-01-01 00:00:00 +0000
276+++ demos/qml-demo-shell/screens.cpp 2017-04-06 08:50:29 +0000
277@@ -0,0 +1,100 @@
278+/*
279+ * Copyright (C) 2016-2017 Canonical, Ltd.
280+ *
281+ * This program is free software: you can redistribute it and/or modify it under
282+ * the terms of the GNU Lesser General Public License version 3, as published by
283+ * the Free Software Foundation.
284+ *
285+ * This program is distributed in the hope that it will be useful, but WITHOUT
286+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
287+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
288+ * Lesser General Public License for more details.
289+ *
290+ * You should have received a copy of the GNU Lesser General Public License
291+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
292+ */
293+
294+#include "screens.h"
295+
296+// qtmirserver
297+#include <qtmir/qtmir.h>
298+#include <qtmir/screens.h>
299+#include <qtmir/screen.h>
300+#include <QGuiApplication>
301+
302+// Qt
303+#include <QScreen>
304+#include <QWindow>
305+
306+Screens::Screens(QObject *parent)
307+ : QAbstractListModel(parent)
308+ , m_wrapped(qtmir::get_screen_model())
309+{
310+ if (qGuiApp->platformName() != QLatin1String("mirserver")) {
311+ qCritical("Not using 'mirserver' QPA plugin. Using qGuiApp may produce unknown results.");
312+ }
313+
314+ connect(m_wrapped.data(), &qtmir::Screens::screenAdded, this, &Screens::onScreenAdded);
315+ connect(m_wrapped.data(), &qtmir::Screens::screenRemoved, this, &Screens::onScreenRemoved);
316+
317+ Q_FOREACH(qtmir::Screen* screen, m_wrapped->screens()) {
318+ m_screenList.push_back(screen);
319+ }
320+}
321+
322+QHash<int, QByteArray> Screens::roleNames() const
323+{
324+ QHash<int, QByteArray> roles;
325+ roles[ScreenRole] = "screen";
326+ return roles;
327+}
328+
329+QVariant Screens::data(const QModelIndex &index, int role) const
330+{
331+ if (!index.isValid() || index.row() >= m_screenList.size()) {
332+ return QVariant();
333+ }
334+
335+ switch(role) {
336+ case ScreenRole:
337+ return QVariant::fromValue(m_screenList.at(index.row()));
338+ } // switch
339+
340+ return QVariant();
341+}
342+
343+int Screens::rowCount(const QModelIndex &) const
344+{
345+ return m_screenList.size();
346+}
347+
348+void Screens::onScreenAdded(qtmir::Screen *screen)
349+{
350+ Q_FOREACH(auto screenWrapper, m_screenList) {
351+ if (screenWrapper == screen) return;
352+ }
353+
354+ beginInsertRows(QModelIndex(), m_screenList.count(), m_screenList.count());
355+ m_screenList.push_back(screen);
356+ endInsertRows();
357+ Q_EMIT screenAdded(screen);
358+}
359+
360+void Screens::onScreenRemoved(qtmir::Screen *screen)
361+{
362+ int index = 0;
363+ QMutableListIterator<qtmir::Screen*> iter(m_screenList);
364+ while(iter.hasNext()) {
365+ auto screenWrapper = iter.next();
366+ if (screenWrapper == screen) {
367+
368+ beginRemoveRows(QModelIndex(), index, index);
369+ iter.remove();
370+ endRemoveRows();
371+
372+ Q_EMIT screenRemoved(screen);
373+ break;
374+ }
375+ index++;
376+ }
377+}
378
379=== added file 'demos/qml-demo-shell/screens.h'
380--- demos/qml-demo-shell/screens.h 1970-01-01 00:00:00 +0000
381+++ demos/qml-demo-shell/screens.h 2017-04-06 08:50:29 +0000
382@@ -0,0 +1,58 @@
383+/*
384+ * Copyright (C) 2016 Canonical, Ltd.
385+ *
386+ * This program is free software: you can redistribute it and/or modify it under
387+ * the terms of the GNU Lesser General Public License version 3, as published by
388+ * the Free Software Foundation.
389+ *
390+ * This program is distributed in the hope that it will be useful, but WITHOUT
391+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
392+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
393+ * Lesser General Public License for more details.
394+ *
395+ * You should have received a copy of the GNU Lesser General Public License
396+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
397+ */
398+
399+#ifndef UNITY_SCREENS_H
400+#define UNITY_SCREENS_H
401+
402+#include <QAbstractListModel>
403+#include <QSharedPointer>
404+
405+namespace qtmir
406+{
407+class Screen;
408+class Screens;
409+}
410+
411+class Screens : public QAbstractListModel
412+{
413+ Q_OBJECT
414+public:
415+ enum ItemRoles {
416+ ScreenRole = Qt::UserRole + 1
417+ };
418+
419+ explicit Screens(QObject *parent = 0);
420+ virtual ~Screens() noexcept = default;
421+
422+ /* QAbstractItemModel */
423+ QHash<int, QByteArray> roleNames() const override;
424+ QVariant data(const QModelIndex &index, int role = ScreenRole) const override;
425+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
426+
427+Q_SIGNALS:
428+ void screenAdded(qtmir::Screen* screen);
429+ void screenRemoved(qtmir::Screen* screen);
430+
431+private Q_SLOTS:
432+ void onScreenAdded(qtmir::Screen *screen);
433+ void onScreenRemoved(qtmir::Screen *screen);
434+
435+private:
436+ QList<qtmir::Screen*> m_screenList;
437+ QSharedPointer<qtmir::Screens> m_wrapped;
438+};
439+
440+#endif // SCREENS_H
441
442=== added file 'demos/qml-demo-shell/screenwindow.cpp'
443--- demos/qml-demo-shell/screenwindow.cpp 1970-01-01 00:00:00 +0000
444+++ demos/qml-demo-shell/screenwindow.cpp 2017-04-06 08:50:29 +0000
445@@ -0,0 +1,47 @@
446+/*
447+ * Copyright (C) 2016-2017 Canonical, Ltd.
448+ *
449+ * This program is free software: you can redistribute it and/or modify it under
450+ * the terms of the GNU Lesser General Public License version 3, as published by
451+ * the Free Software Foundation.
452+ *
453+ * This program is distributed in the hope that it will be useful, but WITHOUT
454+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
455+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
456+ * Lesser General Public License for more details.
457+ *
458+ * You should have received a copy of the GNU Lesser General Public License
459+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
460+ */
461+
462+#include "screenwindow.h"
463+
464+// Qt
465+#include <QGuiApplication>
466+#include <QDebug>
467+
468+ScreenWindow::ScreenWindow(QQuickWindow *parent)
469+ : QQuickWindow(parent)
470+{
471+ if (qGuiApp->platformName() != QLatin1String("mirserver")) {
472+ qCritical("Not using 'mirserver' QPA plugin. Using ScreenWindow may produce unknown results.");
473+ }
474+}
475+
476+ScreenWindow::~ScreenWindow()
477+{
478+}
479+
480+qtmir::Screen *ScreenWindow::screenWrapper() const
481+{
482+ return m_screen.data();
483+}
484+
485+void ScreenWindow::setScreenWrapper(qtmir::Screen *screen)
486+{
487+ if (m_screen != screen) {
488+ m_screen = screen;
489+ Q_EMIT screenWrapperChanged();
490+ }
491+ QQuickWindow::setScreen(screen->qscreen());
492+}
493
494=== added file 'demos/qml-demo-shell/screenwindow.h'
495--- demos/qml-demo-shell/screenwindow.h 1970-01-01 00:00:00 +0000
496+++ demos/qml-demo-shell/screenwindow.h 2017-04-06 08:50:29 +0000
497@@ -0,0 +1,49 @@
498+/*
499+ * Copyright (C) 2016-2017 Canonical, Ltd.
500+ *
501+ * This program is free software: you can redistribute it and/or modify it under
502+ * the terms of the GNU Lesser General Public License version 3, as published by
503+ * the Free Software Foundation.
504+ *
505+ * This program is distributed in the hope that it will be useful, but WITHOUT
506+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
507+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
508+ * Lesser General Public License for more details.
509+ *
510+ * You should have received a copy of the GNU Lesser General Public License
511+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
512+ */
513+
514+#ifndef UNITY_SCREENWINDOW_H
515+#define UNITY_SCREENWINDOW_H
516+
517+#include <QQuickWindow>
518+#include <QPointer>
519+
520+#include "qtmir/screen.h"
521+
522+class ScreenAdapter;
523+
524+/*
525+ * ScreenWindow - wrapper of QQuickWindow to enable QML to specify destination screen.
526+**/
527+class ScreenWindow : public QQuickWindow
528+{
529+ Q_OBJECT
530+ Q_PROPERTY(qtmir::Screen *screen READ screenWrapper WRITE setScreenWrapper NOTIFY screenWrapperChanged)
531+ Q_PROPERTY(int winId READ winId CONSTANT)
532+public:
533+ explicit ScreenWindow(QQuickWindow *parent = 0);
534+ ~ScreenWindow();
535+
536+ qtmir::Screen *screenWrapper() const;
537+ void setScreenWrapper(qtmir::Screen *screen);
538+
539+Q_SIGNALS:
540+ void screenWrapperChanged();
541+
542+private:
543+ QPointer<qtmir::Screen> m_screen;
544+};
545+
546+#endif // UNITY_SCREENWINDOW_H
547
548=== modified file 'include/qtmir/miral/display_configuration_storage.h'
549--- include/qtmir/miral/display_configuration_storage.h 2017-04-06 08:50:28 +0000
550+++ include/qtmir/miral/display_configuration_storage.h 2017-04-06 08:50:29 +0000
551@@ -19,22 +19,16 @@
552 #ifndef MIRAL_DISPLAY_CONFIGURATION_STORAGE_H
553 #define MIRAL_DISPLAY_CONFIGURATION_STORAGE_H
554
555-#include "mir/geometry/rectangle.h"
556-#include "mir/optional_value.h"
557-#include "mir_toolkit/common.h"
558+#include <mir/geometry/rectangle.h>
559+#include <mir/optional_value.h>
560+#include <mir_toolkit/common.h>
561
562-#include "edid.h"
563+#include "display_id.h"
564
565 // Prototyping namespace for later incorporation in MirAL
566 namespace miral
567 {
568
569-struct DisplayId
570-{
571- Edid edid;
572- int output_id; // helps to identify a monitor if we have two of the same.
573-};
574-
575 struct DisplayConfigurationOptions
576 {
577 mir::optional_value<bool> used;
578@@ -59,6 +53,6 @@
579 virtual bool load(const DisplayId&, DisplayConfigurationOptions&) const = 0;
580 };
581
582-}
583+} // namespace miral
584
585 #endif // MIRAL_DISPLAY_CONFIGURATION_STORAGE_H
586
587=== added file 'include/qtmir/miral/display_id.h'
588--- include/qtmir/miral/display_id.h 1970-01-01 00:00:00 +0000
589+++ include/qtmir/miral/display_id.h 2017-04-06 08:50:29 +0000
590@@ -0,0 +1,23 @@
591+#ifndef MIRAL_DISPLAY_ID_H
592+#define MIRAL_DISPLAY_ID_H
593+
594+#include <mir/int_wrapper.h>
595+
596+#include "edid.h"
597+
598+namespace mir { namespace graphics { namespace detail { struct GraphicsConfOutputIdTag; } } }
599+
600+// Prototyping namespace for later incorporation in MirAL
601+namespace miral
602+{
603+using OutputId = mir::IntWrapper<mir::graphics::detail::GraphicsConfOutputIdTag>;
604+
605+struct DisplayId
606+{
607+ Edid edid;
608+ OutputId output_id; // helps to identify a monitor if we have two of the same.
609+};
610+
611+} // namespace miral
612+
613+#endif // MIRAL_DISPLAY_ID_H
614
615=== modified file 'include/qtmir/mirserverapplication.h'
616--- include/qtmir/mirserverapplication.h 2017-04-06 08:50:28 +0000
617+++ include/qtmir/mirserverapplication.h 2017-04-06 08:50:29 +0000
618@@ -22,9 +22,20 @@
619 // std
620 #include <functional>
621
622+#if defined(qApp)
623+#undef qApp
624+#endif
625+#define qApp (static_cast<qtmir::GuiServerApplication *>(QCoreApplication::instance()))
626+
627+#if defined(qGuiApp)
628+#undef qGuiApp
629+#endif
630+#define qGuiApp (static_cast<qtmir::GuiServerApplication *>(QCoreApplication::instance()))
631+
632 class QMirServer;
633
634-namespace qtmir {
635+namespace qtmir
636+{
637
638 class WindowModelNotifier;
639 class AppNotifier;
640
641=== added file 'include/qtmir/qtmir.h'
642--- include/qtmir/qtmir.h 1970-01-01 00:00:00 +0000
643+++ include/qtmir/qtmir.h 2017-04-06 08:50:29 +0000
644@@ -0,0 +1,14 @@
645+#ifndef QTMIR_H
646+#define QTMIR_H
647+
648+#include <QSharedPointer>
649+
650+namespace qtmir
651+{
652+class Screens;
653+
654+QSharedPointer<Screens> get_screen_model();
655+
656+}
657+
658+#endif // QTMIR_H
659
660=== added file 'include/qtmir/screen.h'
661--- include/qtmir/screen.h 1970-01-01 00:00:00 +0000
662+++ include/qtmir/screen.h 2017-04-06 08:50:29 +0000
663@@ -0,0 +1,120 @@
664+/*
665+ * Copyright (C) 2017 Canonical, Ltd.
666+ *
667+ * This program is free software: you can redistribute it and/or modify it under
668+ * the terms of the GNU Lesser General Public License version 3, as published by
669+ * the Free Software Foundation.
670+ *
671+ * This program is distributed in the hope that it will be useful, but WITHOUT
672+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
673+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
674+ * Lesser General Public License for more details.
675+ *
676+ * You should have received a copy of the GNU Lesser General Public License
677+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
678+ */
679+
680+#ifndef QTMIR_SCREEN_H
681+#define QTMIR_SCREEN_H
682+
683+#include <qtmir/types.h>
684+#include <qtmir/miral/display_id.h>
685+
686+#include <QObject>
687+#include <QPointer>
688+
689+#include <QQmlListProperty>
690+#include <QSize>
691+#include <QPoint>
692+
693+#include <mir_toolkit/common.h>
694+
695+class QScreen;
696+
697+namespace qtmir {
698+
699+class ScreenMode;
700+class ScreenConfiguration;
701+
702+class Screen : public QObject
703+{
704+ Q_OBJECT
705+public:
706+ virtual miral::DisplayId displayId() const = 0;
707+ virtual bool used() const = 0;
708+ virtual QString name() const = 0;
709+ virtual float scale() const = 0;
710+ virtual QSizeF physicalSize() const = 0;
711+ virtual qtmir::FormFactor formFactor() const = 0;
712+ virtual qtmir::OutputTypes outputType() const = 0;
713+ virtual MirPowerMode powerMode() const = 0;
714+ virtual Qt::ScreenOrientation orientation() const = 0;
715+ virtual QPoint position() const = 0;
716+ virtual QQmlListProperty<qtmir::ScreenMode> availableModes() = 0;
717+ virtual uint currentModeIndex() const = 0;
718+ virtual bool isActive() const = 0;
719+ virtual void setActive(bool active) = 0;
720+
721+ virtual QScreen* qscreen() const = 0;
722+
723+ virtual ScreenConfiguration *beginConfiguration() const = 0;
724+ virtual bool applyConfiguration(ScreenConfiguration *configuration) = 0;
725+
726+Q_SIGNALS:
727+ void usedChanged();
728+ void nameChanged();
729+ void outputTypeChanged();
730+ void scaleChanged();
731+ void formFactorChanged();
732+ void powerModeChanged();
733+ void orientationChanged();
734+ void positionChanged();
735+ void currentModeIndexChanged();
736+ void physicalSizeChanged();
737+ void availableModesChanged();
738+ void activeChanged(bool active);
739+
740+protected:
741+ Screen(QObject* parent = 0): QObject(parent) {}
742+};
743+
744+class ScreenMode : public QObject
745+{
746+ Q_OBJECT
747+ Q_PROPERTY(qreal refreshRate MEMBER refreshRate CONSTANT)
748+ Q_PROPERTY(QSize size MEMBER size CONSTANT)
749+public:
750+ ScreenMode():refreshRate(-1) {}
751+ ScreenMode(qreal refreshRate, const QSize& size)
752+ : refreshRate{refreshRate},size{size}
753+ {}
754+
755+ qreal refreshRate;
756+ QSize size;
757+};
758+
759+struct ScreenConfiguration
760+{
761+ bool valid{false};
762+ miral::OutputId id;
763+
764+ bool used;
765+ QPoint topLeft;
766+ uint32_t currentModeIndex;
767+ MirPowerMode powerMode;
768+ MirOrientation orientation;
769+ float scale;
770+ qtmir::FormFactor formFactor;
771+};
772+
773+typedef QVector<ScreenConfiguration> ScreenConfigurationList;
774+
775+}
776+
777+Q_DECLARE_METATYPE(qtmir::Screen*)
778+Q_DECLARE_METATYPE(qtmir::ScreenMode*)
779+Q_DECLARE_METATYPE(qtmir::ScreenConfiguration*)
780+
781+Q_DECLARE_METATYPE(MirPowerMode)
782+
783+#endif // SCREEN_H
784
785=== added file 'include/qtmir/screens.h'
786--- include/qtmir/screens.h 1970-01-01 00:00:00 +0000
787+++ include/qtmir/screens.h 2017-04-06 08:50:29 +0000
788@@ -0,0 +1,50 @@
789+/*
790+ * Copyright (C) 2017 Canonical, Ltd.
791+ *
792+ * This program is free software: you can redistribute it and/or modify it under
793+ * the terms of the GNU Lesser General Public License version 3, as published by
794+ * the Free Software Foundation.
795+ *
796+ * This program is distributed in the hope that it will be useful, but WITHOUT
797+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
798+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
799+ * Lesser General Public License for more details.
800+ *
801+ * You should have received a copy of the GNU Lesser General Public License
802+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
803+ */
804+
805+#ifndef QTMIR_SCREENS_H
806+#define QTMIR_SCREENS_H
807+
808+#include <QObject>
809+#include <QVector>
810+
811+class QScreen;
812+
813+namespace qtmir
814+{
815+class Screen;
816+
817+class Screens : public QObject
818+{
819+ Q_OBJECT
820+ Q_PROPERTY(qtmir::Screen* activeScreen READ activeScreen NOTIFY activeScreenChanged)
821+public:
822+ Screens(QObject *parent = 0): QObject(parent) {}
823+ ~Screens() = default;
824+
825+ virtual QVector<qtmir::Screen*> screens() const = 0;
826+
827+ virtual qtmir::Screen* activeScreen() const = 0;
828+
829+Q_SIGNALS:
830+ void screenAdded(qtmir::Screen *screen);
831+ void screenRemoved(qtmir::Screen *screen);
832+
833+ void activeScreenChanged();
834+};
835+
836+} // namespace qtmir
837+
838+#endif // QTMIR_SCREENS_H
839
840=== renamed file 'src/platforms/mirserver/screentypes.h' => 'include/qtmir/types.h'
841--- src/platforms/mirserver/screentypes.h 2017-04-06 08:50:28 +0000
842+++ include/qtmir/types.h 2017-04-06 08:50:29 +0000
843@@ -21,11 +21,8 @@
844
845 #include <QtCore/qmetatype.h>
846
847-namespace mir { namespace graphics { namespace detail { struct GraphicsConfOutputIdTag; } } }
848-
849 namespace qtmir
850 {
851-using OutputId = mir::IntWrapper<mir::graphics::detail::GraphicsConfOutputIdTag>;
852
853 enum OutputTypes {
854 Unknown,
855
856=== modified file 'include/qtmir/windowmanagementpolicy.h'
857--- include/qtmir/windowmanagementpolicy.h 2017-04-06 08:50:28 +0000
858+++ include/qtmir/windowmanagementpolicy.h 2017-04-06 08:50:29 +0000
859@@ -18,7 +18,8 @@
860 #define QTMIR_WINDOWMANAGEMENTPOLICY_H
861
862 // miral
863-#include "miral/canonical_window_manager.h"
864+#include <miral/canonical_window_manager.h>
865+#include <miral/workspace_policy.h>
866 #include <miral/version.h>
867 #if MIRAL_VERSION > MIR_VERSION_NUMBER(1,3,1)
868 #include <miral/set_window_management_policy.h>
869@@ -43,7 +44,8 @@
870 /*
871 Provides window management callbacks for window behaviour customization
872 */
873-class WindowManagementPolicy : public miral::CanonicalWindowManagerPolicy
874+class WindowManagementPolicy : public miral::CanonicalWindowManagerPolicy,
875+ public miral::WorkspacePolicy
876 {
877 public:
878
879@@ -77,7 +79,12 @@
880 void advise_delete_window(const miral::WindowInfo &windowInfo) override;
881 void advise_raise(const std::vector<miral::Window> &windows) override;
882
883- Rectangle confirm_inherited_move(miral::WindowInfo const& windowInfo, Displacement movement) override;
884+ Rectangle confirm_inherited_move(const miral::WindowInfo &windowInfo, Displacement movement) override;
885+
886+ void advise_adding_to_workspace(const std::shared_ptr<miral::Workspace> &workspace,
887+ const std::vector<miral::Window> &windows) override;
888+ void advise_removing_from_workspace(const std::shared_ptr<miral::Workspace> &workspace,
889+ const std::vector<miral::Window> &windows) override;
890
891 protected:
892 WindowManagementPolicy(const miral::WindowManagerTools &tools, std::shared_ptr<qtmir::WindowManagementPolicyPrivate> dd);
893
894=== modified file 'src/common/windowmodelnotifier.h'
895--- src/common/windowmodelnotifier.h 2017-03-24 11:29:56 +0000
896+++ src/common/windowmodelnotifier.h 2017-04-06 08:50:29 +0000
897@@ -23,6 +23,7 @@
898 #include <QMutex>
899
900 #include <miral/window_info.h>
901+#include <miral/workspace_policy.h>
902
903 // Unity API
904 #include <unity/shell/application/Mir.h>
905@@ -71,7 +72,7 @@
906 {
907 Q_OBJECT
908 public:
909- WindowModelNotifier() = default;
910+ WindowModelNotifier();
911
912 Q_SIGNALS: // **Must used Queued Connection or else events will be out of order**
913 void windowAdded(const qtmir::NewWindow &window);
914@@ -83,6 +84,9 @@
915 void windowFocusChanged(const miral::WindowInfo &window, bool focused);
916 void windowsRaised(const std::vector<miral::Window> &windows); // results in deep copy when passed over Queued connection:(
917 void windowRequestedRaise(const miral::WindowInfo &window);
918+ void windowsAddedToWorkspace(const std::shared_ptr<miral::Workspace> &workspace, const std::vector<miral::Window> &windows);
919+ void windowsAboutToBeRemovedFromWorkspace(const std::shared_ptr<miral::Workspace> &workspace,
920+ const std::vector<miral::Window> &windows);
921 void modificationsStarted();
922 void modificationsEnded();
923
924@@ -90,6 +94,26 @@
925 Q_DISABLE_COPY(WindowModelNotifier)
926 };
927
928+class WindowNotifierObserver : public QObject
929+{
930+ Q_OBJECT
931+public:
932+ WindowNotifierObserver(const miral::Window &window);
933+ virtual ~WindowNotifierObserver();
934+
935+ static void foreachObserverForWindow(const miral::Window &window, std::function<void(WindowNotifierObserver*)> fn);
936+
937+Q_SIGNALS:
938+ void windowCreated();
939+ void windowRemoved();
940+ void windowReady();
941+ void windowMoved(const QPoint &topLeft);
942+ void windowResized(const QSize &size);
943+ void windowStateChanged(Mir::State state);
944+ void windowFocusChanged(bool focused);
945+ void windowRequestedRaise();
946+};
947+
948 } // namespace qtmir
949
950 Q_DECLARE_METATYPE(qtmir::NewWindow)
951
952=== added file 'src/common/workspacecontrollerinterface.h'
953--- src/common/workspacecontrollerinterface.h 1970-01-01 00:00:00 +0000
954+++ src/common/workspacecontrollerinterface.h 2017-04-06 08:50:29 +0000
955@@ -0,0 +1,50 @@
956+/*
957+ * Copyright (C) 2017 Canonical, Ltd.
958+ *
959+ * This program is free software: you can redistribute it and/or modify it under
960+ * the terms of the GNU Lesser General Public License version 3, as published by
961+ * the Free Software Foundation.
962+ *
963+ * This program is distributed in the hope that it will be useful, but WITHOUT
964+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
965+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
966+ * Lesser General Public License for more details.
967+ *
968+ * You should have received a copy of the GNU Lesser General Public License
969+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
970+ */
971+
972+#ifndef WORKSPACECONTROLLERINTERFACE_H
973+#define WORKSPACECONTROLLERINTERFACE_H
974+
975+#include <miral/window.h>
976+
977+#include <mir_toolkit/event.h>
978+
979+#include <QPoint>
980+#include <QSize>
981+
982+// Unity API
983+#include <unity/shell/application/Mir.h>
984+
985+namespace miral { class Workspace; }
986+
987+namespace qtmir {
988+
989+class WorkspaceControllerInterface {
990+public:
991+ WorkspaceControllerInterface() = default;
992+ virtual ~WorkspaceControllerInterface() = default;
993+
994+ virtual void forEachWindowInWorkspace(const std::shared_ptr<miral::Workspace> &workspace,
995+ const std::function<void (const miral::Window &)> &callback) = 0;
996+
997+ virtual void moveWorkspaceContentToWorkspace(const std::shared_ptr<miral::Workspace> &to,
998+ const std::shared_ptr<miral::Workspace> &from) = 0;
999+ virtual void moveWindowToWorkspace(const miral::Window &window,
1000+ const std::shared_ptr<miral::Workspace> &workspace) = 0;
1001+};
1002+
1003+} // namespace qtmir
1004+
1005+#endif // WINDOWCONTROLLERINTERFACE_H
1006
1007=== modified file 'src/modules/Unity/Application/CMakeLists.txt'
1008--- src/modules/Unity/Application/CMakeLists.txt 2017-04-06 08:50:28 +0000
1009+++ src/modules/Unity/Application/CMakeLists.txt 2017-04-06 08:50:29 +0000
1010@@ -1,3 +1,5 @@
1011+include(UseLttngGenTp)
1012+
1013 include_directories(
1014 ${CMAKE_SOURCE_DIR}/include
1015 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
1016@@ -29,6 +31,12 @@
1017 # Needed to compile tracepoints in C99 mode.
1018 add_definitions(-DBYTE_ORDER=__BYTE_ORDER)
1019
1020+# Generate tracepoints.c and .h from tracepoints.tp
1021+add_lttng_gen_tp(NAME tracepoints)
1022+add_custom_target(UnityApplication_LTTNG
1023+ DEPENDS tracepoints.h tracepoints.c
1024+)
1025+
1026 set(QMLMIRPLUGIN_SRC
1027 application_manager.cpp
1028 application.cpp
1029@@ -68,11 +76,12 @@
1030 applicationinfo.h
1031 taskcontroller.h
1032 settings_interface.h
1033- )
1034+)
1035
1036 add_library(unityapplicationplugin SHARED
1037 ${QMLMIRPLUGIN_SRC}
1038 )
1039+add_dependencies(unityapplicationplugin UnityApplication_LTTNG)
1040
1041 # Frig for files that still rely on mirserver-dev
1042 string(REPLACE ";" " -I" QTMIR_ADD_MIRSERVER "-I ${MIRSERVER_INCLUDE_DIRS}")
1043@@ -101,10 +110,6 @@
1044 qtmirserver
1045 )
1046
1047-# Generate tracepoints.c and .h from tracepoints.tp
1048-include(UseLttngGenTp)
1049-add_lttng_gen_tp(NAME tracepoints)
1050-
1051
1052 # install
1053 add_qml_plugin(Unity.Application 0.1 Unity/Application TARGETS unityapplicationplugin)
1054
1055=== modified file 'src/modules/Unity/Application/application_manager.cpp'
1056--- src/modules/Unity/Application/application_manager.cpp 2017-03-28 17:12:54 +0000
1057+++ src/modules/Unity/Application/application_manager.cpp 2017-04-06 08:50:29 +0000
1058@@ -120,7 +120,7 @@
1059
1060 ApplicationManager* ApplicationManager::singleton()
1061 {
1062- static ApplicationManager* instance;
1063+ static ApplicationManager* instance{nullptr};
1064 if (!instance) {
1065 instance = create();
1066 }
1067
1068=== modified file 'src/modules/Unity/Application/mirsurface.cpp'
1069--- src/modules/Unity/Application/mirsurface.cpp 2017-04-06 08:50:28 +0000
1070+++ src/modules/Unity/Application/mirsurface.cpp 2017-04-06 08:50:29 +0000
1071@@ -19,8 +19,10 @@
1072 #include "mirsurfacelistmodel.h"
1073 #include "namedcursor.h"
1074 #include "session_interface.h"
1075+#include "surfacemanager.h"
1076 #include "timer.h"
1077 #include "timestamp.h"
1078+#include "tracepoints.h"
1079
1080 // from common dir
1081 #include <debughelpers.h>
1082@@ -122,6 +124,33 @@
1083 QMap<QByteArray, Qt::CursorShape> m_cursorNameToShape;
1084 };
1085
1086+class MirSurface::WindowNotifierObserverImpl : public WindowNotifierObserver
1087+{
1088+public:
1089+ WindowNotifierObserverImpl(MirSurface* surface, const miral::Window &window)
1090+ : WindowNotifierObserver(window)
1091+ {
1092+ connect(this, &WindowNotifierObserver::windowRemoved, this, [surface]() {
1093+ surface->setLive(false);
1094+ });
1095+ connect(this, &WindowNotifierObserver::windowReady, this, [surface]() {
1096+ tracepoint(qtmir, firstFrameDrawn); // MirAL decides surface ready when it swaps its first frame
1097+ surface->setReady();
1098+ });
1099+ connect(this, &WindowNotifierObserver::windowMoved, this, [surface](const QPoint topLeft) {
1100+ surface->setPosition(topLeft);
1101+ });
1102+ connect(this, &WindowNotifierObserver::windowStateChanged, this, [surface](Mir::State state) {
1103+ surface->updateState(state);
1104+ });
1105+ connect(this, &WindowNotifierObserver::windowFocusChanged, this, [surface]( bool focused) {
1106+ surface->setFocused(focused);
1107+ });
1108+ connect(this, &WindowNotifierObserver::windowRequestedRaise, this, [surface]() {
1109+ surface->requestFocus();
1110+ });
1111+ }
1112+};
1113
1114 MirSurface::MirSurface(NewWindow newWindowInfo,
1115 WindowControllerInterface* controller,
1116@@ -146,6 +175,7 @@
1117 , m_visible(newWindowInfo.windowInfo.is_visible())
1118 , m_live(true)
1119 , m_surfaceObserver(std::make_shared<SurfaceObserverImpl>())
1120+ , m_windowModelObserver(std::make_shared<WindowNotifierObserverImpl>(this, m_window))
1121 , m_size(toQSize(m_window.size()))
1122 , m_state(toQtState(newWindowInfo.windowInfo.state()))
1123 , m_shellChrome(toQtShellChrome(newWindowInfo.windowInfo.shell_chrome()))
1124
1125=== modified file 'src/modules/Unity/Application/mirsurface.h'
1126--- src/modules/Unity/Application/mirsurface.h 2017-04-06 08:50:28 +0000
1127+++ src/modules/Unity/Application/mirsurface.h 2017-04-06 08:50:29 +0000
1128@@ -55,7 +55,7 @@
1129 Q_OBJECT
1130
1131 public:
1132- MirSurface(NewWindow windowInfo,
1133+ MirSurface(qtmir::NewWindow windowInfo,
1134 WindowControllerInterface *controller,
1135 SessionInterface *session = nullptr,
1136 MirSurface *parentSurface = nullptr);
1137@@ -263,6 +263,8 @@
1138
1139 class SurfaceObserverImpl;
1140 std::shared_ptr<SurfaceObserverImpl> m_surfaceObserver;
1141+ class WindowNotifierObserverImpl;
1142+ std::shared_ptr<WindowNotifierObserverImpl> m_windowModelObserver;
1143
1144 QPoint m_position;
1145 QPoint m_requestedPosition;
1146
1147=== modified file 'src/modules/Unity/Application/plugin.cpp'
1148--- src/modules/Unity/Application/plugin.cpp 2017-01-18 21:24:15 +0000
1149+++ src/modules/Unity/Application/plugin.cpp 2017-04-06 08:50:29 +0000
1150@@ -49,6 +49,10 @@
1151 QObject* mirSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) {
1152 return qtmir::Mir::instance();
1153 }
1154+
1155+QObject* surfaceManagerSingleton(QQmlEngine* /*engine*/, QJSEngine* /*scriptEngine*/) {
1156+ return qtmir::SurfaceManager::instance();
1157+}
1158 } // anonymous namespace
1159
1160 class UnityApplicationPlugin : public QQmlExtensionPlugin {
1161@@ -67,6 +71,8 @@
1162 qRegisterMetaType<unity::shell::application::SurfaceManagerInterface*>("unity::shell::application::SurfaceManagerInterface*");
1163 qRegisterMetaType<MirWindowAttrib>("MirWindowAttrib");
1164
1165+ qRegisterMetaType<std::shared_ptr<miral::Workspace>>("std::shared_ptr<miral::Workspace>");
1166+
1167 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(
1168 uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
1169 qmlRegisterSingletonType<qtmir::ApplicationManager>(
1170@@ -79,7 +85,7 @@
1171 uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");
1172 qmlRegisterType<qtmir::MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem");
1173 qmlRegisterSingletonType<qtmir::Mir>(uri, 0, 1, "Mir", mirSingleton);
1174- qmlRegisterType<qtmir::SurfaceManager>(uri, 0, 1, "SurfaceManager");
1175+ qmlRegisterSingletonType<qtmir::SurfaceManager>(uri, 0, 1, "SurfaceManager", surfaceManagerSingleton);
1176
1177 qmlRegisterType<qtmir::WindowModel>(uri, 0, 1, "WindowModel");
1178 }
1179
1180=== modified file 'src/modules/Unity/Application/surfacemanager.cpp'
1181--- src/modules/Unity/Application/surfacemanager.cpp 2017-03-20 16:19:42 +0000
1182+++ src/modules/Unity/Application/surfacemanager.cpp 2017-04-06 08:50:29 +0000
1183@@ -26,6 +26,7 @@
1184 // common
1185 #include <debughelpers.h>
1186 #include <mirqtconversion.h>
1187+#include <workspacecontrollerinterface.h>
1188
1189 // Qt
1190 #include <QGuiApplication>
1191@@ -38,6 +39,14 @@
1192 using namespace qtmir;
1193 namespace unityapi = unity::shell::application;
1194
1195+SurfaceManager *SurfaceManager::instance()
1196+{
1197+ static SurfaceManager* instance{nullptr};
1198+ if (!instance) {
1199+ instance = new SurfaceManager;
1200+ }
1201+ return instance;
1202+}
1203
1204 SurfaceManager::SurfaceManager()
1205 {
1206@@ -51,6 +60,7 @@
1207
1208 m_sessionMap = ApplicationManager::singleton();
1209 m_windowController = static_cast<WindowControllerInterface*>(nativeInterface->nativeResourceForIntegration("WindowController"));
1210+ m_workspaceController = static_cast<WorkspaceControllerInterface*>(nativeInterface->nativeResourceForIntegration("WorkspaceController"));
1211
1212 auto windowModel = static_cast<WindowModelNotifier*>(nativeInterface->nativeResourceForIntegration("WindowModelNotifier"));
1213 connectToWindowModelNotifier(windowModel);
1214@@ -68,31 +78,71 @@
1215
1216 void SurfaceManager::connectToWindowModelNotifier(WindowModelNotifier *notifier)
1217 {
1218- connect(notifier, &WindowModelNotifier::windowAdded, this, &SurfaceManager::onWindowAdded, Qt::QueuedConnection);
1219- connect(notifier, &WindowModelNotifier::windowRemoved, this, &SurfaceManager::onWindowRemoved, Qt::QueuedConnection);
1220- connect(notifier, &WindowModelNotifier::windowReady, this, &SurfaceManager::onWindowReady, Qt::QueuedConnection);
1221- connect(notifier, &WindowModelNotifier::windowMoved, this, &SurfaceManager::onWindowMoved, Qt::QueuedConnection);
1222- connect(notifier, &WindowModelNotifier::windowStateChanged, this, &SurfaceManager::onWindowStateChanged, Qt::QueuedConnection);
1223- connect(notifier, &WindowModelNotifier::windowFocusChanged, this, &SurfaceManager::onWindowFocusChanged, Qt::QueuedConnection);
1224- connect(notifier, &WindowModelNotifier::windowsRaised, this, &SurfaceManager::onWindowsRaised, Qt::QueuedConnection);
1225- connect(notifier, &WindowModelNotifier::windowRequestedRaise, this, &SurfaceManager::onWindowsRequestedRaise, Qt::QueuedConnection);
1226- connect(notifier, &WindowModelNotifier::modificationsStarted, this, &SurfaceManager::modificationsStarted, Qt::QueuedConnection);
1227- connect(notifier, &WindowModelNotifier::modificationsEnded, this, &SurfaceManager::modificationsEnded, Qt::QueuedConnection);
1228+ connect(notifier, &WindowModelNotifier::windowAdded,
1229+ this, &SurfaceManager::onWindowAdded, Qt::QueuedConnection);
1230+
1231+ connect(notifier, &WindowModelNotifier::windowRemoved,
1232+ this, &SurfaceManager::onWindowRemoved, Qt::QueuedConnection);
1233+
1234+ connect(notifier, &WindowModelNotifier::windowReady,
1235+ this, [this](const miral::WindowInfo &windowInfo) {
1236+ Q_EMIT surfaceReady(surfaceFor(windowInfo.window()));
1237+ }, Qt::QueuedConnection);
1238+
1239+ connect(notifier, &WindowModelNotifier::windowMoved,
1240+ this, [this](const miral::WindowInfo &windowInfo, const QPoint &top_left) {
1241+ Q_EMIT surfaceMoved(surfaceFor(windowInfo.window()), top_left);
1242+ }, Qt::QueuedConnection);
1243+
1244+ connect(notifier, &WindowModelNotifier::windowResized,
1245+ this, [this](const miral::WindowInfo &windowInfo, const QSize &size) {
1246+ Q_EMIT surfaceResized(surfaceFor(windowInfo.window()), size);
1247+ }, Qt::QueuedConnection);
1248+
1249+ connect(notifier, &WindowModelNotifier::windowStateChanged,
1250+ this, [this](const miral::WindowInfo &windowInfo, Mir::State state) {
1251+ Q_EMIT surfaceStateChanged(surfaceFor(windowInfo.window()), state);
1252+ }, Qt::QueuedConnection);
1253+
1254+ connect(notifier, &WindowModelNotifier::windowFocusChanged,
1255+ this, [this](const miral::WindowInfo &windowInfo, bool focused) {
1256+ Q_EMIT surfaceFocusChanged(surfaceFor(windowInfo.window()), focused);
1257+ }, Qt::QueuedConnection);
1258+
1259+ connect(notifier, &WindowModelNotifier::windowRequestedRaise,
1260+ this, [this](const miral::WindowInfo &windowInfo) {
1261+ Q_EMIT surfaceRequestedRaise(surfaceFor(windowInfo.window()));
1262+ }, Qt::QueuedConnection);
1263+
1264+ connect(notifier, &WindowModelNotifier::windowsRaised,
1265+ this, [this](const std::vector<miral::Window> &windows) {
1266+ Q_EMIT surfacesRaised(surfacesFor(windows));
1267+ }, Qt::QueuedConnection);
1268+
1269+ connect(notifier, &WindowModelNotifier::windowsAddedToWorkspace,
1270+ this, [this](const std::shared_ptr<miral::Workspace> &workspace, const std::vector<miral::Window> &windows) {
1271+ Q_EMIT surfacesAddedToWorkspace(workspace, surfacesFor(windows));
1272+ }, Qt::QueuedConnection);
1273+
1274+ connect(notifier, &WindowModelNotifier::windowsAboutToBeRemovedFromWorkspace,
1275+ this, [this](const std::shared_ptr<miral::Workspace> &workspace, const std::vector<miral::Window> &windows) {
1276+ Q_EMIT surfacesAboutToBeRemovedFromWorkspace(workspace, surfacesFor(windows));
1277+ }, Qt::QueuedConnection);
1278+
1279+ connect(notifier, &WindowModelNotifier::modificationsEnded, this, &SurfaceManager::modificationsEnded, Qt::QueuedConnection);
1280+
1281+ connect(notifier, &WindowModelNotifier::modificationsStarted, this, &SurfaceManager::modificationsStarted, Qt::QueuedConnection);
1282 }
1283
1284 void SurfaceManager::rememberMirSurface(MirSurface *surface)
1285 {
1286- m_allSurfaces.append(surface);
1287+ surface_to_window.insert({ surface, surface->window() });
1288 }
1289
1290 void SurfaceManager::forgetMirSurface(const miral::Window &window)
1291 {
1292- for (int i = 0; i < m_allSurfaces.count(); ++i) {
1293- if (m_allSurfaces[i]->window() == window) {
1294- m_allSurfaces.removeAt(i);
1295- return;
1296- }
1297- }
1298+ std::shared_ptr<mir::scene::Surface> msSurface = window;
1299+ surface_to_window.right.erase(window);
1300 }
1301
1302 void SurfaceManager::onWindowAdded(const NewWindow &window)
1303@@ -109,7 +159,7 @@
1304 auto mirSession = windowInfo.window().application();
1305 SessionInterface* session = m_sessionMap->findSession(mirSession.get());
1306
1307- const auto parentSurface = find(windowInfo.parent());
1308+ const auto parentSurface = surfaceFor(windowInfo.parent());
1309 const auto surface = new MirSurface(window, m_windowController, session, parentSurface);
1310 rememberMirSurface(surface);
1311
1312@@ -136,85 +186,49 @@
1313 void SurfaceManager::onWindowRemoved(const miral::WindowInfo &windowInfo)
1314 {
1315 DEBUG_MSG << "()";
1316- MirSurface *surface = find(windowInfo);
1317+ MirSurface *surface = surfaceFor(windowInfo.window());
1318 forgetMirSurface(windowInfo.window());
1319- if (surface && surface->isBeingDisplayed()) {
1320- surface->setLive(false);
1321- } else {
1322+
1323+ if (!surface) return;
1324+ Q_EMIT surfaceRemoved(surface);
1325+
1326+ if (!surface->isBeingDisplayed()) {
1327 delete surface;
1328 tracepoint(qtmir, surfaceDestroyed);
1329 }
1330 }
1331
1332-MirSurface *SurfaceManager::find(const miral::WindowInfo &needle) const
1333-{
1334- return find(needle.window());
1335-}
1336-
1337-MirSurface *SurfaceManager::find(const miral::Window &window) const
1338-{
1339- Q_FOREACH(const auto surface, m_allSurfaces) {
1340- if (surface->window() == window) {
1341- return surface;
1342- }
1343+MirSurface *SurfaceManager::surfaceFor(const miral::Window &window) const
1344+{
1345+ auto window_iterator = surface_to_window.right.find(window);
1346+ if(window_iterator != surface_to_window.right.end()) {
1347+ return window_iterator->second;
1348 }
1349 return nullptr;
1350 }
1351
1352-void SurfaceManager::onWindowReady(const miral::WindowInfo &windowInfo)
1353-{
1354- if (auto mirSurface = find(windowInfo)) {
1355- tracepoint(qtmir, firstFrameDrawn); // MirAL decides surface ready when it swaps its first frame
1356- mirSurface->setReady();
1357- }
1358-}
1359-
1360-void SurfaceManager::onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft)
1361-{
1362- if (auto mirSurface = find(windowInfo)) {
1363- mirSurface->setPosition(topLeft);
1364- }
1365-}
1366-
1367-void SurfaceManager::onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused)
1368-{
1369- if (auto mirSurface = find(windowInfo)) {
1370- mirSurface->setFocused(focused);
1371- }
1372-}
1373-
1374-void SurfaceManager::onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state)
1375-{
1376- if (auto mirSurface = find(windowInfo)) {
1377- mirSurface->updateState(state);
1378- }
1379-}
1380-
1381-void SurfaceManager::onWindowsRaised(const std::vector<miral::Window> &windows)
1382-{
1383- // sad inefficiency when crossing API boundaries (from miral to qt)
1384-
1385- const int raiseCount = windows.size();
1386-
1387- DEBUG_MSG << "() raiseCount = " << raiseCount;
1388-
1389- QVector<unityapi::MirSurfaceInterface*> surfaces(raiseCount);
1390- for (int i = 0; i < raiseCount; i++) {
1391- auto mirSurface = find(windows[i]);
1392+QVector<unity::shell::application::MirSurfaceInterface *> SurfaceManager::surfacesFor(const std::vector<miral::Window> &windows) const
1393+{
1394+ QVector<unityapi::MirSurfaceInterface*> surfaces;
1395+ for (size_t i = 0; i < windows.size(); i++) {
1396+ auto mirSurface = surfaceFor(windows[i]);
1397 if (mirSurface) {
1398- surfaces[i] = mirSurface;
1399+ surfaces.push_back(mirSurface);
1400 } else {
1401- WARNING_MSG << " Could not find qml surface for " << windows[i];
1402+ std::shared_ptr<mir::scene::Surface> ms = windows[i];
1403+ WARNING_MSG << " Could not find qml surface for " << ms.get();
1404 }
1405 }
1406- Q_EMIT surfacesRaised(surfaces);
1407+ return surfaces;
1408 }
1409
1410-void SurfaceManager::onWindowsRequestedRaise(const miral::WindowInfo &windowInfo)
1411+miral::Window SurfaceManager::windowFor(MirSurface *surface) const
1412 {
1413- if (auto mirSurface = find(windowInfo)) {
1414- mirSurface->requestFocus();
1415+ auto window_iterator = surface_to_window.left.find(surface);
1416+ if(window_iterator != surface_to_window.left.end()) {
1417+ return window_iterator->second;
1418 }
1419+ return miral::Window();
1420 }
1421
1422 void SurfaceManager::raise(unityapi::MirSurfaceInterface *surface)
1423@@ -226,6 +240,32 @@
1424
1425 void SurfaceManager::activate(unityapi::MirSurfaceInterface *surface)
1426 {
1427- auto qtmirSurface = static_cast<qtmir::MirSurface*>(surface);
1428+ auto qtmirSurface = static_cast<MirSurface*>(surface);
1429 m_windowController->activate(qtmirSurface ? qtmirSurface->window() : miral::Window());
1430 }
1431+
1432+void SurfaceManager::forEachSurfaceInWorkspace(const std::shared_ptr<miral::Workspace> &workspace,
1433+ const std::function<void(unity::shell::application::MirSurfaceInterface *)> &callback)
1434+{
1435+ m_workspaceController->forEachWindowInWorkspace(workspace, [&](const miral::Window &window) {
1436+ auto surface = surfaceFor(window);
1437+ if (surface) {
1438+ callback(surface);
1439+ }
1440+ });
1441+}
1442+
1443+void SurfaceManager::moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface *surface,
1444+ const std::shared_ptr<miral::Workspace> &workspace)
1445+{
1446+ miral::Window window = windowFor(static_cast<qtmir::MirSurface*>(surface));
1447+ if (window) {
1448+ m_workspaceController->moveWindowToWorkspace(window, workspace);
1449+ }
1450+}
1451+
1452+void SurfaceManager::moveWorkspaceContentToWorkspace(const std::shared_ptr<miral::Workspace> &to,
1453+ const std::shared_ptr<miral::Workspace> &from)
1454+{
1455+ m_workspaceController->moveWorkspaceContentToWorkspace(to, from);
1456+}
1457
1458=== modified file 'src/modules/Unity/Application/surfacemanager.h'
1459--- src/modules/Unity/Application/surfacemanager.h 2017-03-20 16:19:42 +0000
1460+++ src/modules/Unity/Application/surfacemanager.h 2017-04-06 08:50:29 +0000
1461@@ -26,6 +26,8 @@
1462 #include <QVector>
1463 #include <QLoggingCategory>
1464
1465+#include <boost/bimap.hpp>
1466+
1467 Q_DECLARE_LOGGING_CATEGORY(QTMIR_SURFACEMANAGER)
1468
1469 namespace qtmir {
1470@@ -33,46 +35,56 @@
1471 class MirSurface;
1472 class SessionMapInterface;
1473 class WindowControllerInterface;
1474+class WorkspaceControllerInterface;
1475
1476 class SurfaceManager : public unity::shell::application::SurfaceManagerInterface
1477 {
1478 Q_OBJECT
1479
1480 public:
1481- explicit SurfaceManager();
1482 SurfaceManager(WindowControllerInterface *windowController,
1483 WindowModelNotifier *windowModel,
1484 SessionMapInterface *sessionMap);
1485 virtual ~SurfaceManager() {}
1486
1487+ static SurfaceManager *instance();
1488+
1489 void raise(unity::shell::application::MirSurfaceInterface *surface) override;
1490 void activate(unity::shell::application::MirSurfaceInterface *surface) override;
1491
1492+ void forEachSurfaceInWorkspace(const std::shared_ptr<miral::Workspace> &workspace,
1493+ const std::function<void(unity::shell::application::MirSurfaceInterface*)> &callback) override;
1494+ void moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface* surface,
1495+ const std::shared_ptr<miral::Workspace> &workspace) override;
1496+ void moveWorkspaceContentToWorkspace(const std::shared_ptr<miral::Workspace> &to,
1497+ const std::shared_ptr<miral::Workspace> &from) override;
1498+
1499 // mainly for test usage
1500- MirSurface* find(const miral::WindowInfo &needle) const;
1501+ MirSurface* surfaceFor(const miral::Window &window) const;
1502
1503 private Q_SLOTS:
1504 void onWindowAdded(const qtmir::NewWindow &windowInfo);
1505 void onWindowRemoved(const miral::WindowInfo &windowInfo);
1506- void onWindowReady(const miral::WindowInfo &windowInfo);
1507- void onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft);
1508- void onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state);
1509- void onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused);
1510- void onWindowsRaised(const std::vector<miral::Window> &windows);
1511- void onWindowsRequestedRaise(const miral::WindowInfo &windowInfo);
1512-
1513 private:
1514+ explicit SurfaceManager();
1515+
1516 void connectToWindowModelNotifier(WindowModelNotifier *notifier);
1517 void rememberMirSurface(MirSurface *surface);
1518 void forgetMirSurface(const miral::Window &window);
1519- MirSurface* find(const miral::Window &needle) const;
1520-
1521- QVector<MirSurface*> m_allSurfaces;
1522+ QVector<unity::shell::application::MirSurfaceInterface*> surfacesFor(const std::vector<miral::Window> &windows) const;
1523+ miral::Window windowFor(MirSurface *surface) const;
1524
1525 WindowControllerInterface *m_windowController;
1526+ WorkspaceControllerInterface *m_workspaceController;
1527 SessionMapInterface *m_sessionMap;
1528+
1529+ friend class Workspace;
1530+ using swbimap_t = boost::bimap<MirSurface*, miral::Window>;
1531+ swbimap_t surface_to_window;
1532 };
1533
1534 } // namespace qtmir
1535
1536+Q_DECLARE_METATYPE(std::shared_ptr<miral::Workspace>)
1537+
1538 #endif // QTMIR_SURFACEMANAGER_H
1539
1540=== modified file 'src/modules/Unity/Application/windowmodel.cpp'
1541--- src/modules/Unity/Application/windowmodel.cpp 2017-01-18 21:24:15 +0000
1542+++ src/modules/Unity/Application/windowmodel.cpp 2017-04-06 08:50:29 +0000
1543@@ -52,10 +52,6 @@
1544 {
1545 connect(notifier, &WindowModelNotifier::windowAdded, this, &WindowModel::onWindowAdded, Qt::QueuedConnection);
1546 connect(notifier, &WindowModelNotifier::windowRemoved, this, &WindowModel::onWindowRemoved, Qt::QueuedConnection);
1547- connect(notifier, &WindowModelNotifier::windowReady, this, &WindowModel::onWindowReady, Qt::QueuedConnection);
1548- connect(notifier, &WindowModelNotifier::windowMoved, this, &WindowModel::onWindowMoved, Qt::QueuedConnection);
1549- connect(notifier, &WindowModelNotifier::windowStateChanged, this, &WindowModel::onWindowStateChanged, Qt::QueuedConnection);
1550- connect(notifier, &WindowModelNotifier::windowFocusChanged, this, &WindowModel::onWindowFocusChanged, Qt::QueuedConnection);
1551 connect(notifier, &WindowModelNotifier::windowsRaised, this, &WindowModel::onWindowsRaised, Qt::QueuedConnection);
1552 }
1553
1554@@ -95,41 +91,13 @@
1555 Q_EMIT countChanged();
1556 }
1557
1558-void WindowModel::onWindowReady(const miral::WindowInfo &windowInfo)
1559-{
1560- if (auto mirSurface = find(windowInfo)) {
1561- mirSurface->setReady();
1562- }
1563-}
1564-
1565-void WindowModel::onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft)
1566-{
1567- if (auto mirSurface = find(windowInfo)) {
1568- mirSurface->setPosition(topLeft);
1569- }
1570-}
1571-
1572-void WindowModel::onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused)
1573-{
1574- if (auto mirSurface = find(windowInfo)) {
1575- mirSurface->setFocused(focused);
1576- }
1577-}
1578-
1579-void WindowModel::onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state)
1580-{
1581- if (auto mirSurface = find(windowInfo)) {
1582- mirSurface->updateState(state);
1583- }
1584-}
1585-
1586-void WindowModel::addInputMethodWindow(const NewWindow &windowInfo)
1587+void WindowModel::addInputMethodWindow(const NewWindow &window)
1588 {
1589 if (m_inputMethodSurface) {
1590 qDebug("Multiple Input Method Surfaces created, removing the old one!");
1591 delete m_inputMethodSurface;
1592 }
1593- m_inputMethodSurface = new MirSurface(windowInfo, m_windowController);
1594+ m_inputMethodSurface = new MirSurface(window, m_windowController);
1595 Q_EMIT inputMethodSurfaceChanged(m_inputMethodSurface);
1596 }
1597
1598
1599=== modified file 'src/modules/Unity/Application/windowmodel.h'
1600--- src/modules/Unity/Application/windowmodel.h 2016-11-03 20:17:46 +0000
1601+++ src/modules/Unity/Application/windowmodel.h 2017-04-06 08:50:29 +0000
1602@@ -60,10 +60,6 @@
1603 private Q_SLOTS:
1604 void onWindowAdded(const qtmir::NewWindow &windowInfo);
1605 void onWindowRemoved(const miral::WindowInfo &windowInfo);
1606- void onWindowReady(const miral::WindowInfo &windowInfo);
1607- void onWindowMoved(const miral::WindowInfo &windowInfo, const QPoint topLeft);
1608- void onWindowStateChanged(const miral::WindowInfo &windowInfo, Mir::State state);
1609- void onWindowFocusChanged(const miral::WindowInfo &windowInfo, bool focused);
1610 void onWindowsRaised(const std::vector<miral::Window> &windows);
1611
1612 private:
1613
1614=== modified file 'src/modules/Unity/CMakeLists.txt'
1615--- src/modules/Unity/CMakeLists.txt 2015-08-20 10:16:54 +0000
1616+++ src/modules/Unity/CMakeLists.txt 2017-04-06 08:50:29 +0000
1617@@ -1,2 +1,1 @@
1618 add_subdirectory(Application)
1619-add_subdirectory(Screens)
1620
1621=== removed directory 'src/modules/Unity/Screens'
1622=== removed file 'src/modules/Unity/Screens/CMakeLists.txt'
1623--- src/modules/Unity/Screens/CMakeLists.txt 2017-04-06 08:50:28 +0000
1624+++ src/modules/Unity/Screens/CMakeLists.txt 1970-01-01 00:00:00 +0000
1625@@ -1,35 +0,0 @@
1626-include_directories(
1627- ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
1628-)
1629-
1630-include_directories(
1631- SYSTEM
1632- ${MIRCLIENT_INCLUDE_DIRS}
1633- ${Qt5Gui_PRIVATE_INCLUDE_DIRS}
1634- ${Qt5Quick_INCLUDE_DIRS}
1635- )
1636-
1637-set(SCREENSPLUGIN_SRC
1638- plugin.cpp
1639- screens.cpp
1640- screen.cpp
1641- qquickscreenwindow.cpp
1642- types.h
1643- )
1644-
1645-add_library(unityscreensplugin SHARED
1646- ${SCREENSPLUGIN_SRC}
1647-)
1648-
1649-target_link_libraries(
1650- unityscreensplugin
1651-
1652- qtmirserver
1653-
1654- Qt5::Gui
1655- Qt5::Qml
1656- Qt5::Quick
1657-)
1658-
1659-# install
1660-add_qml_plugin(Unity.Screens 0.1 Unity/Screens TARGETS unityscreensplugin)
1661
1662=== removed file 'src/modules/Unity/Screens/plugin.cpp'
1663--- src/modules/Unity/Screens/plugin.cpp 2017-04-06 08:50:28 +0000
1664+++ src/modules/Unity/Screens/plugin.cpp 1970-01-01 00:00:00 +0000
1665@@ -1,59 +0,0 @@
1666-/*
1667- * Copyright (C) 2016 Canonical, Ltd.
1668- *
1669- * This program is free software: you can redistribute it and/or modify it under
1670- * the terms of the GNU Lesser General Public License version 3, as published by
1671- * the Free Software Foundation.
1672- *
1673- * This program is distributed in the hope that it will be useful, but WITHOUT
1674- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1675- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1676- * Lesser General Public License for more details.
1677- *
1678- * You should have received a copy of the GNU Lesser General Public License
1679- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1680- */
1681-
1682-// Qt
1683-#include <QQmlExtensionPlugin>
1684-#include <QtQml/qqml.h>
1685-#include <QScreen>
1686-
1687-// local
1688-#include "screens.h"
1689-#include "screen.h"
1690-#include "qquickscreenwindow.h"
1691-
1692-using namespace qtmir;
1693-
1694-namespace {
1695-QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
1696- Q_UNUSED(engine);
1697- Q_UNUSED(scriptEngine);
1698- return new qtmir::Screens();
1699-}
1700-}
1701-
1702-
1703-class UnityScreensPlugin : public QQmlExtensionPlugin {
1704- Q_OBJECT
1705- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
1706-
1707- virtual void registerTypes(const char* uri)
1708- {
1709- Q_ASSERT(QLatin1String(uri) == QLatin1String("Unity.Screens"));
1710-
1711- qRegisterMetaType<ScreenAdapter*>("Screen*");
1712- qRegisterMetaType<ScreenMode*>("ScreenMode*");
1713- qRegisterMetaType<ScreenConfig*>("ScreenConfig*");
1714- qmlRegisterUncreatableType<ScreenMode>(uri, 0, 1, "ScreenMode", "ScreenMode is not creatable.");
1715-
1716- qmlRegisterSingletonType<qtmir::Screens>(uri, 0, 1, "Screens", screensSingleton);
1717- qRegisterMetaType<qtmir::FormFactor>("qtmir::FormFactor");
1718-
1719- qmlRegisterType<qtmir::QQuickScreenWindow>(uri, 0, 1, "ScreenWindow");
1720- qmlRegisterRevision<QWindow,1>(uri, 0, 1);
1721- }
1722-};
1723-
1724-#include "plugin.moc"
1725
1726=== removed file 'src/modules/Unity/Screens/qmldir'
1727--- src/modules/Unity/Screens/qmldir 2015-08-24 11:29:57 +0000
1728+++ src/modules/Unity/Screens/qmldir 1970-01-01 00:00:00 +0000
1729@@ -1,2 +0,0 @@
1730-module Unity.Screens
1731-plugin unityscreensplugin
1732
1733=== removed file 'src/modules/Unity/Screens/qquickscreenwindow.cpp'
1734--- src/modules/Unity/Screens/qquickscreenwindow.cpp 2017-04-06 08:50:28 +0000
1735+++ src/modules/Unity/Screens/qquickscreenwindow.cpp 1970-01-01 00:00:00 +0000
1736@@ -1,62 +0,0 @@
1737-/*
1738- * Copyright (C) 2016 Canonical, Ltd.
1739- *
1740- * This program is free software: you can redistribute it and/or modify it under
1741- * the terms of the GNU Lesser General Public License version 3, as published by
1742- * the Free Software Foundation.
1743- *
1744- * This program is distributed in the hope that it will be useful, but WITHOUT
1745- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1746- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1747- * Lesser General Public License for more details.
1748- *
1749- * You should have received a copy of the GNU Lesser General Public License
1750- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1751- */
1752-
1753-#include "qquickscreenwindow.h"
1754-
1755-// mirserver
1756-#include "screen.h"
1757-#include "screenscontroller.h"
1758-#include "logging.h"
1759-
1760-// Qt
1761-#include <QGuiApplication>
1762-#include <QScreen>
1763-#include <qpa/qplatformnativeinterface.h>
1764-#include <QDebug>
1765-
1766-using namespace qtmir;
1767-
1768-#define DEBUG_MSG qCDebug(QTMIR_SCREENS).nospace() << "QQuickScreenWindow[" << (void*)this <<"]::" << __func__
1769-
1770-QQuickScreenWindow::QQuickScreenWindow(QQuickWindow *parent)
1771- : QQuickWindow(parent)
1772-{
1773- if (qGuiApp->platformName() != QLatin1String("mirserver")) {
1774- qCritical("Not using 'mirserver' QPA plugin. Using ScreenWindow may produce unknown results.");
1775- }
1776-
1777- DEBUG_MSG << "()";
1778-}
1779-
1780-QQuickScreenWindow::~QQuickScreenWindow()
1781-{
1782- DEBUG_MSG << "()";
1783-}
1784-
1785-ScreenAdapter *QQuickScreenWindow::screenWrapper() const
1786-{
1787- return m_screen.data();
1788-}
1789-
1790-void QQuickScreenWindow::setScreenWrapper(ScreenAdapter *screen)
1791-{
1792- DEBUG_MSG << "(screen=" << screen << ")";
1793- if (m_screen != screen) {
1794- m_screen = screen;
1795- Q_EMIT screenWrapperChanged();
1796- }
1797- QQuickWindow::setScreen(screen->screen());
1798-}
1799
1800=== removed file 'src/modules/Unity/Screens/qquickscreenwindow.h'
1801--- src/modules/Unity/Screens/qquickscreenwindow.h 2017-04-06 08:50:28 +0000
1802+++ src/modules/Unity/Screens/qquickscreenwindow.h 1970-01-01 00:00:00 +0000
1803@@ -1,51 +0,0 @@
1804-/*
1805- * Copyright (C) 2016 Canonical, Ltd.
1806- *
1807- * This program is free software: you can redistribute it and/or modify it under
1808- * the terms of the GNU Lesser General Public License version 3, as published by
1809- * the Free Software Foundation.
1810- *
1811- * This program is distributed in the hope that it will be useful, but WITHOUT
1812- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1813- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1814- * Lesser General Public License for more details.
1815- *
1816- * You should have received a copy of the GNU Lesser General Public License
1817- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1818- */
1819-
1820-#ifndef QQUICKSCREENWINDOW_H
1821-#define QQUICKSCREENWINDOW_H
1822-
1823-#include <QQuickWindow>
1824-#include <QPointer>
1825-
1826-class ScreenAdapter;
1827-
1828-namespace qtmir {
1829-
1830-/*
1831- * QQuickScreenWindow - wrapper of QQuickWindow to enable QML to specify destination screen.
1832-**/
1833-class QQuickScreenWindow : public QQuickWindow
1834-{
1835- Q_OBJECT
1836- Q_PROPERTY(ScreenAdapter *screen READ screenWrapper WRITE setScreenWrapper NOTIFY screenWrapperChanged)
1837- Q_PROPERTY(int winId READ winId CONSTANT)
1838-public:
1839- explicit QQuickScreenWindow(QQuickWindow *parent = 0);
1840- ~QQuickScreenWindow();
1841-
1842- ScreenAdapter *screenWrapper() const;
1843- void setScreenWrapper(ScreenAdapter *screen);
1844-
1845-Q_SIGNALS:
1846- void screenWrapperChanged();
1847-
1848-private:
1849- QPointer<ScreenAdapter> m_screen;
1850-};
1851-
1852-} //namespace qtmir
1853-
1854-#endif // QQUICKSCREENWINDOW_H
1855
1856=== removed file 'src/modules/Unity/Screens/screen.cpp'
1857--- src/modules/Unity/Screens/screen.cpp 2017-04-06 08:50:28 +0000
1858+++ src/modules/Unity/Screens/screen.cpp 1970-01-01 00:00:00 +0000
1859@@ -1,213 +0,0 @@
1860-#include "screen.h"
1861-
1862-// qtmir
1863-#include "platformscreen.h"
1864-#include "screenscontroller.h"
1865-#include "nativeinterface.h"
1866-
1867-// Qt
1868-#include <QScreen>
1869-#include <QQmlEngine>
1870-#include <QDebug>
1871-#include <QGuiApplication>
1872-
1873-ScreenAdapter::ScreenAdapter(QScreen* screen, QObject* parent)
1874- : QObject(parent)
1875- , m_screen(screen)
1876- , m_screensController(static_cast<ScreensController*>(qGuiApp->platformNativeInterface()
1877- ->nativeResourceForIntegration("ScreensController")))
1878-{
1879- if (!m_screensController) {
1880- qFatal("Screens Controller not initialized");
1881- }
1882-
1883- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1884- if (platformScreen) {
1885- connect(platformScreen, &PlatformScreen::usedChanged, this, &ScreenAdapter::usedChanged);
1886- connect(platformScreen, &PlatformScreen::nameChanged, this, &ScreenAdapter::nameChanged);
1887- connect(platformScreen, &PlatformScreen::outputTypeChanged, this, &ScreenAdapter::outputTypeChanged);
1888- connect(platformScreen, &PlatformScreen::scaleChanged, this, &ScreenAdapter::scaleChanged);
1889- connect(platformScreen, &PlatformScreen::formFactorChanged, this, &ScreenAdapter::formFactorChanged);
1890- connect(platformScreen, &PlatformScreen::physicalSizeChanged, this, &ScreenAdapter::physicalSizeChanged);
1891- connect(platformScreen, &PlatformScreen::positionChanged, this, &ScreenAdapter::positionChanged);
1892- connect(platformScreen, &PlatformScreen::activeChanged, this, &ScreenAdapter::activeChanged);
1893- connect(platformScreen, &PlatformScreen::currentModeIndexChanged, this, &ScreenAdapter::currentModeIndexChanged);
1894- connect(platformScreen, &PlatformScreen::availableModesChanged, this, &ScreenAdapter::updateScreenModes);
1895- }
1896- updateScreenModes();
1897-}
1898-
1899-ScreenAdapter::~ScreenAdapter()
1900-{
1901- qDebug() << "delete screens";
1902- qDeleteAll(m_modes);
1903- m_modes.clear();
1904-}
1905-
1906-qtmir::OutputId ScreenAdapter::outputId() const
1907-{
1908- if (!m_screen) return qtmir::OutputId(-1);
1909- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1910- if (!platformScreen) return qtmir::OutputId(-1);
1911-
1912- return platformScreen->outputId();
1913-}
1914-
1915-bool ScreenAdapter::used() const
1916-{
1917- if (!m_screen) return false;
1918- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1919- if (!platformScreen) return false;
1920-
1921- return platformScreen->used();
1922-}
1923-
1924-QString ScreenAdapter::name() const
1925-{
1926- if (!m_screen) return QString();
1927- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1928- if (!platformScreen) return QString();
1929-
1930- return platformScreen->name();
1931-}
1932-
1933-float ScreenAdapter::scale() const
1934-{
1935- if (!m_screen) return 1.0;
1936- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1937- if (!platformScreen) return 1.0;
1938-
1939- return platformScreen->scale();
1940-}
1941-
1942-QSizeF ScreenAdapter::physicalSize() const
1943-{
1944- if (!m_screen) return QSizeF();
1945- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1946- if (!platformScreen) return QSizeF();
1947-
1948- return platformScreen->physicalSize();
1949-}
1950-
1951-qtmir::FormFactor ScreenAdapter::formFactor() const
1952-{
1953- if (!m_screen) return qtmir::FormFactorUnknown;
1954- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1955- if (!platformScreen) return qtmir::FormFactorUnknown;
1956-
1957- return static_cast<qtmir::FormFactor>(platformScreen->formFactor()); // needs compile time check
1958-}
1959-
1960-qtmir::OutputTypes ScreenAdapter::outputType() const
1961-{
1962- if (!m_screen) return qtmir::Unknown;
1963- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1964- if (!platformScreen) return qtmir::Unknown;
1965-
1966- return platformScreen->outputType();
1967-}
1968-
1969-QPoint ScreenAdapter::position() const
1970-{
1971- if (!m_screen) return QPoint();
1972- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1973- if (!platformScreen) return QPoint();
1974-
1975- return platformScreen->geometry().topLeft();
1976-}
1977-
1978-QQmlListProperty<ScreenMode> ScreenAdapter::availableModes()
1979-{
1980- return QQmlListProperty<ScreenMode>(this, m_modes);
1981-}
1982-
1983-uint ScreenAdapter::currentModeIndex() const
1984-{
1985- if (!m_screen) return -1;
1986- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1987- if (!platformScreen) return -1;
1988-
1989- return platformScreen->currentModeIndex();
1990-}
1991-
1992-bool ScreenAdapter::isActive() const
1993-{
1994- if (!m_screen) return false;
1995- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
1996- if (!platformScreen) return false;
1997-
1998- return platformScreen->isActive();
1999-}
2000-
2001-QScreen *ScreenAdapter::screen() const
2002-{
2003- return m_screen.data();
2004-}
2005-
2006-ScreenConfig *ScreenAdapter::beginConfiguration() const
2007-{
2008- auto newConfig = new ScreenConfig();
2009- auto config = m_screensController->outputConfiguration(this->outputId());
2010- *newConfig = config;
2011-
2012- return newConfig;
2013-}
2014-
2015-bool ScreenAdapter::applyConfiguration(ScreenConfig *configuration)
2016-{
2017- if (!m_screen) return false;
2018- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2019- if (!platformScreen) return false;
2020-
2021- return m_screensController->setOutputConfiguration(*configuration);
2022-}
2023-
2024-void ScreenAdapter::setActive(bool active)
2025-{
2026- if (!m_screen) return;
2027- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2028- if (!platformScreen) return;
2029-
2030- platformScreen->setActive(active);
2031-}
2032-
2033-void ScreenAdapter::updateScreenModes()
2034-{
2035- if (!m_screen) return;
2036- auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2037- if (!platformScreen) return;
2038-
2039- qDeleteAll(m_modes);
2040- m_modes.clear();
2041- Q_FOREACH(auto mode, platformScreen->availableModes()) {
2042- auto newMode(new ScreenMode);
2043- QQmlEngine::setObjectOwnership(newMode, QQmlEngine::CppOwnership);
2044- newMode->refreshRate = mode.first;
2045- newMode->size = mode.second;
2046- m_modes.append(newMode);
2047- }
2048-
2049- Q_EMIT availableModesChanged();
2050-}
2051-
2052-ScreenConfig::ScreenConfig(QObject *parent)
2053- : QObject(parent)
2054-{
2055-}
2056-
2057-ScreenConfig &ScreenConfig::operator=(const CustomScreenConfiguration &other)
2058-{
2059- if (&other == this) return *this;
2060-
2061- valid = other.valid;
2062- id = other.id;
2063- used = other.used;
2064- topLeft = other.topLeft;
2065- currentModeIndex = other.currentModeIndex;
2066- powerMode = other.powerMode;
2067- orientation = other.orientation;
2068- scale = other.scale;
2069- formFactor = other.formFactor;
2070-
2071- return *this;
2072-}
2073
2074=== removed file 'src/modules/Unity/Screens/screen.h'
2075--- src/modules/Unity/Screens/screen.h 2017-04-06 08:50:28 +0000
2076+++ src/modules/Unity/Screens/screen.h 1970-01-01 00:00:00 +0000
2077@@ -1,99 +0,0 @@
2078-#ifndef SCREEN_H
2079-#define SCREEN_H
2080-
2081-#include "types.h"
2082-
2083-#include <QObject>
2084-#include <QPointer>
2085-#include <QQmlListProperty>
2086-
2087-#include <customscreenconfiguration.h>
2088-#include <screentypes.h>
2089-
2090-class QScreen;
2091-class ScreenConfig;
2092-class ScreensController;
2093-
2094-/*
2095- * Screen - Adapter for a QScreen exposed to qml which allows user to read screen properties,
2096- * as well as configure the screen properties in a transactional manner.
2097-**/
2098-class ScreenAdapter : public QObject
2099-{
2100- Q_OBJECT
2101-
2102- Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
2103-
2104- Q_PROPERTY(bool used READ used NOTIFY usedChanged)
2105- Q_PROPERTY(QString name READ name NOTIFY nameChanged)
2106- Q_PROPERTY(qtmir::OutputTypes outputType READ outputType NOTIFY outputTypeChanged)
2107- Q_PROPERTY(float scale READ scale NOTIFY scaleChanged)
2108- Q_PROPERTY(qtmir::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
2109- Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
2110- Q_PROPERTY(uint currentModeIndex READ currentModeIndex NOTIFY currentModeIndexChanged)
2111- Q_PROPERTY(QQmlListProperty<ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
2112- Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
2113-
2114-public:
2115- explicit ScreenAdapter(QScreen* screen, QObject* parent = 0);
2116- ~ScreenAdapter();
2117-
2118- qtmir::OutputId outputId() const;
2119- bool used() const;
2120- QString name() const;
2121- float scale() const;
2122- QSizeF physicalSize() const;
2123- qtmir::FormFactor formFactor() const;
2124- qtmir::OutputTypes outputType() const;
2125- QPoint position() const;
2126- QQmlListProperty<ScreenMode> availableModes();
2127- uint currentModeIndex() const;
2128- bool isActive() const;
2129-
2130- QScreen *screen() const;
2131-
2132- Q_INVOKABLE ScreenConfig *beginConfiguration() const;
2133- Q_INVOKABLE bool applyConfiguration(ScreenConfig *configuration);
2134-
2135- void setActive(bool active);
2136-
2137-Q_SIGNALS:
2138- void usedChanged();
2139- void nameChanged();
2140- void outputTypeChanged();
2141- void scaleChanged();
2142- void formFactorChanged();
2143- void positionChanged();
2144- void currentModeIndexChanged();
2145- void physicalSizeChanged();
2146- void availableModesChanged();
2147- void activeChanged(bool active);
2148-
2149-private Q_SLOTS:
2150- void updateScreenModes();
2151-
2152-private:
2153- QList<ScreenMode*> m_modes;
2154- QPointer<QScreen> m_screen;
2155- ScreensController *m_screensController;
2156-};
2157-
2158-class ScreenConfig: public QObject,
2159- public CustomScreenConfiguration
2160-{
2161- Q_OBJECT
2162- Q_PROPERTY(bool used MEMBER used)
2163- Q_PROPERTY(float scale MEMBER scale)
2164- Q_PROPERTY(qtmir::FormFactor formFactor MEMBER formFactor)
2165- Q_PROPERTY(uint currentModeIndex MEMBER currentModeIndex)
2166- Q_PROPERTY(QPoint position MEMBER topLeft)
2167-
2168-public:
2169- ScreenConfig(QObject* parent = 0);
2170-
2171- ScreenConfig &operator=(const CustomScreenConfiguration& other);
2172-
2173- friend class ScreenAdapter;
2174-};
2175-
2176-#endif // SCREEN_H
2177
2178=== removed file 'src/modules/Unity/Screens/screens.cpp'
2179--- src/modules/Unity/Screens/screens.cpp 2017-04-06 08:50:28 +0000
2180+++ src/modules/Unity/Screens/screens.cpp 1970-01-01 00:00:00 +0000
2181@@ -1,140 +0,0 @@
2182-/*
2183- * Copyright (C) 2016 Canonical, Ltd.
2184- *
2185- * This program is free software: you can redistribute it and/or modify it under
2186- * the terms of the GNU Lesser General Public License version 3, as published by
2187- * the Free Software Foundation.
2188- *
2189- * This program is distributed in the hope that it will be useful, but WITHOUT
2190- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2191- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2192- * Lesser General Public License for more details.
2193- *
2194- * You should have received a copy of the GNU Lesser General Public License
2195- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2196- */
2197-
2198-#include "screens.h"
2199-#include "screen.h"
2200-
2201-// mirserver
2202-#include "platformscreen.h"
2203-#include "logging.h"
2204-
2205-// Qt
2206-#include <QGuiApplication>
2207-#include <QScreen>
2208-
2209-Q_DECLARE_METATYPE(QScreen*)
2210-
2211-#define DEBUG_MSG qCDebug(QTMIR_SCREENS).nospace() << "Screens[" << (void*)this <<"]::" << __func__
2212-
2213-namespace qtmir {
2214-
2215-Screens::Screens(QObject *parent) :
2216- QAbstractListModel(parent)
2217-{
2218- if (qGuiApp->platformName() != QLatin1String("mirserver")) {
2219- qCritical("Not using 'mirserver' QPA plugin. Using Screens may produce unknown results.");
2220- }
2221-
2222- connect(qGuiApp, &QGuiApplication::screenAdded, this, &Screens::onScreenAdded);
2223- connect(qGuiApp, &QGuiApplication::screenRemoved, this, &Screens::onScreenRemoved);
2224- connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &Screens::activeScreenChanged);
2225-
2226- Q_FOREACH(QScreen* screen, QGuiApplication::screens()) {
2227- m_screenList.push_back(new ScreenAdapter(screen));
2228- }
2229- DEBUG_MSG << "(" << m_screenList << ")";
2230-}
2231-
2232-QHash<int, QByteArray> Screens::roleNames() const
2233-{
2234- QHash<int, QByteArray> roles;
2235- roles[ScreenRole] = "screen";
2236- return roles;
2237-}
2238-
2239-QVariant Screens::data(const QModelIndex &index, int role) const
2240-{
2241- if (!index.isValid() || index.row() >= m_screenList.size()) {
2242- return QVariant();
2243- }
2244-
2245- switch(role) {
2246- case ScreenRole:
2247- return QVariant::fromValue(m_screenList.at(index.row()));
2248- } // switch
2249-
2250- return QVariant();
2251-}
2252-
2253-int Screens::rowCount(const QModelIndex &) const
2254-{
2255- return count();
2256-}
2257-
2258-int Screens::count() const
2259-{
2260- return m_screenList.size();
2261-}
2262-
2263-QVariant Screens::activeScreen() const
2264-{
2265- for (int i = 0; i < m_screenList.count(); i++) {
2266- if (m_screenList[i]->isActive()) return i;
2267- }
2268- return QVariant();
2269-}
2270-
2271-void Screens::activateScreen(const QVariant& vindex)
2272-{
2273- bool ok = false;
2274- int index = vindex.toInt(&ok);
2275- if (!ok || index < 0 || m_screenList.count() <= index) return;
2276-
2277- auto screen = static_cast<ScreenAdapter*>(m_screenList.at(index));
2278- screen->setActive(true);
2279-}
2280-
2281-void Screens::onScreenAdded(QScreen *screen)
2282-{
2283- Q_FOREACH(auto screenWrapper, m_screenList) {
2284- if (screenWrapper->screen() == screen) return;
2285- }
2286- DEBUG_MSG << "(screen=" << screen << ")";
2287-
2288- beginInsertRows(QModelIndex(), count(), count());
2289- auto screenWrapper(new ScreenAdapter(screen));
2290- m_screenList.push_back(screenWrapper);
2291- endInsertRows();
2292- Q_EMIT screenAdded(screenWrapper);
2293- Q_EMIT countChanged();
2294-}
2295-
2296-void Screens::onScreenRemoved(QScreen *screen)
2297-{
2298- DEBUG_MSG << "(screen=" << screen << ")";
2299-
2300- int index = 0;
2301- QMutableListIterator<ScreenAdapter*> iter(m_screenList);
2302- while(iter.hasNext()) {
2303- auto screenWrapper = iter.next();
2304- if (screenWrapper->screen() == screen) {
2305-
2306- beginRemoveRows(QModelIndex(), index, index);
2307- auto screenWrapper = m_screenList.takeAt(index);
2308- endRemoveRows();
2309-
2310- Q_EMIT screenRemoved(screenWrapper);
2311- Q_EMIT countChanged();
2312-
2313- iter.remove();
2314- screenWrapper->deleteLater();
2315- break;
2316- }
2317- index++;
2318- }
2319-}
2320-
2321-} // namespace qtmir
2322
2323=== removed file 'src/modules/Unity/Screens/screens.h'
2324--- src/modules/Unity/Screens/screens.h 2017-04-06 08:50:28 +0000
2325+++ src/modules/Unity/Screens/screens.h 1970-01-01 00:00:00 +0000
2326@@ -1,70 +0,0 @@
2327-/*
2328- * Copyright (C) 2016 Canonical, Ltd.
2329- *
2330- * This program is free software: you can redistribute it and/or modify it under
2331- * the terms of the GNU Lesser General Public License version 3, as published by
2332- * the Free Software Foundation.
2333- *
2334- * This program is distributed in the hope that it will be useful, but WITHOUT
2335- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2336- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2337- * Lesser General Public License for more details.
2338- *
2339- * You should have received a copy of the GNU Lesser General Public License
2340- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2341- */
2342-
2343-#ifndef SCREENS_H
2344-#define SCREENS_H
2345-
2346-#include "screentypes.h"
2347-
2348-#include <QAbstractListModel>
2349-
2350-class QScreen;
2351-class ScreenAdapter;
2352-
2353-namespace qtmir {
2354-
2355-class Screens : public QAbstractListModel
2356-{
2357- Q_OBJECT
2358- Q_PROPERTY(int count READ count NOTIFY countChanged)
2359- Q_PROPERTY(QVariant activeScreen READ activeScreen WRITE activateScreen NOTIFY activeScreenChanged)
2360-
2361-public:
2362- enum ItemRoles {
2363- ScreenRole = Qt::UserRole + 1
2364- };
2365-
2366- explicit Screens(QObject *parent = 0);
2367- virtual ~Screens() noexcept = default;
2368-
2369- /* QAbstractItemModel */
2370- QHash<int, QByteArray> roleNames() const override;
2371- QVariant data(const QModelIndex &index, int role = ScreenRole) const override;
2372- int rowCount(const QModelIndex &parent = QModelIndex()) const override;
2373-
2374- int count() const;
2375- QVariant activeScreen() const;
2376-
2377-public Q_SLOTS:
2378- void activateScreen(const QVariant& index);
2379-
2380-Q_SIGNALS:
2381- void countChanged();
2382- void activeScreenChanged();
2383- void screenAdded(ScreenAdapter *screen);
2384- void screenRemoved(ScreenAdapter *screen);
2385-
2386-private Q_SLOTS:
2387- void onScreenAdded(QScreen *screen);
2388- void onScreenRemoved(QScreen *screen);
2389-
2390-private:
2391- QList<ScreenAdapter *> m_screenList;
2392-};
2393-
2394-} // namespace qtmir
2395-
2396-#endif // SCREENS_H
2397
2398=== removed file 'src/modules/Unity/Screens/types.h'
2399--- src/modules/Unity/Screens/types.h 2017-04-06 08:50:28 +0000
2400+++ src/modules/Unity/Screens/types.h 1970-01-01 00:00:00 +0000
2401@@ -1,41 +0,0 @@
2402-/*
2403- * Copyright © 2016 Canonical Ltd.
2404- *
2405- * This program is free software: you can redistribute it and/or modify it under
2406- * the terms of the GNU Lesser General Public License version 3, as published by
2407- * the Free Software Foundation.
2408- *
2409- * This program is distributed in the hope that it will be useful, but WITHOUT
2410- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2411- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2412- * Lesser General Public License for more details.
2413- *
2414- * You should have received a copy of the GNU Lesser General Public License
2415- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2416- */
2417-
2418-#ifndef UNITY_SCREEN_TYPES_H
2419-#define UNITY_SCREEN_TYPES_H
2420-
2421-#include <QObject>
2422-#include <QSize>
2423-
2424-class ScreenMode : public QObject
2425-{
2426- Q_OBJECT
2427- Q_PROPERTY(qreal refreshRate MEMBER refreshRate CONSTANT)
2428- Q_PROPERTY(QSize size MEMBER size CONSTANT)
2429-public:
2430- ScreenMode():refreshRate(-1) {}
2431- ScreenMode(const ScreenMode& other)
2432- : QObject(nullptr),
2433- refreshRate{other.refreshRate},size{other.size}
2434- {}
2435-
2436- qreal refreshRate;
2437- QSize size;
2438-};
2439-
2440-Q_DECLARE_METATYPE(ScreenMode)
2441-
2442-#endif //UNITY_SCREEN_TYPES_H
2443
2444=== modified file 'src/platforms/mirserver/CMakeLists.txt'
2445--- src/platforms/mirserver/CMakeLists.txt 2017-04-06 08:50:28 +0000
2446+++ src/platforms/mirserver/CMakeLists.txt 2017-04-06 08:50:29 +0000
2447@@ -2,6 +2,7 @@
2448 # And also not anymore as pkgconfig module since Qt 5.6.
2449 #pkg_check_modules(QT5PLATFORM_SUPPORT Qt5PlatformSupport REQUIRED)
2450 include(FindQt5PlatformSupport)
2451+include(UseLttngGenTp)
2452
2453 set(QTMIRSERVER_ABI 1)
2454
2455@@ -54,6 +55,12 @@
2456 # Needed to compile tracepoints in C99 mode.
2457 add_definitions(-DBYTE_ORDER=__BYTE_ORDER)
2458
2459+# Generate tracepoints.c and .h from tracepoints.tp
2460+add_lttng_gen_tp(NAME tracepoints)
2461+add_custom_target(MirServer_LTTNG
2462+ DEPENDS tracepoints.h tracepoints.c
2463+)
2464+
2465 # These files will compile without mirserver-dev
2466 add_library(qtmirserver-nomirserver OBJECT
2467 ${CMAKE_SOURCE_DIR}/src/common/timestamp.cpp
2468@@ -67,10 +74,15 @@
2469 nativeinterface.cpp
2470 services.cpp
2471 windowcontroller.cpp
2472+ workspacecontroller.cpp
2473 tracepoints.c
2474 surfaceobserver.cpp
2475 initialsurfacesizes.cpp
2476+ screenadaptor.cpp
2477+ screenadaptormodel.cpp
2478+ qtmir.cpp
2479 )
2480+add_dependencies(qtmirserver-nomirserver MirServer_LTTNG)
2481
2482 set_source_files_properties(tracepoints.c PROPERTIES COMPILE_FLAGS "${CMAKE_CFLAGS} -fPIC")
2483
2484@@ -106,6 +118,7 @@
2485 offscreensurface.cpp
2486 inputdeviceobserver.cpp
2487 mirserverapplication.cpp
2488+ windowmodelnotifier.cpp
2489
2490 # We need to run moc on these headers
2491 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirMousePointerInterface.h
2492@@ -116,8 +129,13 @@
2493 ${CMAKE_SOURCE_DIR}/include/qtmir/sessionauthorizer.h
2494 ${CMAKE_SOURCE_DIR}/include/qtmir/windowmanagementpolicy.h
2495 ${CMAKE_SOURCE_DIR}/include/qtmir/displayconfigurationstorage.h
2496+ ${CMAKE_SOURCE_DIR}/include/qtmir/screen.h
2497+ ${CMAKE_SOURCE_DIR}/include/qtmir/screens.h
2498+ ${CMAKE_SOURCE_DIR}/include/qtmir/types.h
2499+ ${CMAKE_SOURCE_DIR}/include/qtmir/qtmir.h
2500
2501 ${CMAKE_SOURCE_DIR}/src/common/windowcontrollerinterface.h
2502+ ${CMAKE_SOURCE_DIR}/src/common/workspacecontrollerinterface.h
2503 ${CMAKE_SOURCE_DIR}/src/common/windowmodelnotifier.h
2504 ${CMAKE_SOURCE_DIR}/src/common/appnotifier.h
2505 )
2506@@ -166,9 +184,6 @@
2507 @ONLY
2508 )
2509
2510-include(UseLttngGenTp)
2511-add_lttng_gen_tp(NAME tracepoints)
2512-
2513 install(
2514 TARGETS qtmirserver
2515 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
2516
2517=== removed file 'src/platforms/mirserver/customscreenconfiguration.h'
2518--- src/platforms/mirserver/customscreenconfiguration.h 2017-04-06 08:50:28 +0000
2519+++ src/platforms/mirserver/customscreenconfiguration.h 1970-01-01 00:00:00 +0000
2520@@ -1,45 +0,0 @@
2521-/*
2522- * Copyright (C) 2016 Canonical, Ltd.
2523- *
2524- * This program is free software: you can redistribute it and/or modify it under
2525- * the terms of the GNU Lesser General Public License version 3, as published by
2526- * the Free Software Foundation.
2527- *
2528- * This program is distributed in the hope that it will be useful, but WITHOUT
2529- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2530- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2531- * Lesser General Public License for more details.
2532- *
2533- * You should have received a copy of the GNU Lesser General Public License
2534- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2535- */
2536-
2537-#ifndef CUSTOMSCREENCONFIGURATION_H
2538-#define CUSTOMSCREENCONFIGURATION_H
2539-
2540-#include <QPoint>
2541-#include <QVector>
2542-
2543-#include "screentypes.h"
2544-#include <mir_toolkit/common.h>
2545-
2546-
2547-struct CustomScreenConfiguration
2548-{
2549- bool valid{false};
2550- qtmir::OutputId id;
2551-
2552- bool used;
2553- QPoint topLeft;
2554- uint32_t currentModeIndex;
2555- MirPowerMode powerMode;
2556- MirOrientation orientation;
2557- float scale;
2558- qtmir::FormFactor formFactor;
2559-
2560- // To read additional readonly state, consult the Screen
2561-};
2562-
2563-typedef QVector<CustomScreenConfiguration> CustomScreenConfigurationList;
2564-
2565-#endif // CUSTOMSCREENCONFIGURATION_H
2566
2567=== modified file 'src/platforms/mirserver/miral/CMakeLists.txt'
2568--- src/platforms/mirserver/miral/CMakeLists.txt 2017-04-06 08:50:28 +0000
2569+++ src/platforms/mirserver/miral/CMakeLists.txt 2017-04-06 08:50:29 +0000
2570@@ -8,6 +8,7 @@
2571 persist_display_config.cpp persist_display_config.h
2572 mirbuffer.cpp mirbuffer.h
2573 ${CMAKE_SOURCE_DIR}/include/qtmir/miral/display_configuration_storage.h
2574+ edid.cpp ${CMAKE_SOURCE_DIR}/include/qtmir/miral/display_id.h
2575 edid.cpp ${CMAKE_SOURCE_DIR}/include/qtmir/miral/edid.h
2576 display_configuration_policy.cpp ${CMAKE_SOURCE_DIR}/include/qtmir/miral/display_configuration_policy.h
2577 )
2578
2579=== modified file 'src/platforms/mirserver/miral/persist_display_config.cpp'
2580--- src/platforms/mirserver/miral/persist_display_config.cpp 2017-04-06 08:50:28 +0000
2581+++ src/platforms/mirserver/miral/persist_display_config.cpp 2017-04-06 08:50:29 +0000
2582@@ -179,7 +179,7 @@
2583 miral::DisplayId display_id;
2584 // FIXME - output.edid should be std::vector<uint8_t>, not std::vector<uint8_t const>
2585 display_id.edid.parse_data(reinterpret_cast<std::vector<uint8_t> const&>(output.edid));
2586- display_id.output_id = output.id.as_value();
2587+ display_id.output_id = output.id;
2588
2589 // TODO if the h/w profile (by some definition) has changed, then apply corresponding saved config (if any).
2590 // TODO Otherwise...
2591@@ -232,7 +232,7 @@
2592 miral::DisplayId display_id;
2593 // FIXME - output.edid should be std::vector<uint8_t>, not std::vector<uint8_t const>
2594 display_id.edid.parse_data(reinterpret_cast<std::vector<uint8_t> const&>(output.edid));
2595- display_id.output_id = output.id.as_value();
2596+ display_id.output_id = output.id;
2597
2598 miral::DisplayConfigurationOptions config;
2599
2600
2601=== modified file 'src/platforms/mirserver/mirserverapplication.cpp'
2602--- src/platforms/mirserver/mirserverapplication.cpp 2017-04-06 08:50:28 +0000
2603+++ src/platforms/mirserver/mirserverapplication.cpp 2017-04-06 08:50:29 +0000
2604@@ -16,12 +16,14 @@
2605
2606 #include "qtmir/mirserverapplication.h"
2607 #include "qmirserver.h"
2608+#include "qtmir/qtmir.h"
2609
2610 #include <QDebug>
2611
2612-namespace qtmir {
2613-
2614-namespace {
2615+namespace qtmir
2616+{
2617+namespace
2618+{
2619
2620 QSharedPointer<QMirServer> mirServer;
2621
2622
2623=== modified file 'src/platforms/mirserver/platformscreen.cpp'
2624--- src/platforms/mirserver/platformscreen.cpp 2017-04-06 08:50:28 +0000
2625+++ src/platforms/mirserver/platformscreen.cpp 2017-04-06 08:50:29 +0000
2626@@ -156,7 +156,7 @@
2627 , m_unityScreen(nullptr)
2628 {
2629 setMirDisplayConfiguration(screen, false);
2630- DEBUG_MSG_SCREENS << "(output=" << m_outputId.as_value()
2631+ DEBUG_MSG_SCREENS << "(output=" << m_displayId.output_id.as_value()
2632 << ", used=" << (m_used ? "true" : "false")
2633 << ", geometry=" << geometry() << ")";
2634
2635@@ -241,7 +241,13 @@
2636 }
2637
2638 // Output data - each output has a unique id and corresponding type. Can be multiple cards.
2639- m_outputId = screen.id;
2640+ m_displayId.output_id = screen.id;
2641+ try {
2642+ m_displayId.edid.parse_data(reinterpret_cast<std::vector<uint8_t> const&>(screen.edid));
2643+ } catch (std::runtime_error const& e) {
2644+ printf("Failed to parse EDID - %s\n", e.what());
2645+ }
2646+
2647 auto type = static_cast<qtmir::OutputTypes>(screen.type); //FIXME: need compile time check these are equivalent
2648 if (m_type != type) {
2649 m_type = type;
2650@@ -279,7 +285,10 @@
2651 m_depth = 8 * MIR_BYTES_PER_PIXEL(screen.current_format);
2652
2653 // Power mode
2654- m_powerMode = screen.power_mode;
2655+ if (m_powerMode != screen.power_mode) {
2656+ m_powerMode = screen.power_mode;
2657+ Q_EMIT powerModeChanged();
2658+ }
2659
2660 QRect oldGeometry = m_geometry;
2661 // Position of screen in virtual desktop coordinate space
2662@@ -406,7 +415,7 @@
2663
2664 QString PlatformScreen::name() const
2665 {
2666- return displayTypeToString(m_type);
2667+ return QString("%1-%2").arg(displayTypeToString(m_type)).arg(m_displayId.output_id.as_value());
2668 }
2669
2670 QWindow *PlatformScreen::topLevelAt(const QPoint &point) const
2671
2672=== modified file 'src/platforms/mirserver/platformscreen.h'
2673--- src/platforms/mirserver/platformscreen.h 2017-04-06 08:50:28 +0000
2674+++ src/platforms/mirserver/platformscreen.h 2017-04-06 08:50:29 +0000
2675@@ -28,9 +28,10 @@
2676 #include <mir_toolkit/common.h>
2677
2678 // local
2679+#include "qtmir/types.h"
2680+#include "qtmir/miral/display_configuration_storage.h"
2681 #include "cursor.h"
2682 #include "screenplatformwindow.h"
2683-#include "screentypes.h"
2684
2685 class QOrientationSensor;
2686 namespace mir {
2687@@ -63,7 +64,7 @@
2688 float scale() const { return m_scale; }
2689 qtmir::FormFactor formFactor() const { return m_formFactor; }
2690 MirPowerMode powerMode() const { return m_powerMode; }
2691- qtmir::OutputId outputId() const { return m_outputId; }
2692+ miral::DisplayId displayId() const { return m_displayId; }
2693 qtmir::OutputTypes outputType() const { return m_type; }
2694 uint32_t currentModeIndex() const { return m_currentModeIndex; }
2695 bool isActive() const { return m_isActive; }
2696@@ -91,6 +92,8 @@
2697 void outputTypeChanged();
2698 void scaleChanged();
2699 void formFactorChanged();
2700+ void orientationChanged();
2701+ void powerModeChanged();
2702 void currentModeIndexChanged();
2703 void positionChanged();
2704 void modeChanged();
2705@@ -133,7 +136,7 @@
2706
2707 mir::renderer::gl::RenderTarget *m_renderTarget;
2708 mir::graphics::DisplaySyncGroup *m_displayGroup;
2709- qtmir::OutputId m_outputId;
2710+ miral::DisplayId m_displayId;
2711 qtmir::OutputTypes m_type;
2712 MirPowerMode m_powerMode;
2713
2714
2715=== modified file 'src/platforms/mirserver/qmirserver.cpp'
2716--- src/platforms/mirserver/qmirserver.cpp 2017-04-06 08:50:28 +0000
2717+++ src/platforms/mirserver/qmirserver.cpp 2017-04-06 08:50:29 +0000
2718@@ -116,6 +116,8 @@
2719 result = d->promptSessionListener();
2720 else if (resource == "WindowController")
2721 result = d->windowController();
2722+ else if (resource == "WorkspaceController")
2723+ result = d->workspaceController();
2724 else if (resource == "WindowModelNotifier")
2725 result = d->windowModelNotifier();
2726 else if (resource == "ScreensController")
2727
2728=== modified file 'src/platforms/mirserver/qmirserver_p.cpp'
2729--- src/platforms/mirserver/qmirserver_p.cpp 2017-04-06 08:50:28 +0000
2730+++ src/platforms/mirserver/qmirserver_p.cpp 2017-04-06 08:50:29 +0000
2731@@ -182,6 +182,7 @@
2732 m_mirServerHooks,
2733 miral::set_window_management_policy<WrappedWindowManagementPolicy>(m_windowModelNotifier,
2734 m_windowController,
2735+ m_workspaceController,
2736 m_appNotifier,
2737 eventFeeder,
2738 m_windowManagementPolicy),
2739
2740=== modified file 'src/platforms/mirserver/qmirserver_p.h'
2741--- src/platforms/mirserver/qmirserver_p.h 2017-04-06 08:50:28 +0000
2742+++ src/platforms/mirserver/qmirserver_p.h 2017-04-06 08:50:29 +0000
2743@@ -31,6 +31,7 @@
2744 #include "screensmodel.h"
2745 #include "windowcontroller.h"
2746 #include "windowmodelnotifier.h"
2747+#include "workspacecontroller.h"
2748 #include "mirserverhooks.h"
2749 #include "wrappedsessionauthorizer.h"
2750 #include "qteventfeeder.h"
2751@@ -80,6 +81,9 @@
2752 qtmir::WindowControllerInterface *windowController() const
2753 { return &m_windowController; }
2754
2755+ qtmir::WorkspaceControllerInterface *workspaceController() const
2756+ { return &m_workspaceController; }
2757+
2758 qtmir::DisplayConfigurationPolicyWrapper m_displayConfigurationPolicy;
2759 qtmir::WindowManagmentPolicyBuilder m_windowManagementPolicy;
2760 qtmir::BasicSetDisplayConfigurationStorage m_displayConfigurationStorage;
2761@@ -93,6 +97,7 @@
2762 mutable qtmir::AppNotifier m_appNotifier;
2763 mutable qtmir::WindowModelNotifier m_windowModelNotifier;
2764 mutable qtmir::WindowController m_windowController;
2765+ mutable qtmir::WorkspaceController m_workspaceController;
2766 };
2767
2768 class MirServerThread : public QThread
2769
2770=== added file 'src/platforms/mirserver/qtmir.cpp'
2771--- src/platforms/mirserver/qtmir.cpp 1970-01-01 00:00:00 +0000
2772+++ src/platforms/mirserver/qtmir.cpp 2017-04-06 08:50:29 +0000
2773@@ -0,0 +1,15 @@
2774+#include "qtmir/qtmir.h"
2775+#include "screenadaptormodel.h"
2776+
2777+QWeakPointer<qtmir::Screens> weakScreenModel;
2778+
2779+QSharedPointer<qtmir::Screens> qtmir::get_screen_model()
2780+{
2781+ auto model = weakScreenModel.lock();
2782+ if (!model) {
2783+ QSharedPointer<qtmir::Screens> newModel{new ScreenAdaptorModel()};
2784+ weakScreenModel = model;
2785+ return newModel;
2786+ }
2787+ return model;
2788+}
2789
2790=== added file 'src/platforms/mirserver/screenadaptor.cpp'
2791--- src/platforms/mirserver/screenadaptor.cpp 1970-01-01 00:00:00 +0000
2792+++ src/platforms/mirserver/screenadaptor.cpp 2017-04-06 08:50:29 +0000
2793@@ -0,0 +1,175 @@
2794+/*
2795+ * Copyright (C) 2017 Canonical, Ltd.
2796+ *
2797+ * This program is free software: you can redistribute it and/or modify it under
2798+ * the terms of the GNU Lesser General Public License version 3, as published by
2799+ * the Free Software Foundation.
2800+ *
2801+ * This program is distributed in the hope that it will be useful, but WITHOUT
2802+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2803+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2804+ * Lesser General Public License for more details.
2805+ *
2806+ * You should have received a copy of the GNU Lesser General Public License
2807+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2808+ */
2809+
2810+#include "screenadaptor.h"
2811+
2812+// qtmir
2813+#include "platformscreen.h"
2814+#include "screenscontroller.h"
2815+#include "nativeinterface.h"
2816+
2817+// Qt
2818+#include <QScreen>
2819+#include <QQmlEngine>
2820+#include <QDebug>
2821+#include <QGuiApplication>
2822+
2823+ScreenAdaptor::ScreenAdaptor(QScreen* screen, QObject* parent)
2824+ : qtmir::Screen(parent)
2825+ , m_screen(screen)
2826+ , m_screensController(static_cast<ScreensController*>(qGuiApp->platformNativeInterface()
2827+ ->nativeResourceForIntegration("ScreensController")))
2828+{
2829+ if (!m_screensController) {
2830+ qFatal("Screens Controller not initialized");
2831+ }
2832+
2833+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2834+ connect(platformScreen, &PlatformScreen::usedChanged, this, &ScreenAdaptor::usedChanged);
2835+ connect(platformScreen, &PlatformScreen::nameChanged, this, &ScreenAdaptor::nameChanged);
2836+ connect(platformScreen, &PlatformScreen::outputTypeChanged, this, &ScreenAdaptor::outputTypeChanged);
2837+ connect(platformScreen, &PlatformScreen::scaleChanged, this, &ScreenAdaptor::scaleChanged);
2838+ connect(platformScreen, &PlatformScreen::formFactorChanged, this, &ScreenAdaptor::formFactorChanged);
2839+ connect(platformScreen, &PlatformScreen::powerModeChanged, this, &ScreenAdaptor::powerModeChanged);
2840+ connect(platformScreen, &PlatformScreen::physicalSizeChanged, this, &ScreenAdaptor::physicalSizeChanged);
2841+ connect(platformScreen, &PlatformScreen::positionChanged, this, &ScreenAdaptor::positionChanged);
2842+ connect(platformScreen, &PlatformScreen::activeChanged, this, &ScreenAdaptor::activeChanged);
2843+ connect(platformScreen, &PlatformScreen::currentModeIndexChanged, this, &ScreenAdaptor::currentModeIndexChanged);
2844+ connect(platformScreen, &PlatformScreen::availableModesChanged, this, &ScreenAdaptor::updateScreenModes);
2845+ connect(screen, &QScreen::orientationChanged, this, &ScreenAdaptor::orientationChanged);
2846+
2847+ updateScreenModes();
2848+}
2849+
2850+ScreenAdaptor::~ScreenAdaptor()
2851+{
2852+ qDeleteAll(m_modes);
2853+ m_modes.clear();
2854+}
2855+
2856+miral::DisplayId ScreenAdaptor::displayId() const
2857+{
2858+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2859+ return platformScreen->displayId();
2860+}
2861+
2862+bool ScreenAdaptor::used() const
2863+{
2864+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2865+ return platformScreen->used();
2866+}
2867+
2868+QString ScreenAdaptor::name() const
2869+{
2870+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2871+ return platformScreen->name();
2872+}
2873+
2874+float ScreenAdaptor::scale() const
2875+{
2876+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2877+ return platformScreen->scale();
2878+}
2879+
2880+QSizeF ScreenAdaptor::physicalSize() const
2881+{
2882+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2883+ return platformScreen->physicalSize();
2884+}
2885+
2886+qtmir::FormFactor ScreenAdaptor::formFactor() const
2887+{
2888+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2889+ return static_cast<qtmir::FormFactor>(platformScreen->formFactor()); // needs compile time check
2890+}
2891+
2892+qtmir::OutputTypes ScreenAdaptor::outputType() const
2893+{
2894+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2895+ return platformScreen->outputType();
2896+}
2897+
2898+MirPowerMode ScreenAdaptor::powerMode() const
2899+{
2900+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2901+ return platformScreen->powerMode();
2902+}
2903+
2904+Qt::ScreenOrientation ScreenAdaptor::orientation() const
2905+{
2906+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2907+ return platformScreen->orientation();
2908+}
2909+
2910+QPoint ScreenAdaptor::position() const
2911+{
2912+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2913+ return platformScreen->geometry().topLeft();
2914+}
2915+
2916+QQmlListProperty<qtmir::ScreenMode> ScreenAdaptor::availableModes()
2917+{
2918+ return QQmlListProperty<qtmir::ScreenMode>(this, m_modes);
2919+}
2920+
2921+uint ScreenAdaptor::currentModeIndex() const
2922+{
2923+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2924+ return platformScreen->currentModeIndex();
2925+}
2926+
2927+bool ScreenAdaptor::isActive() const
2928+{
2929+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2930+ return platformScreen->isActive();
2931+}
2932+
2933+QScreen *ScreenAdaptor::qscreen() const
2934+{
2935+ return m_screen.data();
2936+}
2937+
2938+qtmir::ScreenConfiguration *ScreenAdaptor::beginConfiguration() const
2939+{
2940+ auto config = m_screensController->outputConfiguration(this->displayId().output_id);
2941+ return new qtmir::ScreenConfiguration(config);
2942+}
2943+
2944+bool ScreenAdaptor::applyConfiguration(qtmir::ScreenConfiguration *configuration)
2945+{
2946+ return m_screensController->setOutputConfiguration(*configuration);
2947+}
2948+
2949+void ScreenAdaptor::setActive(bool active)
2950+{
2951+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2952+ platformScreen->setActive(active);
2953+}
2954+
2955+void ScreenAdaptor::updateScreenModes()
2956+{
2957+ auto platformScreen = static_cast<PlatformScreen*>(m_screen->handle());
2958+
2959+ qDeleteAll(m_modes);
2960+ m_modes.clear();
2961+ Q_FOREACH(auto mode, platformScreen->availableModes()) {
2962+ auto newMode(new qtmir::ScreenMode(mode.first, mode.second));
2963+ QQmlEngine::setObjectOwnership(newMode, QQmlEngine::CppOwnership);
2964+ m_modes.append(newMode);
2965+ }
2966+
2967+ Q_EMIT availableModesChanged();
2968+}
2969
2970=== added file 'src/platforms/mirserver/screenadaptor.h'
2971--- src/platforms/mirserver/screenadaptor.h 1970-01-01 00:00:00 +0000
2972+++ src/platforms/mirserver/screenadaptor.h 2017-04-06 08:50:29 +0000
2973@@ -0,0 +1,66 @@
2974+/*
2975+ * Copyright (C) 2017 Canonical, Ltd.
2976+ *
2977+ * This program is free software: you can redistribute it and/or modify it under
2978+ * the terms of the GNU Lesser General Public License version 3, as published by
2979+ * the Free Software Foundation.
2980+ *
2981+ * This program is distributed in the hope that it will be useful, but WITHOUT
2982+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2983+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2984+ * Lesser General Public License for more details.
2985+ *
2986+ * You should have received a copy of the GNU Lesser General Public License
2987+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2988+ */
2989+
2990+#ifndef QTMIR_SCREENADAPTOR_H
2991+#define QTMIR_SCREENADAPTOR_H
2992+
2993+#include "qtmir/screen.h"
2994+
2995+#include <QObject>
2996+#include <QPointer>
2997+#include <QQmlListProperty>
2998+
2999+class QScreen;
3000+class ScreenConfig;
3001+class ScreensController;
3002+
3003+class ScreenAdaptor : public qtmir::Screen
3004+{
3005+ Q_OBJECT
3006+public:
3007+ ScreenAdaptor(QScreen* screen, QObject* parent = 0);
3008+ ~ScreenAdaptor();
3009+
3010+ miral::DisplayId displayId() const override;
3011+ bool used() const override;
3012+ QString name() const override;
3013+ float scale() const override;
3014+ QSizeF physicalSize() const override;
3015+ qtmir::FormFactor formFactor() const override;
3016+ qtmir::OutputTypes outputType() const override;
3017+ MirPowerMode powerMode() const override;
3018+ Qt::ScreenOrientation orientation() const override;
3019+ QPoint position() const override;
3020+ QQmlListProperty<qtmir::ScreenMode> availableModes() override;
3021+ uint currentModeIndex() const override;
3022+ bool isActive() const override;
3023+ void setActive(bool active) override;
3024+
3025+ QScreen *qscreen() const override;
3026+
3027+ qtmir::ScreenConfiguration *beginConfiguration() const override;
3028+ bool applyConfiguration(qtmir::ScreenConfiguration *configuration) override;
3029+
3030+private Q_SLOTS:
3031+ void updateScreenModes();
3032+
3033+private:
3034+ QList<qtmir::ScreenMode*> m_modes;
3035+ QPointer<QScreen> m_screen;
3036+ ScreensController *m_screensController;
3037+};
3038+
3039+#endif // QTMIR_SCREENADAPTOR_H
3040
3041=== added file 'src/platforms/mirserver/screenadaptormodel.cpp'
3042--- src/platforms/mirserver/screenadaptormodel.cpp 1970-01-01 00:00:00 +0000
3043+++ src/platforms/mirserver/screenadaptormodel.cpp 2017-04-06 08:50:29 +0000
3044@@ -0,0 +1,99 @@
3045+/*
3046+ * Copyright (C) 2017 Canonical, Ltd.
3047+ *
3048+ * This program is free software: you can redistribute it and/or modify it under
3049+ * the terms of the GNU Lesser General Public License version 3, as published by
3050+ * the Free Software Foundation.
3051+ *
3052+ * This program is distributed in the hope that it will be useful, but WITHOUT
3053+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3054+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3055+ * Lesser General Public License for more details.
3056+ *
3057+ * You should have received a copy of the GNU Lesser General Public License
3058+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3059+ */
3060+
3061+#include "screenadaptormodel.h"
3062+
3063+// mirserver
3064+#include "screenadaptor.h"
3065+#include "logging.h"
3066+
3067+// Qt
3068+#include <QGuiApplication>
3069+#include <QScreen>
3070+#include <QWindow>
3071+
3072+#define DEBUG_MSG qCDebug(QTMIR_SCREENS).nospace() << "Screens[" << (void*)this <<"]::" << __func__
3073+
3074+ScreenAdaptorModel::ScreenAdaptorModel(QObject *parent)
3075+ : qtmir::Screens(parent)
3076+{
3077+ if (qGuiApp->platformName() != QLatin1String("mirserver")) {
3078+ qFatal("Can't use the ScreenAdaptorModel model without using 'mirserver' QPA plugin.");
3079+ }
3080+
3081+ connect(qGuiApp, &QGuiApplication::screenAdded, this, &ScreenAdaptorModel::onScreenAdded);
3082+ connect(qGuiApp, &QGuiApplication::screenRemoved, this, &ScreenAdaptorModel::onScreenRemoved);
3083+ connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &ScreenAdaptorModel::activeScreenChanged);
3084+
3085+ Q_FOREACH(QScreen* screen, QGuiApplication::screens()) {
3086+ m_screenList.push_back(new ScreenAdaptor(screen));
3087+ }
3088+ DEBUG_MSG << "(" << m_screenList << ")";
3089+
3090+ // Register types.
3091+ qRegisterMetaType<qtmir::ScreenConfiguration*>("qtmir::ScreenConfiguration*");
3092+ qRegisterMetaType<qtmir::FormFactor>("qtmir::FormFactor");
3093+ qRegisterMetaType<qtmir::OutputTypes>("qtmir::OutputTypes");
3094+}
3095+
3096+ScreenAdaptorModel::~ScreenAdaptorModel()
3097+{
3098+ qDeleteAll(m_screenList);
3099+ m_screenList.clear();
3100+}
3101+
3102+qtmir::Screen *ScreenAdaptorModel::activeScreen() const
3103+{
3104+ QWindow* window = qGuiApp->focusWindow();
3105+ if (!window || !window->screen()) return nullptr;
3106+
3107+ Q_FOREACH(auto screen, m_screenList) {
3108+ if (screen && screen->qscreen() == window->screen()) return screen;
3109+ }
3110+ return nullptr;
3111+}
3112+
3113+void ScreenAdaptorModel::onScreenAdded(QScreen *qscreen)
3114+{
3115+ Q_FOREACH(auto screen, m_screenList) {
3116+ auto adaptor = qobject_cast<ScreenAdaptor*>(screen);
3117+ if (adaptor && adaptor->qscreen() == qscreen) return;
3118+ }
3119+ DEBUG_MSG << "(screen=" << qscreen << ")";
3120+
3121+ auto adaptor(new ScreenAdaptor(qscreen));
3122+ m_screenList.push_back(adaptor);
3123+ Q_EMIT screenAdded(adaptor);
3124+}
3125+
3126+void ScreenAdaptorModel::onScreenRemoved(QScreen *qscreen)
3127+{
3128+ DEBUG_MSG << "(screen=" << qscreen << ")";
3129+
3130+ int index = 0;
3131+ QMutableVectorIterator<qtmir::Screen*> iter(m_screenList);
3132+ while(iter.hasNext()) {
3133+ auto adaptor = qobject_cast<ScreenAdaptor*>(iter.next());
3134+ if (adaptor && adaptor->qscreen() == qscreen) {
3135+ Q_EMIT screenRemoved(adaptor);
3136+
3137+ iter.remove();
3138+ delete adaptor;
3139+ break;
3140+ }
3141+ index++;
3142+ }
3143+}
3144
3145=== added file 'src/platforms/mirserver/screenadaptormodel.h'
3146--- src/platforms/mirserver/screenadaptormodel.h 1970-01-01 00:00:00 +0000
3147+++ src/platforms/mirserver/screenadaptormodel.h 2017-04-06 08:50:29 +0000
3148@@ -0,0 +1,45 @@
3149+/*
3150+ * Copyright (C) 2017 Canonical, Ltd.
3151+ *
3152+ * This program is free software: you can redistribute it and/or modify it under
3153+ * the terms of the GNU Lesser General Public License version 3, as published by
3154+ * the Free Software Foundation.
3155+ *
3156+ * This program is distributed in the hope that it will be useful, but WITHOUT
3157+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3158+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3159+ * Lesser General Public License for more details.
3160+ *
3161+ * You should have received a copy of the GNU Lesser General Public License
3162+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3163+ */
3164+
3165+#ifndef SCREENADAPTORMODEL_H
3166+#define SCREENADAPTORMODEL_H
3167+
3168+#include "qtmir/screens.h"
3169+
3170+namespace qtmir
3171+{
3172+class Screen;
3173+}
3174+
3175+class ScreenAdaptorModel : public qtmir::Screens
3176+{
3177+public:
3178+ ScreenAdaptorModel(QObject* parent = 0);
3179+ ~ScreenAdaptorModel();
3180+
3181+ QVector<qtmir::Screen*> screens() const { return m_screenList; }
3182+
3183+ qtmir::Screen* activeScreen() const;
3184+
3185+private Q_SLOTS:
3186+ void onScreenAdded(QScreen *screen);
3187+ void onScreenRemoved(QScreen *screen);
3188+
3189+private:
3190+ QVector<qtmir::Screen*> m_screenList;
3191+};
3192+
3193+#endif // SCREENADAPTORMODEL_H
3194
3195=== modified file 'src/platforms/mirserver/screenplatformwindow.cpp'
3196--- src/platforms/mirserver/screenplatformwindow.cpp 2017-04-06 08:50:28 +0000
3197+++ src/platforms/mirserver/screenplatformwindow.cpp 2017-04-06 08:50:29 +0000
3198@@ -57,7 +57,7 @@
3199 DEBUG_MSG << "(window=" << window
3200 << ") - windowId=" << uint(m_winId)
3201 << ", on screen=" << platformScreen
3202- << ", outputId=" << platformScreen->outputId().as_value()
3203+ << ", outputId=" << platformScreen->displayId().output_id.as_value()
3204 << ", geometry=" << screenGeometry;
3205
3206 platformScreen->addWindow(this);
3207@@ -172,7 +172,7 @@
3208 auto platformScreen = static_cast<PlatformScreen *>(newScreen);
3209 Q_ASSERT(platformScreen);
3210 DEBUG_MSG << "(screen=" << platformScreen
3211- << ", outputId=" << platformScreen->outputId().as_value() << ")";
3212+ << ", outputId=" << platformScreen->displayId().output_id.as_value() << ")";
3213
3214 // Dis-associate the old screen
3215 if (screen()) {
3216
3217=== modified file 'src/platforms/mirserver/screenscontroller.cpp'
3218--- src/platforms/mirserver/screenscontroller.cpp 2017-04-06 08:50:28 +0000
3219+++ src/platforms/mirserver/screenscontroller.cpp 2017-04-06 08:50:29 +0000
3220@@ -36,15 +36,15 @@
3221 {
3222 }
3223
3224-CustomScreenConfigurationList ScreensController::configuration()
3225+qtmir::ScreenConfigurationList ScreensController::configuration()
3226 {
3227- CustomScreenConfigurationList list;
3228+ qtmir::ScreenConfigurationList list;
3229
3230 Q_FOREACH(auto screen, m_screensModel->screens()) {
3231 list.append(
3232- CustomScreenConfiguration {
3233+ qtmir::ScreenConfiguration {
3234 true,
3235- screen->outputId(),
3236+ screen->displayId().output_id,
3237 screen->used(),
3238 screen->geometry().topLeft(),
3239 screen->currentModeIndex(),
3240@@ -57,7 +57,7 @@
3241 return list;
3242 }
3243
3244-bool ScreensController::setConfiguration(const CustomScreenConfigurationList &newConfig)
3245+bool ScreensController::setConfiguration(const qtmir::ScreenConfigurationList &newConfig)
3246 {
3247 using namespace mir::geometry;
3248
3249@@ -87,17 +87,16 @@
3250 return true;
3251 }
3252
3253-CustomScreenConfiguration ScreensController::outputConfiguration(qtmir::OutputId outputId)
3254+qtmir::ScreenConfiguration ScreensController::outputConfiguration(miral::OutputId outputId)
3255 {
3256 auto displayConfiguration = m_display->configuration();
3257- CustomScreenConfiguration config;
3258+ qtmir::ScreenConfiguration config;
3259
3260 displayConfiguration->for_each_output(
3261 [&config, outputId](mg::UserDisplayConfigurationOutput &outputConfig)
3262 {
3263 if (outputConfig.id == outputId) {
3264 config.valid = true;
3265- config.id = outputConfig.id;
3266 config.used = outputConfig.used;
3267 config.topLeft = QPoint{outputConfig.top_left.x.as_int(), outputConfig.top_left.y.as_int()};
3268 config.currentModeIndex = outputConfig.current_mode_index;
3269@@ -110,7 +109,7 @@
3270 return config;
3271 }
3272
3273-bool ScreensController::setOutputConfiguration(const CustomScreenConfiguration &newConfig)
3274+bool ScreensController::setOutputConfiguration(const qtmir::ScreenConfiguration &newConfig)
3275 {
3276 using namespace mir::geometry;
3277 if (!newConfig.valid)
3278
3279=== modified file 'src/platforms/mirserver/screenscontroller.h'
3280--- src/platforms/mirserver/screenscontroller.h 2017-04-06 08:50:28 +0000
3281+++ src/platforms/mirserver/screenscontroller.h 2017-04-06 08:50:29 +0000
3282@@ -23,7 +23,7 @@
3283 #include <QVector>
3284
3285 // local
3286-#include "customscreenconfiguration.h"
3287+#include "qtmir/screen.h"
3288
3289 #include <memory>
3290
3291@@ -45,11 +45,11 @@
3292 const std::shared_ptr<mir::shell::DisplayConfigurationController> &controller,
3293 QObject *parent = 0);
3294
3295- CustomScreenConfigurationList configuration();
3296- bool setConfiguration(const CustomScreenConfigurationList &newConfig);
3297+ qtmir::ScreenConfigurationList configuration();
3298+ bool setConfiguration(const qtmir::ScreenConfigurationList &newConfig);
3299
3300- CustomScreenConfiguration outputConfiguration(qtmir::OutputId outputId);
3301- bool setOutputConfiguration(const CustomScreenConfiguration &newConfig);
3302+ qtmir::ScreenConfiguration outputConfiguration(miral::OutputId outputId);
3303+ bool setOutputConfiguration(const qtmir::ScreenConfiguration &newConfig);
3304
3305 private:
3306 const std::shared_ptr<ScreensModel> m_screensModel;
3307
3308=== modified file 'src/platforms/mirserver/screensmodel.cpp'
3309--- src/platforms/mirserver/screensmodel.cpp 2017-04-06 08:50:28 +0000
3310+++ src/platforms/mirserver/screensmodel.cpp 2017-04-06 08:50:29 +0000
3311@@ -190,7 +190,7 @@
3312
3313 // Delete any old & unused Screens
3314 Q_FOREACH (auto screen, oldScreenList) {
3315- DEBUG_MSG << "() - removed Screen with id " << screen->m_outputId.as_value()
3316+ DEBUG_MSG << "() - removed Screen with id " << screen->displayId().output_id.as_value()
3317 << " and geometry " << screen->geometry();
3318
3319 Q_FOREACH (ScreenPlatformWindow* window, screen->windows()) {
3320@@ -208,7 +208,7 @@
3321
3322 qCDebug(QTMIR_SCREENS) << "=======================================";
3323 Q_FOREACH (auto screen, m_screenList) {
3324- qCDebug(QTMIR_SCREENS) << screen << "- id:" << screen->m_outputId.as_value()
3325+ qCDebug(QTMIR_SCREENS) << screen << "- id:" << screen->displayId().output_id.as_value()
3326 << "geometry:" << screen->geometry()
3327 << "window:" << screen->primaryWindow()
3328 << "type:" << screen->name()
3329@@ -273,7 +273,7 @@
3330 PlatformScreen* ScreensModel::findScreenWithId(const QList<PlatformScreen *> &list, const mg::DisplayConfigurationOutputId id)
3331 {
3332 Q_FOREACH (auto screen, list) {
3333- if (screen->m_outputId == id) {
3334+ if (screen->displayId().output_id == id) {
3335 return screen;
3336 }
3337 }
3338
3339=== modified file 'src/platforms/mirserver/screensmodel.h'
3340--- src/platforms/mirserver/screensmodel.h 2017-04-06 08:50:28 +0000
3341+++ src/platforms/mirserver/screensmodel.h 2017-04-06 08:50:29 +0000
3342@@ -14,8 +14,8 @@
3343 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3344 */
3345
3346-#ifndef SCREENCONTROLLER_H
3347-#define SCREENCONTROLLER_H
3348+#ifndef SCREENCONFIGURATIONOBSERVER_H
3349+#define SCREENCONFIGURATIONOBSERVER_H
3350
3351 #include "mirdisplayconfigurationobserver.h"
3352
3353@@ -102,4 +102,4 @@
3354 bool m_compositing;
3355 };
3356
3357-#endif // SCREENCONTROLLER_H
3358+#endif // SCREENCONFIGURATIONOBSERVER_H
3359
3360=== added file 'src/platforms/mirserver/windowmodelnotifier.cpp'
3361--- src/platforms/mirserver/windowmodelnotifier.cpp 1970-01-01 00:00:00 +0000
3362+++ src/platforms/mirserver/windowmodelnotifier.cpp 2017-04-06 08:50:29 +0000
3363@@ -0,0 +1,109 @@
3364+/*
3365+ * Copyright (C) 2017 Canonical, Ltd.
3366+ *
3367+ * This program is free software: you can redistribute it and/or modify it under
3368+ * the terms of the GNU Lesser General Public License version 3, as published by
3369+ * the Free Software Foundation.
3370+ *
3371+ * This program is distributed in the hope that it will be useful, but WITHOUT
3372+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3373+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3374+ * Lesser General Public License for more details.
3375+ *
3376+ * You should have received a copy of the GNU Lesser General Public License
3377+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3378+ */
3379+
3380+#include "windowmodelnotifier.h"
3381+
3382+#include <QMultiHash>
3383+#include <QMutex>
3384+
3385+using namespace qtmir;
3386+
3387+namespace {
3388+
3389+QMultiHash<const miral::Window, WindowNotifierObserver*> windowToObserverMap;
3390+QMutex mutex;
3391+
3392+} // anonymous namespace
3393+
3394+WindowModelNotifier::WindowModelNotifier()
3395+{
3396+ connect(this, &WindowModelNotifier::windowAdded, this, [](const qtmir::NewWindow &window) {
3397+ WindowNotifierObserver::foreachObserverForWindow(window.windowInfo.window(), [](WindowNotifierObserver* observer) {
3398+ Q_EMIT observer->windowCreated();
3399+ });
3400+ }, Qt::QueuedConnection);
3401+
3402+ connect(this, &WindowModelNotifier::windowRemoved, this, [](const miral::WindowInfo &windowInfo) {
3403+ WindowNotifierObserver::foreachObserverForWindow(windowInfo.window(), [](WindowNotifierObserver* observer) {
3404+ Q_EMIT observer->windowRemoved();
3405+ });
3406+ }, Qt::QueuedConnection);
3407+
3408+ connect(this, &WindowModelNotifier::windowReady, this, [](const miral::WindowInfo &windowInfo) {
3409+ WindowNotifierObserver::foreachObserverForWindow(windowInfo.window(), [](WindowNotifierObserver* observer) {
3410+ Q_EMIT observer->windowReady();
3411+ });
3412+ }, Qt::QueuedConnection);
3413+
3414+ connect(this, &WindowModelNotifier::windowMoved, this, [](const miral::WindowInfo &windowInfo, const QPoint &top_left) {
3415+ WindowNotifierObserver::foreachObserverForWindow(windowInfo.window(), [top_left](WindowNotifierObserver* observer) {
3416+ Q_EMIT observer->windowMoved(top_left);
3417+ });
3418+ }, Qt::QueuedConnection);
3419+
3420+ connect(this, &WindowModelNotifier::windowResized, this, [](const miral::WindowInfo &windowInfo, const QSize &size) {
3421+ WindowNotifierObserver::foreachObserverForWindow(windowInfo.window(), [size](WindowNotifierObserver* observer) {
3422+ Q_EMIT observer->windowResized(size);
3423+ });
3424+ }, Qt::QueuedConnection);
3425+
3426+ connect(this, &WindowModelNotifier::windowStateChanged, this, [](const miral::WindowInfo &windowInfo, Mir::State state) {
3427+ WindowNotifierObserver::foreachObserverForWindow(windowInfo.window(), [state](WindowNotifierObserver* observer) {
3428+ Q_EMIT observer->windowStateChanged(state);
3429+ });
3430+ }, Qt::QueuedConnection);
3431+
3432+ connect(this, &WindowModelNotifier::windowFocusChanged, this, [](const miral::WindowInfo &windowInfo, bool focused) {
3433+ WindowNotifierObserver::foreachObserverForWindow(windowInfo.window(), [focused](WindowNotifierObserver* observer) {
3434+ Q_EMIT observer->windowFocusChanged(focused);
3435+ });
3436+ }, Qt::QueuedConnection);
3437+
3438+ connect(this, &WindowModelNotifier::windowRequestedRaise, this, [this](const miral::WindowInfo &windowInfo) {
3439+ WindowNotifierObserver::foreachObserverForWindow(windowInfo.window(), [](WindowNotifierObserver* observer) {
3440+ Q_EMIT observer->windowRequestedRaise();
3441+ });
3442+ }, Qt::QueuedConnection);
3443+}
3444+
3445+WindowNotifierObserver::WindowNotifierObserver(const miral::Window &window)
3446+{
3447+ QMutexLocker locker(&mutex);
3448+ windowToObserverMap.insert(window, this);
3449+}
3450+
3451+WindowNotifierObserver::~WindowNotifierObserver()
3452+{
3453+ QMutexLocker locker(&mutex);
3454+ QMutableHashIterator<const miral::Window, WindowNotifierObserver*> i(windowToObserverMap);
3455+ while (i.hasNext()) {
3456+ i.next();
3457+ if (i.value() == this) {
3458+ i.remove();
3459+ return;
3460+ }
3461+ }
3462+}
3463+
3464+void WindowNotifierObserver::foreachObserverForWindow(const miral::Window &window,
3465+ std::function<void(WindowNotifierObserver*)> fn)
3466+{
3467+ QMutexLocker locker(&mutex);
3468+ auto observers = windowToObserverMap.values(window);
3469+ Q_FOREACH(auto observer, observers) {
3470+ fn(observer);
3471+ }
3472+}
3473
3474=== added file 'src/platforms/mirserver/workspacecontroller.cpp'
3475--- src/platforms/mirserver/workspacecontroller.cpp 1970-01-01 00:00:00 +0000
3476+++ src/platforms/mirserver/workspacecontroller.cpp 2017-04-06 08:50:29 +0000
3477@@ -0,0 +1,54 @@
3478+/*
3479+ * Copyright (C) 2017 Canonical, Ltd.
3480+ *
3481+ * This program is free software: you can redistribute it and/or modify it under
3482+ * the terms of the GNU Lesser General Public License version 3, as published by
3483+ * the Free Software Foundation.
3484+ *
3485+ * This program is distributed in the hope that it will be useful, but WITHOUT
3486+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3487+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3488+ * Lesser General Public License for more details.
3489+ *
3490+ * You should have received a copy of the GNU Lesser General Public License
3491+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3492+ */
3493+
3494+#include "workspacecontroller.h"
3495+#include "wrappedwindowmanagementpolicy.h"
3496+
3497+using namespace qtmir;
3498+
3499+
3500+WorkspaceController::WorkspaceController()
3501+ : m_policy(nullptr)
3502+{
3503+}
3504+
3505+void WorkspaceController::forEachWindowInWorkspace(const std::shared_ptr<miral::Workspace> &workspace, const std::function<void (const miral::Window &)> &callback)
3506+{
3507+ if (m_policy) {
3508+ m_policy->for_each_window_in_workspace(workspace, callback);
3509+ }
3510+}
3511+
3512+void WorkspaceController::moveWorkspaceContentToWorkspace(const std::shared_ptr<miral::Workspace> &to,
3513+ const std::shared_ptr<miral::Workspace> &from)
3514+{
3515+ if (m_policy) {
3516+ m_policy->move_worspace_content_to_workspace(to, from);
3517+ }
3518+}
3519+
3520+void WorkspaceController::moveWindowToWorkspace(const miral::Window &window,
3521+ const std::shared_ptr<miral::Workspace> &workspace)
3522+{
3523+ if (m_policy) {
3524+ m_policy->move_window_to_workspace(window, workspace);
3525+ }
3526+}
3527+
3528+void WorkspaceController::setPolicy(WrappedWindowManagementPolicy * const policy)
3529+{
3530+ m_policy = policy;
3531+}
3532
3533=== added file 'src/platforms/mirserver/workspacecontroller.h'
3534--- src/platforms/mirserver/workspacecontroller.h 1970-01-01 00:00:00 +0000
3535+++ src/platforms/mirserver/workspacecontroller.h 2017-04-06 08:50:29 +0000
3536@@ -0,0 +1,49 @@
3537+/*
3538+ * Copyright (C) 2017 Canonical, Ltd.
3539+ *
3540+ * This program is free software: you can redistribute it and/or modify it under
3541+ * the terms of the GNU Lesser General Public License version 3, as published by
3542+ * the Free Software Foundation.
3543+ *
3544+ * This program is distributed in the hope that it will be useful, but WITHOUT
3545+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
3546+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3547+ * Lesser General Public License for more details.
3548+ *
3549+ * You should have received a copy of the GNU Lesser General Public License
3550+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
3551+ */
3552+
3553+#ifndef WORKSPACECONTROLLER_H
3554+#define WORKSPACECONTROLLER_H
3555+
3556+#include "workspacecontrollerinterface.h"
3557+
3558+class WrappedWindowManagementPolicy;
3559+
3560+namespace qtmir {
3561+
3562+class WorkspaceController : public qtmir::WorkspaceControllerInterface
3563+{
3564+public:
3565+ WorkspaceController();
3566+ virtual ~WorkspaceController() = default;
3567+
3568+ void forEachWindowInWorkspace(const std::shared_ptr<miral::Workspace> &workspace,
3569+ const std::function<void (const miral::Window &)> &callback) override;
3570+
3571+ void moveWorkspaceContentToWorkspace(const std::shared_ptr<miral::Workspace> &to,
3572+ const std::shared_ptr<miral::Workspace> &from) override;
3573+
3574+ void moveWindowToWorkspace(const miral::Window &window,
3575+ const std::shared_ptr<miral::Workspace> &workspace) override;
3576+
3577+ void setPolicy(WrappedWindowManagementPolicy *policy);
3578+
3579+protected:
3580+ WrappedWindowManagementPolicy *m_policy;
3581+};
3582+
3583+} // namespace qtmir
3584+
3585+#endif // WINDOWCONTROLLER_H
3586
3587=== modified file 'src/platforms/mirserver/wrappedwindowmanagementpolicy.cpp'
3588--- src/platforms/mirserver/wrappedwindowmanagementpolicy.cpp 2017-04-06 08:50:28 +0000
3589+++ src/platforms/mirserver/wrappedwindowmanagementpolicy.cpp 2017-04-06 08:50:29 +0000
3590@@ -258,6 +258,22 @@
3591 Q_EMIT d->m_windowModel.windowsRaised(windows);
3592 }
3593
3594+ void WindowManagementPolicy::advise_adding_to_workspace(std::shared_ptr<miral::Workspace> const& workspace,
3595+ std::vector<miral::Window> const& windows)
3596+ {
3597+ miral::WorkspacePolicy::advise_adding_to_workspace(workspace, windows);
3598+
3599+ Q_EMIT d->m_windowModel.windowsAddedToWorkspace(workspace, windows);
3600+ }
3601+
3602+ void WindowManagementPolicy::advise_removing_from_workspace(std::shared_ptr<miral::Workspace> const& workspace,
3603+ std::vector<miral::Window> const& windows)
3604+ {
3605+ miral::WorkspacePolicy::advise_removing_from_workspace(workspace, windows);
3606+
3607+ Q_EMIT d->m_windowModel.windowsAboutToBeRemovedFromWorkspace(workspace, windows);
3608+ }
3609+
3610 Rectangle WindowManagementPolicy::confirm_inherited_move(miral::WindowInfo const& windowInfo, Displacement movement)
3611 {
3612 if (d->m_confinementRegions.isEmpty()) {
3613@@ -309,6 +325,7 @@
3614 WrappedWindowManagementPolicy::WrappedWindowManagementPolicy(const miral::WindowManagerTools &tools,
3615 qtmir::WindowModelNotifier &windowModel,
3616 qtmir::WindowController &windowController,
3617+ qtmir::WorkspaceController &workspaceController,
3618 qtmir::AppNotifier &appNotifier,
3619 const std::shared_ptr<QtEventFeeder> &eventFeeder,
3620 const qtmir::WindowManagmentPolicyBuilder &wmBuilder)
3621@@ -321,6 +338,7 @@
3622 qRegisterMetaType<std::vector<miral::Window>>();
3623 qRegisterMetaType<miral::ApplicationInfo>();
3624 windowController.setPolicy(this);
3625+ workspaceController.setPolicy(this);
3626 }
3627
3628 /* Following are hooks to allow custom policy be imposed */
3629@@ -467,6 +485,18 @@
3630 qtmir::dispatchInputEvent(window, mir_pointer_event_input_event(event));
3631 }
3632
3633+void WrappedWindowManagementPolicy::advise_adding_to_workspace(const std::shared_ptr<miral::Workspace> &workspace,
3634+ const std::vector<miral::Window> &windows)
3635+{
3636+ m_wrapper->advise_adding_to_workspace(workspace, windows);
3637+}
3638+
3639+void WrappedWindowManagementPolicy::advise_removing_from_workspace(const std::shared_ptr<miral::Workspace> &workspace,
3640+ const std::vector<miral::Window> &windows)
3641+{
3642+ m_wrapper->advise_removing_from_workspace(workspace, windows);
3643+}
3644+
3645 void WrappedWindowManagementPolicy::activate(const miral::Window &window)
3646 {
3647 if (window) {
3648@@ -574,3 +604,44 @@
3649
3650 // TODO: update window positions/sizes to respect new margins.
3651 }
3652+
3653+void WrappedWindowManagementPolicy::for_each_window_in_workspace(const std::shared_ptr<miral::Workspace> &workspace,
3654+ std::function<void(miral::Window const&)> const& callback)
3655+{
3656+ tools.invoke_under_lock([&]() {
3657+ tools.for_each_window_in_workspace(workspace, callback);
3658+ });
3659+}
3660+
3661+void WrappedWindowManagementPolicy::move_worspace_content_to_workspace(const std::shared_ptr<miral::Workspace> &to,
3662+ const std::shared_ptr<miral::Workspace> &from)
3663+{
3664+ tools.invoke_under_lock([&]() {
3665+ tools.move_workspace_content_to_workspace(to, from);
3666+ });
3667+}
3668+
3669+void WrappedWindowManagementPolicy::move_window_to_workspace(const miral::Window &window,
3670+ const std::shared_ptr<miral::Workspace> &workspace)
3671+{
3672+ tools.invoke_under_lock([&]() {
3673+ auto root = window;
3674+ auto const* info = &tools.info_for(root);
3675+
3676+ while (auto const& parent = info->parent())
3677+ {
3678+ root = parent;
3679+ info = &tools.info_for(root);
3680+ }
3681+
3682+ std::vector<std::shared_ptr<miral::Workspace>> workspaces;
3683+ tools.for_each_workspace_containing(root, [&](std::shared_ptr<miral::Workspace> const& from) {
3684+ workspaces.push_back(from);
3685+ });
3686+ for (auto wks : workspaces) {
3687+ tools.remove_tree_from_workspace(root, wks);
3688+ }
3689+ tools.add_tree_to_workspace(root, workspace);
3690+ });
3691+}
3692+
3693
3694=== modified file 'src/platforms/mirserver/wrappedwindowmanagementpolicy.h'
3695--- src/platforms/mirserver/wrappedwindowmanagementpolicy.h 2017-04-06 08:50:28 +0000
3696+++ src/platforms/mirserver/wrappedwindowmanagementpolicy.h 2017-04-06 08:50:29 +0000
3697@@ -17,11 +17,12 @@
3698 #ifndef WRAPPEDWINDOWMANAGEMENTPOLICY_H
3699 #define WRAPPEDWINDOWMANAGEMENTPOLICY_H
3700
3701+#include "qtmir/windowmanagementpolicy.h"
3702 #include "appnotifier.h"
3703 #include "qteventfeeder.h"
3704 #include "windowcontroller.h"
3705 #include "windowmodelnotifier.h"
3706-#include "qtmir/windowmanagementpolicy.h"
3707+#include "workspacecontroller.h"
3708
3709
3710 using namespace mir::geometry;
3711@@ -34,6 +35,7 @@
3712 WrappedWindowManagementPolicy(const miral::WindowManagerTools &tools,
3713 qtmir::WindowModelNotifier &windowModel,
3714 qtmir::WindowController &windowController,
3715+ qtmir::WorkspaceController &workspaceController,
3716 qtmir::AppNotifier &appNotifier,
3717 const std::shared_ptr<QtEventFeeder> &eventFeeder,
3718 const qtmir::WindowManagmentPolicyBuilder &wmBuilder);
3719@@ -68,7 +70,12 @@
3720 void advise_delete_window(const miral::WindowInfo &windowInfo) override;
3721 void advise_raise(const std::vector<miral::Window> &windows) override;
3722
3723- Rectangle confirm_inherited_move(miral::WindowInfo const& windowInfo, Displacement movement) override;
3724+ Rectangle confirm_inherited_move(const miral::WindowInfo &windowInfo, Displacement movement) override;
3725+
3726+ void advise_adding_to_workspace(const std::shared_ptr<miral::Workspace> &workspace,
3727+ const std::vector<miral::Window> &windows) override;
3728+ void advise_removing_from_workspace(const std::shared_ptr<miral::Workspace> &workspace,
3729+ const std::vector<miral::Window> &windows) override;
3730
3731 // Methods for consumption by WindowControllerInterface
3732 void deliver_keyboard_event(const MirKeyboardEvent *event, const miral::Window &window);
3733@@ -87,6 +94,14 @@
3734 void set_window_confinement_regions(const QVector<QRect> &regions);
3735 void set_window_margins(MirWindowType windowType, const QMargins &margins);
3736
3737+ // Methods for consumption by WorkspaceControllerInterface
3738+ void for_each_window_in_workspace(const std::shared_ptr<miral::Workspace> &workspace,
3739+ std::function<void(miral::Window const&)> const& callback);
3740+ void move_worspace_content_to_workspace(const std::shared_ptr<miral::Workspace> &to,
3741+ const std::shared_ptr<miral::Workspace> &from);
3742+ void move_window_to_workspace(const miral::Window &window,
3743+ const std::shared_ptr<miral::Workspace> &workspace);
3744+
3745 private:
3746 std::shared_ptr<qtmir::WindowManagementPolicy> m_wrapper;
3747 };
3748
3749=== modified file 'tests/mirserver/Screen/CMakeLists.txt'
3750--- tests/mirserver/Screen/CMakeLists.txt 2017-04-06 08:50:28 +0000
3751+++ tests/mirserver/Screen/CMakeLists.txt 2017-04-06 08:50:29 +0000
3752@@ -5,6 +5,7 @@
3753 )
3754
3755 include_directories(
3756+ ${CMAKE_SOURCE_DIR}/include
3757 ${CMAKE_SOURCE_DIR}/tests/framework
3758 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3759 ${CMAKE_SOURCE_DIR}/src/common
3760
3761=== modified file 'tests/mirserver/ScreensModel/CMakeLists.txt'
3762--- tests/mirserver/ScreensModel/CMakeLists.txt 2017-04-06 08:50:28 +0000
3763+++ tests/mirserver/ScreensModel/CMakeLists.txt 2017-04-06 08:50:29 +0000
3764@@ -8,6 +8,7 @@
3765 )
3766
3767 include_directories(
3768+ ${CMAKE_SOURCE_DIR}/include
3769 ${CMAKE_SOURCE_DIR}/tests/framework
3770 ${CMAKE_SOURCE_DIR}/src/platforms/mirserver
3771 ${CMAKE_SOURCE_DIR}/src/common
3772
3773=== modified file 'tests/modules/SurfaceManager/surface_manager_test.cpp'
3774--- tests/modules/SurfaceManager/surface_manager_test.cpp 2017-03-20 16:19:42 +0000
3775+++ tests/modules/SurfaceManager/surface_manager_test.cpp 2017-04-06 08:50:29 +0000
3776@@ -127,7 +127,7 @@
3777 qtApp->sendPostedEvents();
3778
3779 // Check result
3780- auto mirSurface = surfaceManager->find(windowInfo);
3781+ auto mirSurface = surfaceManager->surfaceFor(window);
3782 ASSERT_TRUE(mirSurface);
3783 EXPECT_EQ(window, mirSurface->window());
3784 }
3785@@ -147,7 +147,7 @@
3786 qtApp->sendPostedEvents();
3787
3788 // Check result
3789- auto mirSurface = surfaceManager->find(windowInfo);
3790+ auto mirSurface = surfaceManager->surfaceFor(window);
3791 ASSERT_TRUE(mirSurface);
3792 EXPECT_EQ(&fakeSession, mirSurface->session());
3793 }
3794@@ -171,8 +171,8 @@
3795 qtApp->sendPostedEvents();
3796
3797 // Check result
3798- auto childMirSurface = surfaceManager->find(childWindowInfo);
3799- auto parentMirSurface = surfaceManager->find(parentWindowInfo);
3800+ auto childMirSurface = surfaceManager->surfaceFor(childWindow);
3801+ auto parentMirSurface = surfaceManager->surfaceFor(parentWindow);
3802 ASSERT_TRUE(childMirSurface);
3803 ASSERT_TRUE(parentMirSurface);
3804
3805@@ -198,8 +198,8 @@
3806 qtApp->sendPostedEvents();
3807
3808 // Check result
3809- auto childMirSurface = surfaceManager->find(childWindowInfo);
3810- auto parentMirSurface = surfaceManager->find(parentWindowInfo);
3811+ auto childMirSurface = surfaceManager->surfaceFor(childWindow);
3812+ auto parentMirSurface = surfaceManager->surfaceFor(parentWindow);
3813 ASSERT_TRUE(childMirSurface);
3814 ASSERT_TRUE(parentMirSurface);
3815
3816@@ -216,7 +216,7 @@
3817 // Setup: add window and get corresponding MirSurface
3818 Q_EMIT wmNotifier.windowAdded(windowInfo);
3819 qtApp->sendPostedEvents();
3820- auto mirSurface = surfaceManager->find(windowInfo);
3821+ auto mirSurface = surfaceManager->surfaceFor(window);
3822 ASSERT_TRUE(mirSurface);
3823
3824 QSignalSpy mirSurfaceReadySpy(mirSurface, &MirSurface::ready);
3825@@ -240,7 +240,7 @@
3826 // Setup: add window and get corresponding MirSurface
3827 Q_EMIT wmNotifier.windowAdded(windowInfo);
3828 qtApp->sendPostedEvents();
3829- auto mirSurface = surfaceManager->find(windowInfo);
3830+ auto mirSurface = surfaceManager->surfaceFor(window);
3831 ASSERT_TRUE(mirSurface);
3832
3833 QSignalSpy mirSurfacePositionSpy(mirSurface, &MirSurface::positionChanged);
3834@@ -263,7 +263,7 @@
3835 // Setup: add window and get corresponding MirSurface
3836 Q_EMIT wmNotifier.windowAdded(windowInfo);
3837 qtApp->sendPostedEvents();
3838- auto mirSurface = surfaceManager->find(windowInfo);
3839+ auto mirSurface = surfaceManager->surfaceFor(window);
3840 ASSERT_TRUE(mirSurface);
3841 ASSERT_FALSE(mirSurface->focused()); // false must be the initial state
3842
3843@@ -289,7 +289,7 @@
3844 // Setup: add window and get corresponding MirSurface
3845 Q_EMIT wmNotifier.windowAdded(windowInfo);
3846 qtApp->sendPostedEvents();
3847- auto mirSurface = surfaceManager->find(windowInfo);
3848+ auto mirSurface = surfaceManager->surfaceFor(window);
3849 ASSERT_TRUE(mirSurface);
3850
3851 QSignalSpy mirSurfaceStateSpy(mirSurface, &MirSurface::stateChanged);
3852@@ -319,8 +319,8 @@
3853 Q_EMIT wmNotifier.windowAdded(windowInfo1);
3854 Q_EMIT wmNotifier.windowAdded(windowInfo2);
3855 qtApp->sendPostedEvents();
3856- auto mirSurface1 = surfaceManager->find(windowInfo1);
3857- auto mirSurface2 = surfaceManager->find(windowInfo2);
3858+ auto mirSurface1 = surfaceManager->surfaceFor(window1);
3859+ auto mirSurface2 = surfaceManager->surfaceFor(window2);
3860 ASSERT_TRUE(mirSurface1);
3861 ASSERT_TRUE(mirSurface2);
3862
3863@@ -348,7 +348,7 @@
3864 // Setup: add window and get corresponding MirSurface
3865 Q_EMIT wmNotifier.windowAdded(windowInfo);
3866 qtApp->sendPostedEvents();
3867- auto mirSurface = surfaceManager->find(windowInfo);
3868+ auto mirSurface = surfaceManager->surfaceFor(window);
3869 ASSERT_TRUE(mirSurface);
3870
3871 QSignalSpy mirSurfaceFocusRequestedSpy(mirSurface, &MirSurface::focusRequested);
3872@@ -371,7 +371,7 @@
3873 // Setup: add window and get corresponding MirSurface
3874 Q_EMIT wmNotifier.windowAdded(windowInfo);
3875 qtApp->sendPostedEvents();
3876- auto mirSurface = surfaceManager->find(windowInfo);
3877+ auto mirSurface = surfaceManager->surfaceFor(window);
3878 ASSERT_TRUE(mirSurface);
3879
3880 QSignalSpy mirSurfaceDestroyedSpy(mirSurface, &QObject::destroyed);
3881@@ -382,7 +382,7 @@
3882
3883 // Check result
3884 ASSERT_EQ(2, mirSurfaceDestroyedSpy.count()); //FIXME - should be 1
3885- EXPECT_FALSE(surfaceManager->find(windowInfo));
3886+ EXPECT_FALSE(surfaceManager->surfaceFor(window));
3887 }
3888
3889 /*
3890@@ -395,7 +395,7 @@
3891 // Setup: add window and get corresponding MirSurface
3892 Q_EMIT wmNotifier.windowAdded(windowInfo);
3893 qtApp->sendPostedEvents();
3894- auto mirSurface = surfaceManager->find(windowInfo);
3895+ auto mirSurface = surfaceManager->surfaceFor(window);
3896 ASSERT_TRUE(mirSurface);
3897
3898 QSignalSpy mirSurfaceDestroyedSpy(mirSurface, &QObject::destroyed);
3899@@ -408,7 +408,7 @@
3900
3901 // Check result
3902 ASSERT_EQ(0, mirSurfaceDestroyedSpy.count());
3903- EXPECT_FALSE(surfaceManager->find(windowInfo));
3904+ EXPECT_FALSE(surfaceManager->surfaceFor(window));
3905 EXPECT_FALSE(mirSurface->live());
3906 }
3907
3908@@ -424,7 +424,7 @@
3909 // Setup: add window and get corresponding MirSurface
3910 Q_EMIT wmNotifier.windowAdded(windowInfo);
3911 qtApp->sendPostedEvents();
3912- auto mirSurface = surfaceManager->find(windowInfo);
3913+ auto mirSurface = surfaceManager->surfaceFor(window);
3914 ASSERT_TRUE(mirSurface);
3915
3916 QSignalSpy mirSurfaceDestroyedSpy(mirSurface, &QObject::destroyed);
3917@@ -458,7 +458,7 @@
3918 // Setup: add window and get corresponding MirSurface
3919 Q_EMIT wmNotifier.windowAdded(windowInfo);
3920 qtApp->sendPostedEvents();
3921- auto mirSurface = surfaceManager->find(windowInfo);
3922+ auto mirSurface = surfaceManager->surfaceFor(window);
3923 ASSERT_TRUE(mirSurface);
3924 ASSERT_TRUE(mirSurface->live());
3925

Subscribers

People subscribed via source and target branches