~raof/mir/lots-of-unused-lambda-captures

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Alan Griffiths
  • Date: 2017-08-30 15:19:51 UTC
  • mfrom: (4232.2.18 mir2)
  • Revision ID: tarmac-20170830151951-jizxlto07otfslu1
Incorporate miral project into mir source tree - part 1.

Approved by mir-ci-bot, Gerry Boland, Brandon Schaefer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2016 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_WINDOW_MANAGEMENT_POLICY_H
 
20
#define MIRAL_WINDOW_MANAGEMENT_POLICY_H
 
21
 
 
22
#include <mir/geometry/displacement.h>
 
23
#include <mir/geometry/rectangles.h>
 
24
#include <mir_toolkit/event.h>
 
25
 
 
26
namespace miral
 
27
{
 
28
class Window;
 
29
class WindowSpecification;
 
30
struct ApplicationInfo;
 
31
struct WindowInfo;
 
32
 
 
33
using namespace mir::geometry;
 
34
 
 
35
/// The interface through which the window management policy is determined.
 
36
class WindowManagementPolicy
 
37
{
 
38
public:
 
39
    /// before any related calls begin
 
40
    virtual void advise_begin();
 
41
 
 
42
    /// after any related calls end
 
43
    virtual void advise_end();
 
44
 
 
45
    /** Customize initial window placement
 
46
     *
 
47
     * @param app_info                the application requesting a new window
 
48
     * @param requested_specification the requested specification (updated with default placement)
 
49
     * @return                        the customized specification
 
50
     */
 
51
    virtual auto place_new_window(
 
52
        ApplicationInfo const& app_info,
 
53
        WindowSpecification const& requested_specification) -> WindowSpecification = 0;
 
54
 
 
55
/** @name handle events originating from the client
 
56
 * The policy is expected to update the model as appropriate
 
57
 *  @{ */
 
58
    /** notification that the first buffer has been posted
 
59
     *
 
60
     * @param window_info   the window
 
61
     */
 
62
    virtual void handle_window_ready(WindowInfo& window_info) = 0;
 
63
 
 
64
    /** request from client to modify the window specification.
 
65
     * \note the request has already been validated against the type definition
 
66
     *
 
67
     * @param window_info   the window
 
68
     * @param modifications the requested changes
 
69
     */
 
70
    virtual void handle_modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0;
 
71
 
 
72
    /** request from client to raise the window
 
73
     * \note the request has already been validated against the requesting event
 
74
     *
 
75
     * @param window_info   the window
 
76
     */
 
77
    virtual void handle_raise_window(WindowInfo& window_info) = 0;
 
78
/** @} */
 
79
 
 
80
/** @name handle events originating from user
 
81
 * The policy is expected to interpret (and optionally consume) the event
 
82
 *  @{ */
 
83
    /** keyboard event handler
 
84
     *
 
85
     * @param event the event
 
86
     * @return      whether the policy has consumed the event
 
87
     */
 
88
    virtual bool handle_keyboard_event(MirKeyboardEvent const* event) = 0;
 
89
 
 
90
    /** touch event handler
 
91
     *
 
92
     * @param event the event
 
93
     * @return      whether the policy has consumed the event
 
94
     */
 
95
    virtual bool handle_touch_event(MirTouchEvent const* event) = 0;
 
96
 
 
97
    /** pointer event handler
 
98
     *
 
99
     * @param event the event
 
100
     * @return      whether the policy has consumed the event
 
101
     */
 
102
    virtual bool handle_pointer_event(MirPointerEvent const* event) = 0;
 
103
/** @} */
 
104
 
 
105
/** @name notification of WM events that the policy may need to track.
 
106
 * \note if the policy updates a Window object directly (as opposed to using tools)
 
107
 * no notification is generated.
 
108
 *  @{ */
 
109
    /** Notification that a new application has connected
 
110
     *
 
111
     * @param application the application
 
112
     */
 
113
    virtual void advise_new_app(ApplicationInfo& application);
 
114
 
 
115
    /** Notification that an application has disconnected
 
116
     *
 
117
     * @param application the application
 
118
     */
 
119
    virtual void advise_delete_app(ApplicationInfo const& application);
 
120
 
 
121
    /** Notification that a window has been created
 
122
     *
 
123
     * @param window_info   the window
 
124
     */
 
125
    virtual void advise_new_window(WindowInfo const& window_info);
 
126
 
 
127
    /** Notification that a window has lost focus
 
128
     *
 
129
     * @param window_info   the window
 
130
     */
 
131
    virtual void advise_focus_lost(WindowInfo const& window_info);
 
132
 
 
133
    /** Notification that a window has gained focus
 
134
     *
 
135
     * @param window_info   the window
 
136
     */
 
137
    virtual void advise_focus_gained(WindowInfo const& window_info);
 
138
 
 
139
    /** Notification that a window is about to change state
 
140
     *
 
141
     * @param window_info   the window
 
142
     * @param state         the new state
 
143
     */
 
144
    virtual void advise_state_change(WindowInfo const& window_info, MirWindowState state);
 
145
 
 
146
    /** Notification that a window is about to move
 
147
     *
 
148
     * @param window_info   the window
 
149
     * @param top_left      the new position
 
150
     */
 
151
    virtual void advise_move_to(WindowInfo const& window_info, Point top_left);
 
152
 
 
153
    /** Notification that a window is about to resize
 
154
     *
 
155
     * @param window_info   the window
 
156
     * @param new_size      the new size
 
157
     */
 
158
    virtual void advise_resize(WindowInfo const& window_info, Size const& new_size);
 
159
 
 
160
    /** Notification that a window is about to be destroyed
 
161
     *
 
162
     * @param window_info   the window
 
163
     */
 
164
    virtual void advise_delete_window(WindowInfo const& window_info);
 
165
 
 
166
    /** Notification that windows are being raised to the top.
 
167
     *  These windows are ordered with parents before children,
 
168
     *  and form a single tree rooted at the first element.
 
169
     *
 
170
     * @param windows   the windows
 
171
     * \note The relative Z-order of these windows will be maintained, they will be raised en bloc.
 
172
     */
 
173
    virtual void advise_raise(std::vector<Window> const& windows);
 
174
/** @} */
 
175
 
 
176
    /** Confirm (and optionally adjust) the motion of a child window when the parent is moved.
 
177
     *
 
178
     * @param window_info   the window
 
179
     * @param movement      the movement of the parent
 
180
     *
 
181
     * @return the confirmed placement of the window
 
182
     */
 
183
    virtual auto confirm_inherited_move(WindowInfo const& window_info, Displacement movement) -> Rectangle = 0;
 
184
 
 
185
    virtual ~WindowManagementPolicy() = default;
 
186
    WindowManagementPolicy() = default;
 
187
    WindowManagementPolicy(WindowManagementPolicy const&) = delete;
 
188
    WindowManagementPolicy& operator=(WindowManagementPolicy const&) = delete;
 
189
};
 
190
 
 
191
class WindowManagerTools;
 
192
}
 
193
 
 
194
#endif //MIRAL_WINDOW_MANAGEMENT_POLICY_H