on d1867f5 help sign in
112 lines 2.9 kB history raw
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 */
17#ifndef WINDOWMANAGER_WORKSPACE_H
18#define WINDOWMANAGER_WORKSPACE_H
20#include <QObject>
21#include <QVariant>
22#include <QPointer>
23#include <QSharedPointer>
25#include <memory>
26#include <functional>
28class WorkspaceModel;
29class TopLevelWindowModel;
31namespace miral { class Workspace; }
33namespace unity {
34 namespace shell {
35 namespace application {
36 class MirSurfaceInterface;
37 }
38 }
41class Workspace : public QObject
43 Q_OBJECT
44 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
45 Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel CONSTANT)
46public:
47 virtual ~Workspace();
49 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
50 virtual void unassign();
52 virtual bool isActive() const = 0;
53 virtual TopLevelWindowModel *windowModel() const = 0;
55 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
56 bool isAssigned() const;
58public Q_SLOTS:
59 virtual void activate() = 0;
61Q_SIGNALS:
62 void assigned();
63 void unassigned();
65 void activeChanged(bool);
67protected:
68 Workspace(QObject *parent = nullptr);
69 Workspace(Workspace const& other);
71 std::shared_ptr<miral::Workspace> m_workspace;
72 WorkspaceModel* m_model;
73};
75class ConcreteWorkspace : public Workspace
77public:
78 explicit ConcreteWorkspace(QObject *parent = nullptr);
79 ~ConcreteWorkspace();
81 bool isActive() const override { return m_active; }
82 TopLevelWindowModel *windowModel() const override;
83 void activate() override;
85private:
86 bool m_active;
87 const QScopedPointer<TopLevelWindowModel> m_windowModel;
88};
90class ProxyWorkspace : public Workspace
92 Q_OBJECT
93public:
94 explicit ProxyWorkspace(Workspace*const workspace);
95 ~ProxyWorkspace() = default;
97 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
99 bool isActive() const override;
100 TopLevelWindowModel *windowModel() const override;
101 void activate() override;
103 Workspace* proxyObject() const { return m_original.data(); }
105public Q_SLOTS:
106 void unassign() override;
108private:
109 const QPointer<Workspace> m_original;
110};
112#endif // WINDOWMANAGER_WORKSPACE_H