Merge lp:~alan-griffiths/qtmir/spike-using-WindowManager into lp:qtmir/devel-mir-next

Proposed by Alan Griffiths
Status: Work in progress
Proposed branch: lp:~alan-griffiths/qtmir/spike-using-WindowManager
Merge into: lp:qtmir/devel-mir-next
Prerequisite: lp:~mir-team/qtmir/devel-mir-next-update
Diff against target: 777 lines (+201/-238)
14 files modified
src/modules/Unity/Application/application_manager.h (+1/-1)
src/modules/Unity/Application/mirsurfaceitem.cpp (+2/-2)
src/modules/Unity/Application/mirsurfaceitem.h (+4/-3)
src/modules/Unity/Application/mirsurfacemanager.cpp (+8/-9)
src/modules/Unity/Application/mirsurfacemanager.h (+5/-5)
src/modules/Unity/Application/sessionmanager.cpp (+0/-1)
src/platforms/mirserver/CMakeLists.txt (+1/-1)
src/platforms/mirserver/mirserver.cpp (+32/-50)
src/platforms/mirserver/mirserver.h (+8/-7)
src/platforms/mirserver/mirwindowmanager.cpp (+98/-140)
src/platforms/mirserver/mirwindowmanager.h (+33/-14)
src/platforms/mirserver/nativeinterface.cpp (+7/-2)
src/platforms/mirserver/nativeinterface.h (+1/-1)
tests/modules/common/qtmir_test.h (+1/-2)
To merge this branch: bzr merge lp:~alan-griffiths/qtmir/spike-using-WindowManager
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Pending
Mir development team Pending
Review via email: mp+254907@code.launchpad.net

This proposal supersedes a proposal from 2015-03-26.

Commit message

Switch from subclassing mir::shell::AbstractShell to implementing mir::shell::WindowManager

Description of the change

Switch from subclassing mir::shell::AbstractShell to implementing mir::shell::WindowManager

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
278. By Daniel van Vugt

Merge lp:~mir-team/qtmir/devel-mir-next-update

279. By Alan Griffiths

Mir 0.13.0 fixes

280. By Alan Griffiths

Workaround API that uses references to opaque types

281. By Alan Griffiths

libmircommon-dev dependency should be versioned

282. By Alan Griffiths

merge lp:~alan-griffiths/qtmir/spike-using-WindowManager

283. By Alan Griffiths

Very basic version of MirWindowManager::modify_surface()

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

* Did you perform an exploratory manual test run of the code change and any related functionality?

Works on manta with Mir 0.13.0 stack

 * Did CI run pass?

Not until 0.13.0 is in archive

Unmerged revisions

283. By Alan Griffiths

Very basic version of MirWindowManager::modify_surface()

282. By Alan Griffiths

merge lp:~alan-griffiths/qtmir/spike-using-WindowManager

281. By Alan Griffiths

libmircommon-dev dependency should be versioned

280. By Alan Griffiths

Workaround API that uses references to opaque types

279. By Alan Griffiths

Mir 0.13.0 fixes

278. By Daniel van Vugt

Merge lp:~mir-team/qtmir/devel-mir-next-update

277. By Daniel van Vugt

Update mock headers so they can build again, following racarr's
cursor BufferStream changes.

276. By Daniel van Vugt

Migrate to MirEvent 2.1 API, coming in Mir 0.13

275. By Daniel van Vugt

Link to libmirclient too. That's where all mir_* client (and input
functions) now correctly reside.

274. By Daniel van Vugt

Merge branch lp:~mir-team/qtmir/compatibility-with-mir-API-changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/Application/application_manager.h'
--- src/modules/Unity/Application/application_manager.h 2015-01-09 11:23:34 +0000
+++ src/modules/Unity/Application/application_manager.h 2015-05-06 15:47:57 +0000
@@ -151,7 +151,7 @@
151151
152 Application* findApplicationWithPromptSession(const mir::scene::PromptSession* promptSession);152 Application* findApplicationWithPromptSession(const mir::scene::PromptSession* promptSession);
153153
154 QSharedPointer<MirServer> m_mirServer;154 const QSharedPointer<MirServer> m_mirServer;
155155
156 QList<Application*> m_applications;156 QList<Application*> m_applications;
157 Application* m_focusedApplication;157 Application* m_focusedApplication;
158158
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.cpp'
--- src/modules/Unity/Application/mirsurfaceitem.cpp 2015-03-27 07:29:14 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.cpp 2015-05-06 15:47:57 +0000
@@ -23,7 +23,6 @@
23#include "mirbuffersgtexture.h"23#include "mirbuffersgtexture.h"
24#include "session.h"24#include "session.h"
25#include "mirsurfaceitem.h"25#include "mirsurfaceitem.h"
26#include "mirshell.h"
27#include "logging.h"26#include "logging.h"
28#include "ubuntukeyboardinfo.h"27#include "ubuntukeyboardinfo.h"
2928
@@ -46,6 +45,7 @@
46// Mir45// Mir
47#include <mir/geometry/rectangle.h>46#include <mir/geometry/rectangle.h>
48#include <mir/events/event_builders.h>47#include <mir/events/event_builders.h>
48#include <mir/shell/shell.h>
49#include <mir_toolkit/event.h>49#include <mir_toolkit/event.h>
5050
51namespace mg = mir::graphics;51namespace mg = mir::graphics;
@@ -187,7 +187,7 @@
187187
188MirSurfaceItem::MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,188MirSurfaceItem::MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
189 SessionInterface* session,189 SessionInterface* session,
190 MirShell *shell,190 mir::shell::Shell *shell,
191 std::shared_ptr<SurfaceObserver> observer,191 std::shared_ptr<SurfaceObserver> observer,
192 QQuickItem *parent)192 QQuickItem *parent)
193 : QQuickItem(parent)193 : QQuickItem(parent)
194194
=== modified file 'src/modules/Unity/Application/mirsurfaceitem.h'
--- src/modules/Unity/Application/mirsurfaceitem.h 2015-02-20 15:52:17 +0000
+++ src/modules/Unity/Application/mirsurfaceitem.h 2015-05-06 15:47:57 +0000
@@ -33,8 +33,9 @@
3333
34#include "session_interface.h"34#include "session_interface.h"
3535
36namespace mir { namespace shell { class Shell; } }
37
36class SurfaceObserver;38class SurfaceObserver;
37class MirShell;
3839
39namespace qtmir {40namespace qtmir {
4041
@@ -58,7 +59,7 @@
58public:59public:
59 explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,60 explicit MirSurfaceItem(std::shared_ptr<mir::scene::Surface> surface,
60 SessionInterface* session,61 SessionInterface* session,
61 MirShell *shell,62 mir::shell::Shell *shell,
62 std::shared_ptr<SurfaceObserver> observer,63 std::shared_ptr<SurfaceObserver> observer,
63 QQuickItem *parent = 0);64 QQuickItem *parent = 0);
64 ~MirSurfaceItem();65 ~MirSurfaceItem();
@@ -179,7 +180,7 @@
179180
180 std::shared_ptr<mir::scene::Surface> m_surface;181 std::shared_ptr<mir::scene::Surface> m_surface;
181 QPointer<SessionInterface> m_session;182 QPointer<SessionInterface> m_session;
182 MirShell *const m_shell;183 mir::shell::Shell *const m_shell;
183 bool m_firstFrameDrawn;184 bool m_firstFrameDrawn;
184 bool m_live;185 bool m_live;
185 Qt::ScreenOrientation m_orientation; //FIXME - have to save the state as Mir has no getter for it (bug:1357429)186 Qt::ScreenOrientation m_orientation; //FIXME - have to save the state as Mir has no getter for it (bug:1357429)
186187
=== modified file 'src/modules/Unity/Application/mirsurfacemanager.cpp'
--- src/modules/Unity/Application/mirsurfacemanager.cpp 2015-02-06 09:47:21 +0000
+++ src/modules/Unity/Application/mirsurfacemanager.cpp 2015-05-06 15:47:57 +0000
@@ -31,7 +31,7 @@
31#include "nativeinterface.h"31#include "nativeinterface.h"
32#include "mirserver.h"32#include "mirserver.h"
33#include "sessionlistener.h"33#include "sessionlistener.h"
34#include "mirshell.h"34#include "mirwindowmanager.h"
35#include "logging.h"35#include "logging.h"
3636
37Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")37Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")
@@ -51,9 +51,9 @@
51 manager, &MirSurfaceManager::onSessionDestroyingSurface);51 manager, &MirSurfaceManager::onSessionDestroyingSurface);
52}52}
5353
54void connectToShell(MirSurfaceManager *manager, MirShell *shell)54void connectToWindowManager(MirSurfaceManager *manager, MirWindowManager *windowManager)
55{55{
56 QObject::connect(shell, &MirShell::surfaceAttributeChanged,56 QObject::connect(windowManager, &MirWindowManager::surfaceAttributeChanged,
57 manager, &MirSurfaceManager::onSurfaceAttributeChanged);57 manager, &MirSurfaceManager::onSurfaceAttributeChanged);
58}58}
5959
@@ -70,23 +70,22 @@
70 }70 }
7171
72 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));72 SessionListener *sessionListener = static_cast<SessionListener*>(nativeInterface->nativeResourceForIntegration("SessionListener"));
73 MirShell *shell = static_cast<MirShell*>(nativeInterface->nativeResourceForIntegration("Shell"));73 MirWindowManager *window_manager = static_cast<MirWindowManager*>(nativeInterface->nativeResourceForIntegration("WindowManager"));
74 mir::shell::Shell *const shell = static_cast<mir::shell::Shell*>(nativeInterface->nativeResourceForIntegration("mir::shell::Shell"));
7475
75 the_surface_manager = new MirSurfaceManager(nativeInterface->m_mirServer, shell, SessionManager::singleton());76 the_surface_manager = new MirSurfaceManager(shell, SessionManager::singleton());
7677
77 connectToSessionListener(the_surface_manager, sessionListener);78 connectToSessionListener(the_surface_manager, sessionListener);
78 connectToShell(the_surface_manager, shell);79 connectToWindowManager(the_surface_manager, window_manager);
79 }80 }
80 return the_surface_manager;81 return the_surface_manager;
81}82}
8283
83MirSurfaceManager::MirSurfaceManager(84MirSurfaceManager::MirSurfaceManager(
84 const QSharedPointer<MirServer>& mirServer,85 mir::shell::Shell *shell,
85 MirShell *shell,
86 SessionManager* sessionManager,86 SessionManager* sessionManager,
87 QObject *parent)87 QObject *parent)
88 : MirSurfaceItemModel(parent)88 : MirSurfaceItemModel(parent)
89 , m_mirServer(mirServer)
90 , m_shell(shell)89 , m_shell(shell)
91 , m_sessionManager(sessionManager)90 , m_sessionManager(sessionManager)
92{91{
9392
=== modified file 'src/modules/Unity/Application/mirsurfacemanager.h'
--- src/modules/Unity/Application/mirsurfacemanager.h 2015-02-06 09:47:21 +0000
+++ src/modules/Unity/Application/mirsurfacemanager.h 2015-05-06 15:47:57 +0000
@@ -37,10 +37,12 @@
37 class Session;37 class Session;
38 class PromptSession;38 class PromptSession;
39 }39 }
40 namespace shell {
41 class Shell;
42 }
40}43}
4144
42class MirServer;45class MirServer;
43class MirShell;
4446
45namespace qtmir {47namespace qtmir {
4648
@@ -54,8 +56,7 @@
5456
55public:57public:
56 explicit MirSurfaceManager(58 explicit MirSurfaceManager(
57 const QSharedPointer<MirServer>& mirServer,59 mir::shell::Shell *shell,
58 MirShell *shell,
59 SessionManager* sessionManager,60 SessionManager* sessionManager,
60 QObject *parent = 061 QObject *parent = 0
61 );62 );
@@ -81,8 +82,7 @@
81 QMutex m_mutex;82 QMutex m_mutex;
8283
83private:84private:
84 QSharedPointer<MirServer> m_mirServer;85 mir::shell::Shell *const m_shell;
85 MirShell *const m_shell;
86 SessionManager* m_sessionManager;86 SessionManager* m_sessionManager;
87 static MirSurfaceManager *the_surface_manager;87 static MirSurfaceManager *the_surface_manager;
88};88};
8989
=== modified file 'src/modules/Unity/Application/sessionmanager.cpp'
--- src/modules/Unity/Application/sessionmanager.cpp 2015-01-28 14:25:36 +0000
+++ src/modules/Unity/Application/sessionmanager.cpp 2015-05-06 15:47:57 +0000
@@ -26,7 +26,6 @@
26#include "nativeinterface.h"26#include "nativeinterface.h"
27#include "mirserver.h"27#include "mirserver.h"
28#include "sessionlistener.h"28#include "sessionlistener.h"
29#include "mirshell.h"
30#include "logging.h"29#include "logging.h"
31#include "promptsessionlistener.h"30#include "promptsessionlistener.h"
3231
3332
=== modified file 'src/platforms/mirserver/CMakeLists.txt'
--- src/platforms/mirserver/CMakeLists.txt 2015-04-01 11:59:05 +0000
+++ src/platforms/mirserver/CMakeLists.txt 2015-05-06 15:47:57 +0000
@@ -37,7 +37,7 @@
3737
38set(MIRSERVER_QPA_PLUGIN_SRC38set(MIRSERVER_QPA_PLUGIN_SRC
39 ../../common/debughelpers.cpp39 ../../common/debughelpers.cpp
40 mirshell.cpp40 mirwindowmanager.cpp
41 qteventfeeder.cpp41 qteventfeeder.cpp
42 plugin.cpp42 plugin.cpp
43 qmirserver.cpp43 qmirserver.cpp
4444
=== modified file 'src/platforms/mirserver/mirserver.cpp'
--- src/platforms/mirserver/mirserver.cpp 2015-02-09 16:28:40 +0000
+++ src/platforms/mirserver/mirserver.cpp 2015-05-06 15:47:57 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013-2014 Canonical, Ltd.2 * Copyright (C) 2013-2015 Canonical, Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it under4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by5 * the terms of the GNU Lesser General Public License version 3, as published by
@@ -19,7 +19,7 @@
19#include "mirserver.h"19#include "mirserver.h"
2020
21// local21// local
22#include "mirshell.h"22#include "mirwindowmanager.h"
23#include "mirglconfig.h"23#include "mirglconfig.h"
24#include "mirserverstatuslistener.h"24#include "mirserverstatuslistener.h"
25#include "promptsessionlistener.h"25#include "promptsessionlistener.h"
@@ -51,19 +51,25 @@
51 set_command_line_handler(&ignore_unparsed_arguments);51 set_command_line_handler(&ignore_unparsed_arguments);
52 set_command_line(argc, argv);52 set_command_line(argc, argv);
5353
54 override_the_session_listener([]54 override_the_session_listener([this]
55 {55 {
56 return std::make_shared<SessionListener>();56 const auto result = std::make_shared<SessionListener>();
57 });57 m_sessionListener = result;
5858 return result;
59 override_the_prompt_session_listener([]59 });
60 {60
61 return std::make_shared<PromptSessionListener>();61 override_the_prompt_session_listener([this]
62 });62 {
6363 const auto result = std::make_shared<PromptSessionListener>();
64 override_the_session_authorizer([]64 m_promptSessionListener = result;
65 {65 return result;
66 return std::make_shared<SessionAuthorizer>();66 });
67
68 override_the_session_authorizer([this]
69 {
70 const auto result = std::make_shared<SessionAuthorizer>();
71 m_sessionAuthorizer = result;
72 return result;
67 });73 });
6874
69 override_the_compositor([]75 override_the_compositor([]
@@ -86,17 +92,11 @@
86 return std::make_shared<MirServerStatusListener>();92 return std::make_shared<MirServerStatusListener>();
87 });93 });
8894
89 override_the_shell([this]95 override_the_window_manager_builder([this](mir::shell::FocusController*)
90 {96 {
91 auto const shell = std::make_shared<MirShell>(97 const auto result = std::make_shared<MirWindowManager>(the_shell_display_layout());
92 the_input_targeter(),98 m_windowManager = result;
93 the_surface_coordinator(),99 return result;
94 the_session_coordinator(),
95 the_prompt_session_manager(),
96 the_shell_display_layout());
97
98 m_shell = shell;
99 return shell;
100 });100 });
101101
102 set_terminator([&](int)102 set_terminator([&](int)
@@ -113,43 +113,25 @@
113113
114/************************************ Shell side ************************************/114/************************************ Shell side ************************************/
115115
116//116// Note about the"weak_ptr<X>.lock().get();" constructs used in the functions below.
117// Note about the117// An empty weak_ptr<> means that Mir is not holding the pointer so we return nullptr.
118// if (sharedPtr.unique()) return 0;
119// constructs used in the functions below.
120// The rationale is that if when you do
121// the_session_authorizer()
122// get a pointer that is unique means that Mir is not
123// holding the pointer and thus when we return from the
124// sessionAuthorizer()
125// scope the unique pointer will be destroyed so we return 0
126//
127118
128SessionAuthorizer *MirServer::sessionAuthorizer()119SessionAuthorizer *MirServer::sessionAuthorizer()
129{120{
130 auto sharedPtr = the_session_authorizer();121 return m_sessionAuthorizer.lock().get();
131 if (sharedPtr.unique()) return 0;
132
133 return static_cast<SessionAuthorizer*>(sharedPtr.get());
134}122}
135123
136SessionListener *MirServer::sessionListener()124SessionListener *MirServer::sessionListener()
137{125{
138 auto sharedPtr = the_session_listener();126 return m_sessionListener.lock().get();
139 if (sharedPtr.unique()) return 0;
140
141 return static_cast<SessionListener*>(sharedPtr.get());
142}127}
143128
144PromptSessionListener *MirServer::promptSessionListener()129PromptSessionListener *MirServer::promptSessionListener()
145{130{
146 auto sharedPtr = the_prompt_session_listener();131 return m_promptSessionListener.lock().get();
147 if (sharedPtr.unique()) return 0;
148
149 return static_cast<PromptSessionListener*>(sharedPtr.get());
150}132}
151133
152MirShell *MirServer::shell()134MirWindowManager *MirServer::windowManager()
153{135{
154 return m_shell.lock().get();136 return m_windowManager.lock().get();
155}137}
156138
=== modified file 'src/platforms/mirserver/mirserver.h'
--- src/platforms/mirserver/mirserver.h 2015-03-25 14:49:58 +0000
+++ src/platforms/mirserver/mirserver.h 2015-05-06 15:47:57 +0000
@@ -23,7 +23,7 @@
23class QtEventFeeder;23class QtEventFeeder;
24class SessionListener;24class SessionListener;
25class SessionAuthorizer;25class SessionAuthorizer;
26class MirShell;26class MirWindowManager;
27class PromptSessionListener;27class PromptSessionListener;
2828
29// We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing)29// We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing)
@@ -34,7 +34,7 @@
3434
35 Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT)35 Q_PROPERTY(SessionAuthorizer* sessionAuthorizer READ sessionAuthorizer CONSTANT)
36 Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT)36 Q_PROPERTY(SessionListener* sessionListener READ sessionListener CONSTANT)
37 Q_PROPERTY(MirShell* shell READ shell CONSTANT)37 Q_PROPERTY(MirWindowManager* windowManager READ windowManager CONSTANT)
38 Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT)38 Q_PROPERTY(PromptSessionListener* promptSessionListener READ promptSessionListener CONSTANT)
3939
40public:40public:
@@ -47,21 +47,22 @@
47 using mir::Server::the_display;47 using mir::Server::the_display;
48 using mir::Server::the_gl_config;48 using mir::Server::the_gl_config;
49 using mir::Server::the_main_loop;49 using mir::Server::the_main_loop;
50 using mir::Server::the_prompt_session_listener;
51 using mir::Server::the_prompt_session_manager;50 using mir::Server::the_prompt_session_manager;
52 using mir::Server::the_session_authorizer;51 using mir::Server::the_shell;
53 using mir::Server::the_session_listener;
5452
55 /* qt specific */53 /* qt specific */
56 // getters54 // getters
57 SessionAuthorizer *sessionAuthorizer();55 SessionAuthorizer *sessionAuthorizer();
58 SessionListener *sessionListener();56 SessionListener *sessionListener();
59 PromptSessionListener *promptSessionListener();57 PromptSessionListener *promptSessionListener();
60 MirShell *shell();58 MirWindowManager *windowManager();
6159
62private:60private:
63 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;61 std::shared_ptr<QtEventFeeder> m_qtEventFeeder;
64 std::weak_ptr<MirShell> m_shell;62 std::weak_ptr<SessionAuthorizer> m_sessionAuthorizer;
63 std::weak_ptr<SessionListener> m_sessionListener;
64 std::weak_ptr<PromptSessionListener> m_promptSessionListener;
65 std::weak_ptr<MirWindowManager> m_windowManager;
65};66};
6667
67#endif // MIRSERVER_H68#endif // MIRSERVER_H
6869
=== renamed file 'src/platforms/mirserver/mirshell.cpp' => 'src/platforms/mirserver/mirwindowmanager.cpp'
--- src/platforms/mirserver/mirshell.cpp 2015-05-01 13:21:00 +0000
+++ src/platforms/mirserver/mirwindowmanager.cpp 2015-05-06 15:47:57 +0000
@@ -14,163 +14,121 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#include "mirshell.h"17#include "mirwindowmanager.h"
18#include "logging.h"18#include "logging.h"
19#include "tracepoints.h" // generated from tracepoints.tp19#include "tracepoints.h" // generated from tracepoints.tp
2020
21#include <mir/geometry/rectangle.h>21#include <mir/geometry/rectangle.h>
22#include <mir/scene/session.h>22#include <mir/scene/session.h>
23#include <mir/scene/surface.h>
23#include <mir/scene/surface_creation_parameters.h>24#include <mir/scene/surface_creation_parameters.h>
24#include <mir/scene/surface.h>
25#include <mir/shell/display_layout.h>25#include <mir/shell/display_layout.h>
26#include <mir/shell/window_manager.h>
2726
28namespace ms = mir::scene;27namespace ms = mir::scene;
29using mir::shell::AbstractShell;28
3029MirWindowManager::MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
31namespace30 m_displayLayout{displayLayout}
32{31{
33class NullWindowManager : public mir::shell::WindowManager32 qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::MirWindowManager";
34{33}
35public:34
36 void add_session(std::shared_ptr<ms::Session> const& session) override;35auto MirWindowManager::add_surface(
3736 std::shared_ptr<mir::scene::Session> const& session,
38 void remove_session(std::shared_ptr<ms::Session> const& session) override;37 mir::scene::SurfaceCreationParameters const& requestParameters,
3938 std::function<mir::frontend::SurfaceId(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params)> const& build)
40 mir::frontend::SurfaceId add_surface(39-> mir::frontend::SurfaceId
41 std::shared_ptr<ms::Session> const& session,
42 ms::SurfaceCreationParameters const& params,
43 std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build) override;
44
45 void remove_surface(
46 std::shared_ptr<ms::Session> const& session,
47 std::weak_ptr<ms::Surface> const& surface) override;
48
49 void add_display(mir::geometry::Rectangle const& area) override;
50
51 void remove_display(mir::geometry::Rectangle const& area) override;
52
53 bool handle_keyboard_event(MirKeyboardEvent const* event) override;
54
55 bool handle_touch_event(MirTouchEvent const* event) override;
56
57 bool handle_pointer_event(MirPointerEvent const* event) override;
58
59 int set_surface_attribute(
60 std::shared_ptr<ms::Session> const& session,
61 std::shared_ptr<ms::Surface> const& surface,
62 MirSurfaceAttrib attrib,
63 int value) override;
64
65 void modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&);
66};
67}
68
69
70MirShell::MirShell(
71 const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
72 const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
73 const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
74 const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
75 const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
76 AbstractShell(inputTargeter, surfaceCoordinator, sessionCoordinator, promptSessionManager,
77 [](mir::shell::FocusController*) { return std::make_shared<NullWindowManager>(); }),
78 m_displayLayout{displayLayout}
79{
80 qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::MirShell";
81}
82
83mir::frontend::SurfaceId MirShell::create_surface(const std::shared_ptr<ms::Session> &session, const ms::SurfaceCreationParameters &requestParameters)
84{40{
85 tracepoint(qtmirserver, surfacePlacementStart);41 tracepoint(qtmirserver, surfacePlacementStart);
8642
87 // TODO: Callback unity8 so that it can make a decision on that.43 // TODO: Callback unity8 so that it can make a decision on that.
88 // unity8 must bear in mind that the called function will be on a Mir thread though.44 // unity8 must bear in mind that the called function will be on a Mir thread though.
89 // The QPA shouldn't be deciding for itself on such things.45 // The QPA shouldn't be deciding for itself on such things.
9046
91 ms::SurfaceCreationParameters placedParameters = requestParameters;47 ms::SurfaceCreationParameters placedParameters = requestParameters;
9248
93 // Just make it fullscreen for now49 // Just make it fullscreen for now
94 mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};50 mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size};
95 m_displayLayout->size_to_output(rect);51 m_displayLayout->size_to_output(rect);
96 placedParameters.size = rect.size;52 placedParameters.size = rect.size;
9753
98 qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::create_surface(): size requested ("54 qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::add_surface(): size requested ("
99 << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("55 << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed ("
100 << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";56 << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")";
10157
102 tracepoint(qtmirserver, surfacePlacementEnd);58 tracepoint(qtmirserver, surfacePlacementEnd);
10359
104 return AbstractShell::create_surface(session, placedParameters);60 return build(session, placedParameters);
105}61}
10662
107int MirShell::set_surface_attribute(63void MirWindowManager::modify_surface(
108 const std::shared_ptr<mir::scene::Session> &session,64 std::shared_ptr<mir::scene::Session> const& /*session*/,
109 const std::shared_ptr<mir::scene::Surface> &surface,65 std::shared_ptr<mir::scene::Surface> const& surface,
66 mir::shell::SurfaceSpecification const& modifications)
67{
68 // TODO ought to wire up some window management logic around here
69 // Here's a very basic implementation
70
71 if (modifications.name.is_set())
72 surface->rename(modifications.name.value());
73
74 if (modifications.width.is_set() || modifications.height.is_set())
75 {
76 auto new_size = surface->size();
77
78 if (modifications.width.is_set())
79 new_size.width = modifications.width.value();
80
81 if (modifications.height.is_set())
82 new_size.height = modifications.height.value();
83
84 surface->resize(new_size);
85 }
86}
87
88int MirWindowManager::set_surface_attribute(
89 std::shared_ptr<mir::scene::Session> const& /*session*/,
90 std::shared_ptr<mir::scene::Surface> const& surface,
110 MirSurfaceAttrib attrib,91 MirSurfaceAttrib attrib,
111 int value)92 int value)
112{93{
113 auto const result = AbstractShell::set_surface_attribute(session, surface, attrib, value);94 const auto result = surface->configure(attrib, value);
114 Q_EMIT surfaceAttributeChanged(surface.get(), attrib, result);95 Q_EMIT surfaceAttributeChanged(surface.get(), attrib, result);
115
116 return result;96 return result;
117}97}
11898
119void NullWindowManager::add_session(std::shared_ptr<ms::Session> const& /*session*/)99void MirWindowManager::add_session(std::shared_ptr<mir::scene::Session> const& /*session*/)
120{100{
121}101}
122102
123void NullWindowManager::remove_session(std::shared_ptr<ms::Session> const& /*session*/)103void MirWindowManager::remove_session(std::shared_ptr<mir::scene::Session> const& /*session*/)
124{104{
125}105}
126106
127auto NullWindowManager::add_surface(107void MirWindowManager::remove_surface(
128 std::shared_ptr<ms::Session> const& session,108 std::shared_ptr<mir::scene::Session> const& /*session*/,
129 ms::SurfaceCreationParameters const& params,109 std::weak_ptr<mir::scene::Surface> const& /*surface*/)
130 std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build)110{
131-> mir::frontend::SurfaceId111}
132{112
133 return build(session, params);113void MirWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
134}114{
135115}
136void NullWindowManager::remove_surface(116
137 std::shared_ptr<ms::Session> const& /*session*/,117void MirWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
138 std::weak_ptr<ms::Surface> const& /*surface*/)118{
139{119}
140}120
141121bool MirWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)
142void NullWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)122{
143{123 return false;
144}124}
145125
146void NullWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)126bool MirWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
147{127{
148}128 return false;
149129}
150bool NullWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)130
151{131bool MirWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
152 return false;132{
153}133 return false;
154
155bool NullWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
156{
157 return false;
158}
159
160bool NullWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
161{
162 return false;
163}
164
165int NullWindowManager::set_surface_attribute(
166 std::shared_ptr<ms::Session> const& /*session*/,
167 std::shared_ptr<ms::Surface> const& surface,
168 MirSurfaceAttrib attrib,
169 int value)
170{
171 return surface->configure(attrib, value);
172}
173
174void NullWindowManager::modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&)
175{
176}134}
177135
=== renamed file 'src/platforms/mirserver/mirshell.h' => 'src/platforms/mirserver/mirwindowmanager.h'
--- src/platforms/mirserver/mirshell.h 2015-02-04 17:17:53 +0000
+++ src/platforms/mirserver/mirwindowmanager.h 2015-05-06 15:47:57 +0000
@@ -14,10 +14,10 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#ifndef QPAMIRSERVER_SHELL_H17#ifndef MIRWINDOWMANAGER_H
18#define QPAMIRSERVER_SHELL_H18#define MIRWINDOWMANAGER_H
1919
20#include <mir/shell/abstract_shell.h>20#include <mir/shell/window_manager.h>
21#include <QObject>21#include <QObject>
2222
23namespace mir {23namespace mir {
@@ -26,26 +26,45 @@
26 }26 }
27}27}
2828
29class MirShell : public QObject, public mir::shell::AbstractShell29class MirWindowManager : public QObject, public mir::shell::WindowManager
30{30{
31 Q_OBJECT31 Q_OBJECT
3232
33public:33public:
34 MirShell(34 explicit MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
35 const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
36 const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
37 const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
38 const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
39 const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
4035
41 virtual mir::frontend::SurfaceId create_surface(const std::shared_ptr<mir::scene::Session>& session, const mir::scene::SurfaceCreationParameters &params);36 auto add_surface(
37 std::shared_ptr<mir::scene::Session> const& session,
38 mir::scene::SurfaceCreationParameters const& params,
39 std::function<mir::frontend::SurfaceId(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params)> const& build)
40 -> mir::frontend::SurfaceId override;
4241
43 int set_surface_attribute(42 int set_surface_attribute(
44 const std::shared_ptr<mir::scene::Session> &session,43 std::shared_ptr<mir::scene::Session> const& session,
45 const std::shared_ptr<mir::scene::Surface> &surface,44 std::shared_ptr<mir::scene::Surface> const& surface,
46 MirSurfaceAttrib attrib,45 MirSurfaceAttrib attrib,
47 int value) override;46 int value) override;
4847
48 void add_session(std::shared_ptr<mir::scene::Session> const& session) override;
49
50 void remove_session(std::shared_ptr<mir::scene::Session> const& session) override;
51
52 void remove_surface(
53 std::shared_ptr<mir::scene::Session> const& session,
54 std::weak_ptr<mir::scene::Surface> const& surface) override;
55
56 void modify_surface(std::shared_ptr<mir::scene::Session> const&, std::shared_ptr<mir::scene::Surface> const&, mir::shell::SurfaceSpecification const&);
57
58 void add_display(mir::geometry::Rectangle const& area) override;
59
60 void remove_display(mir::geometry::Rectangle const& area) override;
61
62 bool handle_keyboard_event(MirKeyboardEvent const* event) override;
63
64 bool handle_touch_event(MirTouchEvent const* event) override;
65
66 bool handle_pointer_event(MirPointerEvent const* event) override;
67
49Q_SIGNALS:68Q_SIGNALS:
50 void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int);69 void surfaceAttributeChanged(mir::scene::Surface const*, const MirSurfaceAttrib, const int);
5170
@@ -53,4 +72,4 @@
53 std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;72 std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
54};73};
5574
56#endif /* QPAMIRSERVER_SHELL_H */75#endif /* MIRWINDOWMANAGER_H */
5776
=== modified file 'src/platforms/mirserver/nativeinterface.cpp'
--- src/platforms/mirserver/nativeinterface.cpp 2015-01-28 14:25:36 +0000
+++ src/platforms/mirserver/nativeinterface.cpp 2015-05-06 15:47:57 +0000
@@ -29,12 +29,17 @@
2929
30 if (resource == "SessionAuthorizer")30 if (resource == "SessionAuthorizer")
31 result = m_mirServer->sessionAuthorizer();31 result = m_mirServer->sessionAuthorizer();
32 else if (resource == "Shell")32 else if (resource == "WindowManager")
33 result = m_mirServer->shell();33 result = m_mirServer->windowManager();
34 else if (resource == "SessionListener")34 else if (resource == "SessionListener")
35 result = m_mirServer->sessionListener();35 result = m_mirServer->sessionListener();
36 else if (resource == "PromptSessionListener")36 else if (resource == "PromptSessionListener")
37 result = m_mirServer->promptSessionListener();37 result = m_mirServer->promptSessionListener();
38 else if (resource == "mir::shell::Shell")
39 {
40 const std::weak_ptr<mir::shell::Shell> shell{m_mirServer->the_shell()};
41 result = shell.lock().get();
42 }
3843
39 return result;44 return result;
40}45}
4146
=== modified file 'src/platforms/mirserver/nativeinterface.h'
--- src/platforms/mirserver/nativeinterface.h 2014-12-01 11:05:01 +0000
+++ src/platforms/mirserver/nativeinterface.h 2015-05-06 15:47:57 +0000
@@ -33,7 +33,7 @@
3333
34 virtual void *nativeResourceForIntegration(const QByteArray &resource);34 virtual void *nativeResourceForIntegration(const QByteArray &resource);
3535
36 QSharedPointer<MirServer> m_mirServer;36 const QSharedPointer<MirServer> m_mirServer;
37};37};
3838
39#endif // NATIVEINTEGRATION_H39#endif // NATIVEINTEGRATION_H
4040
=== modified file 'tests/modules/common/qtmir_test.h'
--- tests/modules/common/qtmir_test.h 2015-02-06 09:47:21 +0000
+++ tests/modules/common/qtmir_test.h 2015-05-06 15:47:57 +0000
@@ -109,7 +109,6 @@
109 &applicationManager,109 &applicationManager,
110 }110 }
111 , surfaceManager{111 , surfaceManager{
112 mirServer,
113 mirShell,112 mirShell,
114 &sessionManager113 &sessionManager
115 }114 }
@@ -150,7 +149,7 @@
150 testing::NiceMock<testing::MockDesktopFileReaderFactory> desktopFileReaderFactory;149 testing::NiceMock<testing::MockDesktopFileReaderFactory> desktopFileReaderFactory;
151 testing::NiceMock<testing::MockSharedWakelock> sharedWakelock;150 testing::NiceMock<testing::MockSharedWakelock> sharedWakelock;
152 QSharedPointer<FakeMirServer> mirServer;151 QSharedPointer<FakeMirServer> mirServer;
153 MirShell *mirShell{nullptr};152 mir::shell::Shell *mirShell{nullptr};
154 QSharedPointer<TaskController> taskController;153 QSharedPointer<TaskController> taskController;
155 ApplicationManager applicationManager;154 ApplicationManager applicationManager;
156 SessionManager sessionManager;155 SessionManager sessionManager;

Subscribers

People subscribed via source and target branches