on xenial help sign in
more workspaces
925a0a9Nick Dedekind
plugins/WindowManager/CMakeLists.txt+6
@@ -3,6 +3,11 @@ include_directories(
3 ${QTMIRSERVER_INCLUDE_DIRS}
3 ${QTMIRSERVER_INCLUDE_DIRS}
4)
4)
5
5
6+include_directories(
7+ ${CMAKE_CURRENT_SOURCE_DIR}
8+ ${libunity8-private_SOURCE_DIR}
9+)
10+
6set(WINDOWMANAGER_SRC
11set(WINDOWMANAGER_SRC
7 TopLevelWindowModel.cpp
12 TopLevelWindowModel.cpp
8 Window.cpp
13 Window.cpp
@@ -24,6 +29,7 @@ add_library(windowmanager-qml SHARED ${WINDOWMANAGER_SRC})
24
29
25target_link_libraries(windowmanager-qml
30target_link_libraries(windowmanager-qml
26 ${QTMIRSERVER_LDFLAGS}
31 ${QTMIRSERVER_LDFLAGS}
32+ unity8-private
27)
33)
28
34
29qt5_use_modules(windowmanager-qml Qml Quick Gui)
35qt5_use_modules(windowmanager-qml Qml Quick Gui)
plugins/WindowManager/Screens.cpp+1−1
@@ -36,7 +36,7 @@ Screens::Screens(QObject *parent)
36
36
37 connect(m_wrapped.data(), &qtmir::Screens::screenAdded, this, &Screens::onScreenAdded);
37 connect(m_wrapped.data(), &qtmir::Screens::screenAdded, this, &Screens::onScreenAdded);
38 connect(m_wrapped.data(), &qtmir::Screens::screenRemoved, this, &Screens::onScreenRemoved);
38 connect(m_wrapped.data(), &qtmir::Screens::screenRemoved, this, &Screens::onScreenRemoved);
39− connect(qGuiApp, &QGuiApplication::focusWindowChanged, this, &Screens::activeScreenChanged);
39+ connect(m_wrapped.data(), &qtmir::Screens::activeScreenChanged, this, &Screens::activeScreenChanged);
40
40
41 Q_FOREACH(qtmir::Screen* screen, m_wrapped->screens()) {
41 Q_FOREACH(qtmir::Screen* screen, m_wrapped->screens()) {
42 m_screenList.push_back(new Screen(screen));
42 m_screenList.push_back(new Screen(screen));
plugins/WindowManager/TopLevelWindowModel.cpp+3
@@ -39,10 +39,12 @@ namespace unityapi = unity::shell::application;
39
39
40TopLevelWindowModel::TopLevelWindowModel()
40TopLevelWindowModel::TopLevelWindowModel()
41{
41{
42+ DEBUG_MSG << "\n\nPLOP\n\n";
42}
43}
43
44
44void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInterface* value)
45void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInterface* value)
45{
46{
47+ qDebug() << "\n\nPLOP2\n\n";
46 if (m_applicationManager == value) {
48 if (m_applicationManager == value) {
47 return;
49 return;
48 }
50 }
@@ -90,6 +92,7 @@ void TopLevelWindowModel::setApplicationManager(unityapi::ApplicationManagerInte
90
92
91void TopLevelWindowModel::setSurfaceManager(unityapi::SurfaceManagerInterface *surfaceManager)
93void TopLevelWindowModel::setSurfaceManager(unityapi::SurfaceManagerInterface *surfaceManager)
92{
94{
95+ qDebug() << "\n\nPLOP3\n\n";
93 if (surfaceManager == m_surfaceManager) {
96 if (surfaceManager == m_surfaceManager) {
94 return;
97 return;
95 }
98 }
plugins/WindowManager/WindowManagerPlugin.cpp+1
@@ -46,6 +46,7 @@ void WindowManagerPlugin::registerTypes(const char *uri)
46 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", "Not a creatable type");
46 qmlRegisterUncreatableType<WorkspaceModel>(uri, 1, 0, "WorkspaceModel", "Not a creatable type");
47 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
47 qmlRegisterSingletonType<Screens>(uri, 1, 0, "Screens", screensSingleton);
48 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", "ScreenMode is not creatable.");
48 qmlRegisterUncreatableType<qtmir::ScreenMode>(uri, 1, 0, "ScreenMode", "ScreenMode is not creatable.");
49+ qmlRegisterUncreatableType<Workspace>(uri, 1, 0, "Workspace", "Workspace is not creatable.");
49
50
50 qRegisterMetaType<Window*>("Window*");
51 qRegisterMetaType<Window*>("Window*");
51 qRegisterMetaType<Workspace*>("Workspace*");
52 qRegisterMetaType<Workspace*>("Workspace*");
plugins/WindowManager/Workspace.cpp+37−16
@@ -16,12 +16,25 @@
16
16
17#include "Workspace.h"
17#include "Workspace.h"
18#include "WorkspaceModel.h"
18#include "WorkspaceModel.h"
19+#include "WorkspaceManager.h"
20+#include "TopLevelWindowModel.h"
21+
22+#include "windowmanagementpolicy.h"
19
23
20Workspace::Workspace(QObject *parent)
24Workspace::Workspace(QObject *parent)
21 : QObject(parent)
25 : QObject(parent)
26+ , m_workspace(WindowManagementPolicy::instance()->create_workspace())
27+ , m_windowModel(new TopLevelWindowModel)
22 , m_model(nullptr)
28 , m_model(nullptr)
29+ , m_active(false)
23{
30{
24−
31+ connect(WorkspaceManager::instance(), &WorkspaceManager::activeWorkspaceChanged, this, [this]() {
32+ bool newActive = WorkspaceManager::instance()->activeWorkspace() == this;
33+ if (newActive != m_active) {
34+ m_active = newActive;
35+ Q_EMIT activeChanged(m_active);
36+ }
37+ });
25}
38}
26
39
27Workspace::~Workspace()
40Workspace::~Workspace()
@@ -29,35 +42,43 @@ Workspace::~Workspace()
29 unassign();
42 unassign();
30}
43}
31
44
32−void Workspace::assign(WorkspaceModel *model)
45+void Workspace::assign(WorkspaceModel *model, const QVariant& vIndex)
33{
46{
34− bool wasAssinged = false;
47+ if (m_model == model) return;
48+
35 if (m_model) {
49 if (m_model) {
36 disconnect(model);
50 disconnect(model);
37 m_model->remove(this);
51 m_model->remove(this);
38− wasAssinged = true;
39 }
52 }
40
53
41− m_model = model;
54+ m_model = model ? model : WorkspaceManager::instance();
42− if (model) {
43− model->append(this);
44
55
56+ if (m_model) {
57+ int index = m_model->rowCount();
58+ if (vIndex.isValid() && vIndex.canConvert(QVariant::Int)) {
59+ index = vIndex.toInt();
60+ }
61+ m_model->insert(index, this);
62+
45− connect(model, &QObject::destroyed, this, [this]() {
63+ connect(m_model, &QObject::destroyed, this, [this]() {
64+ m_model->remove(this);
46 m_model = nullptr;
65 m_model = nullptr;
47− Q_EMIT unassigned();
48 });
66 });
49 Q_EMIT assigned();
67 Q_EMIT assigned();
50− } else if (wasAssinged) {
51− Q_EMIT unassigned();
52 }
68 }
53}
69}
54
70
71+void Workspace::activate()
72+{
73+ WorkspaceManager::instance()->setActiveWorkspace(this);
74+}
75+
55void Workspace::unassign()
76void Workspace::unassign()
56{
77{
57− if (m_model) {
58− m_model->remove(this);
59− m_model = nullptr;
78+ assign(nullptr);
79+}
60
80
61− Q_EMIT unassigned();
81+TopLevelWindowModel *Workspace::windowModel() const
62− }
82+{
83+ return m_windowModel.data();
63}
84}
plugins/WindowManager/Workspace.h+27−6
@@ -14,31 +14,52 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#ifndef WORKSPACE_H
17+#ifndef WINDOWMANAGER_WORKSPACE_H
18−#define WORKSPACE_H
18+#define WINDOWMANAGER_WORKSPACE_H
19
19
20#include <QObject>
20#include <QObject>
21+#include <QVariant>
22+
23+#include <memory>
21
24
22class WorkspaceModel;
25class WorkspaceModel;
26+class TopLevelWindowModel;
27+
28+namespace miral { class Workspace; }
23
29
24class Workspace : public QObject
30class Workspace : public QObject
25{
31{
26 Q_OBJECT
32 Q_OBJECT
33+ Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
34+ Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel CONSTANT)
27public:
35public:
28− explicit Workspace(QObject *parent = 0);
29 ~Workspace();
36 ~Workspace();
30
37
31− Q_INVOKABLE void assign(WorkspaceModel* model);
38+ Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant());
39+
40+ bool isActive() const { return m_active; }
41+
42+ TopLevelWindowModel *windowModel() const;
32
43
33−public Q_SLOT:
44+public Q_SLOTS:
45+ void activate();
34 void unassign();
46 void unassign();
35
47
36Q_SIGNALS:
48Q_SIGNALS:
37 void assigned();
49 void assigned();
38 void unassigned();
50 void unassigned();
39
51
52+ void activeChanged(bool);
53+
40private:
54private:
55+ explicit Workspace(QObject *parent = 0);
56+
57+ std::shared_ptr<miral::Workspace> m_workspace;
58+ QScopedPointer<TopLevelWindowModel> m_windowModel;
41 WorkspaceModel* m_model;
59 WorkspaceModel* m_model;
60+ bool m_active;
61+
62+ friend class WorkspaceManager;
42};
63};
43
64
44−#endif // WORKSPACE_H
65+#endif // WINDOWMANAGER_WORKSPACE_H
plugins/WindowManager/WorkspaceManager.cpp+37
@@ -16,6 +16,7 @@
16
16
17#include "WorkspaceManager.h"
17#include "WorkspaceManager.h"
18#include "Workspace.h"
18#include "Workspace.h"
19+#include "TopLevelWindowModel.h"
19
20
20// Qt
21// Qt
21#include <QGuiApplication>
22#include <QGuiApplication>
@@ -29,19 +30,55 @@ WorkspaceManager *WorkspaceManager::instance()
29}
30}
30
31
31WorkspaceManager::WorkspaceManager()
32WorkspaceManager::WorkspaceManager()
33+ : m_activeWorkspace(nullptr)
32{
34{
33}
35}
36+
34Workspace *WorkspaceManager::createWorkspace()
37Workspace *WorkspaceManager::createWorkspace()
35{
38{
36 auto workspace = new Workspace(this);
39 auto workspace = new Workspace(this);
37 QQmlEngine::setObjectOwnership(workspace, QQmlEngine::CppOwnership);
40 QQmlEngine::setObjectOwnership(workspace, QQmlEngine::CppOwnership);
38 m_allWorkspaces.append(workspace);
41 m_allWorkspaces.append(workspace);
39 workspace->assign(this);
42 workspace->assign(this);
43+
44+ if (m_allWorkspaces.count() == 0 && m_activeWorkspace) {
45+ m_activeWorkspace = nullptr;
46+ Q_EMIT activeWorkspaceChanged();
47+ } else if (m_allWorkspaces.count() == 1) {
48+ m_activeWorkspace = workspace;
49+ Q_EMIT activeWorkspaceChanged();
50+ }
51+
40 return workspace;
52 return workspace;
41}
53}
42
54
43void WorkspaceManager::destroyWorkspace(Workspace *workspace)
55void WorkspaceManager::destroyWorkspace(Workspace *workspace)
44{
56{
57+ if (!workspace) return;
58+
59+ int index = m_workspaces.indexOf(workspace);
60+ if (index > 0) {
61+ if (workspace == m_activeWorkspace) {
62+ int newIndex = qMax(index, m_allWorkspaces.count()-1);
63+ m_activeWorkspace = newIndex > 0 ? m_allWorkspaces[newIndex] : nullptr;
64+ Q_EMIT activeWorkspaceChanged();
65+ }
66+// if (m_activeWorkspace) {
67+// m_activeWorkspace->windowModel()->transferWindowsFrom(workspace->windowModel());
68+// }
69+ }
45 workspace->deleteLater();
70 workspace->deleteLater();
46}
71}
47
72
73+Workspace *WorkspaceManager::activeWorkspace() const
74+{
75+ return m_activeWorkspace;
76+}
77+
78+void WorkspaceManager::setActiveWorkspace(Workspace *workspace)
79+{
80+ if (workspace != m_activeWorkspace) {
81+ m_activeWorkspace = workspace;
82+ Q_EMIT activeWorkspaceChanged();
83+ }
84+}
plugins/WindowManager/WorkspaceManager.h+10−2
@@ -24,18 +24,26 @@ class Workspace;
24class WorkspaceManager : public WorkspaceModel
24class WorkspaceManager : public WorkspaceModel
25{
25{
26 Q_OBJECT
26 Q_OBJECT
27+ Q_PROPERTY(Workspace* activeWorkspace READ activeWorkspace WRITE setActiveWorkspace NOTIFY activeWorkspaceChanged)
28+
27public:
29public:
28 static WorkspaceManager* instance();
30 static WorkspaceManager* instance();
29
31
30−private:
32+ Workspace* activeWorkspace() const;
31− WorkspaceManager();
33+ void setActiveWorkspace(Workspace* workspace);
32
34
33public Q_SLOTS:
35public Q_SLOTS:
34 Workspace* createWorkspace();
36 Workspace* createWorkspace();
35 void destroyWorkspace(Workspace* workspace);
37 void destroyWorkspace(Workspace* workspace);
36
38
39+Q_SIGNALS:
40+ void activeWorkspaceChanged();
41+
37private:
42private:
43+ WorkspaceManager();
44+
38 QVector<Workspace*> m_allWorkspaces;
45 QVector<Workspace*> m_allWorkspaces;
46+ Workspace* m_activeWorkspace;
39};
47};
40
48
41#endif // WORKSPACEMANAGER_H
49#endif // WORKSPACEMANAGER_H
plugins/WindowManager/WorkspaceModel.h+5−1
@@ -43,7 +43,7 @@ public:
43 void append(Workspace* workspace);
43 void append(Workspace* workspace);
44 void insert(int index, Workspace* workspace);
44 void insert(int index, Workspace* workspace);
45 void remove(Workspace* workspace);
45 void remove(Workspace* workspace);
46− void move(int from, int to);
46+ Q_INVOKABLE void move(int from, int to);
47
47
48 // From QAbstractItemModel
48 // From QAbstractItemModel
49 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
49 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
@@ -53,8 +53,12 @@ public:
53 return roleNames;
53 return roleNames;
54 }
54 }
55
55
56+ Workspace* activeWorkspace() const;
57+ void setActiveWorkspace(Workspace* workspace);
58+
56Q_SIGNALS:
59Q_SIGNALS:
57 void countChanged();
60 void countChanged();
61+ void activeWorkspaceChanged();
58
62
59protected:
63protected:
60 QVector<Workspace*> m_workspaces;
64 QVector<Workspace*> m_workspaces;
src/libunity8-private/CMakeLists.txt+10
@@ -4,16 +4,26 @@ set(VERSION ${SOVERSION}.0.0)
4
4
5project(lib${LIB_NAME})
5project(lib${LIB_NAME})
6
6
7+include_directories(
8+ SYSTEM
9+ ${QTMIRSERVER_INCLUDE_DIRS}
10+)
11+
7set(lib${LIB_NAME}_SRCS
12set(lib${LIB_NAME}_SRCS
8 abstractdbusservicemonitor.cpp
13 abstractdbusservicemonitor.cpp
9 unitydbusobject.cpp
14 unitydbusobject.cpp
10 unitydbusvirtualobject.cpp
15 unitydbusvirtualobject.cpp
16+ windowmanagementpolicy.cpp
11 )
17 )
12
18
13add_library(${LIB_NAME} SHARED
19add_library(${LIB_NAME} SHARED
14 ${lib${LIB_NAME}_SRCS}
20 ${lib${LIB_NAME}_SRCS}
15 )
21 )
16
22
23+target_link_libraries(${LIB_NAME}
24+ ${QTMIRSERVER_LDFLAGS}
25+ )
26+
17set_target_properties(${LIB_NAME} PROPERTIES
27set_target_properties(${LIB_NAME} PROPERTIES
18 VERSION ${VERSION}
28 VERSION ${VERSION}
19 SOVERSION ${SOVERSION}
29 SOVERSION ${SOVERSION}
src/libunity8-private/windowmanagementpolicy.cppnew file+37
@@ -0,0 +1,37 @@
1+#include "windowmanagementpolicy.h"
2+
3+WindowManagementPolicy* WindowManagementPolicy::m_self = nullptr;
4+
5+WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools, qtmir::WindowManagementPolicyPrivate &dd)
6+ : qtmir::WindowManagementPolicy(tools, dd)
7+{
8+ m_self = this;
9+}
10+
11+WindowManagementPolicy *WindowManagementPolicy::instance()
12+{
13+ return m_self;
14+}
15+
16+void WindowManagementPolicy::advise_new_window(miral::WindowInfo const& window_info)
17+{
18+ qtmir::WindowManagementPolicy::advise_new_window(window_info);
19+
20+ auto const parent = window_info.parent();
21+
22+ if (!parent)
23+ tools.add_tree_to_workspace(window_info.window(), m_activeWorkspace);
24+}
25+
26+std::shared_ptr<miral::Workspace> WindowManagementPolicy::create_workspace()
27+{
28+ return tools.create_workspace();
29+}
30+
31+void WindowManagementPolicy::setActiveWorkspace(const std::shared_ptr<miral::Workspace> &workspace)
32+{
33+ if (workspace == m_activeWorkspace)
34+ return;
35+ m_activeWorkspace = workspace;
36+}
37+
src/libunity8-private/windowmanagementpolicy.hnew file+29
@@ -0,0 +1,29 @@
1+#ifndef UNITY_WINDOWMANAGEMENTPOLICY_H
2+#define UNITY_WINDOWMANAGEMENTPOLICY_H
3+
4+#include <QObject>
5+#include <qtmir/windowmanagementpolicy.h>
6+
7+class Q_DECL_EXPORT WindowManagementPolicy : public QObject,
8+ public qtmir::WindowManagementPolicy
9+{
10+ Q_OBJECT
11+public:
12+ WindowManagementPolicy(const miral::WindowManagerTools &tools, qtmir::WindowManagementPolicyPrivate& dd);
13+
14+ static WindowManagementPolicy *instance();
15+
16+ void advise_new_window(miral::WindowInfo const& window_info) override;
17+
18+
19+ std::shared_ptr<miral::Workspace> create_workspace();
20+
21+public Q_SLOTS:
22+ void setActiveWorkspace(const std::shared_ptr<miral::Workspace>& workspace);
23+
24+private:
25+ static WindowManagementPolicy* m_self;
26+ std::shared_ptr<miral::Workspace> m_activeWorkspace;
27+};
28+
29+#endif // UNITY_WINDOWMANAGEMENTPOLICY_H
tests/mocks/WindowManager/CMakeLists.txt+6−5
@@ -1,22 +1,23 @@
1include_directories(
1include_directories(
2− ${CMAKE_SOURCE_DIR}/plugins/WindowManager
2+ SYSTEM
3+ ${QTMIRSERVER_INCLUDE_DIRS}
3)
4)
4
5
5include_directories(
6include_directories(
6− SYSTEM
7+ ${CMAKE_SOURCE_DIR}/plugins/WindowManager
7− ${QTMIRSERVER_INCLUDE_DIRS}
8+ ${libunity8-private_SOURCE_DIR}
8)
9)
9
10
10set(WINDOWMANAGER_SRC
11set(WINDOWMANAGER_SRC
11 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/TopLevelWindowModel.cpp
12 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/TopLevelWindowModel.cpp
12 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/Window.cpp
13 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/Window.cpp
13− ${CMAKE_SOURCE_DIR}/plugins/WindowManager/Workspace.cpp
14 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceManager.cpp
14 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceManager.cpp
15 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceModel.cpp
15 ${CMAKE_SOURCE_DIR}/plugins/WindowManager/WorkspaceModel.cpp
16− WindowManagerPlugin.cpp
17 Screens.cpp
16 Screens.cpp
18 Screen.cpp
17 Screen.cpp
19 ScreenWindow.cpp
18 ScreenWindow.cpp
19+ Workspace.cpp
20+ WindowManagerPlugin.cpp
20 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
21 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
21 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
22 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
22 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
23 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
tests/mocks/WindowManager/Workspace.cppnew file+80
@@ -0,0 +1,80 @@
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 "Workspace.h"
18+#include "WorkspaceModel.h"
19+#include "WorkspaceManager.h"
20+#include "TopLevelWindowModel.h"
21+
22+#include "windowmanagementpolicy.h"
23+
24+Workspace::Workspace(QObject *parent)
25+ : QObject(parent)
26+ , m_model(nullptr)
27+ , m_windowModel(new TopLevelWindowModel)
28+ , m_active(false)
29+{
30+ connect(WorkspaceManager::instance(), &WorkspaceManager::activeWorkspaceChanged, this, [this]() {
31+ bool newActive = WorkspaceManager::instance()->activeWorkspace() == this;
32+ if (newActive != m_active) {
33+ m_active = newActive;
34+ Q_EMIT activeChanged(m_active);
35+ }
36+ });
37+ connect(this, &Workspace::activeChanged, m_windowModel.data(), &TopLevelWindowModel::setActive);
38+}
39+
40+Workspace::~Workspace()
41+{
42+ unassign();
43+}
44+
45+void Workspace::assign(WorkspaceModel *model)
46+{
47+ if (m_model == model) return;
48+
49+ if (m_model) {
50+ disconnect(model);
51+ m_model->remove(this);
52+ }
53+
54+ m_model = model ? model : WorkspaceManager::instance();
55+
56+ if (m_model) {
57+ m_model->append(this);
58+
59+ connect(m_model, &QObject::destroyed, this, [this]() {
60+ m_model->remove(this);
61+ m_model = nullptr;
62+ });
63+ Q_EMIT assigned();
64+ }
65+}
66+
67+void Workspace::activate()
68+{
69+ WorkspaceManager::instance()->setActiveWorkspace(this);
70+}
71+
72+void Workspace::unassign()
73+{
74+ assign(nullptr);
75+}
76+
77+TopLevelWindowModel *Workspace::windowModel() const
78+{
79+ return m_windowModel.data();
80+}
tests/mocks/WindowManager/Workspace.hnew file+62
@@ -0,0 +1,62 @@
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 WORKSPACE_H
18+#define WORKSPACE_H
19+
20+#include <QObject>
21+#include <memory>
22+
23+class WorkspaceModel;
24+class TopLevelWindowModel;
25+
26+namespace miral { class Workspace; }
27+
28+class Workspace : public QObject
29+{
30+ Q_OBJECT
31+ Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
32+ Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel CONSTANT)
33+public:
34+ ~Workspace();
35+
36+ Q_INVOKABLE void assign(WorkspaceModel* model);
37+
38+ bool isActive() const { return m_active; }
39+
40+ TopLevelWindowModel *windowModel() const;
41+
42+public Q_SLOT:
43+ void activate();
44+ void unassign();
45+
46+Q_SIGNALS:
47+ void assigned();
48+ void unassigned();
49+
50+ void activeChanged();
51+
52+private:
53+ explicit Workspace(QObject *parent = 0);
54+
55+ WorkspaceModel* m_model;
56+ QScopedPointer<TopLevelWindowModel> m_windowModel;
57+ bool m_active;
58+
59+ friend class WorkspaceManager;
60+};
61+
62+#endif // WORKSPACE_H