Lomiri
WorkspaceManager.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 WORKSPACEMANAGER_H
18 #define WORKSPACEMANAGER_H
19 
20 #include <QQmlListProperty>
21 
22 #include "WindowManagerGlobal.h"
23 #include "WorkspaceModel.h"
24 
25 class Workspace;
26 
27 namespace lomiri {
28  namespace shell {
29  namespace application {
30  class MirSurfaceInterface;
31  class SurfaceManagerInterface;
32  }
33  }
34 }
35 
36 class WINDOWMANAGERQML_EXPORT WorkspaceManager : public QObject
37 {
38  Q_OBJECT
39  Q_PROPERTY(Workspace* activeWorkspace READ activeWorkspace WRITE setActiveWorkspace2 NOTIFY activeWorkspaceChanged)
40 
41 public:
42  WorkspaceManager();
43  ~WorkspaceManager();
44  static WorkspaceManager* instance();
45 
46  Workspace* activeWorkspace() const;
47  void setActiveWorkspace(Workspace* workspace);
48 
49  Workspace* createWorkspace();
50  Q_INVOKABLE void destroyWorkspace(Workspace* workspace);
51 
52  void destroyFloatingWorkspaces();
53 
54  Q_INVOKABLE void moveSurfaceToWorkspace(lomiri::shell::application::MirSurfaceInterface* surface,
55  Workspace* workspace);
56 
57  Q_INVOKABLE void moveWorkspaceContentToWorkspace(Workspace* to, Workspace* from);
58 
59 public Q_SLOTS:
60  void setSurfaceManager(lomiri::shell::application::SurfaceManagerInterface*);
61 
62 Q_SIGNALS:
63  void activeWorkspaceChanged(Workspace*);
64 
65 private:
66  void setActiveWorkspace2(Workspace* workspace);
67 
68  QSet<Workspace*> m_allWorkspaces;
69  Workspace* m_activeWorkspace;
70  lomiri::shell::application::SurfaceManagerInterface* m_surfaceManager;
71 };
72 
73 #endif // WORKSPACEMANAGER_H