summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Griffiths <alan@octopull.co.uk>2015-08-04 17:20:57 +0000
committerCI Train Bot <ci-train-bot@canonical.com>2015-08-04 17:20:57 +0000
commit8f8a20be50f1806fd04dc5b236f4c59af5a2ef2f (patch)
tree1d1a3594b68d17af2836c36998cf09e10fbf2ef2
parentd057a4936153ba7c918b3ff9c9361e84edefb3d9 (diff)
parent5ba555df32d5397fed6391b4b857e608081c5b34 (diff)
Start restructuring code to use the Mir WindowManager interface for window management. (Instead of completely replacing the Shell.)
Approved by: Gerry Boland, PS Jenkins bot
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.cpp2
-rw-r--r--src/modules/Unity/Application/mirsurfaceitem.h4
-rw-r--r--src/modules/Unity/Application/mirsurfacemanager.cpp1
-rw-r--r--src/modules/Unity/Application/mirsurfacemanager.h1
-rw-r--r--src/modules/Unity/Application/sessionmanager.cpp1
-rw-r--r--src/platforms/mirserver/CMakeLists.txt2
-rw-r--r--src/platforms/mirserver/mirserver.cpp16
-rw-r--r--src/platforms/mirserver/mirserver.h3
-rw-r--r--src/platforms/mirserver/mirshell.cpp164
-rw-r--r--src/platforms/mirserver/mirshell.h47
-rw-r--r--src/platforms/mirserver/mirwindowmanager.cpp112
-rw-r--r--src/platforms/mirserver/mirwindowmanager.h73
12 files changed, 196 insertions, 230 deletions
diff --git a/src/modules/Unity/Application/mirsurfaceitem.cpp b/src/modules/Unity/Application/mirsurfaceitem.cpp
index 3c98329..53331e4 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.cpp
+++ b/src/modules/Unity/Application/mirsurfaceitem.cpp
@@ -23,7 +23,6 @@
#include "mirbuffersgtexture.h"
#include "session.h"
#include "mirsurfaceitem.h"
-#include "mirshell.h"
#include "logging.h"
#include "ubuntukeyboardinfo.h"
@@ -47,6 +46,7 @@
#include <mir/geometry/rectangle.h>
#include <mir/events/event_builders.h>
#include <mir_toolkit/event.h>
+#include <mir/shell/shell.h>
namespace mg = mir::graphics;
diff --git a/src/modules/Unity/Application/mirsurfaceitem.h b/src/modules/Unity/Application/mirsurfaceitem.h
index 049ae79..952d3cd 100644
--- a/src/modules/Unity/Application/mirsurfaceitem.h
+++ b/src/modules/Unity/Application/mirsurfaceitem.h
@@ -32,8 +32,10 @@
#include "mirsurfaceiteminterface.h"
#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.cpp b/src/modules/Unity/Application/mirsurfacemanager.cpp
index 0015153..9b32363 100644
--- a/src/modules/Unity/Application/mirsurfacemanager.cpp
+++ b/src/modules/Unity/Application/mirsurfacemanager.cpp
@@ -31,7 +31,6 @@
#include "nativeinterface.h"
#include "mirserver.h"
#include "sessionlistener.h"
-#include "mirshell.h"
#include "logging.h"
Q_LOGGING_CATEGORY(QTMIR_SURFACES, "qtmir.surfaces")
diff --git a/src/modules/Unity/Application/mirsurfacemanager.h b/src/modules/Unity/Application/mirsurfacemanager.h
index 62dca6c..83ede11 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/modules/Unity/Application/sessionmanager.cpp b/src/modules/Unity/Application/sessionmanager.cpp
index 75c4ba0..9b5e14f 100644
--- a/src/modules/Unity/Application/sessionmanager.cpp
+++ b/src/modules/Unity/Application/sessionmanager.cpp
@@ -26,7 +26,6 @@
#include "nativeinterface.h"
#include "mirserver.h"
#include "sessionlistener.h"
-#include "mirshell.h"
#include "logging.h"
#include "promptsessionlistener.h"
diff --git a/src/platforms/mirserver/CMakeLists.txt b/src/platforms/mirserver/CMakeLists.txt
index 7397ad1..36d9321 100644
--- a/src/platforms/mirserver/CMakeLists.txt
+++ b/src/platforms/mirserver/CMakeLists.txt
@@ -42,7 +42,7 @@ add_definitions(-DBYTE_ORDER=__BYTE_ORDER)
set(MIRSERVER_QPA_PLUGIN_SRC
${CMAKE_SOURCE_DIR}/src/common/debughelpers.cpp
- mirshell.cpp
+ mirwindowmanager.cpp
qteventfeeder.cpp
plugin.cpp
qmirserver.cpp
diff --git a/src/platforms/mirserver/mirserver.cpp b/src/platforms/mirserver/mirserver.cpp
index a60fb0d..f7bb74a 100644
--- a/src/platforms/mirserver/mirserver.cpp
+++ b/src/platforms/mirserver/mirserver.cpp
@@ -19,7 +19,7 @@
#include "mirserver.h"
// local
-#include "mirshell.h"
+#include "mirwindowmanager.h"
#include "mirglconfig.h"
#include "mirserverstatuslistener.h"
#include "promptsessionlistener.h"
@@ -86,17 +86,10 @@ MirServer::MirServer(int argc, char const* argv[], QObject* parent)
return std::make_shared<MirServerStatusListener>();
});
- override_the_shell([this]
+ override_the_window_manager_builder([this](mir::shell::FocusController* /*focus_controller*/)
+ -> std::shared_ptr<mir::shell::WindowManager>
{
- auto const shell = std::make_shared<MirShell>(
- 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<MirWindowManager>(the_shell_display_layout());
});
set_terminator([&](int)
@@ -151,5 +144,6 @@ PromptSessionListener *MirServer::promptSessionListener()
MirShell *MirServer::shell()
{
+ std::weak_ptr<MirShell> 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<QtEventFeeder> m_qtEventFeeder;
- std::weak_ptr<MirShell> m_shell;
};
#endif // MIRSERVER_H
diff --git a/src/platforms/mirserver/mirshell.cpp b/src/platforms/mirserver/mirshell.cpp
deleted file mode 100644
index 3b1e9c4..0000000
--- a/src/platforms/mirserver/mirshell.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright © 2015 Canonical Ltd.
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3, as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "mirshell.h"
-#include "logging.h"
-#include "tracepoints.h" // generated from tracepoints.tp
-
-#include <mir/geometry/rectangle.h>
-#include <mir/scene/session.h>
-#include <mir/scene/surface_creation_parameters.h>
-#include <mir/scene/surface.h>
-#include <mir/shell/display_layout.h>
-#include <mir/shell/window_manager.h>
-
-namespace ms = mir::scene;
-using mir::shell::AbstractShell;
-
-namespace
-{
-class NullWindowManager : public mir::shell::WindowManager
-{
-public:
- void add_session(std::shared_ptr<ms::Session> const& session) override;
-
- void remove_session(std::shared_ptr<ms::Session> const& session) override;
-
- mir::frontend::SurfaceId add_surface(
- std::shared_ptr<ms::Session> const& session,
- ms::SurfaceCreationParameters const& params,
- std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build) override;
-
- void remove_surface(
- std::shared_ptr<ms::Session> const& session,
- std::weak_ptr<ms::Surface> 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<ms::Session> const& session,
- std::shared_ptr<ms::Surface> const& surface,
- MirSurfaceAttrib attrib,
- int value) override;
-
- void modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&);
-};
-}
-
-
-MirShell::MirShell(
- const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
- const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
- const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
- const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
- AbstractShell(inputTargeter, surfaceCoordinator, sessionCoordinator, promptSessionManager,
- [](mir::shell::FocusController*) { return std::make_shared<NullWindowManager>(); }),
- m_displayLayout{displayLayout}
-{
- qCDebug(QTMIR_MIR_MESSAGES) << "MirShell::MirShell";
-}
-
-mir::frontend::SurfaceId MirShell::create_surface(const std::shared_ptr<ms::Session> &session, const ms::SurfaceCreationParameters &requestParameters)
-{
- 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;
-
- // 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;
-
- 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() << ")";
-
- tracepoint(qtmirserver, surfacePlacementEnd);
-
- return AbstractShell::create_surface(session, placedParameters);
-}
-
-void NullWindowManager::add_session(std::shared_ptr<ms::Session> const& /*session*/)
-{
-}
-
-void NullWindowManager::remove_session(std::shared_ptr<ms::Session> const& /*session*/)
-{
-}
-
-auto NullWindowManager::add_surface(
- std::shared_ptr<ms::Session> const& session,
- ms::SurfaceCreationParameters const& params,
- std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> const& session, ms::SurfaceCreationParameters const& params)> const& build)
--> mir::frontend::SurfaceId
-{
- return build(session, params);
-}
-
-void NullWindowManager::remove_surface(
- std::shared_ptr<ms::Session> const& /*session*/,
- std::weak_ptr<ms::Surface> const& /*surface*/)
-{
-}
-
-void NullWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
-{
-}
-
-void NullWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
-{
-}
-
-bool NullWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)
-{
- return false;
-}
-
-bool NullWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
-{
- return false;
-}
-
-bool NullWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
-{
- return false;
-}
-
-int NullWindowManager::set_surface_attribute(
- std::shared_ptr<ms::Session> const& /*session*/,
- std::shared_ptr<ms::Surface> const& surface,
- MirSurfaceAttrib attrib,
- int value)
-{
- return surface->configure(attrib, value);
-}
-
-void NullWindowManager::modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&)
-{
-}
diff --git a/src/platforms/mirserver/mirshell.h b/src/platforms/mirserver/mirshell.h
deleted file mode 100644
index 85c243e..0000000
--- a/src/platforms/mirserver/mirshell.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright © 2015 Canonical Ltd.
- *
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License version 3, as published by
- * the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef QPAMIRSERVER_SHELL_H
-#define QPAMIRSERVER_SHELL_H
-
-#include <mir/shell/abstract_shell.h>
-#include <QObject>
-
-namespace mir {
- namespace shell {
- class DisplayLayout;
- }
-}
-
-class MirShell : public QObject, public mir::shell::AbstractShell
-{
- Q_OBJECT
-
-public:
- MirShell(
- const std::shared_ptr<mir::shell::InputTargeter> &inputTargeter,
- const std::shared_ptr<mir::scene::SurfaceCoordinator> &surfaceCoordinator,
- const std::shared_ptr<mir::scene::SessionCoordinator> &sessionCoordinator,
- const std::shared_ptr<mir::scene::PromptSessionManager> &promptSessionManager,
- const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
-
- virtual mir::frontend::SurfaceId create_surface(const std::shared_ptr<mir::scene::Session>& session, const mir::scene::SurfaceCreationParameters &params);
-
-private:
- std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
-};
-
-#endif /* QPAMIRSERVER_SHELL_H */
diff --git a/src/platforms/mirserver/mirwindowmanager.cpp b/src/platforms/mirserver/mirwindowmanager.cpp
new file mode 100644
index 0000000..cae66d4
--- /dev/null
+++ b/src/platforms/mirserver/mirwindowmanager.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright © 2015 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License version 3, as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mirwindowmanager.h"
+#include "logging.h"
+#include "tracepoints.h" // generated from tracepoints.tp
+
+#include <mir/geometry/rectangle.h>
+#include <mir/scene/session.h>
+#include <mir/scene/surface_creation_parameters.h>
+#include <mir/scene/surface.h>
+#include <mir/shell/display_layout.h>
+
+namespace ms = mir::scene;
+
+MirWindowManager::MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout) :
+ m_displayLayout{displayLayout}
+{
+ qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::MirWindowManager";
+}
+
+void MirWindowManager::add_session(std::shared_ptr<ms::Session> const& /*session*/)
+{
+}
+
+void MirWindowManager::remove_session(std::shared_ptr<ms::Session> const& /*session*/)
+{
+}
+
+auto MirWindowManager::add_surface(
+ std::shared_ptr<ms::Session> const& session,
+ ms::SurfaceCreationParameters const& requestParameters,
+ std::function<mir::frontend::SurfaceId(std::shared_ptr<ms::Session> 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;
+
+ // 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;
+
+ qCDebug(QTMIR_MIR_MESSAGES) << "MirWindowManager::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() << ")";
+
+ tracepoint(qtmirserver, surfacePlacementEnd);
+
+ return build(session, placedParameters);
+}
+
+void MirWindowManager::remove_surface(
+ std::shared_ptr<ms::Session> const& /*session*/,
+ std::weak_ptr<ms::Surface> const& /*surface*/)
+{
+}
+
+void MirWindowManager::add_display(mir::geometry::Rectangle const& /*area*/)
+{
+}
+
+void MirWindowManager::remove_display(mir::geometry::Rectangle const& /*area*/)
+{
+}
+
+bool MirWindowManager::handle_keyboard_event(MirKeyboardEvent const* /*event*/)
+{
+ return false;
+}
+
+bool MirWindowManager::handle_touch_event(MirTouchEvent const* /*event*/)
+{
+ return false;
+}
+
+bool MirWindowManager::handle_pointer_event(MirPointerEvent const* /*event*/)
+{
+ return false;
+}
+
+int MirWindowManager::set_surface_attribute(
+ std::shared_ptr<ms::Session> const& /*session*/,
+ std::shared_ptr<ms::Surface> const& surface,
+ MirSurfaceAttrib attrib,
+ int value)
+{
+ return surface->configure(attrib, value);
+}
+
+void MirWindowManager::modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&)
+{
+ // TODO support surface modifications
+}
diff --git a/src/platforms/mirserver/mirwindowmanager.h b/src/platforms/mirserver/mirwindowmanager.h
new file mode 100644
index 0000000..0ec1839
--- /dev/null
+++ b/src/platforms/mirserver/mirwindowmanager.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright © 2015 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License version 3, as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef QPAMIRSERVER_WINDOW_MANAGER_H
+#define QPAMIRSERVER_WINDOW_MANAGER_H
+
+#include <mir/shell/window_manager.h>
+
+#include <QObject>
+
+namespace mir {
+ namespace shell {
+ class DisplayLayout;
+ }
+}
+
+class MirWindowManager : public QObject, public mir::shell::WindowManager
+{
+ Q_OBJECT
+
+public:
+
+ MirWindowManager(const std::shared_ptr<mir::shell::DisplayLayout> &displayLayout);
+
+ void add_session(std::shared_ptr<mir::scene::Session> const& session) override;
+
+ void remove_session(std::shared_ptr<mir::scene::Session> const& session) override;
+
+ mir::frontend::SurfaceId add_surface(
+ std::shared_ptr<mir::scene::Session> const& session,
+ mir::scene::SurfaceCreationParameters const& params,
+ std::function<mir::frontend::SurfaceId(std::shared_ptr<mir::scene::Session> const& session, mir::scene::SurfaceCreationParameters const& params)> const& build) override;
+
+ void remove_surface(
+ std::shared_ptr<mir::scene::Session> const& session,
+ std::weak_ptr<mir::scene::Surface> 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<mir::scene::Session> const& session,
+ std::shared_ptr<mir::scene::Surface> const& surface,
+ MirSurfaceAttrib attrib,
+ int value) override;
+
+ void modify_surface(const std::shared_ptr<mir::scene::Session>&, const std::shared_ptr<mir::scene::Surface>&, const mir::shell::SurfaceSpecification&);
+
+private:
+ std::shared_ptr<mir::shell::DisplayLayout> const m_displayLayout;
+};
+
+#endif /* QPAMIRSERVER_WINDOW_MANAGER_H */