on xenial help sign in
merged with prereq
ca7d40dNick Dedekind
plugins/WindowManager/CMakeLists.txt+2
@@ -16,10 +16,12 @@ set(WINDOWMANAGER_SRC
16 ScreenAttached.cpp
16 ScreenAttached.cpp
17 Screens.cpp
17 Screens.cpp
18 ScreenWindow.cpp
18 ScreenWindow.cpp
19+ WindowManagerObjects.cpp
19 Workspace.cpp
20 Workspace.cpp
20 WorkspaceManager.cpp
21 WorkspaceManager.cpp
21 WorkspaceModel.cpp
22 WorkspaceModel.cpp
22 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
23 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
24+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
23 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
25 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
24 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
26 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
25 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
27 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
plugins/WindowManager/Screen.cpp+7−1
@@ -39,6 +39,12 @@ void ScreenInterface::connectToScreen(qtmir::Screen *screen)
39 connect(screen, &qtmir::Screen::availableModesChanged, this, &ScreenInterface::availableModesChanged);
39 connect(screen, &qtmir::Screen::availableModesChanged, this, &ScreenInterface::availableModesChanged);
40}
40}
41
41
42+void ScreenInterface::connectToScreen(ScreenInterface *screen)
43+{
44+ connectToScreen(screen->wrapped());
45+ connect(screen, &ScreenInterface::currentWorkspaceChanged, this, &ScreenInterface::currentWorkspaceChanged);
46+}
47+
42qtmir::OutputId ScreenInterface::outputId() const
48qtmir::OutputId ScreenInterface::outputId() const
43{
49{
44 if (!m_wrapped) return qtmir::OutputId(-1);
50 if (!m_wrapped) return qtmir::OutputId(-1);
@@ -253,7 +259,7 @@ ScreenProxy::ScreenProxy(ScreenInterface *const screen)
253 : m_workspaces(new WorkspaceModelProxy(screen->workspaces()))
259 : m_workspaces(new WorkspaceModelProxy(screen->workspaces()))
254 , m_original(screen)
260 , m_original(screen)
255{
261{
256− connectToScreen(screen->wrapped());
262+ connectToScreen(screen);
257
263
258 auto updateCurrentWorkspaceFn = [this](Workspace* realWorkspace) {
264 auto updateCurrentWorkspaceFn = [this](Workspace* realWorkspace) {
259 Q_FOREACH(Workspace* workspace, m_workspaces->list()) {
265 Q_FOREACH(Workspace* workspace, m_workspaces->list()) {
plugins/WindowManager/Screen.h+1−2
@@ -15,7 +15,6 @@ class ScreenInterface: public QObject
15 Q_OBJECT
15 Q_OBJECT
16
16
17 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
17 Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
18−
19 Q_PROPERTY(bool used READ used NOTIFY usedChanged)
18 Q_PROPERTY(bool used READ used NOTIFY usedChanged)
20 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
19 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
21 Q_PROPERTY(qtmir::OutputTypes outputType READ outputType NOTIFY outputTypeChanged)
20 Q_PROPERTY(qtmir::OutputTypes outputType READ outputType NOTIFY outputTypeChanged)
@@ -28,7 +27,6 @@ class ScreenInterface: public QObject
28 Q_PROPERTY(QQmlListProperty<qtmir::ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
27 Q_PROPERTY(QQmlListProperty<qtmir::ScreenMode> availableModes READ availableModes NOTIFY availableModesChanged)
29 Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
28 Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
30 Q_PROPERTY(QString outputTypeName READ outputTypeName NOTIFY outputTypeChanged)
29 Q_PROPERTY(QString outputTypeName READ outputTypeName NOTIFY outputTypeChanged)
31−
32 Q_PROPERTY(WorkspaceModel* workspaces READ workspaces CONSTANT)
30 Q_PROPERTY(WorkspaceModel* workspaces READ workspaces CONSTANT)
33 Q_PROPERTY(Workspace* currentWorkspace READ currentWorkspace WRITE setCurrentWorkspace NOTIFY currentWorkspaceChanged)
31 Q_PROPERTY(Workspace* currentWorkspace READ currentWorkspace WRITE setCurrentWorkspace NOTIFY currentWorkspaceChanged)
34public:
32public:
@@ -82,6 +80,7 @@ protected:
82 ScreenInterface(QObject* parent = 0);
80 ScreenInterface(QObject* parent = 0);
83
81
84 void connectToScreen(qtmir::Screen* screen);
82 void connectToScreen(qtmir::Screen* screen);
83+ void connectToScreen(ScreenInterface* screen);
85
84
86protected:
85protected:
87 QPointer<qtmir::Screen> m_wrapped;
86 QPointer<qtmir::Screen> m_wrapped;
plugins/WindowManager/ScreenAttached.cpp+1−1
@@ -140,7 +140,7 @@ void ScreenAttached::screenChanged2(ScreenInterface* screen)
140 Q_EMIT availableModesChanged();
140 Q_EMIT availableModesChanged();
141 }
141 }
142
142
143− connectToScreen(screen->wrapped());
143+ connectToScreen(screen);
144}
144}
145
145
146ScreenAttached *WMScreen::qmlAttachedProperties(QObject *owner)
146ScreenAttached *WMScreen::qmlAttachedProperties(QObject *owner)
plugins/WindowManager/TopLevelWindowModel.cpp+10−29
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17#include "TopLevelWindowModel.h"
17#include "TopLevelWindowModel.h"
18+#include "WindowManagerObjects.h"
18
19
19// unity-api
20// unity-api
20#include <unity/shell/application/ApplicationInfoInterface.h>
21#include <unity/shell/application/ApplicationInfoInterface.h>
@@ -42,8 +43,16 @@ Q_LOGGING_CATEGORY(TOPLEVELWINDOWMODEL, "toplevelwindowmodel", QtInfoMsg)
42
43
43namespace unityapi = unity::shell::application;
44namespace unityapi = unity::shell::application;
44
45
45−TopLevelWindowModel::TopLevelWindowModel()
46+TopLevelWindowModel::TopLevelWindowModel(Workspace* workspace)
47+ : m_workspace(workspace)
46{
48{
49+ connect(WindowManagerObjects::instance(), &WindowManagerObjects::applicationManagerChanged,
50+ this, &TopLevelWindowModel::setApplicationManager);
51+ connect(WindowManagerObjects::instance(), &WindowManagerObjects::surfaceManagerChanged,
52+ this, &TopLevelWindowModel::setSurfaceManager);
53+
54+ setApplicationManager(WindowManagerObjects::instance()->applicationManager());
55+ setSurfaceManager(WindowManagerObjects::instance()->surfaceManager());
47}
56}
48
57
49void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInterface* value)
58void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInterface* value)
@@ -86,7 +95,6 @@ void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInte
86 });
95 });
87 }
96 }
88
97
89− Q_EMIT applicationManagerChanged(m_applicationManager);
90 refreshWindows();
98 refreshWindows();
91
99
92 endResetModel();
100 endResetModel();
@@ -125,33 +133,6 @@ void TopLevelWindowModel::setSurfaceManager(unityapi::SurfaceManagerInterface *s
125 }
133 }
126
134
127 refreshWindows();
135 refreshWindows();
128− Q_EMIT surfaceManagerChanged(m_surfaceManager);
129−
130− endResetModel();
131− m_modelState = IdleState;
132−}
133−
134−void TopLevelWindowModel::setWorkspace(Workspace *workspace)
135−{
136− if (workspace == m_workspace) {
137− return;
138− }
139−
140− DEBUG_MSG << "(" << workspace << ")";
141−
142− Q_ASSERT(m_modelState == IdleState);
143− m_modelState = ResettingState;
144−
145− beginResetModel();
146−
147− if (m_workspace) {
148− disconnect(m_workspace, 0, this, 0);
149− }
150−
151− m_workspace = workspace;
152−
153− refreshWindows();
154− Q_EMIT workspaceChanged(workspace);
155
136
156 endResetModel();
137 endResetModel();
157 m_modelState = IdleState;
138 m_modelState = IdleState;
plugins/WindowManager/TopLevelWindowModel.h+5−30
@@ -75,21 +75,6 @@ class TopLevelWindowModel : public QAbstractListModel
75 */
75 */
76 Q_PROPERTY(Window* focusedWindow READ focusedWindow NOTIFY focusedWindowChanged)
76 Q_PROPERTY(Window* focusedWindow READ focusedWindow NOTIFY focusedWindowChanged)
77
77
78− Q_PROPERTY(Workspace* workspace
79− READ workspace
80− WRITE setWorkspace
81− NOTIFY workspaceChanged)
82−
83− Q_PROPERTY(unity::shell::application::SurfaceManagerInterface* surfaceManager
84− READ surfaceManager
85− WRITE setSurfaceManager
86− NOTIFY surfaceManagerChanged)
87−
88− Q_PROPERTY(unity::shell::application::ApplicationManagerInterface* applicationManager
89− READ applicationManager
90− WRITE setApplicationManager
91− NOTIFY applicationManagerChanged)
92−
93 /**
78 /**
94 The id to be used on the next entry created
79 The id to be used on the next entry created
95 Useful for tests
80 Useful for tests
@@ -108,7 +93,7 @@ public:
108 ApplicationRole = Qt::UserRole + 1,
93 ApplicationRole = Qt::UserRole + 1,
109 };
94 };
110
95
111− TopLevelWindowModel();
96+ TopLevelWindowModel(Workspace* workspace);
112
97
113 // From QAbstractItemModel
98 // From QAbstractItemModel
114 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
99 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -119,20 +104,11 @@ public:
119 return roleNames;
104 return roleNames;
120 }
105 }
121
106
122− // Own API
107+ // Own API;
123−
124− Workspace* workspace() const { return m_workspace; }
125− void setWorkspace(Workspace* workspace);
126
108
127 unity::shell::application::MirSurfaceInterface* inputMethodSurface() const;
109 unity::shell::application::MirSurfaceInterface* inputMethodSurface() const;
128 Window* focusedWindow() const;
110 Window* focusedWindow() const;
129
111
130− unity::shell::application::ApplicationManagerInterface *applicationManager() const { return m_applicationManager; }
131− void setApplicationManager(unity::shell::application::ApplicationManagerInterface*);
132−
133− unity::shell::application::SurfaceManagerInterface *surfaceManager() const { return m_surfaceManager; }
134− void setSurfaceManager(unity::shell::application::SurfaceManagerInterface*);
135−
136 int nextId() const { return m_nextId; }
112 int nextId() const { return m_nextId; }
137
113
138public:
114public:
@@ -179,8 +155,6 @@ Q_SIGNALS:
179 void countChanged();
155 void countChanged();
180 void inputMethodSurfaceChanged(unity::shell::application::MirSurfaceInterface* inputMethodSurface);
156 void inputMethodSurfaceChanged(unity::shell::application::MirSurfaceInterface* inputMethodSurface);
181 void focusedWindowChanged(Window *focusedWindow);
157 void focusedWindowChanged(Window *focusedWindow);
182− void applicationManagerChanged(unity::shell::application::ApplicationManagerInterface*);
183− void surfaceManagerChanged(unity::shell::application::SurfaceManagerInterface*);
184
158
185 /**
159 /**
186 * @brief Emitted when the list changes
160 * @brief Emitted when the list changes
@@ -191,9 +165,10 @@ Q_SIGNALS:
191
165
192 void nextIdChanged();
166 void nextIdChanged();
193
167
194− void workspaceChanged(Workspace*);
195−
196private Q_SLOTS:
168private Q_SLOTS:
169+ void setApplicationManager(unity::shell::application::ApplicationManagerInterface*);
170+ void setSurfaceManager(unity::shell::application::SurfaceManagerInterface*);
171+
197 void onSurfaceCreated(unity::shell::application::MirSurfaceInterface *surface);
172 void onSurfaceCreated(unity::shell::application::MirSurfaceInterface *surface);
198 void onSurfacesAddedToWorkspace(const std::shared_ptr<miral::Workspace>& workspace,
173 void onSurfacesAddedToWorkspace(const std::shared_ptr<miral::Workspace>& workspace,
199 const QVector<unity::shell::application::MirSurfaceInterface*> surfaces);
174 const QVector<unity::shell::application::MirSurfaceInterface*> surfaces);
plugins/WindowManager/WindowManagerObjects.cppnew file+47
@@ -0,0 +1,47 @@
1+/*
2+ * Copyright (C) 2017 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "WindowManagerObjects.h"
18+
19+WindowManagerObjects::WindowManagerObjects(QObject *parent)
20+ : QObject(parent)
21+ , m_surfaceManager(nullptr)
22+ , m_applicationManager(nullptr)
23+{
24+}
25+
26+WindowManagerObjects *WindowManagerObjects::instance()
27+{
28+ static WindowManagerObjects* objects(new WindowManagerObjects());
29+ return objects;
30+}
31+
32+
33+void WindowManagerObjects::setSurfaceManager(unity::shell::application::SurfaceManagerInterface *surfaceManager)
34+{
35+ if (m_surfaceManager == surfaceManager) return;
36+
37+ m_surfaceManager = surfaceManager;
38+ Q_EMIT surfaceManagerChanged(surfaceManager);
39+}
40+
41+void WindowManagerObjects::setApplicationManager(unity::shell::application::ApplicationManagerInterface *applicationManager)
42+{
43+ if (m_applicationManager == applicationManager) return;
44+
45+ m_applicationManager = applicationManager;
46+ Q_EMIT applicationManagerChanged(applicationManager);
47+}
plugins/WindowManager/WindowManagerObjects.hnew file+64
@@ -0,0 +1,64 @@
1+/*
2+ * Copyright (C) 2017 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef WINDOWMANAGEROBJECTS_H
18+#define WINDOWMANAGEROBJECTS_H
19+
20+#include <QObject>
21+
22+namespace unity {
23+ namespace shell {
24+ namespace application {
25+ class SurfaceManagerInterface;
26+ class ApplicationManagerInterface;
27+ }
28+ }
29+}
30+
31+class WindowManagerObjects : public QObject
32+{
33+ Q_OBJECT
34+
35+ Q_PROPERTY(unity::shell::application::SurfaceManagerInterface* surfaceManager
36+ READ surfaceManager
37+ WRITE setSurfaceManager
38+ NOTIFY surfaceManagerChanged)
39+
40+ Q_PROPERTY(unity::shell::application::ApplicationManagerInterface* applicationManager
41+ READ applicationManager
42+ WRITE setApplicationManager
43+ NOTIFY applicationManagerChanged)
44+public:
45+ explicit WindowManagerObjects(QObject *parent = 0);
46+
47+ static WindowManagerObjects *instance();
48+
49+ unity::shell::application::SurfaceManagerInterface *surfaceManager() const { return m_surfaceManager; }
50+ void setSurfaceManager(unity::shell::application::SurfaceManagerInterface*);
51+
52+ unity::shell::application::ApplicationManagerInterface *applicationManager() const { return m_applicationManager; }
53+ void setApplicationManager(unity::shell::application::ApplicationManagerInterface*);
54+
55+Q_SIGNALS:
56+ void surfaceManagerChanged(unity::shell::application::SurfaceManagerInterface*);
57+ void applicationManagerChanged(unity::shell::application::ApplicationManagerInterface*);
58+
59+private:
60+ unity::shell::application::SurfaceManagerInterface* m_surfaceManager;
61+ unity::shell::application::ApplicationManagerInterface* m_applicationManager;
62+};
63+
64+#endif // WINDOWMANAGEROBJECTS_H
plugins/WindowManager/WindowManagerPlugin.cpp+8−1
@@ -22,6 +22,7 @@
22#include "ScreenWindow.h"
22#include "ScreenWindow.h"
23#include "TopLevelWindowModel.h"
23#include "TopLevelWindowModel.h"
24#include "Window.h"
24#include "Window.h"
25+#include "WindowManagerObjects.h"
25#include "WorkspaceManager.h"
26#include "WorkspaceManager.h"
26#include "Workspace.h"
27#include "Workspace.h"
27#include "WorkspaceModel.h"
28#include "WorkspaceModel.h"
@@ -42,19 +43,25 @@ QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
42 Q_UNUSED(scriptEngine);
43 Q_UNUSED(scriptEngine);
43 return new Screens(qtmir::get_screen_model());
44 return new Screens(qtmir::get_screen_model());
44}
45}
46+QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
47+ Q_UNUSED(engine);
48+ Q_UNUSED(scriptEngine);
49+ return WindowManagerObjects::instance();
50+}
45
51
46void WindowManagerPlugin::registerTypes(const char *uri)
52void WindowManagerPlugin::registerTypes(const char *uri)
47{
53{
48− qmlRegisterType<TopLevelWindowModel>(uri, 1, 0, "TopLevelWindowModel");
49 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
54 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
50 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
55 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
51 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
56 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
52 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
57 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
53 qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
58 qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
59+ qmlRegisterSingletonType<WindowManagerObjects>(uri, 1, 0, "WindowManagerObjects", objectsSingleton);
54
60
55 qRegisterMetaType<Screen*>("Screen*");
61 qRegisterMetaType<Screen*>("Screen*");
56 qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
62 qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
57 qRegisterMetaType<Workspace*>("Workspace*");
63 qRegisterMetaType<Workspace*>("Workspace*");
64+ qRegisterMetaType<TopLevelWindowModel*>("TopLevelWindowModel*");
58
65
59 qRegisterMetaType<Window*>("Window*");
66 qRegisterMetaType<Window*>("Window*");
60 qRegisterMetaType<QAbstractListModel*>("QAbstractListModel*");
67 qRegisterMetaType<QAbstractListModel*>("QAbstractListModel*");
plugins/WindowManager/Workspace.cpp+2
@@ -27,6 +27,7 @@ Workspace::Workspace(QObject *parent)
27 : QObject(parent)
27 : QObject(parent)
28 , m_workspace(WMPolicyInterface::instance()->createWorkspace())
28 , m_workspace(WMPolicyInterface::instance()->createWorkspace())
29 , m_model(nullptr)
29 , m_model(nullptr)
30+ , m_windowModel(new TopLevelWindowModel(this))
30 , m_active(false)
31 , m_active(false)
31{
32{
32 setObjectName((QString("Wks%1").arg(nextWorkspace++)));
33 setObjectName((QString("Wks%1").arg(nextWorkspace++)));
@@ -48,6 +49,7 @@ Workspace::Workspace(const Workspace &other)
48 : QObject(nullptr)
49 : QObject(nullptr)
49 , m_workspace(other.m_workspace)
50 , m_workspace(other.m_workspace)
50 , m_model(nullptr)
51 , m_model(nullptr)
52+ , m_windowModel(other.m_windowModel)
51 , m_active(other.m_active)
53 , m_active(other.m_active)
52{
54{
53 setObjectName(other.objectName());
55 setObjectName(other.objectName());
plugins/WindowManager/Workspace.h+5−3
@@ -41,6 +41,7 @@ class Workspace : public QObject
41{
41{
42 Q_OBJECT
42 Q_OBJECT
43 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
43 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
44+ Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel NOTIFY windowModelChanged)
44public:
45public:
45 ~Workspace();
46 ~Workspace();
46
47
@@ -49,10 +50,10 @@ public:
49 void release();
50 void release();
50
51
51 virtual bool isActive() const { return m_active; }
52 virtual bool isActive() const { return m_active; }
52− bool isAssigned() const;
53
53
54+ TopLevelWindowModel *windowModel() const { return m_windowModel; }
54 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
55 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
55−
56+ bool isAssigned() const;
56
57
57public Q_SLOTS:
58public Q_SLOTS:
58 virtual void activate();
59 virtual void activate();
@@ -62,6 +63,7 @@ Q_SIGNALS:
62 void unassigned();
63 void unassigned();
63
64
64 void activeChanged(bool);
65 void activeChanged(bool);
66+ void windowModelChanged();
65
67
66protected:
68protected:
67 Workspace(QObject *parent = 0);
69 Workspace(QObject *parent = 0);
@@ -69,6 +71,7 @@ protected:
69
71
70 std::shared_ptr<miral::Workspace> m_workspace;
72 std::shared_ptr<miral::Workspace> m_workspace;
71 WorkspaceModel* m_model;
73 WorkspaceModel* m_model;
74+ TopLevelWindowModel* m_windowModel;
72 bool m_active;
75 bool m_active;
73
76
74 friend class WorkspaceManager;
77 friend class WorkspaceManager;
@@ -83,7 +86,6 @@ public:
83 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
86 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
84
87
85 bool isActive() const override;
88 bool isActive() const override;
86−
87 void activate() override;
89 void activate() override;
88
90
89 Workspace* proxyObject() const { return m_original.data(); }
91 Workspace* proxyObject() const { return m_original.data(); }
plugins/WindowManager/WorkspaceManager.cpp+7−13
@@ -17,6 +17,7 @@
17#include "WorkspaceManager.h"
17#include "WorkspaceManager.h"
18#include "Workspace.h"
18#include "Workspace.h"
19#include "TopLevelWindowModel.h"
19#include "TopLevelWindowModel.h"
20+#include "WindowManagerObjects.h"
20#include <unity/shell/application/SurfaceManagerInterface.h>
21#include <unity/shell/application/SurfaceManagerInterface.h>
21
22
22// Qt
23// Qt
@@ -32,7 +33,6 @@ WorkspaceManager *WorkspaceManager::instance()
32
33
33WorkspaceManager::WorkspaceManager()
34WorkspaceManager::WorkspaceManager()
34 : m_activeWorkspace(nullptr)
35 : m_activeWorkspace(nullptr)
35− , m_surfaceManager(nullptr)
36{
36{
37}
37}
38
38
@@ -99,25 +99,19 @@ void WorkspaceManager::destroyFloatingWorkspaces()
99 }
99 }
100}
100}
101
101
102−void WorkspaceManager::setSurfaceManager(unity::shell::application::SurfaceManagerInterface *surfaceManager)
103−{
104− if (m_surfaceManager == surfaceManager) return;
105−
106− m_surfaceManager = surfaceManager;
107− Q_EMIT surfaceManagerChanged();
108−}
109−
110void WorkspaceManager::moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface *surface, Workspace *workspace)
102void WorkspaceManager::moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface *surface, Workspace *workspace)
111{
103{
112− if (m_surfaceManager) {
104+ auto surfaceManager = WindowManagerObjects::instance()->surfaceManager();
105+ if (surfaceManager) {
113− m_surfaceManager->moveSurfaceToWorkspace(surface, workspace->workspace());
106+ surfaceManager->moveSurfaceToWorkspace(surface, workspace->workspace());
114 }
107 }
115}
108}
116
109
117void WorkspaceManager::moveWorkspaceContentToWorkspace(Workspace *from, Workspace *to)
110void WorkspaceManager::moveWorkspaceContentToWorkspace(Workspace *from, Workspace *to)
118{
111{
119− if (m_surfaceManager) {
112+ auto surfaceManager = WindowManagerObjects::instance()->surfaceManager();
113+ if (surfaceManager) {
120− m_surfaceManager->moveWorkspaceContentToWorkspace(from->workspace(), to->workspace());
114+ surfaceManager->moveWorkspaceContentToWorkspace(from->workspace(), to->workspace());
121 }
115 }
122}
116}
123
117
plugins/WindowManager/WorkspaceManager.h−9
@@ -37,11 +37,6 @@ class WorkspaceManager : public QObject
37 Q_OBJECT
37 Q_OBJECT
38 Q_PROPERTY(Workspace* activeWorkspace READ activeWorkspace WRITE setActiveWorkspace2 NOTIFY activeWorkspaceChanged)
38 Q_PROPERTY(Workspace* activeWorkspace READ activeWorkspace WRITE setActiveWorkspace2 NOTIFY activeWorkspaceChanged)
39
39
40− Q_PROPERTY(unity::shell::application::SurfaceManagerInterface* surfaceManager
41− READ surfaceManager
42− WRITE setSurfaceManager
43− NOTIFY surfaceManagerChanged)
44−
45public:
40public:
46 static WorkspaceManager* instance();
41 static WorkspaceManager* instance();
47
42
@@ -54,9 +49,6 @@ public:
54 QQmlListProperty<Workspace> floatingWorkspaces();
49 QQmlListProperty<Workspace> floatingWorkspaces();
55 void destroyFloatingWorkspaces();
50 void destroyFloatingWorkspaces();
56
51
57− unity::shell::application::SurfaceManagerInterface *surfaceManager() const { return m_surfaceManager; }
58− void setSurfaceManager(unity::shell::application::SurfaceManagerInterface*);
59−
60 Q_INVOKABLE void moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface* surface,
52 Q_INVOKABLE void moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface* surface,
61 Workspace* workspace);
53 Workspace* workspace);
62
54
@@ -65,7 +57,6 @@ public:
65Q_SIGNALS:
57Q_SIGNALS:
66 void activeWorkspaceChanged();
58 void activeWorkspaceChanged();
67 void floatingWorkspacesChanged();
59 void floatingWorkspacesChanged();
68− void surfaceManagerChanged();
69
60
70private:
61private:
71 WorkspaceManager();
62 WorkspaceManager();
qml/Shell.qml+10−13
@@ -98,6 +98,11 @@ StyledItem {
98
98
99 readonly property var mainApp: stage.mainApp
99 readonly property var mainApp: stage.mainApp
100
100
101+ readonly property var topLevelSurfaceList: {
102+ if (!WMScreen.currentWorkspace) return null;
103+ return WMScreen.currentWorkspace.windowModel
104+ }
105+
101 onMainAppChanged: {
106 onMainAppChanged: {
102 if (mainApp) {
107 if (mainApp) {
103 _onMainAppChanged(mainApp.appId);
108 _onMainAppChanged(mainApp.appId);
@@ -274,14 +279,6 @@ StyledItem {
274 width: parent.width
279 width: parent.width
275 height: parent.height
280 height: parent.height
276
281
277− TopLevelWindowModel {
278− id: topLevelSurfaceList
279− objectName: "topLevelSurfaceList"
280− applicationManager: ApplicationManager // it's a singleton
281− surfaceManager: SurfaceManager
282− workspace: screenWindow.screen.currentWorkspace
283− }
284−
285 Stage {
282 Stage {
286 id: stage
283 id: stage
287 objectName: "stage"
284 objectName: "stage"
@@ -292,7 +289,7 @@ StyledItem {
292 background: wallpaperResolver.background
289 background: wallpaperResolver.background
293
290
294 applicationManager: ApplicationManager
291 applicationManager: ApplicationManager
295− topLevelSurfaceList: topLevelSurfaceList
292+ topLevelSurfaceList: shell.topLevelSurfaceList
296 inputMethodRect: inputMethod.visibleRect
293 inputMethodRect: inputMethod.visibleRect
297 rightEdgePushProgress: rightEdgeBarrier.progress
294 rightEdgePushProgress: rightEdgeBarrier.progress
298
295
@@ -362,7 +359,7 @@ StyledItem {
362 InputMethod {
359 InputMethod {
363 id: inputMethod
360 id: inputMethod
364 objectName: "inputMethod"
361 objectName: "inputMethod"
365− surface: topLevelSurfaceList.inputMethodSurface
362+ surface: shell.topLevelSurfaceList.inputMethodSurface
366 anchors {
363 anchors {
367 fill: parent
364 fill: parent
368 topMargin: panel.panelHeight
365 topMargin: panel.panelHeight
@@ -546,8 +543,8 @@ StyledItem {
546 && !stage.spreadShown
543 && !stage.spreadShown
547 }
544 }
548
545
549− readonly property bool focusedSurfaceIsFullscreen: topLevelSurfaceList.focusedWindow
546+ readonly property bool focusedSurfaceIsFullscreen: shell.topLevelSurfaceList.focusedWindow
550− ? topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
547+ ? shell.topLevelSurfaceList.focusedWindow.state === Mir.FullscreenState
551 : false
548 : false
552 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0 && !stage.spreadShown)
549 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0 && !stage.spreadShown)
553 || greeter.hasLockedApp
550 || greeter.hasLockedApp
@@ -876,7 +873,7 @@ StyledItem {
876
873
877 // non-visual objects
874 // non-visual objects
878 KeymapSwitcher {
875 KeymapSwitcher {
879− focusedSurface: topLevelSurfaceList.focusedWindow ? topLevelSurfaceList.focusedWindow.surface : null
876+ focusedSurface: shell.topLevelSurfaceList.focusedWindow ? shell.topLevelSurfaceList.focusedWindow.surface : null
880 }
877 }
881 BrightnessControl {}
878 BrightnessControl {}
882
879
qml/ShellApplication.qml+7−2
@@ -47,9 +47,14 @@ Instantiator {
47 primary: index == 0
47 primary: index == 0
48 }
48 }
49
49
50− property var workspaceManagerSurfaceManagerBinding: Binding {
50+ property var windowManagerSurfaceManagerBinding: Binding {
51− target: WorkspaceManager
51+ target: WindowManagerObjects
52 property: "surfaceManager"
52 property: "surfaceManager"
53 value: SurfaceManager
53 value: SurfaceManager
54 }
54 }
55+ property var windowManagerApplicationManagerBinding: Binding {
56+ target: WindowManagerObjects
57+ property: "applicationManager"
58+ value: ApplicationManager
59+ }
55}
60}
qml/Stage/Spread/WorkspacePreview.qml+3−8
@@ -9,6 +9,8 @@ Item {
9 id: previewSpace
9 id: previewSpace
10 clip: true
10 clip: true
11
11
12+ property var workspace
13+
12 property string background
14 property string background
13 property int screenHeight
15 property int screenHeight
14
16
@@ -26,16 +28,9 @@ Item {
26 sourceSize.width: width
28 sourceSize.width: width
27 sourceSize.height: height
29 sourceSize.height: height
28
30
29− TopLevelWindowModel {
30− id: windowModel
31− applicationManager: ApplicationManager
32− surfaceManager: SurfaceManager
33− workspace: model.workspace
34− }
35−
36 Repeater {
31 Repeater {
37 id: topLevelSurfaceRepeater
32 id: topLevelSurfaceRepeater
38− model: visible ? windowModel : null
33+ model: visible ? workspace.windowModel : null
39 delegate: Rectangle {
34 delegate: Rectangle {
40 width: surfaceItem.width
35 width: surfaceItem.width
41 height: surfaceItem.height + decorationHeight * previewScale
36 height: surfaceItem.height + decorationHeight * previewScale
qml/Stage/Spread/Workspaces.qml+1−1
@@ -243,6 +243,7 @@ Item {
243 containsDragLeft: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "left"
243 containsDragLeft: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "left"
244 containsDragRight: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "right"
244 containsDragRight: listView.hoveredWorkspaceIndex == index && listView.hoveredHalf == "right"
245 isActive: model.workspace.active
245 isActive: model.workspace.active
246+ workspace: model.workspace
246 }
247 }
247 MouseArea {
248 MouseArea {
248 anchors.fill: parent
249 anchors.fill: parent
@@ -366,7 +367,6 @@ Item {
366 Drag.active: hoverMouseArea.drag.active
367 Drag.active: hoverMouseArea.drag.active
367 Drag.keys: ['workspace']
368 Drag.keys: ['workspace']
368
369
369− property var workspace
370 property bool inDropArea: false
370 property bool inDropArea: false
371
371
372 Rectangle {
372 Rectangle {
tests/mocks/WindowManager/CMakeLists.txt+2
@@ -26,6 +26,7 @@ set(WINDOWMANAGER_SRC
26 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/ScreenWindow.cpp
26 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/ScreenWindow.cpp
27 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/TopLevelWindowModel.cpp
27 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/TopLevelWindowModel.cpp
28 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/Window.cpp
28 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/Window.cpp
29+ ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WindowManagerObjects.cpp
29 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceManager.cpp
30 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceManager.cpp
30 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceModel.cpp
31 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceModel.cpp
31 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/Workspace.cpp
32 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/Workspace.cpp
@@ -33,6 +34,7 @@ set(WINDOWMANAGER_SRC
33 MockScreenWindow.cpp
34 MockScreenWindow.cpp
34 WindowManagerPlugin.cpp
35 WindowManagerPlugin.cpp
35 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
36 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
37+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
36 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
38 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
37 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
39 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
38 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
40 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceListInterface.h
tests/mocks/WindowManager/WindowManagerPlugin.cpp+8−1
@@ -27,6 +27,7 @@
27#include "Workspace.h"
27#include "Workspace.h"
28#include "WorkspaceModel.h"
28#include "WorkspaceModel.h"
29#include "WindowManagementPolicy.h"
29#include "WindowManagementPolicy.h"
30+#include "WindowManagerObjects.h"
30
31
31#include <QtQml>
32#include <QtQml>
32
33
@@ -43,19 +44,25 @@ QObject* screensSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
43 Q_UNUSED(scriptEngine);
44 Q_UNUSED(scriptEngine);
44 return new Screens(MockScreens::instance());
45 return new Screens(MockScreens::instance());
45}
46}
47+QObject* objectsSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
48+ Q_UNUSED(engine);
49+ Q_UNUSED(scriptEngine);
50+ return WindowManagerObjects::instance();
51+}
46
52
47void WindowManagerPlugin::registerTypes(const char *uri)
53void WindowManagerPlugin::registerTypes(const char *uri)
48{
54{
49− qmlRegisterType<TopLevelWindowModel>(uri, 1, 0, "TopLevelWindowModel");
50 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
55 qmlRegisterSingletonType<WorkspaceManager>(uri, 1, 0, "WorkspaceManager", workspace_manager);
51 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
56 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", notInstantiatable);
52 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
57 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
53 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
58 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", notInstantiatable);
54 qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
59 qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", notInstantiatable);
60+ qmlRegisterSingletonType<WindowManagerObjects>(uri, 1, 0, "WindowManagerObjects", objectsSingleton);
55
61
56 qRegisterMetaType<Screen*>("Screen*");
62 qRegisterMetaType<Screen*>("Screen*");
57 qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
63 qRegisterMetaType<ScreensProxy*>("ScreensProxy*");
58 qRegisterMetaType<Workspace*>("Workspace*");
64 qRegisterMetaType<Workspace*>("Workspace*");
65+ qRegisterMetaType<TopLevelWindowModel*>("TopLevelWindowModel*");
59
66
60 qRegisterMetaType<Window*>("Window*");
67 qRegisterMetaType<Window*>("Window*");
61 qRegisterMetaType<QAbstractListModel*>("QAbstractListModel*");
68 qRegisterMetaType<QAbstractListModel*>("QAbstractListModel*");