on 27430d5 help sign in
122 lines 3.2 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;
32class Screen;
34namespace miral { class Workspace; }
36namespace unity {
37 namespace shell {
38 namespace application {
39 class MirSurfaceInterface;
40 }
41 }
44class WINDOWMANAGERQML_EXPORT Workspace : public QObject
46 Q_OBJECT
47 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
48 Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel CONSTANT)
49public:
50 virtual ~Workspace();
52 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
53 virtual void unassign();
55 virtual bool isActive() const = 0;
56 virtual TopLevelWindowModel *windowModel() const = 0;
57 virtual void setCurrentOn(Screen*) = 0;
59 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
60 bool isAssigned() const;
61 Q_INVOKABLE bool isSameAs(Workspace*) const;
63public Q_SLOTS:
64 virtual void activate() = 0;
66Q_SIGNALS:
67 void assigned();
68 void unassigned();
70 void activeChanged(bool);
72protected:
73 Workspace(QObject *parent = nullptr);
74 Workspace(Workspace const& other);
76 std::shared_ptr<miral::Workspace> m_workspace;
77 WorkspaceModel* m_model;
78};
80class WINDOWMANAGERQML_EXPORT ConcreteWorkspace : public Workspace
82public:
83 ~ConcreteWorkspace();
85 bool isActive() const override { return m_active; }
86 TopLevelWindowModel *windowModel() const override;
87 void activate() override;
88 void setCurrentOn(Screen*) override;
90private:
91 explicit ConcreteWorkspace(QObject *parent = nullptr);
93 bool m_active;
94 const QScopedPointer<TopLevelWindowModel> m_windowModel;
96 friend class WorkspaceManager;
97};
99class ProxyWorkspace : public Workspace
101 Q_OBJECT
102public:
103 explicit ProxyWorkspace(Workspace*const workspace);
104 ~ProxyWorkspace() = default;
106 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
108 bool isActive() const override;
109 TopLevelWindowModel *windowModel() const override;
110 void activate() override;
111 void setCurrentOn(Screen*) override;
113 Workspace* proxyObject() const { return m_original.data(); }
115public Q_SLOTS:
116 void unassign() override;
118private:
119 const QPointer<Workspace> m_original;
120};
122#endif // WINDOWMANAGER_WORKSPACE_H