Lomiri
Loading...
Searching...
No Matches
Workspace.h
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 */
16
17#ifndef WINDOWMANAGER_WORKSPACE_H
18#define WINDOWMANAGER_WORKSPACE_H
19
20#include <QObject>
21#include <QVariant>
22#include <QPointer>
23#include <QSharedPointer>
24
25#include <memory>
26#include <functional>
27
28#include "WindowManagerGlobal.h"
29
30class WorkspaceModel;
32class Screen;
33
34namespace miral { class Workspace; }
35
36namespace lomiri {
37 namespace shell {
38 namespace application {
39 class MirSurfaceInterface;
40 }
41 }
42}
43
44class WINDOWMANAGERQML_EXPORT Workspace : public QObject
45{
46 Q_OBJECT
47 Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
48 Q_PROPERTY(TopLevelWindowModel* windowModel READ windowModel CONSTANT)
49public:
50 virtual ~Workspace();
51
52 virtual void assign(WorkspaceModel* model, const QVariant& index = QVariant());
53 virtual void unassign();
54
55 virtual bool isActive() const = 0;
56 virtual TopLevelWindowModel *windowModel() const = 0;
57 virtual void setCurrentOn(Screen*) = 0;
58
59 std::shared_ptr<miral::Workspace> workspace() const { return m_workspace; }
60 bool isAssigned() const;
61 Q_INVOKABLE bool isSameAs(Workspace*) const;
62
63public Q_SLOTS:
64 virtual void activate() = 0;
65
66Q_SIGNALS:
67 void assigned();
68 void unassigned();
69
70 void activeChanged(bool);
71
72protected:
73 Workspace(QObject *parent = nullptr);
74 Workspace(Workspace const& other);
75
76 std::shared_ptr<miral::Workspace> m_workspace;
77 WorkspaceModel* m_model;
78};
79
80class WINDOWMANAGERQML_EXPORT ConcreteWorkspace : public Workspace
81{
82public:
83 ~ConcreteWorkspace();
84
85 bool isActive() const override { return m_active; }
86 TopLevelWindowModel *windowModel() const override;
87 void activate() override;
88 void setCurrentOn(Screen*) override;
89
90private:
91 explicit ConcreteWorkspace(QObject *parent = nullptr);
92
93 bool m_active;
94 const QScopedPointer<TopLevelWindowModel> m_windowModel;
95
96 friend class WorkspaceManager;
97};
98
99class ProxyWorkspace : public Workspace
100{
101 Q_OBJECT
102public:
103 explicit ProxyWorkspace(Workspace*const workspace);
104 ~ProxyWorkspace() = default;
105
106 Q_INVOKABLE void assign(WorkspaceModel* model, const QVariant& index = QVariant()) override;
107
108 bool isActive() const override;
109 TopLevelWindowModel *windowModel() const override;
110 void activate() override;
111 void setCurrentOn(Screen*) override;
112
113 Workspace* proxyObject() const { return m_original.data(); }
114
115public Q_SLOTS:
116 void unassign() override;
117
118private:
119 const QPointer<Workspace> m_original;
120};
121
122#endif // WINDOWMANAGER_WORKSPACE_H
A model of top-level surfaces.