~alan-griffiths/mir/migrate-tests-to-miral

« back to all changes in this revision

Viewing changes to include/miral/miral/workspace_policy.h

  • Committer: Christopher James Halse Rogers
  • Date: 2017-09-07 05:58:13 UTC
  • mfrom: (4242 development-branch)
  • mto: (4243.1.1 mir3)
  • mto: This revision was merged to the branch mainline in revision 4244.
  • Revision ID: christopher.halse.rogers@canonical.com-20170907055813-4qsg25nirybc8jj3
Merge trunk, resolving conflict

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2017 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 2 or 3 as
 
6
 * published by the Free Software Foundation.
 
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
 * Authored by: Alan Griffiths <alan@octopull.co.uk>
 
17
 */
 
18
 
 
19
#ifndef MIRAL_WORKSPACE_POLICY_H
 
20
#define MIRAL_WORKSPACE_POLICY_H
 
21
 
 
22
#include "miral/version.h"
 
23
 
 
24
#include <memory>
 
25
#include <vector>
 
26
 
 
27
namespace miral
 
28
{
 
29
class Window;
 
30
 
 
31
/**
 
32
 * Workspace is intentionally opaque in the miral API. Its only purpose is to
 
33
 * provide a shared_ptr which is used as an identifier.
 
34
 */
 
35
class Workspace;
 
36
 
 
37
/**
 
38
 *  Advise changes to workspaces.
 
39
 *
 
40
 *  \note This interface is intended to be implemented by a WindowManagementPolicy
 
41
 *  implementation, we can't add these functions directly to that interface without
 
42
 *  breaking ABI (the vtab could be incompatible).
 
43
 *  When initializing the window manager this interface will be detected by
 
44
 *  dynamic_cast and registered accordingly.
 
45
 */
 
46
class WorkspacePolicy
 
47
{
 
48
public:
 
49
/** @name notification of WM events that the policy may need to track.
 
50
 * These calls happen "under lock" and are wrapped by the usual
 
51
 * WindowManagementPolicy::advise_begin(), advise_end() calls.
 
52
 * They should not call WindowManagerTools::invoke_under_lock()
 
53
 *  @{ */
 
54
 
 
55
    /** Notification that windows are being added to a workspace.
 
56
     *  These windows are ordered with parents before children,
 
57
     *  and form a single tree rooted at the first element.
 
58
     *
 
59
     * @param workspace   the workspace
 
60
     * @param windows   the windows
 
61
     */
 
62
    virtual void advise_adding_to_workspace(
 
63
        std::shared_ptr<Workspace> const& workspace,
 
64
        std::vector<Window> const& windows);
 
65
 
 
66
    /** Notification that windows are being removed from a workspace.
 
67
     *  These windows are ordered with parents before children,
 
68
     *  and form a single tree rooted at the first element.
 
69
     *
 
70
     * @param workspace   the workspace
 
71
     * @param windows   the windows
 
72
     */
 
73
    virtual void advise_removing_from_workspace(
 
74
        std::shared_ptr<Workspace> const& workspace,
 
75
        std::vector<Window> const& windows);
 
76
 
 
77
/** @} */
 
78
 
 
79
    virtual ~WorkspacePolicy() = default;
 
80
    WorkspacePolicy() = default;
 
81
    WorkspacePolicy(WorkspacePolicy const&) = delete;
 
82
    WorkspacePolicy& operator=(WorkspacePolicy const&) = delete;
 
83
};
 
84
#if MIRAL_VERSION >= MIR_VERSION_NUMBER(2, 0, 0)
 
85
#error "We've presumably broken ABI - please roll this interface into WindowManagementPolicy"
 
86
#endif
 
87
}
 
88
#endif //MIRAL_WORKSPACE_POLICY_H