Merge lp:~alan-griffiths/unity-system-compositor/use-WindowMangager-NOT-ShellWrapper into lp:unity-system-compositor

Proposed by Alan Griffiths
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 202
Proposed branch: lp:~alan-griffiths/unity-system-compositor/use-WindowMangager-NOT-ShellWrapper
Merge into: lp:unity-system-compositor
Diff against target: 695 lines (+329/-235)
11 files modified
debian/control (+1/-1)
spinner/eglapp.c (+1/-6)
src/CMakeLists.txt (+1/-1)
src/screen_event_handler.cpp (+6/-5)
src/server.cpp (+9/-6)
src/shell.cpp (+0/-159)
src/shell.h (+0/-54)
src/window_manager.cpp (+224/-0)
src/window_manager.h (+80/-0)
tests/unit-tests/test_screen_event_handler.cpp (+3/-3)
tests/unit-tests/test_session_switcher.cpp (+4/-0)
To merge this branch: bzr merge lp:~alan-griffiths/unity-system-compositor/use-WindowMangager-NOT-ShellWrapper
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
Kevin DuBois (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+252933@code.launchpad.net

Commit message

Use the new mir::shell::WindowManager interface instead of wrapping the default shell

Description of the change

Use the new mir::shell::WindowManager interface instead of wrapping the default shell

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
201. By Alexandros Frantzis

Add unit tests for components managing screen state.

Approved by PS Jenkins bot, Alberto Aguirre, Andreas Pokorny, Alan Griffiths.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

426 + focus_controller->set_focus_to(session, {});

437 + auto const next_session = session_coordinator->successor_of({});
438 + if (next_session)
439 + focus_controller->set_focus_to(next_session, next_session->default_surface());
440 + else
441 + focus_controller->set_focus_to(next_session, {});

I think that the focus setting code is not needed, since the session_switcher will set the focus as needed. I need to try this manually to check (unfortunately we don't have tests covering these interactions yet).

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> 426 + focus_controller->set_focus_to(session, {});
>
> 437 + auto const next_session = session_coordinator->successor_of({});
> 438 + if (next_session)
> 439 + focus_controller->set_focus_to(next_session,
> next_session->default_surface());
> 440 + else
> 441 + focus_controller->set_focus_to(next_session, {});
>
> I think that the focus setting code is not needed, since the session_switcher

You're likely right - I took the conservative approach of simply moving the calls from one site to another. I didn't try to figure out which were redundant.

> will set the focus as needed. I need to try this manually to check
> (unfortunately we don't have tests covering these interactions yet).

Are you volunteering to test?

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> > will set the focus as needed. I need to try this manually to check
> > (unfortunately we don't have tests covering these interactions yet).
>
> Are you volunteering to test?

Yes, hopefully I will manage to do so today.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> > Are you volunteering to test?
>
> Yes, hopefully I will manage to do so today.

I am having trouble getting input to work properly when I install packages based on lp:mir (which are needed to test this branch) on the phone (which has 0.12 packages). So testing this branch will need to be postponed until the situation is investigated and resolved.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Kevin DuBois (kdub) wrote :

Some of the code looks moved from an old location (via CP), and the new code looks okay to me

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

I would like to test this manually before it lands, but since testing is blocked [1], let's merge this and test later (it's a priority for me as soon as it is possible to do so). In any case, this branch won't hit production any time soon, so we have plenty of time to test.

[1] I am trying to work around problems with parallel mir installs by rebuilding qtmir (devel-mir-next) against latest mir too, but it seems it needs further updates to build properly.

review: Approve
202. By Alan Griffiths

Use the new mir::shell::WindowManager interface instead of wrapping the default shell.

Approved by Alexandros Frantzis, Kevin DuBois, PS Jenkins bot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-03-16 14:54:17 +0000
3+++ debian/control 2015-03-31 13:42:52 +0000
4@@ -18,7 +18,7 @@
5 libcairo2-dev,
6 libglib2.0-dev,
7 libgles2-mesa-dev,
8- libmirclient-dev (>= 0.6.0),
9+ libmirclient-dev (>= 0.13.0~),
10 libmirserver-dev (>= 0.13.0~),
11 libprotobuf-dev,
12 pkg-config,
13
14=== modified file 'spinner/eglapp.c'
15--- spinner/eglapp.c 2014-03-28 13:02:02 +0000
16+++ spinner/eglapp.c 2015-03-31 13:42:52 +0000
17@@ -144,11 +144,6 @@
18 mir_buffer_usage_hardware,
19 mir_display_output_id_invalid
20 };
21- MirEventDelegate delegate =
22- {
23- mir_eglapp_handle_event,
24- NULL
25- };
26 EGLConfig eglconfig;
27 EGLint neglconfigs;
28 EGLContext eglctx;
29@@ -323,7 +318,7 @@
30 surface = mir_connection_create_surface_sync(connection, &surfaceparm);
31 CHECK(mir_surface_is_valid(surface), "Can't create a surface");
32
33- mir_surface_set_event_handler(surface, &delegate);
34+ mir_surface_set_event_handler(surface, mir_eglapp_handle_event, NULL);
35
36 egldisplay = eglGetDisplay(
37 (EGLNativeDisplayType) mir_connection_get_egl_native_display(connection));
38
39=== modified file 'src/CMakeLists.txt'
40--- src/CMakeLists.txt 2015-02-18 14:40:29 +0000
41+++ src/CMakeLists.txt 2015-03-31 13:42:52 +0000
42@@ -22,9 +22,9 @@
43 screen_event_handler.cpp
44 mir_screen.cpp
45 server.cpp
46- shell.cpp
47 session_switcher.cpp
48 system_compositor.cpp
49+ window_manager.cpp
50 worker_thread.cpp
51 )
52
53
54=== modified file 'src/screen_event_handler.cpp'
55--- src/screen_event_handler.cpp 2015-03-16 10:24:45 +0000
56+++ src/screen_event_handler.cpp 2015-03-31 13:42:52 +0000
57@@ -19,6 +19,7 @@
58 #include "power_state_change_reason.h"
59
60 #include <mir/time/alarm_factory.h>
61+#include <mir_toolkit/events/input/input_event.h>
62
63 #include <cstdio>
64
65@@ -52,14 +53,14 @@
66
67 if (input_event_type == mir_input_event_type_key)
68 {
69- auto const kev = mir_input_event_get_key_input_event(input_event);
70- if (mir_key_input_event_get_key_code(kev) != POWER_KEY_CODE)
71+ auto const kev = mir_input_event_get_keyboard_event(input_event);
72+ if (mir_keyboard_event_key_code(kev) != POWER_KEY_CODE)
73 return false;
74
75- auto const action = mir_key_input_event_get_action(kev);
76- if (action == mir_key_input_event_action_down)
77+ auto const action = mir_keyboard_event_action(kev);
78+ if (action == mir_keyboard_action_down)
79 power_key_down();
80- else if (action == mir_key_input_event_action_up)
81+ else if (action == mir_keyboard_action_up)
82 power_key_up();
83 }
84 else if (input_event_type == mir_input_event_type_touch ||
85
86=== modified file 'src/server.cpp'
87--- src/server.cpp 2015-03-16 10:24:45 +0000
88+++ src/server.cpp 2015-03-31 13:42:52 +0000
89@@ -18,9 +18,9 @@
90
91 #include "server.h"
92 #include "external_spinner.h"
93-#include "shell.h"
94 #include "asio_dm_connection.h"
95 #include "session_switcher.h"
96+#include "window_manager.h"
97 #include "powerd_mediator.h"
98
99 #include <mir/input/cursor_listener.h>
100@@ -127,11 +127,14 @@
101 return std::make_shared<ServerStatusListener>(the_focus_controller());
102 });
103
104- wrap_shell([this](std::shared_ptr<msh::Shell> const& wrapped)
105- -> std::shared_ptr<msh::Shell>
106- {
107- return std::make_shared<Shell>(wrapped, the_session_switcher());
108- });
109+ override_the_window_manager_builder([this](msh::FocusController* focus_controller)
110+ {
111+ return std::make_shared<WindowManager>(
112+ focus_controller,
113+ the_shell_display_layout(),
114+ the_session_coordinator(),
115+ the_session_switcher());
116+ });
117
118 set_config_filename("unity-system-compositor.conf");
119
120
121=== removed file 'src/shell.cpp'
122--- src/shell.cpp 2015-03-16 10:24:45 +0000
123+++ src/shell.cpp 1970-01-01 00:00:00 +0000
124@@ -1,159 +0,0 @@
125-/*
126- * Copyright © 2014-2015 Canonical Ltd.
127- *
128- * This program is free software: you can redistribute it and/or modify
129- * it under the terms of the GNU General Public License version 3 as
130- * published by the Free Software Foundation.
131- *
132- * This program is distributed in the hope that it will be useful,
133- * but WITHOUT ANY WARRANTY; without even the implied warranty of
134- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135- * GNU General Public License for more details.
136- *
137- * You should have received a copy of the GNU General Public License
138- * along with this program. If not, see <http://www.gnu.org/licenses/>.
139- *
140- * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
141- */
142-
143-#include "shell.h"
144-#include "session_switcher.h"
145-
146-#include <mir/scene/null_surface_observer.h>
147-#include <mir/scene/session.h>
148-#include <mir/scene/surface.h>
149-#include <mir/frontend/session.h>
150-
151-#include <iostream>
152-
153-namespace msh = mir::shell;
154-namespace ms = mir::scene;
155-namespace mf = mir::frontend;
156-
157-namespace
158-{
159-
160-class UscSession : public usc::Session
161-{
162-public:
163- UscSession(
164- std::shared_ptr<ms::Session> const& scene_session,
165- msh::FocusController& focus_controller)
166- : scene_session{scene_session},
167- focus_controller(focus_controller)
168- {
169- }
170-
171- std::string name()
172- {
173- return scene_session->name();
174- }
175-
176- void show() override
177- {
178- scene_session->show();
179- }
180-
181- void hide() override
182- {
183- scene_session->hide();
184- }
185-
186- void raise_and_focus() override
187- {
188- auto const surface = scene_session->default_surface();
189- focus_controller.raise({surface});
190- focus_controller.set_focus_to(scene_session, surface);
191- }
192-
193- bool corresponds_to(mir::frontend::Session const* s) override
194- {
195- return scene_session.get() == s;
196- }
197-
198- std::shared_ptr<ms::Session> const scene_session;
199- msh::FocusController& focus_controller;
200-};
201-
202-
203-struct SessionReadyObserver : ms::NullSurfaceObserver,
204- std::enable_shared_from_this<SessionReadyObserver>
205-{
206- SessionReadyObserver(
207- std::shared_ptr<usc::SessionSwitcher> const& switcher,
208- std::shared_ptr<ms::Surface> const& surface,
209- ms::Session const* session)
210- : switcher{switcher},
211- surface{surface},
212- session{session}
213- {
214- }
215-
216- void frame_posted(int) override
217- {
218- ++num_frames_posted;
219- if (num_frames_posted == num_frames_for_session_ready)
220- {
221- switcher->mark_ready(session);
222- surface->remove_observer(shared_from_this());
223- }
224- }
225-
226- std::shared_ptr<usc::SessionSwitcher> const switcher;
227- std::shared_ptr<ms::Surface> const surface;
228- ms::Session const* const session;
229- // We need to wait for the second frame before marking the session
230- // as ready. The first frame posted from sessions is a blank frame.
231- // TODO: Solve this issue at its root and remove this workaround
232- int const num_frames_for_session_ready{2};
233- int num_frames_posted{0};
234-};
235-
236-}
237-
238-usc::Shell::Shell(
239- std::shared_ptr<msh::Shell> const& wrapped,
240- std::shared_ptr<SessionSwitcher> const& session_switcher)
241- : msh::ShellWrapper{wrapped},
242- session_switcher{session_switcher}
243-{
244-}
245-
246-std::shared_ptr<ms::Session>
247-usc::Shell::open_session(
248- pid_t client_pid,
249- std::string const& name,
250- std::shared_ptr<mf::EventSink> const& sink)
251-{
252- std::cerr << "Opening session " << name << std::endl;
253-
254- auto orig = msh::ShellWrapper::open_session(client_pid, name, sink);
255-
256- auto const usc_session = std::make_shared<UscSession>(orig, *this);
257-
258- session_switcher->add(usc_session, client_pid);
259-
260- return orig;
261-}
262-
263-void usc::Shell::close_session(std::shared_ptr<ms::Session> const& session)
264-{
265- std::cerr << "Closing session " << session->name() << std::endl;
266-
267- msh::ShellWrapper::close_session(session);
268-
269- session_switcher->remove(session);
270-}
271-
272-mf::SurfaceId usc::Shell::create_surface(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)
273-{
274- auto const id = msh::ShellWrapper::create_surface(session, params);
275-
276- auto const surface = session->surface(id);
277- auto const session_ready_observer = std::make_shared<SessionReadyObserver>(
278- session_switcher, surface, session.get());
279-
280- surface->add_observer(session_ready_observer);
281-
282- return id;
283-}
284
285=== removed file 'src/shell.h'
286--- src/shell.h 2015-01-27 17:43:17 +0000
287+++ src/shell.h 1970-01-01 00:00:00 +0000
288@@ -1,54 +0,0 @@
289-/*
290- * Copyright © 2014-2015 Canonical Ltd.
291- *
292- * This program is free software: you can redistribute it and/or modify
293- * it under the terms of the GNU General Public License version 3 as
294- * published by the Free Software Foundation.
295- *
296- * This program is distributed in the hope that it will be useful,
297- * but WITHOUT ANY WARRANTY; without even the implied warranty of
298- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
299- * GNU General Public License for more details.
300- *
301- * You should have received a copy of the GNU General Public License
302- * along with this program. If not, see <http://www.gnu.org/licenses/>.
303- *
304- * Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
305- */
306-
307-#ifndef USC_SHELL_H_
308-#define USC_SHELL_H_
309-
310-#include <mir/shell/shell_wrapper.h>
311-
312-#include <memory>
313-
314-
315-namespace usc
316-{
317-class SessionSwitcher;
318-
319-class Shell : public mir::shell::ShellWrapper
320-{
321-public:
322- Shell(
323- std::shared_ptr<mir::shell::Shell> const& wrapped,
324- std::shared_ptr<SessionSwitcher> const& session_switcher);
325-
326-private:
327- std::shared_ptr<mir::scene::Session> open_session(
328- pid_t client_pid,
329- std::string const& name,
330- std::shared_ptr<mir::frontend::EventSink> const& sink) override;
331- void close_session(std::shared_ptr<mir::scene::Session> const& session) override;
332-
333- mir::frontend::SurfaceId create_surface(
334- std::shared_ptr<mir::scene::Session> const& session,
335- mir::scene::SurfaceCreationParameters const& params) override;
336-
337- std::shared_ptr<SessionSwitcher> const session_switcher;
338-};
339-
340-}
341-
342-#endif
343
344=== added file 'src/window_manager.cpp'
345--- src/window_manager.cpp 1970-01-01 00:00:00 +0000
346+++ src/window_manager.cpp 2015-03-31 13:42:52 +0000
347@@ -0,0 +1,224 @@
348+/*
349+ * Copyright © 2015 Canonical Ltd.
350+ *
351+ * This program is free software: you can redistribute it and/or modify it
352+ * under the terms of the GNU General Public License version 3,
353+ * as published by the Free Software Foundation.
354+ *
355+ * This program is distributed in the hope that it will be useful,
356+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
357+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
358+ * GNU General Public License for more details.
359+ *
360+ * You should have received a copy of the GNU General Public License
361+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
362+ *
363+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
364+ */
365+
366+#include "window_manager.h"
367+
368+#include "session_switcher.h"
369+
370+#include "mir/geometry/rectangle.h"
371+#include "mir/scene/null_surface_observer.h"
372+#include "mir/scene/session.h"
373+#include "mir/scene/session_coordinator.h"
374+#include "mir/scene/surface.h"
375+#include "mir/scene/surface_creation_parameters.h"
376+#include "mir/shell/display_layout.h"
377+#include "mir/shell/focus_controller.h"
378+
379+#include "mir_toolkit/client_types.h"
380+
381+#include <iostream>
382+
383+namespace mf = mir::frontend;
384+namespace ms = mir::scene;
385+namespace msh = mir::shell;
386+
387+namespace
388+{
389+
390+class UscSession : public usc::Session
391+{
392+public:
393+ UscSession(
394+ std::shared_ptr<ms::Session> const& scene_session,
395+ msh::FocusController& focus_controller)
396+ : scene_session{scene_session},
397+ focus_controller(focus_controller)
398+ {
399+ }
400+
401+ std::string name()
402+ {
403+ return scene_session->name();
404+ }
405+
406+ void show() override
407+ {
408+ scene_session->show();
409+ }
410+
411+ void hide() override
412+ {
413+ scene_session->hide();
414+ }
415+
416+ void raise_and_focus() override
417+ {
418+ auto const surface = scene_session->default_surface();
419+ focus_controller.raise({surface});
420+ focus_controller.set_focus_to(scene_session, surface);
421+ }
422+
423+ bool corresponds_to(mir::frontend::Session const* s) override
424+ {
425+ return scene_session.get() == s;
426+ }
427+
428+ std::shared_ptr<ms::Session> const scene_session;
429+ msh::FocusController& focus_controller;
430+};
431+
432+
433+struct SessionReadyObserver : ms::NullSurfaceObserver,
434+ std::enable_shared_from_this<SessionReadyObserver>
435+{
436+ SessionReadyObserver(
437+ std::shared_ptr<usc::SessionSwitcher> const& switcher,
438+ std::shared_ptr<ms::Surface> const& surface,
439+ ms::Session const* session)
440+ : switcher{switcher},
441+ surface{surface},
442+ session{session}
443+ {
444+ }
445+
446+ void frame_posted(int) override
447+ {
448+ ++num_frames_posted;
449+ if (num_frames_posted == num_frames_for_session_ready)
450+ {
451+ switcher->mark_ready(session);
452+ surface->remove_observer(shared_from_this());
453+ }
454+ }
455+
456+ std::shared_ptr<usc::SessionSwitcher> const switcher;
457+ std::shared_ptr<ms::Surface> const surface;
458+ ms::Session const* const session;
459+ // We need to wait for the second frame before marking the session
460+ // as ready. The first frame posted from sessions is a blank frame.
461+ // TODO: Solve this issue at its root and remove this workaround
462+ int const num_frames_for_session_ready{2};
463+ int num_frames_posted{0};
464+};
465+
466+}
467+
468+usc::WindowManager::WindowManager(
469+ mir::shell::FocusController* focus_controller,
470+ std::shared_ptr<mir::shell::DisplayLayout> const& display_layout,
471+ std::shared_ptr<ms::SessionCoordinator> const& session_coordinator,
472+ std::shared_ptr<SessionSwitcher> const& session_switcher) :
473+ focus_controller{focus_controller},
474+ display_layout{display_layout},
475+ session_coordinator{session_coordinator},
476+ session_switcher{session_switcher}
477+{
478+}
479+
480+void usc::WindowManager::add_session(std::shared_ptr<ms::Session> const& session)
481+{
482+ std::cerr << "Opening session " << session->name() << std::endl;
483+
484+ focus_controller->set_focus_to(session, {});
485+
486+ auto const usc_session = std::make_shared<UscSession>(session, *focus_controller);
487+
488+ session_switcher->add(usc_session, session->process_id());
489+}
490+
491+void usc::WindowManager::remove_session(std::shared_ptr<ms::Session> const& session)
492+{
493+ std::cerr << "Closing session " << session->name() << std::endl;
494+
495+ auto const next_session = session_coordinator->successor_of({});
496+ if (next_session)
497+ focus_controller->set_focus_to(next_session, next_session->default_surface());
498+ else
499+ focus_controller->set_focus_to(next_session, {});
500+
501+ session_switcher->remove(session);
502+}
503+
504+auto usc::WindowManager::add_surface(
505+ std::shared_ptr<ms::Session> const& session,
506+ ms::SurfaceCreationParameters const& params,
507+ std::function<mf::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build)
508+-> mf::SurfaceId
509+{
510+ mir::graphics::DisplayConfigurationOutputId const output_id_invalid{
511+ mir_display_output_id_invalid};
512+ auto placed_parameters = params;
513+
514+ mir::geometry::Rectangle rect{params.top_left, params.size};
515+
516+ if (params.output_id != output_id_invalid)
517+ {
518+ display_layout->place_in_output(params.output_id, rect);
519+ }
520+
521+ placed_parameters.top_left = rect.top_left;
522+ placed_parameters.size = rect.size;
523+
524+ auto const result = build(session, placed_parameters);
525+ auto const surface = session->surface(result);
526+
527+ auto const session_ready_observer = std::make_shared<SessionReadyObserver>(
528+ session_switcher, surface, session.get());
529+
530+ surface->add_observer(session_ready_observer);
531+
532+ return result;
533+}
534+
535+void usc::WindowManager::remove_surface(
536+ std::shared_ptr<ms::Session> const& /*session*/,
537+ std::weak_ptr<ms::Surface> const& /*surface*/)
538+{
539+}
540+
541+void usc::WindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
542+{
543+}
544+
545+void usc::WindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
546+{
547+}
548+
549+bool usc::WindowManager::handle_key_event(MirKeyboardEvent const* /*event*/)
550+{
551+ return false;
552+}
553+
554+bool usc::WindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
555+{
556+ return false;
557+}
558+
559+bool usc::WindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
560+{
561+ return false;
562+}
563+
564+int usc::WindowManager::set_surface_attribute(
565+ std::shared_ptr<ms::Session> const& /*session*/,
566+ std::shared_ptr<ms::Surface> const& surface,
567+ MirSurfaceAttrib attrib,
568+ int value)
569+{
570+ return surface->configure(attrib, value);
571+}
572
573=== added file 'src/window_manager.h'
574--- src/window_manager.h 1970-01-01 00:00:00 +0000
575+++ src/window_manager.h 2015-03-31 13:42:52 +0000
576@@ -0,0 +1,80 @@
577+/*
578+ * Copyright © 2015 Canonical Ltd.
579+ *
580+ * This program is free software: you can redistribute it and/or modify it
581+ * under the terms of the GNU General Public License version 3,
582+ * as published by the Free Software Foundation.
583+ *
584+ * This program is distributed in the hope that it will be useful,
585+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
586+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
587+ * GNU General Public License for more details.
588+ *
589+ * You should have received a copy of the GNU General Public License
590+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
591+ *
592+ * Authored By: Alan Griffiths <alan@octopull.co.uk>
593+ */
594+
595+#ifndef USC_WINDOW_MANAGER_H_
596+#define USC_WINDOW_MANAGER_H_
597+
598+#include <mir/shell/window_manager.h>
599+
600+namespace mir
601+{
602+namespace scene { class PlacementStrategy; class SessionCoordinator; }
603+namespace shell { class FocusController; class DisplayLayout; }
604+}
605+
606+namespace usc
607+{
608+class SessionSwitcher;
609+
610+class WindowManager : public mir::shell::WindowManager
611+{
612+public:
613+ explicit WindowManager(
614+ mir::shell::FocusController* focus_controller,
615+ std::shared_ptr<mir::shell::DisplayLayout> const& display_layout,
616+ std::shared_ptr<mir::scene::SessionCoordinator> const& session_coordinator,
617+ std::shared_ptr<SessionSwitcher> const& session_switcher);
618+
619+ void add_session(std::shared_ptr<mir::scene::Session> const& session) override;
620+
621+ void remove_session(std::shared_ptr<mir::scene::Session> const& session) override;
622+
623+ mir::frontend::SurfaceId add_surface(
624+ std::shared_ptr<mir::scene::Session> const& session,
625+ mir::scene::SurfaceCreationParameters const& params,
626+ std::function<mir::frontend::SurfaceId(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params)> const& build) override;
627+
628+ void remove_surface(
629+ std::shared_ptr<mir::scene::Session> const& session,
630+ std::weak_ptr<mir::scene::Surface> const& surface) override;
631+
632+ void add_display(mir::geometry::Rectangle const& area) override;
633+
634+ void remove_display(mir::geometry::Rectangle const& area) override;
635+
636+ bool handle_key_event(MirKeyboardEvent const* event) override;
637+
638+ bool handle_touch_event(MirTouchEvent const* event) override;
639+
640+ bool handle_pointer_event(MirPointerEvent const* event) override;
641+
642+ int set_surface_attribute(
643+ std::shared_ptr<mir::scene::Session> const& session,
644+ std::shared_ptr<mir::scene::Surface> const& surface,
645+ MirSurfaceAttrib attrib,
646+ int value) override;
647+
648+private:
649+ mir::shell::FocusController* const focus_controller;
650+ std::shared_ptr<mir::shell::DisplayLayout> const display_layout;
651+ std::shared_ptr<mir::scene::SessionCoordinator> const session_coordinator;
652+ std::shared_ptr<SessionSwitcher> const session_switcher;
653+};
654+}
655+
656+#endif /* USC_WINDOW_MANAGER_H_ */
657
658=== modified file 'tests/unit-tests/test_screen_event_handler.cpp'
659--- tests/unit-tests/test_screen_event_handler.cpp 2015-02-18 14:40:29 +0000
660+++ tests/unit-tests/test_screen_event_handler.cpp 2015-03-31 13:42:52 +0000
661@@ -73,16 +73,16 @@
662
663 static const int32_t POWER_KEY_CODE = 26;
664 mir::EventUPtr power_key_down_event = mir::events::make_event(
665- MirInputDeviceId{1}, 0, mir_key_input_event_action_down,
666+ MirInputDeviceId{1}, 0, mir_keyboard_action_down,
667 POWER_KEY_CODE, 0, mir_input_event_modifier_none);
668 mir::EventUPtr power_key_up_event = mir::events::make_event(
669- MirInputDeviceId{1}, 0, mir_key_input_event_action_up,
670+ MirInputDeviceId{1}, 0, mir_keyboard_action_up,
671 POWER_KEY_CODE, 0, mir_input_event_modifier_none);
672 mir::EventUPtr touch_event = mir::events::make_event(
673 MirInputDeviceId{1}, 0, mir_input_event_modifier_none);
674 mir::EventUPtr pointer_event = mir::events::make_event(
675 MirInputDeviceId{1}, 0, mir_input_event_modifier_none,
676- mir_pointer_input_event_action_motion,
677+ mir_pointer_action_motion,
678 {}, 0.0f, 0.0f, 0.0f, 0.0f);
679
680 AdvanceableTimer timer;
681
682=== modified file 'tests/unit-tests/test_session_switcher.cpp'
683--- tests/unit-tests/test_session_switcher.cpp 2015-01-27 17:43:17 +0000
684+++ tests/unit-tests/test_session_switcher.cpp 2015-03-31 13:42:52 +0000
685@@ -98,6 +98,10 @@
686
687 std::shared_ptr<mir::frontend::Surface> get_surface(mir::frontend::SurfaceId surface) const override { return nullptr; }
688
689+ mir::frontend::BufferStreamId create_buffer_stream(mir::graphics::BufferProperties const& /*props*/) override { return {}; }
690+ std::shared_ptr<mir::frontend::BufferStream> get_buffer_stream(mir::frontend::BufferStreamId /*stream*/) const override { return nullptr; }
691+ void destroy_buffer_stream(mir::frontend::BufferStreamId /*stream*/) override {}
692+
693 std::string name() const override { return name_; }
694
695 private:

Subscribers

People subscribed via source and target branches