2 * Copyright (C) 2017 Canonical, Ltd.
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.
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.
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/>.
17#include "WorkspaceManager.h"
19#include "TopLevelWindowModel.h"
20#include "WindowManagerObjects.h"
21#include <unity/shell/application/SurfaceManagerInterface.h>
24#include <QGuiApplication>
28WorkspaceManager *WorkspaceManager::instance()
30 static WorkspaceManager* workspaceManager(new WorkspaceManager());
31 return workspaceManager;
34WorkspaceManager::WorkspaceManager()
35 : m_activeWorkspace(nullptr)
39Workspace *WorkspaceManager::createWorkspace()
41 auto workspace = new ConcreteWorkspace(this);
42 QQmlEngine::setObjectOwnership(workspace, QQmlEngine::CppOwnership);
43 m_allWorkspaces.insert(workspace);
45 if (m_allWorkspaces.count() == 0 && m_activeWorkspace) {
46 setActiveWorkspace(nullptr);
47 } else if (m_allWorkspaces.count() == 1) {
48 setActiveWorkspace(workspace);
54void WorkspaceManager::destroyWorkspace(Workspace *workspace)
56 if (!workspace) return;
58 if (workspace->isAssigned()) {
59 workspace->unassign();
61 m_allWorkspaces.remove(workspace);
63 if (m_activeWorkspace == workspace) {
64 Q_ASSERT(false); // Shouldn't happen, should have chosen something by now.
65 // just choose anything.
66 setActiveWorkspace(m_allWorkspaces.count() ? *m_allWorkspaces.begin() : nullptr);
68 if (m_activeWorkspace) {
69 moveWorkspaceContentToWorkspace(m_activeWorkspace, workspace);
72 disconnect(workspace, 0, this, 0);
75void WorkspaceManager::moveSurfaceToWorkspace(unity::shell::application::MirSurfaceInterface *surface, Workspace *workspace)
77 auto surfaceManager = WindowManagerObjects::instance()->surfaceManager();
79 surfaceManager->moveSurfaceToWorkspace(surface, workspace->workspace());
83void WorkspaceManager::moveWorkspaceContentToWorkspace(Workspace *to, Workspace *from)
85 auto surfaceManager = WindowManagerObjects::instance()->surfaceManager();
87 surfaceManager->moveWorkspaceContentToWorkspace(to->workspace(), from->workspace());
91Workspace *WorkspaceManager::activeWorkspace() const
93 return m_activeWorkspace;
96void WorkspaceManager::setActiveWorkspace(Workspace *workspace)
98 if (workspace != m_activeWorkspace) {
99 m_activeWorkspace = workspace;
100 Q_EMIT activeWorkspaceChanged(workspace);
104void WorkspaceManager::setActiveWorkspace2(Workspace *workspace)
106 if (!workspace) return;
107 workspace->activate();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list