on 0bcac19 help sign in
98 lines 2.3 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)
44public:
45 ~Workspace();
47 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
48 virtual void unassign();
49 void release();
51 virtual bool isActive() const { return m_active; }
52 bool isAssigned() const;
54 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
57public Q_SLOTS:
58 virtual void activate();
60Q_SIGNALS:
61 void assigned();
62 void unassigned();
64 void activeChanged(bool);
66protected:
67 Workspace(QObject *parent = 0);
68 Workspace(Workspace const& other);
70 std::shared_ptr<miral::Workspace> m_workspace;
71 WorkspaceModel* m_model;
72 bool m_active;
74 friend class WorkspaceManager;
75};
77class WorkspaceProxy : public Workspace
79 Q_OBJECT
80public:
81 WorkspaceProxy(Workspace*const workspace);
83 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
85 bool isActive() const override;
87 void activate() override;
89 Workspace* proxyObject() const { return m_original.data(); }
91public Q_SLOTS:
92 void unassign() override;
94private:
95 const QPointer<Workspace> m_original;
96};
98#endif // WINDOWMANAGER_WORKSPACE_H