From 7c7c8982b23a5cb6ce30f4dbbc6b4fd9d7add306 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Fri, 18 Nov 2016 13:07:39 +0100 Subject: [PATCH] Add initial bits of window management abstraction --- src/CMakeLists.txt | 3 ++ src/anbox/cmds/run.cpp | 4 +- src/anbox/wm/default_platform_policy.cpp | 39 ++++++++++++++++ src/anbox/wm/default_platform_policy.h | 33 +++++++++++++ src/anbox/wm/manager.cpp | 3 +- src/anbox/wm/manager.h | 6 ++- src/anbox/wm/platform_policy.cpp | 25 ++++++++++ src/anbox/wm/platform_policy.h | 38 +++++++++++++++ src/anbox/wm/window.cpp | 38 +++++++++++++++ src/anbox/wm/window.h | 59 ++++++++++++++++++++++++ 10 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 src/anbox/wm/default_platform_policy.cpp create mode 100644 src/anbox/wm/default_platform_policy.h create mode 100644 src/anbox/wm/platform_policy.cpp create mode 100644 src/anbox/wm/platform_policy.h create mode 100644 src/anbox/wm/window.cpp create mode 100644 src/anbox/wm/window.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a4aaed..d49897d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -134,6 +134,9 @@ set(SOURCES anbox/wm/task.cpp anbox/wm/manager.cpp anbox/wm/window_state.cpp + anbox/wm/window.cpp + anbox/wm/platform_policy.cpp + anbox/wm/default_platform_policy.cpp anbox/input/manager.cpp anbox/input/device.cpp diff --git a/src/anbox/cmds/run.cpp b/src/anbox/cmds/run.cpp index e65ce28..9ec3e0b 100644 --- a/src/anbox/cmds/run.cpp +++ b/src/anbox/cmds/run.cpp @@ -37,6 +37,7 @@ #include "anbox/dbus/skeleton/service.h" #include "anbox/container/client.h" #include "anbox/wm/manager.h" +#include "anbox/wm/default_platform_policy.h" #include @@ -89,7 +90,8 @@ anbox::cmds::Run::Run(const BusFactory& bus_factory) auto input_manager = std::make_shared(rt); - auto window_manager = std::make_shared(); + auto policy = std::make_shared(); + auto window_manager = std::make_shared(policy); auto window_creator = std::make_shared(input_manager); auto renderer = std::make_shared(window_creator); diff --git a/src/anbox/wm/default_platform_policy.cpp b/src/anbox/wm/default_platform_policy.cpp new file mode 100644 index 0000000..9c6cbc9 --- /dev/null +++ b/src/anbox/wm/default_platform_policy.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/wm/default_platform_policy.h" +#include "anbox/wm/window.h" + +namespace { +class Window : public anbox::wm::Window { +public: + Window(const anbox::wm::WindowState &state) : + anbox::wm::Window(state) { + } +}; +} + +namespace anbox { +namespace wm { +DefaultPlatformPolicy::DefaultPlatformPolicy() { +} + +std::shared_ptr DefaultPlatformPolicy::create_window(const WindowState &state) { + return std::make_shared<::Window>(state); +} +} // namespace wm +} // namespace anbox diff --git a/src/anbox/wm/default_platform_policy.h b/src/anbox/wm/default_platform_policy.h new file mode 100644 index 0000000..e9af49c --- /dev/null +++ b/src/anbox/wm/default_platform_policy.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_WM_DEFAULT_PLATFORM_POLICY_H_ +#define ANBOX_WM_DEFAULT_PLATFORM_POLICY_H_ + +#include "anbox/wm/platform_policy.h" + +namespace anbox { +namespace wm { +class DefaultPlatformPolicy : public PlatformPolicy { +public: + DefaultPlatformPolicy(); + std::shared_ptr create_window(const WindowState &state) override; +}; +} // namespace wm +} // namespace anbox + +#endif diff --git a/src/anbox/wm/manager.cpp b/src/anbox/wm/manager.cpp index 9e40895..8ef817a 100644 --- a/src/anbox/wm/manager.cpp +++ b/src/anbox/wm/manager.cpp @@ -20,7 +20,8 @@ namespace anbox { namespace wm { -Manager::Manager() { +Manager::Manager(const std::shared_ptr &platform) : + platform_(platform) { } Manager::~Manager() { diff --git a/src/anbox/wm/manager.h b/src/anbox/wm/manager.h index d882321..ebaf4e9 100644 --- a/src/anbox/wm/manager.h +++ b/src/anbox/wm/manager.h @@ -20,17 +20,21 @@ #include "anbox/wm/window_state.h" +#include + namespace anbox { namespace wm { +class PlatformPolicy; class Manager { public: - Manager(); + Manager(const std::shared_ptr &platform); ~Manager(); void apply_window_state_update(const WindowState::List &updated, const WindowState::List &removed); private: + std::shared_ptr platform_; }; } // namespace wm } // namespace anbox diff --git a/src/anbox/wm/platform_policy.cpp b/src/anbox/wm/platform_policy.cpp new file mode 100644 index 0000000..922acf5 --- /dev/null +++ b/src/anbox/wm/platform_policy.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/wm/platform_policy.h" + +namespace anbox { +namespace wm { +PlatformPolicy::~PlatformPolicy() { +} +} // namespace wm +} // namespace anbox diff --git a/src/anbox/wm/platform_policy.h b/src/anbox/wm/platform_policy.h new file mode 100644 index 0000000..7270ae0 --- /dev/null +++ b/src/anbox/wm/platform_policy.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_WM_PLATFORM_POLICY_H_ +#define ANBOX_WM_PLATFORM_POLICY_H_ + +#include "anbox/graphics/rect.h" +#include "anbox/wm/window_state.h" + +#include + +namespace anbox { +namespace wm { +class Window; +class PlatformPolicy { +public: + virtual ~PlatformPolicy(); + + virtual std::shared_ptr create_window(const WindowState &state) = 0; +}; +} // namespace wm +} // namespace anbox + +#endif diff --git a/src/anbox/wm/window.cpp b/src/anbox/wm/window.cpp new file mode 100644 index 0000000..f8b8307 --- /dev/null +++ b/src/anbox/wm/window.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#include "anbox/wm/window.h" + +namespace anbox { +namespace wm { +Window::Window(const WindowState &state) : + state_(state) { +} + +Window::~Window() { +} + +void Window::update_state(const WindowState &state) { + state_ = state; +} + +void Window::render_layer(const Layer &layer) { + (void) layer; +} +} // namespace wm +} // namespace anbox + diff --git a/src/anbox/wm/window.h b/src/anbox/wm/window.h new file mode 100644 index 0000000..687aefd --- /dev/null +++ b/src/anbox/wm/window.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 Simon Fels + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + */ + +#ifndef ANBOX_WM_WINDOW_H_ +#define ANBOX_WM_WINDOW_H_ + +#include "anbox/wm/window_state.h" + +#include +#include + +namespace anbox { +namespace wm { +// FIXME(morphis): move this somewhere else once we have the integration +// with the emugl layer. +class Layer { +public: + graphics::Rect frame() const { return frame_; } + +private: + graphics::Rect frame_; +}; + +class Window { +public: + typedef std::vector List; + + Window(const WindowState &state); + virtual ~Window(); + + void update_state(const WindowState &state); + + // Render a layer into the window. The layer itself includes all + // necessary information for correct rendering. + void render_layer(const Layer &layer); + + WindowState state() const; + +private: + WindowState state_; +}; +} // namespace wm +} // namespace anbox + +#endif