on e174ec3 help sign in
100 lines 2.5 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>
24#include <memory>
25#include <functional>
27class WorkspaceModel;
28class TopLevelWindowModel;
30namespace miral { class Workspace; }
32namespace unity {
33 namespace shell {
34 namespace application {
35 class MirSurfaceInterface;
36 }
37 }
40class Workspace : public QObject
42 Q_OBJECT
43 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
44 Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel NOTIFY windowModelChanged)
45public:
46 ~Workspace();
48 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
49 virtual void unassign();
50 void release();
52 virtual bool isActive() const { return m_active; }
54 TopLevelWindowModel *windowModel() const { return m_windowModel; }
55 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
56 bool isAssigned() const;
58public Q_SLOTS:
59 virtual void activate();
61Q_SIGNALS:
62 void assigned();
63 void unassigned();
65 void activeChanged(bool);
66 void windowModelChanged();
68protected:
69 Workspace(QObject *parent = 0);
70 Workspace(Workspace const& other);
72 std::shared_ptr<miral::Workspace> m_workspace;
73 WorkspaceModel* m_model;
74 TopLevelWindowModel* m_windowModel;
75 bool m_active;
77 friend class WorkspaceManager;
78};
80class WorkspaceProxy : public Workspace
82 Q_OBJECT
83public:
84 WorkspaceProxy(Workspace*const workspace);
86 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
88 bool isActive() const override;
89 void activate() override;
91 Workspace* proxyObject() const { return m_original.data(); }
93public Q_SLOTS:
94 void unassign() override;
96private:
97 const QPointer<Workspace> m_original;
98};
100#endif // WINDOWMANAGER_WORKSPACE_H