Merge lp:~alan-griffiths/qtmir/use-WindowManager into lp:qtmir

Proposed by Alan Griffiths on 2015-07-29
Status: Merged
Approved by: Gerry Boland on 2015-07-29
Approved revision: 350
Merged at revision: 355
Proposed branch: lp:~alan-griffiths/qtmir/use-WindowManager
Merge into: lp:qtmir
Diff against target: 441 lines (+114/-148)
10 files modified
src/modules/Unity/Application/mirsurfaceitem.cpp (+1/-1)
src/modules/Unity/Application/mirsurfaceitem.h (+3/-1)
src/modules/Unity/Application/mirsurfacemanager.cpp (+0/-1)
src/modules/Unity/Application/mirsurfacemanager.h (+0/-1)
src/modules/Unity/Application/sessionmanager.cpp (+0/-1)
src/platforms/mirserver/CMakeLists.txt (+1/-1)
src/platforms/mirserver/mirserver.cpp (+5/-11)
src/platforms/mirserver/mirserver.h (+1/-2)
src/platforms/mirserver/mirwindowmanager.cpp (+63/-115)
src/platforms/mirserver/mirwindowmanager.h (+40/-14)
To merge this branch: bzr merge lp:~alan-griffiths/qtmir/use-WindowManager
Reviewer Review Type Date Requested Status
Gerry Boland 2015-07-29 Approve on 2015-07-29
PS Jenkins bot continuous-integration Approve on 2015-07-29
Review via email: mp+266219@code.launchpad.net

Commit Message

Start restructuring code to use the Mir WindowManager interface for window management. (Instead of completely replacing the Shell.)

Description of the Change

Start restructuring code to use the Mir WindowManager interface for window management. (Instead of completely replacing the Shell.)

To post a comment you must log in.
Gerry Boland (gerboland) wrote :

- Q_OBJECT
+Q_OBJECT
Qt convention has this indented.

Tested it works fine. Just fix the indent and it's good to go (note unfortunately there's a bit of a queue built up, I might have to prod you to re-merge trunk)

review: Needs Fixing
350. By Alan Griffiths on 2015-07-29

Revert unwanted layout change

Alan Griffiths (alan-griffiths) wrote :

Thanks!

Gerry Boland (gerboland) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
2--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-07-16 06:53:53 +0000
3+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-07-29 16:19:38 +0000
4@@ -23,7 +23,6 @@
5 #include "mirbuffersgtexture.h"
6 #include "session.h"
7 #include "mirsurfaceitem.h"
8-#include "mirshell.h"
9 #include "logging.h"
10 #include "ubuntukeyboardinfo.h"
11
12@@ -47,6 +46,7 @@
13 #include <mir/geometry/rectangle.h>
14 #include <mir/events/event_builders.h>
15 #include <mir_toolkit/event.h>
16+#include <mir/shell/shell.h>
17
18 namespace mg = mir::graphics;
19
20
21=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
22--- src/modules/Unity/Application/mirsurfaceitem.h 2015-05-13 17:18:45 +0000
23+++ src/modules/Unity/Application/mirsurfaceitem.h 2015-07-29 16:19:38 +0000
24@@ -33,8 +33,10 @@
25
26 #include "session_interface.h"
27
28+namespace mir { namespace shell { class Shell; }}
29+
30 class SurfaceObserver;
31-class MirShell;
32+using MirShell = mir::shell::Shell;
33
34 namespace qtmir {
35
36
37=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
38--- src/modules/Unity/Application/mirsurfacemanager.cpp 2015-03-11 10:10:49 +0000
39+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2015-07-29 16:19:38 +0000
40@@ -31,7 +31,6 @@
41 #include "nativeinterface.h"
42 #include "mirserver.h"
43 #include "sessionlistener.h"
44-#include "mirshell.h"
45 #include "logging.h"
46
47 Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")
48
49=== modified file 'src/modules/Unity/Application/mirsurfacemanager.h'
50--- src/modules/Unity/Application/mirsurfacemanager.h 2015-03-11 10:10:49 +0000
51+++ src/modules/Unity/Application/mirsurfacemanager.h 2015-07-29 16:19:38 +0000
52@@ -40,7 +40,6 @@
53 }
54
55 class MirServer;
56-class MirShell;
57
58 namespace qtmir {
59
60
61=== modified file 'src/modules/Unity/Application/sessionmanager.cpp'
62--- src/modules/Unity/Application/sessionmanager.cpp 2015-01-28 14:25:36 +0000
63+++ src/modules/Unity/Application/sessionmanager.cpp 2015-07-29 16:19:38 +0000
64@@ -26,7 +26,6 @@
65 #include "nativeinterface.h"
66 #include "mirserver.h"
67 #include "sessionlistener.h"
68-#include "mirshell.h"
69 #include "logging.h"
70 #include "promptsessionlistener.h"
71
72
73=== modified file 'src/platforms/mirserver/CMakeLists.txt'
74--- src/platforms/mirserver/CMakeLists.txt 2015-05-19 15:10:48 +0000
75+++ src/platforms/mirserver/CMakeLists.txt 2015-07-29 16:19:38 +0000
76@@ -40,7 +40,7 @@
77
78 set(MIRSERVER_QPA_PLUGIN_SRC
79 ${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
80- mirshell.cpp
81+ mirwindowmanager.cpp
82 qteventfeeder.cpp
83 plugin.cpp
84 qmirserver.cpp
85
86=== modified file 'src/platforms/mirserver/mirserver.cpp'
87--- src/platforms/mirserver/mirserver.cpp 2015-02-09 16:28:40 +0000
88+++ src/platforms/mirserver/mirserver.cpp 2015-07-29 16:19:38 +0000
89@@ -19,7 +19,7 @@
90 #include "mirserver.h"
91
92 // local
93-#include "mirshell.h"
94+#include "mirwindowmanager.h"
95 #include "mirglconfig.h"
96 #include "mirserverstatuslistener.h"
97 #include "promptsessionlistener.h"
98@@ -86,17 +86,10 @@
99 return std::make_shared<MirServerStatusListener>();
100 });
101
102- override_the_shell([this]
103+ override_the_window_manager_builder([this](mir::shell::FocusController* /*focus_controller*/)
104+ -> std::shared_ptr<mir::shell::WindowManager>
105 {
106- auto const shell = std::make_shared<MirShell>(
107- the_input_targeter(),
108- the_surface_coordinator(),
109- the_session_coordinator(),
110- the_prompt_session_manager(),
111- the_shell_display_layout());
112-
113- m_shell = shell;
114- return shell;
115+ return std::make_shared<MirWindowManager>(the_shell_display_layout());
116 });
117
118 set_terminator([&](int)
119@@ -151,5 +144,6 @@
120
121 MirShell *MirServer::shell()
122 {
123+ std::weak_ptr<MirShell> m_shell = the_shell();
124 return m_shell.lock().get();
125 }
126
127=== modified file 'src/platforms/mirserver/mirserver.h'
128--- src/platforms/mirserver/mirserver.h 2015-03-25 14:49:58 +0000
129+++ src/platforms/mirserver/mirserver.h 2015-07-29 16:19:38 +0000
130@@ -23,7 +23,7 @@
131 class QtEventFeeder;
132 class SessionListener;
133 class SessionAuthorizer;
134-class MirShell;
135+using MirShell = mir::shell::Shell;
136 class PromptSessionListener;
137
138 // We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing)
139@@ -61,7 +61,6 @@
140
141 private:
142 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;
143- std::weak_ptr<MirShell> m_shell;
144 };
145
146 #endif // MIRSERVER_H
147
148=== renamed file 'src/platforms/mirserver/mirshell.cpp' => 'src/platforms/mirserver/mirwindowmanager.cpp'
149--- src/platforms/mirserver/mirshell.cpp 2015-05-13 09:40:03 +0000
150+++ src/platforms/mirserver/mirwindowmanager.cpp 2015-07-29 16:19:38 +0000
151@@ -14,7 +14,7 @@
152 * along with this program. If not, see <http://www.gnu.org/licenses/>.
153 */
154
155-#include "mirshell.h"
156+#include "mirwindowmanager.h"
157 #include "logging.h"
158 #include "tracepoints.h" // generated from tracepoints.tp
159
160@@ -23,134 +23,81 @@
161 #include <mir/scene/surface_creation_parameters.h>
162 #include <mir/scene/surface.h>
163 #include <mir/shell/display_layout.h>
164-#include <mir/shell/window_manager.h>
165
166 namespace ms = mir::scene;
167-using mir::shell::AbstractShell;
168-
169-namespace
170-{
171-class NullWindowManager : public mir::shell::WindowManager
172-{
173-public:
174- void add_session(std::shared_ptr<ms::Session> const& session) override;
175-
176- void remove_session(std::shared_ptr<ms::Session> const& session) override;
177-
178- mir::frontend::SurfaceId add_surface(
179- std::shared_ptr<ms::Session> const& session,
180- ms::SurfaceCreationParameters const& params,
181- std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build) override;
182-
183- void remove_surface(
184- std::shared_ptr<ms::Session> const& session,
185- std::weak_ptr<ms::Surface> const& surface) override;
186-
187- void add_display(mir::geometry::Rectangle const& area) override;
188-
189- void remove_display(mir::geometry::Rectangle const& area) override;
190-
191- bool handle_keyboard_event(MirKeyboardEvent const* event) override;
192-
193- bool handle_touch_event(MirTouchEvent const* event) override;
194-
195- bool handle_pointer_event(MirPointerEvent const* event) override;
196-
197- int set_surface_attribute(
198- std::shared_ptr<ms::Session> const& session,
199- std::shared_ptr<ms::Surface> const& surface,
200- MirSurfaceAttrib attrib,
201- int value) override;
202-
203- void modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&);
204-};
205-}
206-
207-
208-MirShell::MirShell(
209- const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
210- const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
211- const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
212- const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
213- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
214- AbstractShell(inputTargeter, surfaceCoordinator, sessionCoordinator, promptSessionManager,
215- [](mir::shell::FocusController*) { return std::make_shared<NullWindowManager>(); }),
216+
217+MirWindowManager::MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
218 m_displayLayout{displayLayout}
219 {
220- qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::MirShell";
221-}
222-
223-mir::frontend::SurfaceId MirShell::create_surface(const std::shared_ptr<ms::Session> &session, const ms::SurfaceCreationParameters &requestParameters)
224-{
225- tracepoint(qtmirserver, surfacePlacementStart);
226-
227- // TODO: Callback unity8 so that it can make a decision on that.
228- // unity8 must bear in mind that the called function will be on a Mir thread though.
229- // The QPA shouldn't be deciding for itself on such things.
230-
231- ms::SurfaceCreationParameters placedParameters = requestParameters;
232-
233- // Just make it fullscreen for now
234- mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
235- m_displayLayout->size_to_output(rect);
236- placedParameters.size = rect.size;
237-
238- qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::create_surface(): size requested ("
239- << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("
240- << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";
241-
242- tracepoint(qtmirserver, surfacePlacementEnd);
243-
244- return AbstractShell::create_surface(session, placedParameters);
245-}
246-
247-void NullWindowManager::add_session(std::shared_ptr<ms::Session> const& /*session*/)
248-{
249-}
250-
251-void NullWindowManager::remove_session(std::shared_ptr<ms::Session> const& /*session*/)
252-{
253-}
254-
255-auto NullWindowManager::add_surface(
256+ qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::MirWindowManager";
257+}
258+
259+void MirWindowManager::add_session(std::shared_ptr<ms::Session> const& /*session*/)
260+{
261+}
262+
263+void MirWindowManager::remove_session(std::shared_ptr<ms::Session> const& /*session*/)
264+{
265+}
266+
267+auto MirWindowManager::add_surface(
268 std::shared_ptr<ms::Session> const& session,
269- ms::SurfaceCreationParameters const& params,
270+ ms::SurfaceCreationParameters const& requestParameters,
271 std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build)
272 -> mir::frontend::SurfaceId
273 {
274- return build(session, params);
275+ tracepoint(qtmirserver, surfacePlacementStart);
276+
277+ // TODO: Callback unity8 so that it can make a decision on that.
278+ // unity8 must bear in mind that the called function will be on a Mir thread though.
279+ // The QPA shouldn't be deciding for itself on such things.
280+
281+ ms::SurfaceCreationParameters placedParameters = requestParameters;
282+
283+ // Just make it fullscreen for now
284+ mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
285+ m_displayLayout->size_to_output(rect);
286+ placedParameters.size = rect.size;
287+
288+ qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::add_surface(): size requested ("
289+ << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("
290+ << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";
291+
292+ tracepoint(qtmirserver, surfacePlacementEnd);
293+
294+ return build(session, placedParameters);
295 }
296
297-void NullWindowManager::remove_surface(
298+void MirWindowManager::remove_surface(
299 std::shared_ptr<ms::Session> const& /*session*/,
300 std::weak_ptr<ms::Surface> const& /*surface*/)
301 {
302 }
303
304-void NullWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
305-{
306-}
307-
308-void NullWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
309-{
310-}
311-
312-bool NullWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)
313-{
314- return false;
315-}
316-
317-bool NullWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
318-{
319- return false;
320-}
321-
322-bool NullWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
323-{
324- return false;
325-}
326-
327-int NullWindowManager::set_surface_attribute(
328+void MirWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
329+{
330+}
331+
332+void MirWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
333+{
334+}
335+
336+bool MirWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)
337+{
338+ return false;
339+}
340+
341+bool MirWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
342+{
343+ return false;
344+}
345+
346+bool MirWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
347+{
348+ return false;
349+}
350+
351+int MirWindowManager::set_surface_attribute(
352 std::shared_ptr<ms::Session> const& /*session*/,
353 std::shared_ptr<ms::Surface> const& surface,
354 MirSurfaceAttrib attrib,
355@@ -159,6 +106,7 @@
356 return surface->configure(attrib, value);
357 }
358
359-void NullWindowManager::modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&)
360+void MirWindowManager::modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&)
361 {
362+ // TODO support surface modifications
363 }
364
365=== renamed file 'src/platforms/mirserver/mirshell.h' => 'src/platforms/mirserver/mirwindowmanager.h'
366--- src/platforms/mirserver/mirshell.h 2015-03-11 10:10:49 +0000
367+++ src/platforms/mirserver/mirwindowmanager.h 2015-07-29 16:19:38 +0000
368@@ -14,10 +14,11 @@
369 * along with this program. If not, see <http://www.gnu.org/licenses/>.
370 */
371
372-#ifndef QPAMIRSERVER_SHELL_H
373-#define QPAMIRSERVER_SHELL_H
374-
375-#include <mir/shell/abstract_shell.h>
376+#ifndef QPAMIRSERVER_WINDOW_MANAGER_H
377+#define QPAMIRSERVER_WINDOW_MANAGER_H
378+
379+#include <mir/shell/window_manager.h>
380+
381 #include <QObject>
382
383 namespace mir {
384@@ -26,22 +27,47 @@
385 }
386 }
387
388-class MirShell : public QObject, public mir::shell::AbstractShell
389+class MirWindowManager : public QObject, public mir::shell::WindowManager
390 {
391 Q_OBJECT
392
393 public:
394- MirShell(
395- const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
396- const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
397- const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
398- const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
399- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
400-
401- virtual mir::frontend::SurfaceId create_surface(const std::shared_ptr<mir::scene::Session>& session, const mir::scene::SurfaceCreationParameters &params);
402+
403+ MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
404+
405+ void add_session(std::shared_ptr<mir::scene::Session> const& session) override;
406+
407+ void remove_session(std::shared_ptr<mir::scene::Session> const& session) override;
408+
409+ mir::frontend::SurfaceId add_surface(
410+ std::shared_ptr<mir::scene::Session> const& session,
411+ mir::scene::SurfaceCreationParameters const& params,
412+ std::function<mir::frontend::SurfaceId(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params)> const& build) override;
413+
414+ void remove_surface(
415+ std::shared_ptr<mir::scene::Session> const& session,
416+ std::weak_ptr<mir::scene::Surface> const& surface) override;
417+
418+ void add_display(mir::geometry::Rectangle const& area) override;
419+
420+ void remove_display(mir::geometry::Rectangle const& area) override;
421+
422+ bool handle_keyboard_event(MirKeyboardEvent const* event) override;
423+
424+ bool handle_touch_event(MirTouchEvent const* event) override;
425+
426+ bool handle_pointer_event(MirPointerEvent const* event) override;
427+
428+ int set_surface_attribute(
429+ std::shared_ptr<mir::scene::Session> const& session,
430+ std::shared_ptr<mir::scene::Surface> const& surface,
431+ MirSurfaceAttrib attrib,
432+ int value) override;
433+
434+ void modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&);
435
436 private:
437 std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
438 };
439
440-#endif /* QPAMIRSERVER_SHELL_H */
441+#endif /* QPAMIRSERVER_WINDOW_MANAGER_H */

Subscribers

People subscribed via source and target branches