From df40292fa0eec457f47949f9a9f65f4d23430fa6 Mon Sep 17 00:00:00 2001 From: Alan Griffiths Date: Wed, 24 Jun 2015 15:12:08 +0100 Subject: Hack out MirShell and move functionality to WindowManager --- src/modules/Unity/Application/mirsurfaceitem.cpp | 1 + src/modules/Unity/Application/mirsurfaceitem.h | 4 +- src/modules/Unity/Application/mirsurfacemanager.h | 1 - src/platforms/mirserver/mirserver.cpp | 14 +-- src/platforms/mirserver/mirserver.h | 3 +- src/platforms/mirserver/mirshell.cpp | 118 ++++++---------------- src/platforms/mirserver/mirshell.h | 48 +++++++-- 7 files changed, 79 insertions(+), 110 deletions(-) diff --git a/src/modules/Unity/Application/mirsurfaceitem.cpp b/src/modules/Unity/Application/mirsurfaceitem.cpp index c8d895a..bb2582f 100644 --- a/src/modules/Unity/Application/mirsurfaceitem.cpp +++ b/src/modules/Unity/Application/mirsurfaceitem.cpp @@ -47,6 +47,7 @@ #include #include #include +#include namespace mg = mir::graphics; diff --git a/src/modules/Unity/Application/mirsurfaceitem.h b/src/modules/Unity/Application/mirsurfaceitem.h index fd3ab45..aae1a94 100644 --- a/src/modules/Unity/Application/mirsurfaceitem.h +++ b/src/modules/Unity/Application/mirsurfaceitem.h @@ -33,8 +33,10 @@ #include "session_interface.h" +namespace mir { namespace shell { class Shell; }} + class SurfaceObserver; -class MirShell; +using MirShell = mir::shell::Shell; namespace qtmir { diff --git a/src/modules/Unity/Application/mirsurfacemanager.h b/src/modules/Unity/Application/mirsurfacemanager.h index b9e5533..8f5080a 100644 --- a/src/modules/Unity/Application/mirsurfacemanager.h +++ b/src/modules/Unity/Application/mirsurfacemanager.h @@ -40,7 +40,6 @@ namespace mir { } class MirServer; -class MirShell; namespace qtmir { diff --git a/src/platforms/mirserver/mirserver.cpp b/src/platforms/mirserver/mirserver.cpp index a60fb0d..e90296a 100644 --- a/src/platforms/mirserver/mirserver.cpp +++ b/src/platforms/mirserver/mirserver.cpp @@ -86,17 +86,10 @@ MirServer::MirServer(int argc, char const* argv[], QObject* parent) return std::make_shared(); }); - override_the_shell([this] + override_the_window_manager_builder([this](mir::shell::FocusController* /*focus_controller*/) + -> std::shared_ptr { - auto const shell = std::make_shared( - the_input_targeter(), - the_surface_coordinator(), - the_session_coordinator(), - the_prompt_session_manager(), - the_shell_display_layout()); - - m_shell = shell; - return shell; + return std::make_shared(the_shell_display_layout()); }); set_terminator([&](int) @@ -151,5 +144,6 @@ PromptSessionListener *MirServer::promptSessionListener() MirShell *MirServer::shell() { + std::weak_ptr m_shell = the_shell(); return m_shell.lock().get(); } diff --git a/src/platforms/mirserver/mirserver.h b/src/platforms/mirserver/mirserver.h index b4b8dc2..3956f9c 100644 --- a/src/platforms/mirserver/mirserver.h +++ b/src/platforms/mirserver/mirserver.h @@ -23,7 +23,7 @@ class QtEventFeeder; class SessionListener; class SessionAuthorizer; -class MirShell; +using MirShell = mir::shell::Shell; class PromptSessionListener; // We use virtual inheritance of mir::Server to facilitate derived classes (e.g. testing) @@ -61,7 +61,6 @@ public: private: std::shared_ptr m_qtEventFeeder; - std::weak_ptr m_shell; }; #endif // MIRSERVER_H diff --git a/src/platforms/mirserver/mirshell.cpp b/src/platforms/mirserver/mirshell.cpp index 3b1e9c4..d62c76c 100644 --- a/src/platforms/mirserver/mirshell.cpp +++ b/src/platforms/mirserver/mirshell.cpp @@ -26,131 +26,79 @@ #include namespace ms = mir::scene; -using mir::shell::AbstractShell; -namespace -{ -class NullWindowManager : public mir::shell::WindowManager +QtMirWindowManager::QtMirWindowManager(const std::shared_ptr &displayLayout) : + m_displayLayout{displayLayout} { -public: - void add_session(std::shared_ptr const& session) override; - - void remove_session(std::shared_ptr const& session) override; - - mir::frontend::SurfaceId add_surface( - std::shared_ptr const& session, - ms::SurfaceCreationParameters const& params, - std::function const& session, ms::SurfaceCreationParameters const& params)> const& build) override; - - void remove_surface( - std::shared_ptr const& session, - std::weak_ptr const& surface) override; - - void add_display(mir::geometry::Rectangle const& area) override; - - void remove_display(mir::geometry::Rectangle const& area) override; - - bool handle_keyboard_event(MirKeyboardEvent const* event) override; - - bool handle_touch_event(MirTouchEvent const* event) override; - - bool handle_pointer_event(MirPointerEvent const* event) override; - - int set_surface_attribute( - std::shared_ptr const& session, - std::shared_ptr const& surface, - MirSurfaceAttrib attrib, - int value) override; - - void modify_surface(const std::shared_ptr&, const std::shared_ptr&, const mir::shell::SurfaceSpecification&); -}; + qCDebug(QTMIR_MIR_MESSAGES) << "QtMirWindowManager::QtMirWindowManager"; } +void QtMirWindowManager::add_session(std::shared_ptr const& /*session*/) +{ +} -MirShell::MirShell( - const std::shared_ptr &inputTargeter, - const std::shared_ptr &surfaceCoordinator, - const std::shared_ptr &sessionCoordinator, - const std::shared_ptr &promptSessionManager, - const std::shared_ptr &displayLayout) : - AbstractShell(inputTargeter, surfaceCoordinator, sessionCoordinator, promptSessionManager, - [](mir::shell::FocusController*) { return std::make_shared(); }), - m_displayLayout{displayLayout} +void QtMirWindowManager::remove_session(std::shared_ptr const& /*session*/) { - qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::MirShell"; } -mir::frontend::SurfaceId MirShell::create_surface(const std::shared_ptr &session, const ms::SurfaceCreationParameters &requestParameters) +auto QtMirWindowManager::add_surface( + std::shared_ptr const& session, + ms::SurfaceCreationParameters const& requestParameters, + std::function const& session, ms::SurfaceCreationParameters const& params)> const& build) +-> mir::frontend::SurfaceId { tracepoint(qtmirserver, surfacePlacementStart); - // TODO: Callback unity8 so that it can make a decision on that. - // unity8 must bear in mind that the called function will be on a Mir thread though. - // The QPA shouldn't be deciding for itself on such things. - - ms::SurfaceCreationParameters placedParameters = requestParameters; + // TODO: Callback unity8 so that it can make a decision on that. + // unity8 must bear in mind that the called function will be on a Mir thread though. + // The QPA shouldn't be deciding for itself on such things. - // Just make it fullscreen for now - mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size}; - m_displayLayout->size_to_output(rect); - placedParameters.size = rect.size; + ms::SurfaceCreationParameters placedParameters = requestParameters; - qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::create_surface(): size requested (" - << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed (" - << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")"; + // Just make it fullscreen for now + mir::geometry::Rectangle rect{requestParameters.top_left, requestParameters.size}; + m_displayLayout->size_to_output(rect); + placedParameters.size = rect.size; - tracepoint(qtmirserver, surfacePlacementEnd); + qCDebug(QTMIR_MIR_MESSAGES) << "QtMirWindowManager::add_surface(): size requested (" + << requestParameters.size.width.as_int() << "," << requestParameters.size.height.as_int() << ") and placed (" + << placedParameters.size.width.as_int() << "," << placedParameters.size.height.as_int() << ")"; - return AbstractShell::create_surface(session, placedParameters); -} - -void NullWindowManager::add_session(std::shared_ptr const& /*session*/) -{ -} + tracepoint(qtmirserver, surfacePlacementEnd); -void NullWindowManager::remove_session(std::shared_ptr const& /*session*/) -{ -} - -auto NullWindowManager::add_surface( - std::shared_ptr const& session, - ms::SurfaceCreationParameters const& params, - std::function const& session, ms::SurfaceCreationParameters const& params)> const& build) --> mir::frontend::SurfaceId -{ - return build(session, params); + return build(session, placedParameters); } -void NullWindowManager::remove_surface( +void QtMirWindowManager::remove_surface( std::shared_ptr const& /*session*/, std::weak_ptr const& /*surface*/) { } -void NullWindowManager::add_display(mir::geometry::Rectangle const& /*area*/) +void QtMirWindowManager::add_display(mir::geometry::Rectangle const& /*area*/) { } -void NullWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/) +void QtMirWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/) { } -bool NullWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/) +bool QtMirWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/) { return false; } -bool NullWindowManager::handle_touch_event(MirTouchEvent const* /*event*/) +bool QtMirWindowManager::handle_touch_event(MirTouchEvent const* /*event*/) { return false; } -bool NullWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/) +bool QtMirWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/) { return false; } -int NullWindowManager::set_surface_attribute( +int QtMirWindowManager::set_surface_attribute( std::shared_ptr const& /*session*/, std::shared_ptr const& surface, MirSurfaceAttrib attrib, @@ -159,6 +107,6 @@ int NullWindowManager::set_surface_attribute( return surface->configure(attrib, value); } -void NullWindowManager::modify_surface(const std::shared_ptr&, const std::shared_ptr&, const mir::shell::SurfaceSpecification&) +void QtMirWindowManager::modify_surface(const std::shared_ptr&, const std::shared_ptr&, const mir::shell::SurfaceSpecification&) { } diff --git a/src/platforms/mirserver/mirshell.h b/src/platforms/mirserver/mirshell.h index 85c243e..a467bbe 100644 --- a/src/platforms/mirserver/mirshell.h +++ b/src/platforms/mirserver/mirshell.h @@ -17,7 +17,8 @@ #ifndef QPAMIRSERVER_SHELL_H #define QPAMIRSERVER_SHELL_H -#include +#include + #include namespace mir { @@ -26,19 +27,44 @@ namespace mir { } } -class MirShell : public QObject, public mir::shell::AbstractShell +class QtMirWindowManager : public QObject, public mir::shell::WindowManager { - Q_OBJECT +Q_OBJECT public: - MirShell( - const std::shared_ptr &inputTargeter, - const std::shared_ptr &surfaceCoordinator, - const std::shared_ptr &sessionCoordinator, - const std::shared_ptr &promptSessionManager, - const std::shared_ptr &displayLayout); - - virtual mir::frontend::SurfaceId create_surface(const std::shared_ptr& session, const mir::scene::SurfaceCreationParameters ¶ms); + + QtMirWindowManager(const std::shared_ptr &displayLayout); + + void add_session(std::shared_ptr const& session) override; + + void remove_session(std::shared_ptr const& session) override; + + mir::frontend::SurfaceId add_surface( + std::shared_ptr const& session, + mir::scene::SurfaceCreationParameters const& params, + std::function const& session, mir::scene::SurfaceCreationParameters const& params)> const& build) override; + + void remove_surface( + std::shared_ptr const& session, + std::weak_ptr const& surface) override; + + void add_display(mir::geometry::Rectangle const& area) override; + + void remove_display(mir::geometry::Rectangle const& area) override; + + bool handle_keyboard_event(MirKeyboardEvent const* event) override; + + bool handle_touch_event(MirTouchEvent const* event) override; + + bool handle_pointer_event(MirPointerEvent const* event) override; + + int set_surface_attribute( + std::shared_ptr const& session, + std::shared_ptr const& surface, + MirSurfaceAttrib attrib, + int value) override; + + void modify_surface(const std::shared_ptr&, const std::shared_ptr&, const mir::shell::SurfaceSpecification&); private: std::shared_ptr const m_displayLayout; -- cgit v1.2.3