1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
/*
* Copyright (C) 2017 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MOCKWINDOMANAGEMENTPOLICY_H
#define MOCKWINDOMANAGEMENTPOLICY_H
#include "wmpolicyinterface.h"
#include <QObject>
#include <QMultiMap>
#include <QVector>
#include <miral/window.h>
#include <memory>
#include <unordered_set>
namespace miral {
class Workspace {};
}
// A Fake window management policy for the mock.
class Q_DECL_EXPORT WindowManagementPolicy : public QObject,
public WMPolicyInterface
{
Q_OBJECT
public:
WindowManagementPolicy();
// for use in mocks
static WindowManagementPolicy *instance();
// From WMPolicyInterface
std::shared_ptr<miral::Workspace> createWorkspace() override;
void releaseWorkspace(const std::shared_ptr<miral::Workspace> &workspace) override;
void setActiveWorkspace(const std::shared_ptr<miral::Workspace> &workspace) override;
void addWindow(const miral::Window& window);
void removeWindow(const miral::Window& window);
void forEachWindowInWorkspace(std::shared_ptr<miral::Workspace> const &workspace,
std::function<void(miral::Window const&)> const &callback);
void moveWindowToWorkspace(const miral::Window &window, const std::shared_ptr<miral::Workspace> &workspace);
void moveWorkspaceContentToWorkspace(const std::shared_ptr<miral::Workspace> &to,
const std::shared_ptr<miral::Workspace> &from);
Q_SIGNALS:
void windowAdded(const miral::Window& window);
void windowRemoved(const miral::Window& window);
void windowsAddedToWorkspace(const std::shared_ptr<miral::Workspace> &workspace, const std::vector<miral::Window> &windows);
void windowsAboutToBeRemovedFromWorkspace(const std::shared_ptr<miral::Workspace> &workspace, const std::vector<miral::Window> &windows);
private:
std::weak_ptr<miral::Workspace> m_activeWorkspace;
std::shared_ptr<miral::Workspace> m_dummyWorkspace;
std::unordered_set<std::shared_ptr<miral::Workspace>> m_workspaces;
typedef QMultiMap<std::shared_ptr<miral::Workspace>, miral::Window> WorkspaceWindows;
WorkspaceWindows m_windows;
};
#endif // LOMIRI_WINDOWMANAGEMENTPOLICY_H
|