on c403943 help sign in
117 lines 3.0 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>
28#include "WindowManagerGlobal.h"
30class WorkspaceModel;
31class TopLevelWindowModel;
33namespace miral { class Workspace; }
35namespace unity {
36 namespace shell {
37 namespace application {
38 class MirSurfaceInterface;
39 }
40 }
43class WINDOWMANAGERQML_EXPORT Workspace : public QObject
45 Q_OBJECT
46 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
47 Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel CONSTANT)
48public:
49 virtual ~Workspace();
51 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
52 virtual void unassign();
54 virtual bool isActive() const = 0;
55 virtual TopLevelWindowModel *windowModel() const = 0;
57 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
58 bool isAssigned() const;
60public Q_SLOTS:
61 virtual void activate() = 0;
63Q_SIGNALS:
64 void assigned();
65 void unassigned();
67 void activeChanged(bool);
69protected:
70 Workspace(QObject *parent = nullptr);
71 Workspace(Workspace const& other);
73 std::shared_ptr<miral::Workspace> m_workspace;
74 WorkspaceModel* m_model;
75};
77class WINDOWMANAGERQML_EXPORT ConcreteWorkspace : public Workspace
79public:
80 ~ConcreteWorkspace();
82 bool isActive() const override { return m_active; }
83 TopLevelWindowModel *windowModel() const override;
84 void activate() override;
86private:
87 explicit ConcreteWorkspace(QObject *parent = nullptr);
89 bool m_active;
90 const QScopedPointer<TopLevelWindowModel> m_windowModel;
92 friend class WorkspaceManager;
93};
95class ProxyWorkspace : public Workspace
97 Q_OBJECT
98public:
99 explicit ProxyWorkspace(Workspace*const workspace);
100 ~ProxyWorkspace() = default;
102 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
104 bool isActive() const override;
105 TopLevelWindowModel *windowModel() const override;
106 void activate() override;
108 Workspace* proxyObject() const { return m_original.data(); }
110public Q_SLOTS:
111 void unassign() override;
113private:
114 const QPointer<Workspace> m_original;
115};
117#endif // WINDOWMANAGER_WORKSPACE_H