From db7d18d01c5b4b86c67ba46d0680aad8838dbb9e Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Mon, 19 Jun 2017 21:20:47 +0200 Subject: [PATCH 1/3] Introduce platform concept instead of having different policies --- src/CMakeLists.txt | 5 +++-- src/anbox/audio/server.cpp | 6 +++--- src/anbox/audio/server.h | 6 +++--- src/anbox/bridge/platform_api_skeleton.cpp | 10 +++++----- src/anbox/bridge/platform_api_skeleton.h | 6 +++--- src/anbox/cmds/session_manager.cpp | 14 +++++++------- .../platform/{policy.cpp => base_platform.cpp} | 17 +++++++++++++---- .../platform/{policy.h => base_platform.h} | 5 +++-- .../{default_policy.cpp => null/platform.cpp} | 14 +++++++------- .../{default_policy.h => null/platform.h} | 10 +++++----- src/anbox/ubuntu/platform_policy.h | 4 ++-- src/anbox/wm/multi_window_manager.cpp | 8 ++++---- src/anbox/wm/multi_window_manager.h | 6 +++--- src/anbox/wm/single_window_manager.cpp | 8 ++++---- src/anbox/wm/single_window_manager.h | 6 +++--- tests/anbox/graphics/layer_composer_tests.cpp | 18 +++++++++--------- 16 files changed, 77 insertions(+), 66 deletions(-) rename src/anbox/platform/{policy.cpp => base_platform.cpp} (67%) rename src/anbox/platform/{policy.h => base_platform.h} (92%) rename src/anbox/platform/{default_policy.cpp => null/platform.cpp} (78%) rename src/anbox/platform/{default_policy.h => null/platform.h} (86%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3fb6a7e..3dc5f09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -164,8 +164,9 @@ set(SOURCES anbox/wm/window_state.cpp anbox/wm/window.cpp - anbox/platform/policy.cpp - anbox/platform/default_policy.cpp + anbox/platform/base_platform.cpp + + anbox/platform/null/platform.cpp anbox/input/manager.cpp anbox/input/device.cpp diff --git a/src/anbox/audio/server.cpp b/src/anbox/audio/server.cpp index ee8e731..02f3415 100644 --- a/src/anbox/audio/server.cpp +++ b/src/anbox/audio/server.cpp @@ -47,8 +47,8 @@ class AudioForwarder : public anbox::network::MessageProcessor { namespace anbox { namespace audio { -Server::Server(const std::shared_ptr& rt, const std::shared_ptr &platform_policy) : - platform_policy_(platform_policy), +Server::Server(const std::shared_ptr& rt, const std::shared_ptr &platform) : + platform_(platform), socket_file_(utils::string_format("%s/anbox_audio", SystemConfiguration::instance().socket_dir())), connector_(std::make_shared( socket_file_, rt, @@ -81,7 +81,7 @@ void Server::create_connection_for(std::shared_ptr(platform_policy_->create_audio_sink()); + processor = std::make_shared(platform_->create_audio_sink()); break; case ClientInfo::Type::Recording: break; diff --git a/src/anbox/audio/server.h b/src/anbox/audio/server.h index 6a49764..34ce8f9 100644 --- a/src/anbox/audio/server.h +++ b/src/anbox/audio/server.h @@ -22,7 +22,7 @@ #include "anbox/audio/client_info.h" #include "anbox/network/socket_messenger.h" #include "anbox/network/socket_connection.h" -#include "anbox/platform/policy.h" +#include "anbox/platform/base_platform.h" #include @@ -33,7 +33,7 @@ class PublishedSocketConnector; namespace audio { class Server { public: - Server(const std::shared_ptr& rt, const std::shared_ptr &platform_policy); + Server(const std::shared_ptr& rt, const std::shared_ptr &platform); ~Server(); std::string socket_file() const { return socket_file_; } @@ -44,7 +44,7 @@ class Server { int next_id(); - std::shared_ptr platform_policy_; + std::shared_ptr platform_; std::string socket_file_; std::shared_ptr connector_; std::shared_ptr> const connections_; diff --git a/src/anbox/bridge/platform_api_skeleton.cpp b/src/anbox/bridge/platform_api_skeleton.cpp index 10fe227..b445748 100644 --- a/src/anbox/bridge/platform_api_skeleton.cpp +++ b/src/anbox/bridge/platform_api_skeleton.cpp @@ -17,7 +17,7 @@ #include "anbox/bridge/platform_api_skeleton.h" #include "anbox/application/database.h" -#include "anbox/platform/policy.h" +#include "anbox/platform/base_platform.h" #include "anbox/wm/manager.h" #include "anbox/wm/window_state.h" #include "anbox/logger.h" @@ -32,11 +32,11 @@ namespace anbox { namespace bridge { PlatformApiSkeleton::PlatformApiSkeleton( const std::shared_ptr &pending_calls, - const std::shared_ptr &platform_policy, + const std::shared_ptr &platform, const std::shared_ptr &window_manager, const std::shared_ptr &app_db) : pending_calls_(pending_calls), - platform_policy_(platform_policy), + platform_(platform), window_manager_(window_manager), app_db_(app_db) {} @@ -49,7 +49,7 @@ void PlatformApiSkeleton::set_clipboard_data(anbox::protobuf::bridge::ClipboardD (void)response; if (request->has_text()) - platform_policy_->set_clipboard_data(platform::Policy::ClipboardData{request->text()}); + platform_->set_clipboard_data(platform::BasePlatform::ClipboardData{request->text()}); done->Run(); } @@ -59,7 +59,7 @@ void PlatformApiSkeleton::get_clipboard_data(anbox::protobuf::rpc::Void const *r google::protobuf::Closure *done) { (void)request; - auto data = platform_policy_->get_clipboard_data(); + auto data = platform_->get_clipboard_data(); if (!data.text.empty()) response->set_text(data.text); diff --git a/src/anbox/bridge/platform_api_skeleton.h b/src/anbox/bridge/platform_api_skeleton.h index 843416e..02fe1d6 100644 --- a/src/anbox/bridge/platform_api_skeleton.h +++ b/src/anbox/bridge/platform_api_skeleton.h @@ -40,7 +40,7 @@ class ApplicationListUpdateEvent; } // namespace bridge } // namespace protobuf namespace platform { -class Policy; +class BasePlatform; } // namespace platform namespace rpc { class PendingCallCache; @@ -56,7 +56,7 @@ class PlatformApiSkeleton { public: PlatformApiSkeleton( const std::shared_ptr &pending_calls, - const std::shared_ptr &platform_policy, + const std::shared_ptr &platform, const std::shared_ptr &window_manager, const std::shared_ptr &app_db); virtual ~PlatformApiSkeleton(); @@ -79,7 +79,7 @@ class PlatformApiSkeleton { private: std::shared_ptr pending_calls_; - std::shared_ptr platform_policy_; + std::shared_ptr platform_; std::shared_ptr window_manager_; std::shared_ptr app_db_; std::function boot_finished_handler_; diff --git a/src/anbox/cmds/session_manager.cpp b/src/anbox/cmds/session_manager.cpp index 731de0a..4a8f028 100644 --- a/src/anbox/cmds/session_manager.cpp +++ b/src/anbox/cmds/session_manager.cpp @@ -176,25 +176,25 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) if (single_window_) display_frame = window_size_; - auto policy = std::make_shared(input_manager, display_frame, single_window_); + auto platform = std::make_shared(input_manager, display_frame, single_window_); auto app_db = std::make_shared(); std::shared_ptr window_manager; if (single_window_) - window_manager = std::make_shared(policy, display_frame, app_db); + window_manager = std::make_shared(platform, display_frame, app_db); else - window_manager = std::make_shared(policy, android_api_stub, app_db); + window_manager = std::make_shared(platform, android_api_stub, app_db); auto gl_server = std::make_shared( graphics::GLRendererServer::Config{gles_driver_, single_window_}, window_manager); - policy->set_window_manager(window_manager); - policy->set_renderer(gl_server->renderer()); + platform->set_window_manager(window_manager); + platform->set_renderer(gl_server->renderer()); window_manager->setup(); - auto audio_server = std::make_shared(rt, policy); + auto audio_server = std::make_shared(rt, platform); const auto socket_path = SystemConfiguration::instance().socket_dir(); @@ -219,7 +219,7 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) android_api_stub->set_rpc_channel(rpc_channel); auto server = std::make_shared( - pending_calls, policy, window_manager, app_db); + pending_calls, platform, window_manager, app_db); server->register_boot_finished_handler([&]() { DEBUG("Android successfully booted"); android_api_stub->ready().set(true); diff --git a/src/anbox/platform/policy.cpp b/src/anbox/platform/base_platform.cpp similarity index 67% rename from src/anbox/platform/policy.cpp rename to src/anbox/platform/base_platform.cpp index 8cc41ff..26c49c0 100644 --- a/src/anbox/platform/policy.cpp +++ b/src/anbox/platform/base_platform.cpp @@ -15,10 +15,19 @@ * */ -#include "anbox/platform/policy.h" +#include "anbox/platform/base_platform.h" +#include "anbox/platform/null/platform.h" +#include "anbox/logger.h" namespace anbox { namespace platform { -Policy::~Policy() {} -} // namespace wm -} // namespace anbox +std::shared_ptr create(const std::string &name) { + if (name.empty()) + return std::make_shared(); + + WARNING("Unsupported platfrom '%s'", name); + + return nullptr; +} +} // namespace platform +} // namespace anbox diff --git a/src/anbox/platform/policy.h b/src/anbox/platform/base_platform.h similarity index 92% rename from src/anbox/platform/policy.h rename to src/anbox/platform/base_platform.h index 59aefca..a73f5b3 100644 --- a/src/anbox/platform/policy.h +++ b/src/anbox/platform/base_platform.h @@ -32,9 +32,9 @@ namespace wm { class Window; } // namespace wm namespace platform { -class Policy { +class BasePlatform { public: - virtual ~Policy(); + virtual ~BasePlatform() {} virtual std::shared_ptr create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) = 0; @@ -48,6 +48,7 @@ class Policy { virtual std::shared_ptr create_audio_sink() = 0; virtual std::shared_ptr create_audio_source() = 0; }; +std::shared_ptr create(const std::string &name = ""); } // namespace wm } // namespace anbox diff --git a/src/anbox/platform/default_policy.cpp b/src/anbox/platform/null/platform.cpp similarity index 78% rename from src/anbox/platform/default_policy.cpp rename to src/anbox/platform/null/platform.cpp index e335157..e49b1fe 100644 --- a/src/anbox/platform/default_policy.cpp +++ b/src/anbox/platform/null/platform.cpp @@ -15,7 +15,7 @@ * */ -#include "anbox/platform/default_policy.h" +#include "anbox/platform/null/platform.h" #include "anbox/wm/window.h" #include "anbox/logger.h" @@ -31,29 +31,29 @@ class NullWindow : public anbox::wm::Window { namespace anbox { namespace platform { -DefaultPolicy::DefaultPolicy() {} +NullPlatform::NullPlatform() {} -std::shared_ptr DefaultPolicy::create_window( +std::shared_ptr NullPlatform::create_window( const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) { return std::make_shared<::NullWindow>(task, frame, title); } -void DefaultPolicy::set_clipboard_data(const ClipboardData &data) { +void NullPlatform::set_clipboard_data(const ClipboardData &data) { (void)data; ERROR("Not implemented"); } -DefaultPolicy::ClipboardData DefaultPolicy::get_clipboard_data() { +NullPlatform::ClipboardData NullPlatform::get_clipboard_data() { ERROR("Not implemented"); return ClipboardData{}; } -std::shared_ptr DefaultPolicy::create_audio_sink() { +std::shared_ptr NullPlatform::create_audio_sink() { ERROR("Not implemented"); return nullptr; } -std::shared_ptr DefaultPolicy::create_audio_source() { +std::shared_ptr NullPlatform::create_audio_source() { ERROR("Not implemented"); return nullptr; } diff --git a/src/anbox/platform/default_policy.h b/src/anbox/platform/null/platform.h similarity index 86% rename from src/anbox/platform/default_policy.h rename to src/anbox/platform/null/platform.h index 68dfdc7..7210e61 100644 --- a/src/anbox/platform/default_policy.h +++ b/src/anbox/platform/null/platform.h @@ -15,16 +15,16 @@ * */ -#ifndef ANBOX_PLATFORM_DEFAULT_POLICY_H_ -#define ANBOX_PLATFORM_DEFAULT_POLICY_H_ +#ifndef ANBOX_PLATFORM_NULL_PLATFORM_H_ +#define ANBOX_PLATFORM_NULL_PLATFORM_H_ -#include "anbox/platform/policy.h" +#include "anbox/platform/base_platform.h" namespace anbox { namespace platform { -class DefaultPolicy : public Policy { +class NullPlatform : public BasePlatform { public: - DefaultPolicy(); + NullPlatform(); std::shared_ptr create_window( const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, diff --git a/src/anbox/ubuntu/platform_policy.h b/src/anbox/ubuntu/platform_policy.h index 62d69f5..ea1b403 100644 --- a/src/anbox/ubuntu/platform_policy.h +++ b/src/anbox/ubuntu/platform_policy.h @@ -19,7 +19,7 @@ #define ANBOX_UBUNTU_PLATFORM_POLICY_H_ #include "anbox/ubuntu/window.h" -#include "anbox/platform/policy.h" +#include "anbox/platform/base_platform.h" #include "anbox/graphics/emugl/DisplayManager.h" @@ -40,7 +40,7 @@ class Manager; } // namespace wm namespace ubuntu { class PlatformPolicy : public std::enable_shared_from_this, - public platform::Policy, + public platform::BasePlatform, public Window::Observer { public: PlatformPolicy(const std::shared_ptr &input_manager, diff --git a/src/anbox/wm/multi_window_manager.cpp b/src/anbox/wm/multi_window_manager.cpp index 04806f3..b48f5d2 100644 --- a/src/anbox/wm/multi_window_manager.cpp +++ b/src/anbox/wm/multi_window_manager.cpp @@ -17,7 +17,7 @@ #include "anbox/application/database.h" #include "anbox/wm/multi_window_manager.h" -#include "anbox/platform/policy.h" +#include "anbox/platform/base_platform.h" #include "anbox/bridge/android_api_stub.h" #include "anbox/logger.h" @@ -25,10 +25,10 @@ namespace anbox { namespace wm { -MultiWindowManager::MultiWindowManager(const std::weak_ptr &policy, +MultiWindowManager::MultiWindowManager(const std::weak_ptr &platform, const std::shared_ptr &android_api_stub, const std::shared_ptr &app_db) - : platform_policy_(policy), android_api_stub_(android_api_stub), app_db_(app_db) {} + : platform_(platform), android_api_stub_(android_api_stub), app_db_(app_db) {} MultiWindowManager::~MultiWindowManager() {} @@ -67,7 +67,7 @@ void MultiWindowManager::apply_window_state_update(const WindowState::List &upda if (app.valid()) title = app.name; - if (auto p = platform_policy_.lock()) { + if (auto p = platform_.lock()) { auto w = p->create_window(window.task(), window.frame(), title); if (w) { w->attach(); diff --git a/src/anbox/wm/multi_window_manager.h b/src/anbox/wm/multi_window_manager.h index 845986c..3af0ce9 100644 --- a/src/anbox/wm/multi_window_manager.h +++ b/src/anbox/wm/multi_window_manager.h @@ -32,12 +32,12 @@ namespace bridge { class AndroidApiStub; } // namespace bridge namespace platform { -class Policy; +class BasePlatform; } // namespace platform namespace wm { class MultiWindowManager : public Manager { public: - MultiWindowManager(const std::weak_ptr &policy, + MultiWindowManager(const std::weak_ptr &platform, const std::shared_ptr &android_api_stub, const std::shared_ptr &app_db); ~MultiWindowManager(); @@ -53,7 +53,7 @@ class MultiWindowManager : public Manager { private: std::mutex mutex_; - std::weak_ptr platform_policy_; + std::weak_ptr platform_; std::shared_ptr android_api_stub_; std::shared_ptr app_db_; std::map> windows_; diff --git a/src/anbox/wm/single_window_manager.cpp b/src/anbox/wm/single_window_manager.cpp index 10dd8f9..b8937cb 100644 --- a/src/anbox/wm/single_window_manager.cpp +++ b/src/anbox/wm/single_window_manager.cpp @@ -16,7 +16,7 @@ */ #include "anbox/wm/single_window_manager.h" -#include "anbox/platform/policy.h" +#include "anbox/platform/base_platform.h" #include "anbox/logger.h" #include @@ -26,15 +26,15 @@ namespace anbox { namespace wm { -SingleWindowManager::SingleWindowManager(const std::weak_ptr &policy, +SingleWindowManager::SingleWindowManager(const std::weak_ptr &platform, const graphics::Rect &window_size, const std::shared_ptr &app_db) - : platform_policy_(policy), window_size_(window_size), app_db_(app_db) {} + : platform_(platform), window_size_(window_size), app_db_(app_db) {} SingleWindowManager::~SingleWindowManager() {} void SingleWindowManager::setup() { - if (auto p = platform_policy_.lock()) { + if (auto p = platform_.lock()) { window_ = p->create_window(0, window_size_, "Anbox - Android in a Box"); if (!window_->attach()) WARNING("Failed to attach window to renderer"); diff --git a/src/anbox/wm/single_window_manager.h b/src/anbox/wm/single_window_manager.h index 7595776..871d809 100644 --- a/src/anbox/wm/single_window_manager.h +++ b/src/anbox/wm/single_window_manager.h @@ -29,13 +29,13 @@ namespace application { class Database; } // namespace application namespace platform { -class Policy; +class BasePlatform; } // namespace platform namespace wm { class Window; class SingleWindowManager : public Manager { public: - SingleWindowManager(const std::weak_ptr &policy, + SingleWindowManager(const std::weak_ptr &platform, const graphics::Rect &window_size, const std::shared_ptr &app_db); ~SingleWindowManager(); @@ -52,7 +52,7 @@ class SingleWindowManager : public Manager { void remove_task(const Task::Id &task) override; private: - std::weak_ptr platform_policy_; + std::weak_ptr platform_; graphics::Rect window_size_; std::shared_ptr app_db_; std::shared_ptr window_; diff --git a/tests/anbox/graphics/layer_composer_tests.cpp b/tests/anbox/graphics/layer_composer_tests.cpp index c99801b..daeee66 100644 --- a/tests/anbox/graphics/layer_composer_tests.cpp +++ b/tests/anbox/graphics/layer_composer_tests.cpp @@ -21,7 +21,7 @@ #include #include "anbox/application/database.h" -#include "anbox/platform/default_policy.h" +#include "anbox/platform/base_platform.h" #include "anbox/wm/multi_window_manager.h" #include "anbox/wm/window_state.h" @@ -45,9 +45,9 @@ TEST(LayerComposer, FindsNoSuitableWindowForLayer) { // The default policy will create a dumb window instance when requested // from the manager. - auto platform_policy = std::make_shared(); + auto platform = platform::create(); auto app_db = std::make_shared(); - auto wm = std::make_shared(platform_policy, nullptr, app_db); + auto wm = std::make_shared(platform, nullptr, app_db); auto single_window = wm::WindowState{ wm::Display::Id{1}, @@ -79,9 +79,9 @@ TEST(LayerComposer, MapsLayersToWindows) { // The default policy will create a dumb window instance when requested // from the manager. - auto platform_policy = std::make_shared(); + auto platform = platform::create(); auto app_db = std::make_shared(); - auto wm = std::make_shared(platform_policy, nullptr, app_db); + auto wm = std::make_shared(platform, nullptr, app_db); auto first_window = wm::WindowState{ wm::Display::Id{1}, @@ -139,9 +139,9 @@ TEST(LayerComposer, WindowPartiallyOffscreen) { // The default policy will create a dumb window instance when requested // from the manager. - auto platform_policy = std::make_shared(); + auto platform = platform::create(); auto app_db = std::make_shared(); - auto wm = std::make_shared(platform_policy, nullptr, app_db); + auto wm = std::make_shared(platform, nullptr, app_db); auto window = wm::WindowState{ wm::Display::Id{1}, @@ -184,9 +184,9 @@ TEST(LayerComposer, PopupShouldNotCauseWindowLayerOffset) { // The default policy will create a dumb window instance when requested // from the manager. - auto platform_policy = std::make_shared(); + auto platform = platform::create(); auto app_db = std::make_shared(); - auto wm = std::make_shared(platform_policy, nullptr, app_db); + auto wm = std::make_shared(platform, nullptr, app_db); auto window = wm::WindowState{ wm::Display::Id{1}, From 66688167dfcecb78d96ae79c20accf45af9e5f8e Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Mon, 19 Jun 2017 21:33:57 +0200 Subject: [PATCH 2/3] Move sdl platform into anbox/platform/sdl --- src/CMakeLists.txt | 10 ++-- src/anbox/cmds/session_manager.cpp | 9 +++- src/anbox/platform/base_platform.cpp | 9 +++- src/anbox/platform/base_platform.h | 16 +++++- src/anbox/platform/null/platform.cpp | 10 ++++ src/anbox/platform/null/platform.h | 2 + .../{ubuntu => platform/sdl}/audio_sink.cpp | 8 +-- .../{ubuntu => platform/sdl}/audio_sink.h | 10 ++-- .../sdl}/keycode_converter.cpp | 10 ++-- .../sdl}/keycode_converter.h | 12 +++-- .../sdl}/mir_display_connection.cpp | 6 +-- .../sdl}/mir_display_connection.h | 8 +-- .../sdl/platform.cpp} | 50 ++++++++++--------- .../sdl/platform.h} | 24 +++++---- src/anbox/{ubuntu => platform/sdl}/window.cpp | 10 ++-- src/anbox/{ubuntu => platform/sdl}/window.h | 12 +++-- 16 files changed, 129 insertions(+), 77 deletions(-) rename src/anbox/{ubuntu => platform/sdl}/audio_sink.cpp (95%) rename src/anbox/{ubuntu => platform/sdl}/audio_sink.h (89%) rename src/anbox/{ubuntu => platform/sdl}/keycode_converter.cpp (99%) rename src/anbox/{ubuntu => platform/sdl}/keycode_converter.h (82%) rename src/anbox/{ubuntu => platform/sdl}/mir_display_connection.cpp (97%) rename src/anbox/{ubuntu => platform/sdl}/mir_display_connection.h (89%) rename src/anbox/{ubuntu/platform_policy.cpp => platform/sdl/platform.cpp} (87%) rename src/anbox/{ubuntu/platform_policy.h => platform/sdl/platform.h} (85%) rename src/anbox/{ubuntu => platform/sdl}/window.cpp (96%) rename src/anbox/{ubuntu => platform/sdl}/window.h (91%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3dc5f09..603bceb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,6 +168,11 @@ set(SOURCES anbox/platform/null/platform.cpp + anbox/platform/sdl/window.cpp + anbox/platform/sdl/keycode_converter.cpp + anbox/platform/sdl/platform.cpp + anbox/platform/sdl/audio_sink.cpp + anbox/input/manager.cpp anbox/input/device.cpp @@ -188,11 +193,6 @@ set(SOURCES anbox/bridge/platform_api_skeleton.cpp anbox/bridge/android_api_stub.cpp - anbox/ubuntu/window.cpp - anbox/ubuntu/keycode_converter.cpp - anbox/ubuntu/platform_policy.cpp - anbox/ubuntu/audio_sink.cpp - anbox/dbus/interface.h anbox/dbus/codecs.h anbox/dbus/skeleton/service.cpp diff --git a/src/anbox/cmds/session_manager.cpp b/src/anbox/cmds/session_manager.cpp index 4a8f028..0446a10 100644 --- a/src/anbox/cmds/session_manager.cpp +++ b/src/anbox/cmds/session_manager.cpp @@ -45,7 +45,7 @@ std::istream& operator>>(std::istream& in, anbox::graphics::GLRendererServer::Co #include "anbox/rpc/channel.h" #include "anbox/rpc/connection_creator.h" #include "anbox/runtime.h" -#include "anbox/ubuntu/platform_policy.h" +#include "anbox/platform/base_platform.h" #include "anbox/wm/multi_window_manager.h" #include "anbox/wm/single_window_manager.h" @@ -176,7 +176,12 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) if (single_window_) display_frame = window_size_; - auto platform = std::make_shared(input_manager, display_frame, single_window_); + auto platform = platform::create(utils::get_env_value("ANBOX_PLATFORM", "sdl"), + input_manager, + display_frame, + single_window_); + if (!platform) + return EXIT_FAILURE; auto app_db = std::make_shared(); diff --git a/src/anbox/platform/base_platform.cpp b/src/anbox/platform/base_platform.cpp index 26c49c0..6d29a07 100644 --- a/src/anbox/platform/base_platform.cpp +++ b/src/anbox/platform/base_platform.cpp @@ -17,14 +17,21 @@ #include "anbox/platform/base_platform.h" #include "anbox/platform/null/platform.h" +#include "anbox/platform/sdl/platform.h" #include "anbox/logger.h" namespace anbox { namespace platform { -std::shared_ptr create(const std::string &name) { +std::shared_ptr create(const std::string &name, + const std::shared_ptr &input_manager, + const graphics::Rect &display_frame, + bool single_window) { if (name.empty()) return std::make_shared(); + if (name == "sdl") + return std::make_shared(input_manager, display_frame, single_window); + WARNING("Unsupported platfrom '%s'", name); return nullptr; diff --git a/src/anbox/platform/base_platform.h b/src/anbox/platform/base_platform.h index a73f5b3..53836db 100644 --- a/src/anbox/platform/base_platform.h +++ b/src/anbox/platform/base_platform.h @@ -23,6 +23,8 @@ #include +class Renderer; + namespace anbox { namespace audio { class Sink; @@ -30,7 +32,11 @@ class Source; } // namespace audio namespace wm { class Window; +class Manager; } // namespace wm +namespace input { +class Manager; +} // namespace input namespace platform { class BasePlatform { public: @@ -47,9 +53,15 @@ class BasePlatform { virtual std::shared_ptr create_audio_sink() = 0; virtual std::shared_ptr create_audio_source() = 0; + + virtual void set_renderer(const std::shared_ptr &renderer) = 0; + virtual void set_window_manager(const std::shared_ptr &window_manager) = 0; }; -std::shared_ptr create(const std::string &name = ""); -} // namespace wm +std::shared_ptr create(const std::string &name = "", + const std::shared_ptr &input_manager = nullptr, + const graphics::Rect &display_frame = graphics::Rect::Invalid, + bool single_window = false); +} // namespace platform } // namespace anbox #endif diff --git a/src/anbox/platform/null/platform.cpp b/src/anbox/platform/null/platform.cpp index e49b1fe..23d6a68 100644 --- a/src/anbox/platform/null/platform.cpp +++ b/src/anbox/platform/null/platform.cpp @@ -57,5 +57,15 @@ std::shared_ptr NullPlatform::create_audio_source() { ERROR("Not implemented"); return nullptr; } + +void NullPlatform::set_renderer(const std::shared_ptr &renderer) { + (void) renderer; + ERROR("Not implemented"); +} + +void NullPlatform::set_window_manager(const std::shared_ptr &window_manager) { + (void) window_manager; + ERROR("Not implemented"); +} } // namespace wm } // namespace anbox diff --git a/src/anbox/platform/null/platform.h b/src/anbox/platform/null/platform.h index 7210e61..b0ff743 100644 --- a/src/anbox/platform/null/platform.h +++ b/src/anbox/platform/null/platform.h @@ -33,6 +33,8 @@ class NullPlatform : public BasePlatform { ClipboardData get_clipboard_data() override; std::shared_ptr create_audio_sink() override; std::shared_ptr create_audio_source() override; + void set_renderer(const std::shared_ptr &renderer) override; + void set_window_manager(const std::shared_ptr &window_manager) override; }; } // namespace wm } // namespace anbox diff --git a/src/anbox/ubuntu/audio_sink.cpp b/src/anbox/platform/sdl/audio_sink.cpp similarity index 95% rename from src/anbox/ubuntu/audio_sink.cpp rename to src/anbox/platform/sdl/audio_sink.cpp index 58ab813..d9e04d2 100644 --- a/src/anbox/ubuntu/audio_sink.cpp +++ b/src/anbox/platform/sdl/audio_sink.cpp @@ -15,7 +15,7 @@ * */ -#include "anbox/ubuntu/audio_sink.h" +#include "anbox/platform/sdl/audio_sink.h" #include "anbox/logger.h" #include @@ -27,7 +27,8 @@ const constexpr size_t max_queue_size{16}; } namespace anbox { -namespace ubuntu { +namespace platform { +namespace sdl { AudioSink::AudioSink() : device_id_(0), queue_(max_queue_size) { @@ -113,5 +114,6 @@ void AudioSink::write_data(const std::vector &data) { graphics::Buffer buffer{data.data(), data.data() + data.size()}; queue_.push_locked(std::move(buffer), l); } -} // namespace ubuntu +} // namespace sdl +} // namespace platform } // namespace anbox diff --git a/src/anbox/ubuntu/audio_sink.h b/src/anbox/platform/sdl/audio_sink.h similarity index 89% rename from src/anbox/ubuntu/audio_sink.h rename to src/anbox/platform/sdl/audio_sink.h index 1a597a0..ee3e11e 100644 --- a/src/anbox/ubuntu/audio_sink.h +++ b/src/anbox/platform/sdl/audio_sink.h @@ -15,8 +15,8 @@ * */ -#ifndef ANBOX_UBUNTU_AUDIO_SINK_H_ -#define ANBOX_UBUNTU_AUDIO_SINK_H_ +#ifndef ANBOX_PLATFORM_SDL_AUDIO_SINK_H_ +#define ANBOX_PLATFORM_SDL_AUDIO_SINK_H_ #include "anbox/audio/sink.h" #include "anbox/graphics/buffer_queue.h" @@ -26,7 +26,8 @@ #include namespace anbox { -namespace ubuntu { +namespace platform { +namespace sdl { class AudioSink : public audio::Sink { public: AudioSink(); @@ -48,7 +49,8 @@ class AudioSink : public audio::Sink { graphics::Buffer read_buffer_; size_t read_buffer_left_ = 0; }; -} // namespace ubuntu +} // namespace sdl +} // namespace platform } // namespace anbox #endif diff --git a/src/anbox/ubuntu/keycode_converter.cpp b/src/anbox/platform/sdl/keycode_converter.cpp similarity index 99% rename from src/anbox/ubuntu/keycode_converter.cpp rename to src/anbox/platform/sdl/keycode_converter.cpp index 2b2a617..3243ca4 100644 --- a/src/anbox/ubuntu/keycode_converter.cpp +++ b/src/anbox/platform/sdl/keycode_converter.cpp @@ -16,13 +16,14 @@ */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch-default" -#include "anbox/ubuntu/keycode_converter.h" +#include "anbox/platform/sdl/keycode_converter.h" #pragma GCC diagnostic pop #include namespace anbox { -namespace ubuntu { +namespace platform { +namespace sdl { std::uint16_t KeycodeConverter::convert(const SDL_Scancode &scan_code) { for (std::uint16_t n = 0; n < code_map.size(); n++) { if (code_map[n] == scan_code) return n; @@ -289,5 +290,6 @@ const std::array KeycodeConverter::code_map = {{ */ SDL_SCANCODE_UNKNOWN /* KEY_MICMUTE 248 Mute / unmute the microphone */ }}; -} // namespace ubuntu -} // namespace anbox +} // namespace sdl +} // namespace platform +} // namespace anbox diff --git a/src/anbox/ubuntu/keycode_converter.h b/src/anbox/platform/sdl/keycode_converter.h similarity index 82% rename from src/anbox/ubuntu/keycode_converter.h rename to src/anbox/platform/sdl/keycode_converter.h index 45f3d80..d0fa59a 100644 --- a/src/anbox/ubuntu/keycode_converter.h +++ b/src/anbox/platform/sdl/keycode_converter.h @@ -15,8 +15,8 @@ * */ -#ifndef ANBOX_UBUNTU_KEYCODE_CONVERTER_H_ -#define ANBOX_UBUNTU_KEYCODE_CONVERTER_H_ +#ifndef ANBOX_PLATFORM_SDL_KEYCODE_CONVERTER_H_ +#define ANBOX_PLATFORM_SDL_KEYCODE_CONVERTER_H_ #include @@ -25,7 +25,8 @@ #include namespace anbox { -namespace ubuntu { +namespace platform { +namespace sdl { class KeycodeConverter { public: static std::uint16_t convert(const SDL_Scancode &scan_code); @@ -33,7 +34,8 @@ class KeycodeConverter { private: static const std::array code_map; }; -} // namespace ubuntu -} // namespace anbox +} // namespace sdl +} // namespace platform +} // namespace anbox #endif diff --git a/src/anbox/ubuntu/mir_display_connection.cpp b/src/anbox/platform/sdl/mir_display_connection.cpp similarity index 97% rename from src/anbox/ubuntu/mir_display_connection.cpp rename to src/anbox/platform/sdl/mir_display_connection.cpp index 5146d78..481afbc 100644 --- a/src/anbox/ubuntu/mir_display_connection.cpp +++ b/src/anbox/platform/sdl/mir_display_connection.cpp @@ -14,7 +14,7 @@ * with this program. If not, see . * */ -#include "anbox/ubuntu/mir_display_connection.h" +#include "anbox/platform/sdlmir_display_connection.h" #include "anbox/logger.h" #include @@ -43,7 +43,7 @@ static const MirDisplayOutput *find_active_output( } namespace anbox { -namespace ubuntu { +namespace sdl { MirDisplayConnection::MirDisplayConnection() : connection_(nullptr), output_id_(-1), @@ -119,5 +119,5 @@ int MirDisplayConnection::vertical_resolution() const { int MirDisplayConnection::horizontal_resolution() const { return horizontal_resolution_; } -} // namespace ubuntu +} // namespace sdl } // namespace anbox diff --git a/src/anbox/ubuntu/mir_display_connection.h b/src/anbox/platform/sdl/mir_display_connection.h similarity index 89% rename from src/anbox/ubuntu/mir_display_connection.h rename to src/anbox/platform/sdl/mir_display_connection.h index 7904208..2cfc7aa 100644 --- a/src/anbox/ubuntu/mir_display_connection.h +++ b/src/anbox/platform/sdl/mir_display_connection.h @@ -15,8 +15,8 @@ * */ -#ifndef ANBOX_UBUNTU_MIR_DISPLAY_CONNECTION_H_ -#define ANBOX_UBUNTU_MIR_DISPLAY_CONNECTION_H_ +#ifndef ANBOX_PLATFORM_SDL_MIR_DISPLAY_CONNECTION_H_ +#define ANBOX_PLATFORM_SDL_MIR_DISPLAY_CONNECTION_H_ #define MIR_EGL_PLATFORM @@ -25,7 +25,7 @@ #include namespace anbox { -namespace ubuntu { +namespace sdl { class MirDisplayConnection { public: MirDisplayConnection(); @@ -46,7 +46,7 @@ class MirDisplayConnection { int vertical_resolution_; int horizontal_resolution_; }; -} // namespace ubuntu +} // namespace sdl } // namespace anbox #endif diff --git a/src/anbox/ubuntu/platform_policy.cpp b/src/anbox/platform/sdl/platform.cpp similarity index 87% rename from src/anbox/ubuntu/platform_policy.cpp rename to src/anbox/platform/sdl/platform.cpp index cea5551..64d6124 100644 --- a/src/anbox/ubuntu/platform_policy.cpp +++ b/src/anbox/platform/sdl/platform.cpp @@ -17,13 +17,13 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch-default" -#include "anbox/ubuntu/platform_policy.h" +#include "anbox/platform/sdl/platform.h" #include "anbox/input/device.h" #include "anbox/input/manager.h" #include "anbox/logger.h" -#include "anbox/ubuntu/keycode_converter.h" -#include "anbox/ubuntu/window.h" -#include "anbox/ubuntu/audio_sink.h" +#include "anbox/platform/sdl/keycode_converter.h" +#include "anbox/platform/sdl/window.h" +#include "anbox/platform/sdl/audio_sink.h" #include "anbox/wm/manager.h" #include @@ -33,8 +33,9 @@ #pragma GCC diagnostic pop namespace anbox { -namespace ubuntu { -PlatformPolicy::PlatformPolicy( +namespace platform { +namespace sdl { +Platform::Platform( const std::shared_ptr &input_manager, const graphics::Rect &static_display_frame, bool single_window) @@ -92,25 +93,25 @@ PlatformPolicy::PlatformPolicy( keyboard_->set_key_bit(BTN_MISC); keyboard_->set_key_bit(KEY_OK); - event_thread_ = std::thread(&PlatformPolicy::process_events, this); + event_thread_ = std::thread(&Platform::process_events, this); } -PlatformPolicy::~PlatformPolicy() { +Platform::~Platform() { if (event_thread_running_) { event_thread_running_ = false; event_thread_.join(); } } -void PlatformPolicy::set_renderer(const std::shared_ptr &renderer) { +void Platform::set_renderer(const std::shared_ptr &renderer) { renderer_ = renderer; } -void PlatformPolicy::set_window_manager(const std::shared_ptr &window_manager) { +void Platform::set_window_manager(const std::shared_ptr &window_manager) { window_manager_ = window_manager; } -void PlatformPolicy::process_events() { +void Platform::process_events() { event_thread_running_ = true; while (event_thread_running_) { @@ -144,7 +145,7 @@ void PlatformPolicy::process_events() { } } -void PlatformPolicy::process_input_event(const SDL_Event &event) { +void Platform::process_input_event(const SDL_Event &event) { std::vector mouse_events; std::vector keyboard_events; @@ -216,12 +217,12 @@ void PlatformPolicy::process_input_event(const SDL_Event &event) { if (keyboard_events.size() > 0) keyboard_->send_events(keyboard_events); } -Window::Id PlatformPolicy::next_window_id() { +Window::Id Platform::next_window_id() { static Window::Id next_id = 0; return next_id++; } -std::shared_ptr PlatformPolicy::create_window( +std::shared_ptr Platform::create_window( const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) { if (!renderer_) { ERROR("Can't create window without a renderer set"); @@ -234,7 +235,7 @@ std::shared_ptr PlatformPolicy::create_window( return w; } -void PlatformPolicy::window_deleted(const Window::Id &id) { +void Platform::window_deleted(const Window::Id &id) { auto w = windows_.find(id); if (w == windows_.end()) { WARNING("Got window removed event for unknown window (id %d)", id); @@ -245,7 +246,7 @@ void PlatformPolicy::window_deleted(const Window::Id &id) { windows_.erase(w); } -void PlatformPolicy::window_wants_focus(const Window::Id &id) { +void Platform::window_wants_focus(const Window::Id &id) { auto w = windows_.find(id); if (w == windows_.end()) return; @@ -253,7 +254,7 @@ void PlatformPolicy::window_wants_focus(const Window::Id &id) { window_manager_->set_focused_task(window->task()); } -void PlatformPolicy::window_moved(const Window::Id &id, const std::int32_t &x, +void Platform::window_moved(const Window::Id &id, const std::int32_t &x, const std::int32_t &y) { auto w = windows_.find(id); if (w == windows_.end()) return; @@ -266,7 +267,7 @@ void PlatformPolicy::window_moved(const Window::Id &id, const std::int32_t &x, } } -void PlatformPolicy::window_resized(const Window::Id &id, +void Platform::window_resized(const Window::Id &id, const std::int32_t &width, const std::int32_t &height) { auto w = windows_.find(id); @@ -284,13 +285,13 @@ void PlatformPolicy::window_resized(const Window::Id &id, } } -void PlatformPolicy::set_clipboard_data(const ClipboardData &data) { +void Platform::set_clipboard_data(const ClipboardData &data) { if (data.text.empty()) return; SDL_SetClipboardText(data.text.c_str()); } -PlatformPolicy::ClipboardData PlatformPolicy::get_clipboard_data() { +Platform::ClipboardData Platform::get_clipboard_data() { if (!SDL_HasClipboardText()) return ClipboardData{}; @@ -303,13 +304,14 @@ PlatformPolicy::ClipboardData PlatformPolicy::get_clipboard_data() { return data; } -std::shared_ptr PlatformPolicy::create_audio_sink() { +std::shared_ptr Platform::create_audio_sink() { return std::make_shared(); } -std::shared_ptr PlatformPolicy::create_audio_source() { +std::shared_ptr Platform::create_audio_source() { ERROR("Not implemented"); return nullptr; } -} // namespace wm -} // namespace anbox +} // namespace sdl +} // namespace platform +} // namespace anbox diff --git a/src/anbox/ubuntu/platform_policy.h b/src/anbox/platform/sdl/platform.h similarity index 85% rename from src/anbox/ubuntu/platform_policy.h rename to src/anbox/platform/sdl/platform.h index ea1b403..ff4af52 100644 --- a/src/anbox/ubuntu/platform_policy.h +++ b/src/anbox/platform/sdl/platform.h @@ -15,10 +15,10 @@ * */ -#ifndef ANBOX_UBUNTU_PLATFORM_POLICY_H_ -#define ANBOX_UBUNTU_PLATFORM_POLICY_H_ +#ifndef ANBOX_PLATFORM_SDL_PLATFORM_H_ +#define ANBOX_PLATFORM_SDL_PLATFORM_H_ -#include "anbox/ubuntu/window.h" +#include "anbox/platform/sdl/window.h" #include "anbox/platform/base_platform.h" #include "anbox/graphics/emugl/DisplayManager.h" @@ -38,15 +38,16 @@ class Manager; namespace wm { class Manager; } // namespace wm -namespace ubuntu { -class PlatformPolicy : public std::enable_shared_from_this, +namespace platform { +namespace sdl { +class Platform : public std::enable_shared_from_this, public platform::BasePlatform, public Window::Observer { public: - PlatformPolicy(const std::shared_ptr &input_manager, + Platform(const std::shared_ptr &input_manager, const graphics::Rect &static_display_frame = graphics::Rect::Invalid, bool single_window = false); - ~PlatformPolicy(); + ~Platform(); std::shared_ptr create_window( const anbox::wm::Task::Id &task, @@ -60,8 +61,8 @@ class PlatformPolicy : public std::enable_shared_from_this, void window_resized(const Window::Id &id, const std::int32_t &width, const std::int32_t &height) override; - void set_renderer(const std::shared_ptr &renderer); - void set_window_manager(const std::shared_ptr &window_manager); + void set_renderer(const std::shared_ptr &renderer) override; + void set_window_manager(const std::shared_ptr &window_manager) override; void set_clipboard_data(const ClipboardData &data) override; ClipboardData get_clipboard_data() override; @@ -89,7 +90,8 @@ class PlatformPolicy : public std::enable_shared_from_this, bool window_size_immutable_ = false; bool single_window_ = false; }; -} // namespace wm -} // namespace anbox +} // namespace sdl +} // namespace platform +} // namespace anbox #endif diff --git a/src/anbox/ubuntu/window.cpp b/src/anbox/platform/sdl/window.cpp similarity index 96% rename from src/anbox/ubuntu/window.cpp rename to src/anbox/platform/sdl/window.cpp index a9795c9..59b5ceb 100644 --- a/src/anbox/ubuntu/window.cpp +++ b/src/anbox/platform/sdl/window.cpp @@ -17,7 +17,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wswitch-default" -#include "anbox/ubuntu/window.h" +#include "anbox/platform/sdl/window.h" #include "anbox/logger.h" #include "anbox/wm/window_state.h" @@ -31,7 +31,8 @@ #pragma GCC diagnostic pop namespace anbox { -namespace ubuntu { +namespace platform { +namespace sdl { Window::Id Window::Invalid{-1}; Window::Observer::~Observer() {} @@ -129,5 +130,6 @@ EGLNativeWindowType Window::native_handle() const { return native_window_; } Window::Id Window::id() const { return id_; } std::uint32_t Window::window_id() const { return SDL_GetWindowID(window_); } -} // namespace bridge -} // namespace anbox +} // namespace sdl +} // namespace platform +} // namespace anbox diff --git a/src/anbox/ubuntu/window.h b/src/anbox/platform/sdl/window.h similarity index 91% rename from src/anbox/ubuntu/window.h rename to src/anbox/platform/sdl/window.h index 801fa38..ce081ea 100644 --- a/src/anbox/ubuntu/window.h +++ b/src/anbox/platform/sdl/window.h @@ -15,8 +15,8 @@ * */ -#ifndef ANBOX_UBUNTU_WINDOW_H_ -#define ANBOX_UBUNTU_WINDOW_H_ +#ifndef ANBOX_PLATFORM_SDL_WINDOW_H_ +#define ANBOX_PLATFORM_SDL_WINDOW_H_ #include "anbox/wm/window.h" @@ -30,7 +30,8 @@ class Renderer; namespace anbox { -namespace ubuntu { +namespace platform { +namespace sdl { class Window : public std::enable_shared_from_this, public wm::Window { public: typedef std::int32_t Id; @@ -68,7 +69,8 @@ class Window : public std::enable_shared_from_this, public wm::Window { EGLNativeWindowType native_window_; SDL_Window *window_; }; -} // namespace bridge -} // namespace anbox +} // namespace sdl +} // namespace platform +} // namespace anbox #endif From fa2c5f20885b8e80a36bcaaae547b68398ebaf8c Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Tue, 20 Jun 2017 07:26:58 +0200 Subject: [PATCH 3/3] Add simple header to wrap SDL headers and ignore any compiler warnings --- src/CMakeLists.txt | 1 + src/anbox/platform/sdl/audio_sink.h | 3 +-- src/anbox/platform/sdl/keycode_converter.h | 2 +- src/anbox/platform/sdl/platform.h | 4 +-- src/anbox/platform/sdl/sdl_wrapper.h | 29 ++++++++++++++++++++++ src/anbox/platform/sdl/window.cpp | 5 ---- src/anbox/platform/sdl/window.h | 3 +-- 7 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 src/anbox/platform/sdl/sdl_wrapper.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 603bceb..e48ade5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -168,6 +168,7 @@ set(SOURCES anbox/platform/null/platform.cpp + anbox/platform/sdl/sdl_wrapper.h anbox/platform/sdl/window.cpp anbox/platform/sdl/keycode_converter.cpp anbox/platform/sdl/platform.cpp diff --git a/src/anbox/platform/sdl/audio_sink.h b/src/anbox/platform/sdl/audio_sink.h index ee3e11e..f09db69 100644 --- a/src/anbox/platform/sdl/audio_sink.h +++ b/src/anbox/platform/sdl/audio_sink.h @@ -20,8 +20,7 @@ #include "anbox/audio/sink.h" #include "anbox/graphics/buffer_queue.h" - -#include +#include "anbox/platform/sdl/sdl_wrapper.h" #include diff --git a/src/anbox/platform/sdl/keycode_converter.h b/src/anbox/platform/sdl/keycode_converter.h index d0fa59a..d0b3f37 100644 --- a/src/anbox/platform/sdl/keycode_converter.h +++ b/src/anbox/platform/sdl/keycode_converter.h @@ -18,7 +18,7 @@ #ifndef ANBOX_PLATFORM_SDL_KEYCODE_CONVERTER_H_ #define ANBOX_PLATFORM_SDL_KEYCODE_CONVERTER_H_ -#include +#include "anbox/platform/sdl/sdl_wrapper.h" #include diff --git a/src/anbox/platform/sdl/platform.h b/src/anbox/platform/sdl/platform.h index ff4af52..2a01cf0 100644 --- a/src/anbox/platform/sdl/platform.h +++ b/src/anbox/platform/sdl/platform.h @@ -19,15 +19,13 @@ #define ANBOX_PLATFORM_SDL_PLATFORM_H_ #include "anbox/platform/sdl/window.h" +#include "anbox/platform/sdl/sdl_wrapper.h" #include "anbox/platform/base_platform.h" - #include "anbox/graphics/emugl/DisplayManager.h" #include #include -#include - class Renderer; namespace anbox { diff --git a/src/anbox/platform/sdl/sdl_wrapper.h b/src/anbox/platform/sdl/sdl_wrapper.h new file mode 100644 index 0000000..e880c16 --- /dev/null +++ b/src/anbox/platform/sdl/sdl_wrapper.h @@ -0,0 +1,29 @@ +/* + * 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_PLATFORM_SDL_WRAPPER_H_ +#define ANBOX_PLATFORM_SDL_WRAPPER_H_ + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch-default" +#include +#include +#include +#include +#pragma GCC diagnostic pop + +#endif diff --git a/src/anbox/platform/sdl/window.cpp b/src/anbox/platform/sdl/window.cpp index 59b5ceb..c129d2b 100644 --- a/src/anbox/platform/sdl/window.cpp +++ b/src/anbox/platform/sdl/window.cpp @@ -15,8 +15,6 @@ * */ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wswitch-default" #include "anbox/platform/sdl/window.h" #include "anbox/logger.h" #include "anbox/wm/window_state.h" @@ -27,9 +25,6 @@ #include #endif -#include -#pragma GCC diagnostic pop - namespace anbox { namespace platform { namespace sdl { diff --git a/src/anbox/platform/sdl/window.h b/src/anbox/platform/sdl/window.h index ce081ea..b44a7cb 100644 --- a/src/anbox/platform/sdl/window.h +++ b/src/anbox/platform/sdl/window.h @@ -19,14 +19,13 @@ #define ANBOX_PLATFORM_SDL_WINDOW_H_ #include "anbox/wm/window.h" +#include "anbox/platform/sdl/sdl_wrapper.h" #include #include #include -#include - class Renderer; namespace anbox {