Mir
window_management_policy.h
Go to the documentation of this file.
1/*
2 * Copyright © 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
17#ifndef MIRAL_WINDOW_MANAGEMENT_POLICY_H
18#define MIRAL_WINDOW_MANAGEMENT_POLICY_H
19
20#include <mir/geometry/displacement.h>
21#include <mir/geometry/rectangles.h>
22#include <mir_toolkit/common.h>
23
24struct MirKeyboardEvent;
25struct MirTouchEvent;
26struct MirPointerEvent;
27struct MirInputEvent;
28
29#include <memory>
30
31namespace miral
32{
33class Window;
35struct ApplicationInfo;
36class Output;
37class Zone;
38struct WindowInfo;
39
40/**
41 * Workspace is intentionally opaque in the miral API. Its only purpose is to
42 * provide a shared_ptr which is used as an identifier.
43 */
44class Workspace;
45
46using namespace mir::geometry;
47
48/// The interface through which the window management policy is determined.
50{
51public:
52 /// before any related calls begin
53 virtual void advise_begin();
54
55 /// after any related calls end
56 virtual void advise_end();
57
58 /** Customize initial window placement
59 *
60 * @param app_info the application requesting a new window
61 * @param requested_specification the requested specification (updated with default placement)
62 * @return the customized specification
63 */
64 virtual auto place_new_window(
65 ApplicationInfo const& app_info,
66 WindowSpecification const& requested_specification) -> WindowSpecification = 0;
67
68/** @name handle events originating from the client
69 * The policy is expected to update the model as appropriate
70 * @{ */
71 /** notification that the first buffer has been posted
72 *
73 * @param window_info the window
74 */
75 virtual void handle_window_ready(WindowInfo& window_info) = 0;
76
77 /** request from client to modify the window specification.
78 * \note the request has already been validated against the type definition
79 *
80 * @param window_info the window
81 * @param modifications the requested changes
82 */
83 virtual void handle_modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0;
84
85 /** request from client to raise the window
86 * \note the request has already been validated against the requesting event
87 *
88 * @param window_info the window
89 */
90 virtual void handle_raise_window(WindowInfo& window_info) = 0;
91
92 /** Confirm (and optionally adjust) the placement of a window on the display.
93 * Called when (re)placing fullscreen, maximized, horizontally maximised and
94 * vertically maximized windows to allow adjustment for decorations.
95 *
96 * @param window_info the window
97 * @param new_state the new state
98 * @param new_placement the suggested placement
99 *
100 * @return the confirmed placement of the window
101 */
103 WindowInfo const& window_info,
104 MirWindowState new_state,
105 Rectangle const& new_placement) -> Rectangle = 0;
106/** @} */
107
108/** @name handle events originating from user
109 * The policy is expected to interpret (and optionally consume) the event
110 * @{ */
111 /** keyboard event handler
112 *
113 * @param event the event
114 * @return whether the policy has consumed the event
115 */
116 virtual bool handle_keyboard_event(MirKeyboardEvent const* event) = 0;
117
118 /** touch event handler
119 *
120 * @param event the event
121 * @return whether the policy has consumed the event
122 */
123 virtual bool handle_touch_event(MirTouchEvent const* event) = 0;
124
125 /** pointer event handler
126 *
127 * @param event the event
128 * @return whether the policy has consumed the event
129 */
130 virtual bool handle_pointer_event(MirPointerEvent const* event) = 0;
131/** @} */
132
133/** @name notification of WM events that the policy may need to track.
134 * \note if the policy updates a Window object directly (as opposed to using tools)
135 * no notification is generated.
136 * @{ */
137 /** Notification that a new application has connected
138 *
139 * @param application the application
140 */
141 virtual void advise_new_app(ApplicationInfo& application);
142
143 /** Notification that an application has disconnected
144 *
145 * @param application the application
146 */
147 virtual void advise_delete_app(ApplicationInfo const& application);
148
149 /** Notification that a window has been created
150 *
151 * @param window_info the window
152 */
153 virtual void advise_new_window(WindowInfo const& window_info);
154
155 /** Notification that a window has lost focus
156 *
157 * @param window_info the window
158 */
159 virtual void advise_focus_lost(WindowInfo const& window_info);
160
161 /** Notification that a window has gained focus
162 *
163 * @param window_info the window
164 */
165 virtual void advise_focus_gained(WindowInfo const& window_info);
166
167 /** Notification that a window is about to change state
168 *
169 * @param window_info the window
170 * @param state the new state
171 */
172 virtual void advise_state_change(WindowInfo const& window_info, MirWindowState state);
173
174 /** Notification that a window is about to move
175 *
176 * @param window_info the window
177 * @param top_left the new position
178 */
179 virtual void advise_move_to(WindowInfo const& window_info, Point top_left);
180
181 /** Notification that a window is about to resize
182 *
183 * @param window_info the window
184 * @param new_size the new size
185 */
186 virtual void advise_resize(WindowInfo const& window_info, Size const& new_size);
187
188 /** Notification that a window is about to be destroyed
189 *
190 * @param window_info the window
191 */
192 virtual void advise_delete_window(WindowInfo const& window_info);
193
194 /** Notification that windows are being raised to the top.
195 * These windows are ordered with parents before children,
196 * and form a single tree rooted at the first element.
197 *
198 * @param windows the windows
199 * \note The relative Z-order of these windows will be maintained, they will be raised en bloc.
200 */
201 virtual void advise_raise(std::vector<Window> const& windows);
202/** @} */
203
204/** @name notification of WM events that the policy may need to track.
205 * @{ */
206
207 /** Notification that windows are being added to a workspace.
208 * These windows are ordered with parents before children,
209 * and form a single tree rooted at the first element.
210 *
211 * @param workspace the workspace
212 * @param windows the windows
213 */
215 std::shared_ptr<Workspace> const& workspace,
216 std::vector<Window> const& windows);
217
218 /** Notification that windows are being removed from a workspace.
219 * These windows are ordered with parents before children,
220 * and form a single tree rooted at the first element.
221 *
222 * @param workspace the workspace
223 * @param windows the windows
224 */
226 std::shared_ptr<Workspace> const& workspace,
227 std::vector<Window> const& windows);
228/** @} */
229
230/** @name handle requests originating from the client
231 * The policy is expected to update the model as appropriate
232 * @{ */
233 /** request from client to initiate drag and drop
234 * \note the request has already been validated against the requesting event
235 *
236 * @param window_info the window
237 */
238 virtual void handle_request_drag_and_drop(WindowInfo& window_info) = 0;
239
240 /** request from client to initiate move
241 * \note the request has already been validated against the requesting event
242 *
243 * @param window_info the window
244 * @param input_event the requesting event
245 */
246 virtual void handle_request_move(WindowInfo& window_info, MirInputEvent const* input_event) = 0;
247
248 /** request from client to initiate resize
249 * \note the request has already been validated against the requesting event
250 *
251 * @param window_info the window
252 * @param input_event the requesting event
253 * @param edge the edge(s) being dragged
254 */
255 virtual void handle_request_resize(WindowInfo& window_info, MirInputEvent const* input_event, MirResizeEdge edge) = 0;
256/** @} */
257
258/** @name notification of changes to the (connected, active) outputs.
259 * @{ */
260 virtual void advise_output_create(Output const& output);
261 virtual void advise_output_update(Output const& updated, Output const& original);
262 virtual void advise_output_delete(Output const& output);
263
264/** @} */
265
266 /** Confirm (and optionally adjust) the motion of a child window when the parent is moved.
267 *
268 * @param window_info the window
269 * @param movement the movement of the parent
270 *
271 * @return the confirmed placement of the window
272 */
273 virtual auto confirm_inherited_move(WindowInfo const& window_info, Displacement movement) -> Rectangle = 0;
274
275 /** @name notification of changes to the current application zones
276 * An application zone is the area a maximized application will fill.
277 * There is often (but not necessarily) one zone per output.
278 * The areas normal applications windows should avoid (such as the areas covered by panels)
279 * will not be part of an application zone
280 * @{ */
281 virtual void advise_application_zone_create(Zone const& application_zone);
282 virtual void advise_application_zone_update(Zone const& updated, Zone const& original);
283 virtual void advise_application_zone_delete(Zone const& application_zone);
284 /** @} */
285
286 virtual ~WindowManagementPolicy() = default;
290};
291
293}
294
295#endif //MIRAL_WINDOW_MANAGEMENT_POLICY_H
Definition: output.h:35
Handle class to manage a Mir surface. It may be null (e.g. default initialized)
Definition: window.h:36
The interface through which the window management policy is determined.
Definition: window_management_policy.h:50
virtual void advise_delete_window(WindowInfo const &window_info)
Notification that a window is about to be destroyed.
virtual void advise_move_to(WindowInfo const &window_info, Point top_left)
Notification that a window is about to move.
virtual void advise_removing_from_workspace(std::shared_ptr< Workspace > const &workspace, std::vector< Window > const &windows)
Notification that windows are being removed from a workspace.
virtual void handle_raise_window(WindowInfo &window_info)=0
request from client to raise the window
virtual void handle_request_resize(WindowInfo &window_info, MirInputEvent const *input_event, MirResizeEdge edge)=0
request from client to initiate resize
virtual void advise_application_zone_update(Zone const &updated, Zone const &original)
virtual auto confirm_placement_on_display(WindowInfo const &window_info, MirWindowState new_state, Rectangle const &new_placement) -> Rectangle=0
Confirm (and optionally adjust) the placement of a window on the display.
virtual void handle_request_drag_and_drop(WindowInfo &window_info)=0
request from client to initiate drag and drop
virtual void advise_focus_lost(WindowInfo const &window_info)
Notification that a window has lost focus.
virtual ~WindowManagementPolicy()=default
virtual void handle_window_ready(WindowInfo &window_info)=0
notification that the first buffer has been posted
virtual void advise_begin()
before any related calls begin
virtual void handle_request_move(WindowInfo &window_info, MirInputEvent const *input_event)=0
request from client to initiate move
virtual void advise_output_create(Output const &output)
virtual auto confirm_inherited_move(WindowInfo const &window_info, Displacement movement) -> Rectangle=0
Confirm (and optionally adjust) the motion of a child window when the parent is moved.
virtual auto place_new_window(ApplicationInfo const &app_info, WindowSpecification const &requested_specification) -> WindowSpecification=0
Customize initial window placement.
virtual void advise_output_update(Output const &updated, Output const &original)
virtual void advise_focus_gained(WindowInfo const &window_info)
Notification that a window has gained focus.
virtual void advise_new_window(WindowInfo const &window_info)
Notification that a window has been created.
virtual void advise_delete_app(ApplicationInfo const &application)
Notification that an application has disconnected.
virtual void advise_output_delete(Output const &output)
virtual void advise_application_zone_delete(Zone const &application_zone)
virtual bool handle_pointer_event(MirPointerEvent const *event)=0
pointer event handler
WindowManagementPolicy(WindowManagementPolicy const &)=delete
virtual void advise_resize(WindowInfo const &window_info, Size const &new_size)
Notification that a window is about to resize.
virtual void advise_state_change(WindowInfo const &window_info, MirWindowState state)
Notification that a window is about to change state.
virtual void advise_application_zone_create(Zone const &application_zone)
virtual void advise_raise(std::vector< Window > const &windows)
Notification that windows are being raised to the top.
virtual bool handle_touch_event(MirTouchEvent const *event)=0
touch event handler
virtual void advise_adding_to_workspace(std::shared_ptr< Workspace > const &workspace, std::vector< Window > const &windows)
Notification that windows are being added to a workspace.
virtual void handle_modify_window(WindowInfo &window_info, WindowSpecification const &modifications)=0
request from client to modify the window specification.
virtual void advise_end()
after any related calls end
WindowManagementPolicy & operator=(WindowManagementPolicy const &)=delete
virtual void advise_new_app(ApplicationInfo &application)
Notification that a new application has connected.
virtual bool handle_keyboard_event(MirKeyboardEvent const *event)=0
keyboard event handler
Window management functions for querying and updating MirAL's model.
Definition: window_manager_tools.h:58
Definition: window_specification.h:42
A rectangular area of the display. Not tied to a specific output.
Definition: zone.h:34
Basic geometry types. Types for dimensions, displacements, etc. and the operations that they support.
Definition: size.h:27
Definition: runner.h:27
Mir Abstraction Layer.
Definition: runner.h:35
Definition: application_info.h:30
Definition: window_info.h:31

Copyright © 2012-2023 Canonical Ltd.
Generated on Tue 2 May 10:01:24 UTC 2023
This documentation is licensed under the GPL version 2 or 3.