Merge lp:~alan-griffiths/miral/add-indirection-to-stabilize-WindowManagerTools-ABI into lp:miral
- add-indirection-to-stabilize-WindowManagerTools-ABI
- Merge into trunk
Proposed by
Alan Griffiths
Status: | Merged |
---|---|
Approved by: | Gerry Boland |
Approved revision: | 245 |
Merged at revision: | 241 |
Proposed branch: | lp:~alan-griffiths/miral/add-indirection-to-stabilize-WindowManagerTools-ABI |
Merge into: | lp:miral |
Diff against target: |
1149 lines (+314/-137) 20 files modified
include/miral/canonical_window_manager.h (+3/-2) include/miral/set_window_managment_policy.h (+3/-3) include/miral/window_management_options.h (+2/-2) include/miral/window_manager_tools.h (+29/-26) miral-kiosk/kiosk_window_manager.cpp (+8/-8) miral-kiosk/kiosk_window_manager.h (+1/-1) miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp (+16/-16) miral-qt/src/platforms/mirserver/windowmanagementpolicy.h (+2/-2) miral-shell/tiling_window_manager.cpp (+31/-31) miral-shell/tiling_window_manager.h (+3/-2) miral-shell/titlebar_provider.cpp (+2/-2) miral-shell/titlebar_provider.h (+2/-2) miral-shell/titlebar_window_manager.cpp (+28/-28) miral-shell/titlebar_window_manager.h (+1/-1) miral/CMakeLists.txt (+2/-2) miral/basic_window_manager.cpp (+2/-1) miral/basic_window_manager.h (+3/-3) miral/canonical_window_manager.cpp (+5/-5) miral/window_manager_tools.cpp (+87/-0) miral/window_manager_tools_implementation.h (+84/-0) |
To merge this branch: | bzr merge lp:~alan-griffiths/miral/add-indirection-to-stabilize-WindowManagerTools-ABI |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Approve | ||
Review via email: mp+301299@code.launchpad.net |
Commit message
Rework WindowManagerTools to a form better suited to ABI stability.
Description of the change
Rework WindowManagerTools to a form better suited to ABI stability.
Not accessing a vtable from client code means that we don't have to keep it stable.
Also, BasicWindowManager no longer inherits from a public MirAL interface, which is one step towards being able to backport it into Mir proper.
To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote : | # |
- 243. By Alan Griffiths
-
merge lp:miral
- 244. By Alan Griffiths
-
Tidy CMakeLists
- 245. By Alan Griffiths
-
Fix miral-qt
Revision history for this message
Gerry Boland (gerboland) wrote : | # |
Looks good, thanks!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'include/miral/canonical_window_manager.h' |
2 | --- include/miral/canonical_window_manager.h 2016-07-22 16:46:38 +0000 |
3 | +++ include/miral/canonical_window_manager.h 2016-07-28 08:41:50 +0000 |
4 | @@ -20,6 +20,7 @@ |
5 | #define MIRAL_CANONICAL_WINDOW_MANAGER_H_ |
6 | |
7 | #include <miral/window_management_policy.h> |
8 | +#include <miral/window_manager_tools.h> |
9 | |
10 | namespace miral |
11 | { |
12 | @@ -27,7 +28,7 @@ |
13 | { |
14 | public: |
15 | |
16 | - explicit CanonicalWindowManagerPolicy(WindowManagerTools* const tools); |
17 | + explicit CanonicalWindowManagerPolicy(WindowManagerTools const& tools); |
18 | |
19 | auto place_new_surface( |
20 | ApplicationInfo const& app_info, |
21 | @@ -41,7 +42,7 @@ |
22 | void advise_focus_gained(WindowInfo const& info) override; |
23 | |
24 | protected: |
25 | - miral::WindowManagerTools* const tools; |
26 | + WindowManagerTools tools; |
27 | }; |
28 | } |
29 | |
30 | |
31 | === modified file 'include/miral/set_window_managment_policy.h' |
32 | --- include/miral/set_window_managment_policy.h 2016-06-06 18:44:28 +0000 |
33 | +++ include/miral/set_window_managment_policy.h 2016-07-28 08:41:50 +0000 |
34 | @@ -34,19 +34,19 @@ |
35 | class SetWindowManagmentPolicy |
36 | { |
37 | public: |
38 | - SetWindowManagmentPolicy(std::function<std::unique_ptr<WindowManagementPolicy>(WindowManagerTools* tools)> const& builder); |
39 | + SetWindowManagmentPolicy(std::function<std::unique_ptr<WindowManagementPolicy>(WindowManagerTools const& tools)> const& builder); |
40 | ~SetWindowManagmentPolicy(); |
41 | |
42 | void operator()(mir::Server& server) const; |
43 | |
44 | private: |
45 | - std::function<std::unique_ptr<WindowManagementPolicy>(WindowManagerTools* tools)> builder; |
46 | + std::function<std::unique_ptr<WindowManagementPolicy>(WindowManagerTools const& tools)> builder; |
47 | }; |
48 | |
49 | template<typename Policy, typename ...Args> |
50 | auto set_window_managment_policy(Args& ... args) -> SetWindowManagmentPolicy |
51 | { |
52 | - return SetWindowManagmentPolicy{[&args...](WindowManagerTools* tools) -> std::unique_ptr<WindowManagementPolicy> |
53 | + return SetWindowManagmentPolicy{[&args...](WindowManagerTools const& tools) -> std::unique_ptr<WindowManagementPolicy> |
54 | { return std::make_unique<Policy>(tools, args...); }}; |
55 | } |
56 | } |
57 | |
58 | === modified file 'include/miral/window_management_options.h' |
59 | --- include/miral/window_management_options.h 2016-05-17 13:56:40 +0000 |
60 | +++ include/miral/window_management_options.h 2016-07-28 08:41:50 +0000 |
61 | @@ -35,7 +35,7 @@ |
62 | class WindowManagementPolicy; |
63 | |
64 | using WindowManagementPolicyBuilder = |
65 | - std::function<std::unique_ptr<miral::WindowManagementPolicy>(miral::WindowManagerTools* tools)>; |
66 | + std::function<std::unique_ptr<miral::WindowManagementPolicy>(WindowManagerTools const& tools)>; |
67 | |
68 | struct WindowManagerOption |
69 | { |
70 | @@ -46,7 +46,7 @@ |
71 | template<typename Policy, typename ...Args> |
72 | inline auto add_window_manager_policy(std::string const& name, Args&... args) -> WindowManagerOption |
73 | { |
74 | - return {name, [&args...](miral::WindowManagerTools* tools) -> std::unique_ptr<miral::WindowManagementPolicy> |
75 | + return {name, [&args...](WindowManagerTools const& tools) -> std::unique_ptr<miral::WindowManagementPolicy> |
76 | { return std::make_unique<Policy>(tools, args...); }}; |
77 | } |
78 | |
79 | |
80 | === modified file 'include/miral/window_manager_tools.h' |
81 | --- include/miral/window_manager_tools.h 2016-06-29 13:17:33 +0000 |
82 | +++ include/miral/window_manager_tools.h 2016-07-28 08:41:50 +0000 |
83 | @@ -32,7 +32,6 @@ |
84 | namespace scene { class Surface; } |
85 | } |
86 | |
87 | - |
88 | namespace miral |
89 | { |
90 | class Window; |
91 | @@ -40,34 +39,40 @@ |
92 | struct ApplicationInfo; |
93 | class WindowSpecification; |
94 | |
95 | -/// The interface through which the policy instructs the controller. |
96 | +class WindowManagerToolsImplementation; |
97 | + |
98 | class WindowManagerTools |
99 | { |
100 | public: |
101 | + explicit WindowManagerTools(WindowManagerToolsImplementation* tools); |
102 | + WindowManagerTools(WindowManagerTools const&); |
103 | + WindowManagerTools& operator=(WindowManagerTools const&); |
104 | + ~WindowManagerTools(); |
105 | + |
106 | /** @name Update Model |
107 | * These functions assume that the BasicWindowManager data structures can be accessed freely. |
108 | * I.e. they should only be used by a thread that has called the WindowManagementPolicy methods |
109 | * (where any necessary locks are held) or via a invoke_under_lock() callback. |
110 | * @{ */ |
111 | - virtual auto count_applications() const -> unsigned int = 0; |
112 | - virtual void for_each_application(std::function<void(ApplicationInfo& info)> const& functor) = 0; |
113 | - virtual auto find_application(std::function<bool(ApplicationInfo const& info)> const& predicate) |
114 | - -> Application = 0; |
115 | - virtual auto info_for(std::weak_ptr<mir::scene::Session> const& session) const -> ApplicationInfo& = 0; |
116 | - virtual auto info_for(std::weak_ptr<mir::scene::Surface> const& surface) const -> WindowInfo& = 0; |
117 | - virtual auto info_for(Window const& window) const -> WindowInfo& = 0; |
118 | - virtual void kill_active_application(int sig) = 0; |
119 | - virtual auto active_window() const -> Window = 0; |
120 | - virtual auto select_active_window(Window const& hint) -> Window = 0; |
121 | - virtual void drag_active_window(mir::geometry::Displacement movement) = 0; |
122 | - virtual void focus_next_application() = 0; |
123 | - virtual void focus_next_within_application() = 0; |
124 | - virtual auto window_at(mir::geometry::Point cursor) const -> Window = 0; |
125 | - virtual auto active_display() -> mir::geometry::Rectangle const = 0; |
126 | - virtual void raise_tree(Window const& root) = 0; |
127 | - virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0; |
128 | - virtual void place_and_size(WindowInfo& window_info, Point const& new_pos, Size const& new_size) = 0; |
129 | - virtual void set_state(WindowInfo& window_info, MirSurfaceState value) = 0; |
130 | + auto count_applications() const -> unsigned int; |
131 | + void for_each_application(std::function<void(ApplicationInfo& info)> const& functor); |
132 | + auto find_application(std::function<bool(ApplicationInfo const& info)> const& predicate) |
133 | + -> Application; |
134 | + auto info_for(std::weak_ptr<mir::scene::Session> const& session) const -> ApplicationInfo&; |
135 | + auto info_for(std::weak_ptr<mir::scene::Surface> const& surface) const -> WindowInfo&; |
136 | + auto info_for(Window const& window) const -> WindowInfo&; |
137 | + void kill_active_application(int sig); |
138 | + auto active_window() const -> Window; |
139 | + auto select_active_window(Window const& hint) -> Window; |
140 | + void drag_active_window(mir::geometry::Displacement movement); |
141 | + void focus_next_application(); |
142 | + void focus_next_within_application(); |
143 | + auto window_at(mir::geometry::Point cursor) const -> Window; |
144 | + auto active_display() -> mir::geometry::Rectangle const; |
145 | + void raise_tree(Window const& root); |
146 | + void modify_window(WindowInfo& window_info, WindowSpecification const& modifications); |
147 | + void place_and_size(WindowInfo& window_info, Point const& new_pos, Size const& new_size); |
148 | + void set_state(WindowInfo& window_info, MirSurfaceState value); |
149 | /** @} */ |
150 | |
151 | /** @name Multi-thread support |
152 | @@ -76,13 +81,11 @@ |
153 | * This should NOT be used by a thread that has called the WindowManagementPolicy methods (and |
154 | * already holds the lock). |
155 | * @{ */ |
156 | - virtual void invoke_under_lock(std::function<void()> const& callback) = 0; |
157 | + void invoke_under_lock(std::function<void()> const& callback); |
158 | /** @} */ |
159 | |
160 | - virtual ~WindowManagerTools() = default; |
161 | - WindowManagerTools() = default; |
162 | - WindowManagerTools(WindowManagerTools const&) = delete; |
163 | - WindowManagerTools& operator=(WindowManagerTools const&) = delete; |
164 | +private: |
165 | + WindowManagerToolsImplementation* tools; |
166 | }; |
167 | } |
168 | |
169 | |
170 | === modified file 'miral-kiosk/kiosk_window_manager.cpp' |
171 | --- miral-kiosk/kiosk_window_manager.cpp 2016-07-25 15:42:29 +0000 |
172 | +++ miral-kiosk/kiosk_window_manager.cpp 2016-07-28 08:41:50 +0000 |
173 | @@ -27,7 +27,7 @@ |
174 | namespace ms = mir::scene; |
175 | using namespace miral; |
176 | |
177 | -KioskWindowManagerPolicy::KioskWindowManagerPolicy(WindowManagerTools* const tools, SwSplash const& splash) : |
178 | +KioskWindowManagerPolicy::KioskWindowManagerPolicy(WindowManagerTools const& tools, SwSplash const& splash) : |
179 | CanonicalWindowManagerPolicy{tools}, |
180 | splash{splash} |
181 | { |
182 | @@ -43,7 +43,7 @@ |
183 | modifiers == mir_input_event_modifier_alt && |
184 | scan_code == KEY_TAB) |
185 | { |
186 | - tools->focus_next_application(); |
187 | + tools.focus_next_application(); |
188 | |
189 | return true; |
190 | } |
191 | @@ -51,7 +51,7 @@ |
192 | modifiers == mir_input_event_modifier_alt && |
193 | scan_code == KEY_GRAVE) |
194 | { |
195 | - tools->focus_next_within_application(); |
196 | + tools.focus_next_within_application(); |
197 | |
198 | return true; |
199 | } |
200 | @@ -60,7 +60,7 @@ |
201 | switch (modifiers & modifier_mask) |
202 | { |
203 | case mir_input_event_modifier_alt: |
204 | - if (auto const window = tools->active_window()) |
205 | + if (auto const window = tools.active_window()) |
206 | window.request_client_surface_close(); |
207 | |
208 | return true; |
209 | @@ -88,7 +88,7 @@ |
210 | |
211 | Point const cursor{total_x/count, total_y/count}; |
212 | |
213 | - tools->select_active_window(tools->window_at(cursor)); |
214 | + tools.select_active_window(tools.window_at(cursor)); |
215 | |
216 | return false; |
217 | } |
218 | @@ -103,7 +103,7 @@ |
219 | |
220 | if (action == mir_pointer_action_button_down) |
221 | { |
222 | - tools->select_active_window(tools->window_at(cursor)); |
223 | + tools.select_active_window(tools.window_at(cursor)); |
224 | } |
225 | |
226 | return false; |
227 | @@ -115,9 +115,9 @@ |
228 | |
229 | if (auto session = splash.session().lock()) |
230 | { |
231 | - auto const& app_info = tools->info_for(session); |
232 | + auto const& app_info = tools.info_for(session); |
233 | |
234 | for (auto const& s : app_info.windows()) |
235 | - tools->raise_tree(s); |
236 | + tools.raise_tree(s); |
237 | } |
238 | } |
239 | |
240 | === modified file 'miral-kiosk/kiosk_window_manager.h' |
241 | --- miral-kiosk/kiosk_window_manager.h 2016-07-25 15:42:29 +0000 |
242 | +++ miral-kiosk/kiosk_window_manager.h 2016-07-28 08:41:50 +0000 |
243 | @@ -28,7 +28,7 @@ |
244 | class KioskWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy |
245 | { |
246 | public: |
247 | - KioskWindowManagerPolicy(miral::WindowManagerTools* const tools, SwSplash const&); |
248 | + KioskWindowManagerPolicy(miral::WindowManagerTools const& tools, SwSplash const&); |
249 | |
250 | void advise_focus_gained(miral::WindowInfo const& info) override; |
251 | |
252 | |
253 | === modified file 'miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp' |
254 | --- miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-07-27 12:04:05 +0000 |
255 | +++ miral-qt/src/platforms/mirserver/windowmanagementpolicy.cpp 2016-07-28 08:41:50 +0000 |
256 | @@ -24,7 +24,7 @@ |
257 | #include "mir/scene/surface.h" |
258 | #include <QDebug> |
259 | |
260 | -WindowManagementPolicy::WindowManagementPolicy(miral::WindowManagerTools * const tools, |
261 | +WindowManagementPolicy::WindowManagementPolicy(const miral::WindowManagerTools &tools, |
262 | qtmir::WindowModel &windowModel, |
263 | const QSharedPointer<ScreensModel> screensModel) |
264 | : CanonicalWindowManagerPolicy(tools) |
265 | @@ -47,7 +47,7 @@ |
266 | void WindowManagementPolicy::handle_window_ready(miral::WindowInfo &windowInfo) |
267 | { |
268 | qDebug("Window ready"); |
269 | - m_tools->select_active_window(windowInfo.window()); |
270 | + m_tools.select_active_window(windowInfo.window()); |
271 | } |
272 | |
273 | void WindowManagementPolicy::handle_modify_window( |
274 | @@ -55,13 +55,13 @@ |
275 | const miral::WindowSpecification &modifications) |
276 | { |
277 | qDebug("Window Modified!"); |
278 | - m_tools->modify_window(windowInfo, modifications); |
279 | + m_tools.modify_window(windowInfo, modifications); |
280 | } |
281 | |
282 | void WindowManagementPolicy::handle_raise_window(miral::WindowInfo &windowInfo) |
283 | { |
284 | qDebug("Window Raise"); |
285 | - m_tools->select_active_window(windowInfo.window()); |
286 | + m_tools.select_active_window(windowInfo.window()); |
287 | } |
288 | |
289 | /* Handle input events - here just inject them into Qt event loop for later processing */ |
290 | @@ -155,9 +155,9 @@ |
291 | void WindowManagementPolicy::deliver_keyboard_event(const MirKeyboardEvent *event, |
292 | const std::shared_ptr<mir::scene::Surface> &surface) |
293 | { |
294 | - m_tools->invoke_under_lock([&surface, this]() { |
295 | - auto windowInfo = m_tools->info_for(surface); |
296 | - m_tools->select_active_window(windowInfo.window()); |
297 | + m_tools.invoke_under_lock([&surface, this]() { |
298 | + auto windowInfo = m_tools.info_for(surface); |
299 | + m_tools.select_active_window(windowInfo.window()); |
300 | }); |
301 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty |
302 | surface->consume(e); |
303 | @@ -166,9 +166,9 @@ |
304 | void WindowManagementPolicy::deliver_touch_event(const MirTouchEvent *event, |
305 | const std::shared_ptr<mir::scene::Surface> &surface) |
306 | { |
307 | - m_tools->invoke_under_lock([&surface, this]() { |
308 | - auto windowInfo = m_tools->info_for(surface); |
309 | - m_tools->select_active_window(windowInfo.window()); |
310 | + m_tools.invoke_under_lock([&surface, this]() { |
311 | + auto windowInfo = m_tools.info_for(surface); |
312 | + m_tools.select_active_window(windowInfo.window()); |
313 | }); |
314 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty |
315 | surface->consume(e); |
316 | @@ -177,9 +177,9 @@ |
317 | void WindowManagementPolicy::deliver_pointer_event(const MirPointerEvent *event, |
318 | const std::shared_ptr<mir::scene::Surface> &surface) |
319 | { |
320 | - m_tools->invoke_under_lock([&surface, this]() { |
321 | - auto windowInfo = m_tools->info_for(surface); |
322 | - m_tools->select_active_window(windowInfo.window()); |
323 | + m_tools.invoke_under_lock([&surface, this]() { |
324 | + auto windowInfo = m_tools.info_for(surface); |
325 | + m_tools.select_active_window(windowInfo.window()); |
326 | }); |
327 | auto e = reinterpret_cast<MirEvent const*>(event); // naughty |
328 | surface->consume(e); |
329 | @@ -188,15 +188,15 @@ |
330 | /* Methods to allow Shell to request changes to the window stack */ |
331 | void WindowManagementPolicy::focus(const miral::Window window) |
332 | { |
333 | - m_tools->select_active_window(window); |
334 | + m_tools.select_active_window(window); |
335 | } |
336 | |
337 | void WindowManagementPolicy::resize(const miral::Window window, const Size &size) |
338 | { |
339 | - m_tools->place_and_size(m_tools->info_for(window), window.top_left(), size); |
340 | + m_tools.place_and_size(m_tools.info_for(window), window.top_left(), size); |
341 | } |
342 | |
343 | void WindowManagementPolicy::move(const miral::Window window, const Point &top_left) |
344 | { |
345 | - m_tools->place_and_size(m_tools->info_for(window), top_left, window.size() ); |
346 | + m_tools.place_and_size(m_tools.info_for(window), top_left, window.size() ); |
347 | } |
348 | |
349 | === modified file 'miral-qt/src/platforms/mirserver/windowmanagementpolicy.h' |
350 | --- miral-qt/src/platforms/mirserver/windowmanagementpolicy.h 2016-07-27 12:04:05 +0000 |
351 | +++ miral-qt/src/platforms/mirserver/windowmanagementpolicy.h 2016-07-28 08:41:50 +0000 |
352 | @@ -33,7 +33,7 @@ |
353 | class WindowManagementPolicy : public QObject, public miral::CanonicalWindowManagerPolicy |
354 | { |
355 | public: |
356 | - WindowManagementPolicy(miral::WindowManagerTools * const tools, |
357 | + WindowManagementPolicy(const miral::WindowManagerTools &tools, |
358 | qtmir::WindowModel &windowModel, |
359 | const QSharedPointer<ScreensModel> screensModel); |
360 | |
361 | @@ -81,7 +81,7 @@ |
362 | Q_SIGNALS: |
363 | |
364 | private: |
365 | - miral::WindowManagerTools * const m_tools; |
366 | + miral::WindowManagerTools m_tools; |
367 | qtmir::WindowModel &m_windowModel; |
368 | const QScopedPointer<QtEventFeeder> m_eventFeeder; |
369 | }; |
370 | |
371 | === modified file 'miral-shell/tiling_window_manager.cpp' |
372 | --- miral-shell/tiling_window_manager.cpp 2016-07-25 10:18:21 +0000 |
373 | +++ miral-shell/tiling_window_manager.cpp 2016-07-28 08:41:50 +0000 |
374 | @@ -49,8 +49,8 @@ |
375 | |
376 | // Demonstrate implementing a simple tiling algorithm |
377 | |
378 | -TilingWindowManagerPolicy::TilingWindowManagerPolicy(WindowManagerTools* const tools, SpinnerSplash const& spinner, |
379 | - miral::InternalClientLauncher const& launcher) : |
380 | +TilingWindowManagerPolicy::TilingWindowManagerPolicy(WindowManagerTools const& tools, SpinnerSplash const& spinner, |
381 | + InternalClientLauncher const& launcher) : |
382 | tools{tools}, |
383 | spinner{spinner}, |
384 | launcher{launcher} |
385 | @@ -59,8 +59,8 @@ |
386 | |
387 | void TilingWindowManagerPolicy::click(Point cursor) |
388 | { |
389 | - auto const window = tools->window_at(cursor); |
390 | - tools->select_active_window(window); |
391 | + auto const window = tools.window_at(cursor); |
392 | + tools.select_active_window(window); |
393 | } |
394 | |
395 | void TilingWindowManagerPolicy::advise_displays_updated(Rectangles const& displays) |
396 | @@ -75,9 +75,9 @@ |
397 | { |
398 | if (application == application_under(old_cursor)) |
399 | { |
400 | - if (auto const window = tools->select_active_window(tools->window_at(old_cursor))) |
401 | + if (auto const window = tools.select_active_window(tools.window_at(old_cursor))) |
402 | { |
403 | - resize(window, cursor, old_cursor, tile_for(tools->info_for(application))); |
404 | + resize(window, cursor, old_cursor, tile_for(tools.info_for(application))); |
405 | } |
406 | } |
407 | } |
408 | @@ -104,7 +104,7 @@ |
409 | else |
410 | { |
411 | auto top_level_windows = count_if(begin(app_info.windows()), end(app_info.windows()), [this] |
412 | - (Window const& window){ return !tools->info_for(window).parent(); }); |
413 | + (Window const& window){ return !tools.info_for(window).parent(); }); |
414 | |
415 | parameters.top_left() = tile.top_left + top_level_windows*Displacement{15, 15}; |
416 | } |
417 | @@ -124,7 +124,7 @@ |
418 | |
419 | void TilingWindowManagerPolicy::handle_window_ready(WindowInfo& window_info) |
420 | { |
421 | - tools->select_active_window(window_info.window()); |
422 | + tools.select_active_window(window_info.window()); |
423 | } |
424 | |
425 | namespace |
426 | @@ -162,7 +162,7 @@ |
427 | window_info.window().set_state(state); |
428 | } |
429 | |
430 | - tools->modify_window(window_info, mods); |
431 | + tools.modify_window(window_info, mods); |
432 | } |
433 | |
434 | auto TilingWindowManagerPolicy::transform_set_state(WindowInfo& window_info, MirSurfaceState value) |
435 | @@ -215,7 +215,7 @@ |
436 | return window_info.state(); |
437 | } |
438 | |
439 | - auto const& tile = tile_for(tools->info_for(window_info.window().application())); |
440 | + auto const& tile = tile_for(tools.info_for(window_info.window().application())); |
441 | |
442 | switch (value) |
443 | { |
444 | @@ -253,9 +253,9 @@ |
445 | { |
446 | window_info.window().show(); |
447 | } |
448 | - else if (window_info.window() == tools->active_window()) |
449 | + else if (window_info.window() == tools.active_window()) |
450 | { |
451 | - tools->select_active_window(window_info.parent()); |
452 | + tools.select_active_window(window_info.parent()); |
453 | } |
454 | |
455 | return value; |
456 | @@ -267,9 +267,9 @@ |
457 | { |
458 | if (application == application_under(old_cursor)) |
459 | { |
460 | - if (auto const window = tools->select_active_window(tools->window_at(old_cursor))) |
461 | + if (auto const window = tools.select_active_window(tools.window_at(old_cursor))) |
462 | { |
463 | - drag(tools->info_for(window), cursor, old_cursor, tile_for(tools->info_for(application))); |
464 | + drag(tools.info_for(window), cursor, old_cursor, tile_for(tools.info_for(application))); |
465 | } |
466 | } |
467 | } |
468 | @@ -277,7 +277,7 @@ |
469 | |
470 | void TilingWindowManagerPolicy::handle_raise_window(WindowInfo& window_info) |
471 | { |
472 | - tools-> select_active_window(window_info.window()); |
473 | + tools. select_active_window(window_info.window()); |
474 | } |
475 | |
476 | bool TilingWindowManagerPolicy::handle_keyboard_event(MirKeyboardEvent const* event) |
477 | @@ -318,11 +318,11 @@ |
478 | switch (modifiers & modifier_mask) |
479 | { |
480 | case mir_input_event_modifier_alt|mir_input_event_modifier_shift: |
481 | - tools->kill_active_application(SIGTERM); |
482 | + tools.kill_active_application(SIGTERM); |
483 | return true; |
484 | |
485 | case mir_input_event_modifier_alt: |
486 | - if (auto const window = tools->active_window()) |
487 | + if (auto const window = tools.active_window()) |
488 | window.request_client_surface_close(); |
489 | |
490 | return true; |
491 | @@ -335,7 +335,7 @@ |
492 | modifiers == mir_input_event_modifier_alt && |
493 | scan_code == KEY_TAB) |
494 | { |
495 | - tools->focus_next_application(); |
496 | + tools.focus_next_application(); |
497 | |
498 | return true; |
499 | } |
500 | @@ -343,7 +343,7 @@ |
501 | modifiers == mir_input_event_modifier_alt && |
502 | scan_code == KEY_GRAVE) |
503 | { |
504 | - tools->focus_next_within_application(); |
505 | + tools.focus_next_within_application(); |
506 | |
507 | return true; |
508 | } |
509 | @@ -400,8 +400,8 @@ |
510 | } |
511 | else |
512 | { |
513 | - if (auto const& window = tools->window_at(cursor)) |
514 | - tools->select_active_window(window); |
515 | + if (auto const& window = tools.window_at(cursor)) |
516 | + tools.select_active_window(window); |
517 | } |
518 | |
519 | old_cursor = cursor; |
520 | @@ -443,9 +443,9 @@ |
521 | |
522 | void TilingWindowManagerPolicy::toggle(MirSurfaceState state) |
523 | { |
524 | - if (auto window = tools->active_window()) |
525 | + if (auto window = tools.active_window()) |
526 | { |
527 | - auto& window_info = tools->info_for(window); |
528 | + auto& window_info = tools.info_for(window); |
529 | |
530 | if (window_info.state() == state) |
531 | state = mir_surface_state_restored; |
532 | @@ -458,13 +458,13 @@ |
533 | auto TilingWindowManagerPolicy::application_under(Point position) |
534 | -> Application |
535 | { |
536 | - return tools->find_application([&, this](ApplicationInfo const& info) |
537 | + return tools.find_application([&, this](ApplicationInfo const& info) |
538 | { return spinner.session() != info.application() && tile_for(info).contains(position);}); |
539 | } |
540 | |
541 | void TilingWindowManagerPolicy::update_tiles(Rectangles const& displays) |
542 | { |
543 | - auto applications = tools->count_applications(); |
544 | + auto applications = tools.count_applications(); |
545 | |
546 | if (spinner.session()) --applications; |
547 | |
548 | @@ -477,7 +477,7 @@ |
549 | |
550 | auto index = 0; |
551 | |
552 | - tools->for_each_application([&](ApplicationInfo& info) |
553 | + tools.for_each_application([&](ApplicationInfo& info) |
554 | { |
555 | if (spinner.session() == info.application()) |
556 | return; |
557 | @@ -504,7 +504,7 @@ |
558 | { |
559 | if (window) |
560 | { |
561 | - auto& window_info = tools->info_for(window); |
562 | + auto& window_info = tools.info_for(window); |
563 | |
564 | if (!window_info.parent()) |
565 | { |
566 | @@ -519,7 +519,7 @@ |
567 | auto width = std::min(new_tile.size.width.as_int() - offset.dx.as_int(), scaled_width.as_int()); |
568 | auto height = std::min(new_tile.size.height.as_int() - offset.dy.as_int(), scaled_height.as_int()); |
569 | |
570 | - tools->place_and_size(window_info, new_pos, {width, height}); |
571 | + tools.place_and_size(window_info, new_pos, {width, height}); |
572 | } |
573 | } |
574 | } |
575 | @@ -608,14 +608,14 @@ |
576 | |
577 | void TilingWindowManagerPolicy::advise_focus_gained(WindowInfo const& info) |
578 | { |
579 | - tools->raise_tree(info.window()); |
580 | + tools.raise_tree(info.window()); |
581 | |
582 | if (auto const spinner_session = spinner.session()) |
583 | { |
584 | - auto const& spinner_info = tools->info_for(spinner_session); |
585 | + auto const& spinner_info = tools.info_for(spinner_session); |
586 | |
587 | if (spinner_info.windows().size() > 0) |
588 | - tools->raise_tree(spinner_info.windows()[0]); |
589 | + tools.raise_tree(spinner_info.windows()[0]); |
590 | } |
591 | } |
592 | |
593 | |
594 | === modified file 'miral-shell/tiling_window_manager.h' |
595 | --- miral-shell/tiling_window_manager.h 2016-07-11 13:45:44 +0000 |
596 | +++ miral-shell/tiling_window_manager.h 2016-07-28 08:41:50 +0000 |
597 | @@ -23,6 +23,7 @@ |
598 | |
599 | #include <miral/application.h> |
600 | #include <miral/window_management_policy.h> |
601 | +#include <miral/window_manager_tools.h> |
602 | |
603 | #include <mir/geometry/displacement.h> |
604 | #include <miral/internal_client.h> |
605 | @@ -42,7 +43,7 @@ |
606 | class TilingWindowManagerPolicy : public miral::WindowManagementPolicy |
607 | { |
608 | public: |
609 | - explicit TilingWindowManagerPolicy(miral::WindowManagerTools* const tools, SpinnerSplash const& spinner, |
610 | + explicit TilingWindowManagerPolicy(miral::WindowManagerTools const& tools, SpinnerSplash const& spinner, |
611 | miral::InternalClientLauncher const& launcher); |
612 | |
613 | auto place_new_surface( |
614 | @@ -89,7 +90,7 @@ |
615 | static void resize(miral::Window window, Point cursor, Point old_cursor, Rectangle bounds); |
616 | static void constrained_move(miral::Window window, Displacement& movement, Rectangle const& bounds); |
617 | |
618 | - miral::WindowManagerTools* const tools; |
619 | + miral::WindowManagerTools tools; |
620 | SpinnerSplash spinner; |
621 | miral::InternalClientLauncher const launcher; |
622 | Point old_cursor{}; |
623 | |
624 | === modified file 'miral-shell/titlebar_provider.cpp' |
625 | --- miral-shell/titlebar_provider.cpp 2016-07-14 16:19:53 +0000 |
626 | +++ miral-shell/titlebar_provider.cpp 2016-07-28 08:41:50 +0000 |
627 | @@ -58,7 +58,7 @@ |
628 | using namespace miral::toolkit; |
629 | using namespace mir::geometry; |
630 | |
631 | -TitlebarProvider::TitlebarProvider(miral::WindowManagerTools* const tools) : tools{tools} |
632 | +TitlebarProvider::TitlebarProvider(miral::WindowManagerTools const& tools) : tools{tools} |
633 | { |
634 | |
635 | } |
636 | @@ -179,7 +179,7 @@ |
637 | { |
638 | auto window = window_info.window(); |
639 | element.second.window = window; |
640 | - auto& parent_info = tools->info_for(scene_surface); |
641 | + auto& parent_info = tools.info_for(scene_surface); |
642 | parent_info.add_child(window); |
643 | window_info.parent(parent_info.window()); |
644 | window.move_to(parent_info.window().top_left() - Displacement{0, title_bar_height}); |
645 | |
646 | === modified file 'miral-shell/titlebar_provider.h' |
647 | --- miral-shell/titlebar_provider.h 2016-07-11 15:11:07 +0000 |
648 | +++ miral-shell/titlebar_provider.h 2016-07-28 08:41:50 +0000 |
649 | @@ -57,7 +57,7 @@ |
650 | class TitlebarProvider : Worker |
651 | { |
652 | public: |
653 | - TitlebarProvider(miral::WindowManagerTools* const tools); |
654 | + TitlebarProvider(miral::WindowManagerTools const& tools); |
655 | ~TitlebarProvider(); |
656 | |
657 | void operator()(miral::toolkit::Connection connection); |
658 | @@ -86,7 +86,7 @@ |
659 | |
660 | using SurfaceMap = std::map<std::weak_ptr<mir::scene::Surface>, Data, std::owner_less<std::weak_ptr<mir::scene::Surface>>>; |
661 | |
662 | - miral::WindowManagerTools* const tools; |
663 | + miral::WindowManagerTools tools; |
664 | std::mutex mutable mutex; |
665 | miral::toolkit::Connection connection; |
666 | std::weak_ptr<mir::scene::Session> weak_session; |
667 | |
668 | === modified file 'miral-shell/titlebar_window_manager.cpp' |
669 | --- miral-shell/titlebar_window_manager.cpp 2016-07-25 15:42:29 +0000 |
670 | +++ miral-shell/titlebar_window_manager.cpp 2016-07-28 08:41:50 +0000 |
671 | @@ -35,7 +35,7 @@ |
672 | } |
673 | |
674 | TitlebarWindowManagerPolicy::TitlebarWindowManagerPolicy( |
675 | - WindowManagerTools* const tools, |
676 | + WindowManagerTools const& tools, |
677 | SpinnerSplash const& spinner, |
678 | miral::InternalClientLauncher const& launcher) : |
679 | CanonicalWindowManagerPolicy(tools), |
680 | @@ -60,18 +60,18 @@ |
681 | |
682 | if (action == mir_pointer_action_button_down) |
683 | { |
684 | - if (auto const window = tools->window_at(cursor)) |
685 | - tools->select_active_window(window); |
686 | + if (auto const window = tools.window_at(cursor)) |
687 | + tools.select_active_window(window); |
688 | } |
689 | else if (action == mir_pointer_action_motion && |
690 | modifiers == mir_input_event_modifier_alt) |
691 | { |
692 | if (mir_pointer_event_button_state(event, mir_pointer_button_primary)) |
693 | { |
694 | - if (auto const target = tools->window_at(old_cursor)) |
695 | + if (auto const target = tools.window_at(old_cursor)) |
696 | { |
697 | - tools->select_active_window(target); |
698 | - tools->drag_active_window(cursor - old_cursor); |
699 | + tools.select_active_window(target); |
700 | + tools.drag_active_window(cursor - old_cursor); |
701 | } |
702 | consumes_event = true; |
703 | } |
704 | @@ -79,8 +79,8 @@ |
705 | if (mir_pointer_event_button_state(event, mir_pointer_button_tertiary)) |
706 | { |
707 | if (!resizing) |
708 | - tools->select_active_window(tools->window_at(old_cursor)); |
709 | - is_resize_event = resize(tools->active_window(), cursor, old_cursor); |
710 | + tools.select_active_window(tools.window_at(old_cursor)); |
711 | + is_resize_event = resize(tools.active_window(), cursor, old_cursor); |
712 | consumes_event = true; |
713 | } |
714 | } |
715 | @@ -89,13 +89,13 @@ |
716 | { |
717 | if (mir_pointer_event_button_state(event, mir_pointer_button_primary)) |
718 | { |
719 | - if (auto const possible_titlebar = tools->window_at(old_cursor)) |
720 | + if (auto const possible_titlebar = tools.window_at(old_cursor)) |
721 | { |
722 | if (possible_titlebar.application() == titlebar_provider->session()) |
723 | { |
724 | - auto const& info = tools->info_for(possible_titlebar); |
725 | - tools->select_active_window(info.parent()); |
726 | - tools->drag_active_window(cursor - old_cursor); |
727 | + auto const& info = tools.info_for(possible_titlebar); |
728 | + tools.select_active_window(info.parent()); |
729 | + tools.drag_active_window(cursor - old_cursor); |
730 | consumes_event = true; |
731 | } |
732 | } |
733 | @@ -176,7 +176,7 @@ |
734 | { |
735 | if (count == 3) |
736 | { |
737 | - if (auto window = tools->active_window()) |
738 | + if (auto window = tools.active_window()) |
739 | { |
740 | auto const old_size = window.size(); |
741 | auto const delta_width = DeltaX{touch_pinch_width - old_touch_pinch_width}; |
742 | @@ -189,15 +189,15 @@ |
743 | auto const new_height = std::max(old_size.height + delta_height, Height{5}); |
744 | auto const new_pos = window.top_left() + delta_x + delta_y; |
745 | |
746 | - tools->place_and_size(tools->info_for(window), new_pos, {new_width, new_height}); |
747 | + tools.place_and_size(tools.info_for(window), new_pos, {new_width, new_height}); |
748 | } |
749 | consumes_event = true; |
750 | } |
751 | } |
752 | else |
753 | { |
754 | - if (auto const& window = tools->window_at(cursor)) |
755 | - tools->select_active_window(window); |
756 | + if (auto const& window = tools.window_at(cursor)) |
757 | + tools.select_active_window(window); |
758 | } |
759 | |
760 | old_cursor = cursor; |
761 | @@ -217,7 +217,7 @@ |
762 | if (application == titlebar_provider->session()) |
763 | { |
764 | titlebar_provider->advise_new_titlebar(window_info); |
765 | - tools->raise_tree(window_info.parent()); |
766 | + tools.raise_tree(window_info.parent()); |
767 | return; |
768 | } |
769 | |
770 | @@ -243,10 +243,10 @@ |
771 | // Frig to force the spinner to the top |
772 | if (auto const spinner_session = spinner.session()) |
773 | { |
774 | - auto const& spinner_info = tools->info_for(spinner_session); |
775 | + auto const& spinner_info = tools.info_for(spinner_session); |
776 | |
777 | if (spinner_info.windows().size() > 0) |
778 | - tools->raise_tree(spinner_info.windows()[0]); |
779 | + tools.raise_tree(spinner_info.windows()[0]); |
780 | } |
781 | } |
782 | |
783 | @@ -302,11 +302,11 @@ |
784 | switch (modifiers & modifier_mask) |
785 | { |
786 | case mir_input_event_modifier_alt|mir_input_event_modifier_shift: |
787 | - tools->kill_active_application(SIGTERM); |
788 | + tools.kill_active_application(SIGTERM); |
789 | return true; |
790 | |
791 | case mir_input_event_modifier_alt: |
792 | - if (auto const window = tools->active_window()) |
793 | + if (auto const window = tools.active_window()) |
794 | window.request_client_surface_close(); |
795 | |
796 | return true; |
797 | @@ -319,7 +319,7 @@ |
798 | modifiers == mir_input_event_modifier_alt && |
799 | scan_code == KEY_TAB) |
800 | { |
801 | - tools->focus_next_application(); |
802 | + tools.focus_next_application(); |
803 | |
804 | return true; |
805 | } |
806 | @@ -327,7 +327,7 @@ |
807 | modifiers == mir_input_event_modifier_alt && |
808 | scan_code == KEY_GRAVE) |
809 | { |
810 | - tools->focus_next_within_application(); |
811 | + tools.focus_next_within_application(); |
812 | |
813 | return true; |
814 | } |
815 | @@ -345,14 +345,14 @@ |
816 | |
817 | void TitlebarWindowManagerPolicy::toggle(MirSurfaceState state) |
818 | { |
819 | - if (auto const window = tools->active_window()) |
820 | + if (auto const window = tools.active_window()) |
821 | { |
822 | - auto& info = tools->info_for(window); |
823 | + auto& info = tools.info_for(window); |
824 | |
825 | if (info.state() == state) |
826 | state = mir_surface_state_restored; |
827 | |
828 | - tools->set_state(info, state); |
829 | + tools.set_state(info, state); |
830 | } |
831 | } |
832 | |
833 | @@ -361,7 +361,7 @@ |
834 | if (!window) |
835 | return false; |
836 | |
837 | - auto& window_info = tools->info_for(window); |
838 | + auto& window_info = tools.info_for(window); |
839 | |
840 | auto const top_left = window.top_left(); |
841 | Rectangle const old_pos{top_left, window.size()}; |
842 | @@ -415,7 +415,7 @@ |
843 | Point new_pos = top_left + left_resize*delta.dx + top_resize*delta.dy; |
844 | |
845 | window_info.constrain_resize(new_pos, new_size); |
846 | - tools->place_and_size(window_info, new_pos, new_size); |
847 | + tools.place_and_size(window_info, new_pos, new_size); |
848 | |
849 | return true; |
850 | } |
851 | |
852 | === modified file 'miral-shell/titlebar_window_manager.h' |
853 | --- miral-shell/titlebar_window_manager.h 2016-07-25 15:42:29 +0000 |
854 | +++ miral-shell/titlebar_window_manager.h 2016-07-28 08:41:50 +0000 |
855 | @@ -32,7 +32,7 @@ |
856 | class TitlebarWindowManagerPolicy : public miral::CanonicalWindowManagerPolicy |
857 | { |
858 | public: |
859 | - TitlebarWindowManagerPolicy(miral::WindowManagerTools* const tools, SpinnerSplash const& spinner, miral::InternalClientLauncher const& launcher); |
860 | + TitlebarWindowManagerPolicy(miral::WindowManagerTools const& tools, SpinnerSplash const& spinner, miral::InternalClientLauncher const& launcher); |
861 | ~TitlebarWindowManagerPolicy(); |
862 | |
863 | virtual miral::WindowSpecification place_new_surface( |
864 | |
865 | === modified file 'miral/CMakeLists.txt' |
866 | --- miral/CMakeLists.txt 2016-07-22 11:14:14 +0000 |
867 | +++ miral/CMakeLists.txt 2016-07-28 08:41:50 +0000 |
868 | @@ -19,9 +19,9 @@ |
869 | internal_client.cpp ${CMAKE_SOURCE_DIR}/include/miral/internal_client.h |
870 | mru_window_list.cpp mru_window_list.h |
871 | set_window_managment_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/set_window_managment_policy.h |
872 | - basic_window_manager.cpp basic_window_manager.h |
873 | + basic_window_manager.cpp basic_window_manager.h window_manager_tools_implementation.h |
874 | window_management_policy.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_management_policy.h |
875 | - ${CMAKE_SOURCE_DIR}/include/miral/window_manager_tools.h |
876 | + window_manager_tools.cpp ${CMAKE_SOURCE_DIR}/include/miral/window_manager_tools.h |
877 | ${CMAKE_SOURCE_DIR}/include/miral/stream_specification.h |
878 | ${CMAKE_SOURCE_DIR}/include/miral/toolkit/surface_spec.h |
879 | ${CMAKE_SOURCE_DIR}/include/miral/toolkit/connection.h |
880 | |
881 | === modified file 'miral/basic_window_manager.cpp' |
882 | --- miral/basic_window_manager.cpp 2016-07-26 11:22:49 +0000 |
883 | +++ miral/basic_window_manager.cpp 2016-07-28 08:41:50 +0000 |
884 | @@ -17,6 +17,7 @@ |
885 | */ |
886 | |
887 | #include "basic_window_manager.h" |
888 | +#include "miral/window_manager_tools.h" |
889 | |
890 | #include <mir/scene/session.h> |
891 | #include <mir/scene/surface.h> |
892 | @@ -60,7 +61,7 @@ |
893 | WindowManagementPolicyBuilder const& build) : |
894 | focus_controller(focus_controller), |
895 | display_layout(display_layout), |
896 | - policy(build(this)), |
897 | + policy(build(WindowManagerTools{this})), |
898 | surface_builder([](std::shared_ptr<scene::Session> const&, WindowSpecification const&) -> Window |
899 | { throw std::logic_error{"Can't create a window yet"};}) |
900 | { |
901 | |
902 | === modified file 'miral/basic_window_manager.h' |
903 | --- miral/basic_window_manager.h 2016-07-25 11:49:06 +0000 |
904 | +++ miral/basic_window_manager.h 2016-07-28 08:41:50 +0000 |
905 | @@ -20,7 +20,7 @@ |
906 | #define MIR_ABSTRACTION_BASIC_WINDOW_MANAGER_H_ |
907 | |
908 | #include "miral/window_management_policy.h" |
909 | -#include "miral/window_manager_tools.h" |
910 | +#include "window_manager_tools_implementation.h" |
911 | #include "miral/window_info.h" |
912 | #include "miral/application.h" |
913 | #include "miral/application_info.h" |
914 | @@ -42,12 +42,12 @@ |
915 | { |
916 | using mir::shell::SurfaceSet; |
917 | using WindowManagementPolicyBuilder = |
918 | - std::function<std::unique_ptr<miral::WindowManagementPolicy>(miral::WindowManagerTools* tools)>; |
919 | + std::function<std::unique_ptr<miral::WindowManagementPolicy>(miral::WindowManagerTools const& tools)>; |
920 | |
921 | /// A policy based window manager. |
922 | /// This takes care of the management of any meta implementation held for the sessions and windows. |
923 | class BasicWindowManager : public virtual mir::shell::WindowManager, |
924 | - protected WindowManagerTools |
925 | + protected WindowManagerToolsImplementation |
926 | { |
927 | public: |
928 | BasicWindowManager( |
929 | |
930 | === modified file 'miral/canonical_window_manager.cpp' |
931 | --- miral/canonical_window_manager.cpp 2016-07-22 16:33:35 +0000 |
932 | +++ miral/canonical_window_manager.cpp 2016-07-28 08:41:50 +0000 |
933 | @@ -25,7 +25,7 @@ |
934 | |
935 | // Based on "Mir and Unity: Surfaces, input, and displays (v0.3)" |
936 | |
937 | -miral::CanonicalWindowManagerPolicy::CanonicalWindowManagerPolicy(WindowManagerTools* const tools) : |
938 | +miral::CanonicalWindowManagerPolicy::CanonicalWindowManagerPolicy(WindowManagerTools const& tools) : |
939 | tools{tools} |
940 | { |
941 | } |
942 | @@ -40,22 +40,22 @@ |
943 | |
944 | void miral::CanonicalWindowManagerPolicy::handle_window_ready(WindowInfo& window_info) |
945 | { |
946 | - tools->select_active_window(window_info.window()); |
947 | + tools.select_active_window(window_info.window()); |
948 | } |
949 | |
950 | void miral::CanonicalWindowManagerPolicy::handle_modify_window( |
951 | WindowInfo& window_info, |
952 | WindowSpecification const& modifications) |
953 | { |
954 | - tools->modify_window(window_info, modifications); |
955 | + tools.modify_window(window_info, modifications); |
956 | } |
957 | |
958 | void miral::CanonicalWindowManagerPolicy::handle_raise_window(WindowInfo& window_info) |
959 | { |
960 | - tools->select_active_window(window_info.window()); |
961 | + tools.select_active_window(window_info.window()); |
962 | } |
963 | |
964 | void miral::CanonicalWindowManagerPolicy::advise_focus_gained(WindowInfo const& info) |
965 | { |
966 | - tools->raise_tree(info.window()); |
967 | + tools.raise_tree(info.window()); |
968 | } |
969 | |
970 | === added file 'miral/window_manager_tools.cpp' |
971 | --- miral/window_manager_tools.cpp 1970-01-01 00:00:00 +0000 |
972 | +++ miral/window_manager_tools.cpp 2016-07-28 08:41:50 +0000 |
973 | @@ -0,0 +1,87 @@ |
974 | +/* |
975 | + * Copyright © 2016 Canonical Ltd. |
976 | + * |
977 | + * This program is free software: you can redistribute it and/or modify it |
978 | + * under the terms of the GNU General Public License version 3, |
979 | + * as published by the Free Software Foundation. |
980 | + * |
981 | + * This program is distributed in the hope that it will be useful, |
982 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
983 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
984 | + * GNU General Public License for more details. |
985 | + * |
986 | + * You should have received a copy of the GNU General Public License |
987 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
988 | + * |
989 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
990 | + */ |
991 | + |
992 | +#include "miral/window_manager_tools.h" |
993 | +#include "window_manager_tools_implementation.h" |
994 | + |
995 | +miral::WindowManagerTools::WindowManagerTools(WindowManagerToolsImplementation* tools) : |
996 | + tools{tools} |
997 | +{ |
998 | +} |
999 | + |
1000 | +miral::WindowManagerTools::WindowManagerTools(WindowManagerTools const&) = default; |
1001 | +miral::WindowManagerTools& miral::WindowManagerTools::operator=(WindowManagerTools const&) = default; |
1002 | +miral::WindowManagerTools::~WindowManagerTools() = default; |
1003 | + |
1004 | +auto miral::WindowManagerTools::count_applications() const -> unsigned int |
1005 | +{ return tools->count_applications(); } |
1006 | + |
1007 | +void miral::WindowManagerTools::for_each_application(std::function<void(ApplicationInfo& info)> const& functor) |
1008 | +{ tools->for_each_application(functor); } |
1009 | + |
1010 | +auto miral::WindowManagerTools::find_application(std::function<bool(ApplicationInfo const& info)> const& predicate) |
1011 | +-> Application |
1012 | +{ return tools->find_application(predicate); } |
1013 | + |
1014 | +auto miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Session> const& session) const -> ApplicationInfo& |
1015 | +{ return tools->info_for(session); } |
1016 | + |
1017 | +auto miral::WindowManagerTools::info_for(std::weak_ptr<mir::scene::Surface> const& surface) const -> WindowInfo& |
1018 | +{ return tools->info_for(surface); } |
1019 | + |
1020 | +auto miral::WindowManagerTools::info_for(Window const& window) const -> WindowInfo& |
1021 | +{ return tools->info_for(window); } |
1022 | + |
1023 | +void miral::WindowManagerTools::kill_active_application(int sig) |
1024 | +{ tools->kill_active_application(sig); } |
1025 | + |
1026 | +auto miral::WindowManagerTools::active_window() const -> Window |
1027 | +{ return tools->active_window(); } |
1028 | + |
1029 | +auto miral::WindowManagerTools::select_active_window(Window const& hint) -> Window |
1030 | +{ return tools->select_active_window(hint); } |
1031 | + |
1032 | +void miral::WindowManagerTools::drag_active_window(mir::geometry::Displacement movement) |
1033 | +{ tools->drag_active_window(movement); } |
1034 | + |
1035 | +void miral::WindowManagerTools::focus_next_application() |
1036 | +{ tools->focus_next_application(); } |
1037 | + |
1038 | +void miral::WindowManagerTools::focus_next_within_application() |
1039 | +{ tools->focus_next_within_application(); } |
1040 | + |
1041 | +auto miral::WindowManagerTools::window_at(mir::geometry::Point cursor) const -> Window |
1042 | +{ return tools->window_at(cursor); } |
1043 | + |
1044 | +auto miral::WindowManagerTools::active_display() -> mir::geometry::Rectangle const |
1045 | +{ return tools->active_display(); } |
1046 | + |
1047 | +void miral::WindowManagerTools::raise_tree(Window const& root) |
1048 | +{ tools->raise_tree(root); } |
1049 | + |
1050 | +void miral::WindowManagerTools::modify_window(WindowInfo& window_info, WindowSpecification const& modifications) |
1051 | +{ tools->modify_window(window_info,modifications); } |
1052 | + |
1053 | +void miral::WindowManagerTools::place_and_size(WindowInfo& window_info, Point const& new_pos, Size const& new_size) |
1054 | +{ tools->place_and_size(window_info, new_pos, new_size); } |
1055 | + |
1056 | +void miral::WindowManagerTools::set_state(WindowInfo& window_info, MirSurfaceState value) |
1057 | +{ tools->set_state(window_info, value); } |
1058 | + |
1059 | +void miral::WindowManagerTools::invoke_under_lock(std::function<void()> const& callback) |
1060 | +{ tools->invoke_under_lock(callback); } |
1061 | |
1062 | === added file 'miral/window_manager_tools_implementation.h' |
1063 | --- miral/window_manager_tools_implementation.h 1970-01-01 00:00:00 +0000 |
1064 | +++ miral/window_manager_tools_implementation.h 2016-07-28 08:41:50 +0000 |
1065 | @@ -0,0 +1,84 @@ |
1066 | +/* |
1067 | + * Copyright © 2016 Canonical Ltd. |
1068 | + * |
1069 | + * This program is free software: you can redistribute it and/or modify it |
1070 | + * under the terms of the GNU General Public License version 3, |
1071 | + * as published by the Free Software Foundation. |
1072 | + * |
1073 | + * This program is distributed in the hope that it will be useful, |
1074 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1075 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1076 | + * GNU General Public License for more details. |
1077 | + * |
1078 | + * You should have received a copy of the GNU General Public License |
1079 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1080 | + * |
1081 | + * Authored by: Alan Griffiths <alan@octopull.co.uk> |
1082 | + */ |
1083 | + |
1084 | +#ifndef MIRAL_WINDOW_MANAGER_TOOLS_IMPLEMENTATION_H |
1085 | +#define MIRAL_WINDOW_MANAGER_TOOLS_IMPLEMENTATION_H |
1086 | + |
1087 | +#include "miral/application.h" |
1088 | + |
1089 | +#include <mir/geometry/displacement.h> |
1090 | + |
1091 | +#include <functional> |
1092 | +#include <memory> |
1093 | + |
1094 | +namespace mir { namespace scene { class Surface; } } |
1095 | + |
1096 | +namespace miral |
1097 | +{ |
1098 | +class Window; |
1099 | +struct WindowInfo; |
1100 | +struct ApplicationInfo; |
1101 | +class WindowSpecification; |
1102 | + |
1103 | +// The interface through which the policy instructs the controller. |
1104 | +class WindowManagerToolsImplementation |
1105 | +{ |
1106 | +public: |
1107 | +/** @name Update Model |
1108 | + * These functions assume that the BasicWindowManager data structures can be accessed freely. |
1109 | + * I.e. they should only be used by a thread that has called the WindowManagementPolicy methods |
1110 | + * (where any necessary locks are held) or via a invoke_under_lock() callback. |
1111 | + * @{ */ |
1112 | + virtual auto count_applications() const -> unsigned int = 0; |
1113 | + virtual void for_each_application(std::function<void(ApplicationInfo& info)> const& functor) = 0; |
1114 | + virtual auto find_application(std::function<bool(ApplicationInfo const& info)> const& predicate) |
1115 | + -> Application = 0; |
1116 | + virtual auto info_for(std::weak_ptr<mir::scene::Session> const& session) const -> ApplicationInfo& = 0; |
1117 | + virtual auto info_for(std::weak_ptr<mir::scene::Surface> const& surface) const -> WindowInfo& = 0; |
1118 | + virtual auto info_for(Window const& window) const -> WindowInfo& = 0; |
1119 | + virtual void kill_active_application(int sig) = 0; |
1120 | + virtual auto active_window() const -> Window = 0; |
1121 | + virtual auto select_active_window(Window const& hint) -> Window = 0; |
1122 | + virtual void drag_active_window(mir::geometry::Displacement movement) = 0; |
1123 | + virtual void focus_next_application() = 0; |
1124 | + virtual void focus_next_within_application() = 0; |
1125 | + virtual auto window_at(mir::geometry::Point cursor) const -> Window = 0; |
1126 | + virtual auto active_display() -> mir::geometry::Rectangle const = 0; |
1127 | + virtual void raise_tree(Window const& root) = 0; |
1128 | + virtual void modify_window(WindowInfo& window_info, WindowSpecification const& modifications) = 0; |
1129 | + virtual void place_and_size(WindowInfo& window_info, Point const& new_pos, Size const& new_size) = 0; |
1130 | + virtual void set_state(WindowInfo& window_info, MirSurfaceState value) = 0; |
1131 | +/** @} */ |
1132 | + |
1133 | +/** @name Multi-thread support |
1134 | + * Allows threads that don't hold a lock on the model to acquire one and call the "Update Model" |
1135 | + * member functions. |
1136 | + * This should NOT be used by a thread that has called the WindowManagementPolicy methods (and |
1137 | + * already holds the lock). |
1138 | + * @{ */ |
1139 | + virtual void invoke_under_lock(std::function<void()> const& callback) = 0; |
1140 | +/** @} */ |
1141 | + |
1142 | + virtual ~WindowManagerToolsImplementation() = default; |
1143 | + WindowManagerToolsImplementation() = default; |
1144 | + WindowManagerToolsImplementation(WindowManagerToolsImplementation const&) = delete; |
1145 | + WindowManagerToolsImplementation& operator=(WindowManagerToolsImplementation const&) = delete; |
1146 | +}; |
1147 | +} |
1148 | + |
1149 | +#endif //MIRAL_WINDOW_MANAGER_TOOLS_IMPLEMENTATION_H |
-) manager_ tools_implement ation.h)
+ window_
indent a bit wonky?
Rest looks fine. I really hope your IDE helped with it :)