From 8c19a8e42b56d497c96a0a36b4a35a2af0578000 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Fri, 21 Oct 2016 20:02:53 +0200 Subject: [PATCH] Use current display resolution as display size --- src/anbox/ubuntu/window_creator.cpp | 14 +++++++++++--- src/anbox/ubuntu/window_creator.h | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/anbox/ubuntu/window_creator.cpp b/src/anbox/ubuntu/window_creator.cpp index 7ba0c2c..6e05691 100644 --- a/src/anbox/ubuntu/window_creator.cpp +++ b/src/anbox/ubuntu/window_creator.cpp @@ -29,12 +29,21 @@ namespace ubuntu { WindowCreator::WindowCreator(const std::shared_ptr &input_manager) : graphics::WindowCreator(input_manager), input_manager_(input_manager), - event_thread_running_(false) { + event_thread_running_(false), + display_info_({1920, 1080}) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) BOOST_THROW_EXCEPTION(std::runtime_error("Failed to initialize SDL")); event_thread_ = std::thread(&WindowCreator::process_events, this); + + SDL_DisplayMode display_mode; + // FIXME statically just check the first (primary) display for its mode; + // once we get multi-monitor support we need to do this better. + if (SDL_GetCurrentDisplayMode(0, &display_mode) == 0) { + display_info_.horizontal_resolution = display_mode.w; + display_info_.vertical_resolution = display_mode.h; + } } WindowCreator::~WindowCreator() { @@ -107,8 +116,7 @@ void WindowCreator::destroy_window(EGLNativeWindowType win) { } WindowCreator::DisplayInfo WindowCreator::display_info() const { - // FIXME: force for now until we have real detection for this - return {1280, 720}; + return display_info_; } EGLNativeDisplayType WindowCreator::native_display() const { diff --git a/src/anbox/ubuntu/window_creator.h b/src/anbox/ubuntu/window_creator.h index a8b6ca0..cef70c4 100644 --- a/src/anbox/ubuntu/window_creator.h +++ b/src/anbox/ubuntu/window_creator.h @@ -50,6 +50,7 @@ private: std::shared_ptr current_window_; std::thread event_thread_; bool event_thread_running_; + graphics::WindowCreator::DisplayInfo display_info_; }; } // namespace bridge } // namespace anbox