diff --git a/src/anbox/cmds/session_manager.cpp b/src/anbox/cmds/session_manager.cpp index a4d368d..d6ceac8 100644 --- a/src/anbox/cmds/session_manager.cpp +++ b/src/anbox/cmds/session_manager.cpp @@ -89,7 +89,8 @@ anbox::cmds::SessionManager::BusFactory anbox::cmds::SessionManager::session_bus anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) : CommandWithFlagsAndAction{cli::Name{"session-manager"}, cli::Usage{"session-manager"}, cli::Description{"Run the the anbox session manager"}}, - bus_factory_(bus_factory) { + bus_factory_(bus_factory), + window_size_(default_single_window_size) { // Just for the purpose to allow QtMir (or unity8) to find this on our // /proc/*/cmdline // for proper confinement etc. @@ -102,6 +103,9 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) flag(cli::make_flag(cli::Name{"single-window"}, cli::Description{"Start in single window mode."}, single_window_)); + flag(cli::make_flag(cli::Name{"window-size"}, + cli::Description{"Size of the window in single window mode, e.g. --window-size=1024,768"}, + window_size_)); action([this](const cli::Command::Context &) { auto trap = core::posix::trap_signals_for_process( @@ -143,7 +147,7 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory) auto display_frame = graphics::Rect::Invalid; if (single_window_) - display_frame = default_single_window_size; + display_frame = window_size_; auto policy = std::make_shared(input_manager, display_frame, single_window_); // FIXME this needs to be removed and solved differently behind the scenes diff --git a/src/anbox/cmds/session_manager.h b/src/anbox/cmds/session_manager.h index e212f1d..9ffb419 100644 --- a/src/anbox/cmds/session_manager.h +++ b/src/anbox/cmds/session_manager.h @@ -27,6 +27,7 @@ #include #include "anbox/graphics/gl_renderer_server.h" +#include "anbox/graphics/rect.h" namespace anbox { namespace cmds { @@ -43,6 +44,7 @@ class SessionManager : public cli::CommandWithFlagsAndAction { std::string desktop_file_hint_; graphics::GLRendererServer::Config::Driver gles_driver_; bool single_window_ = false; + graphics::Rect window_size_; }; } // namespace cmds } // namespace anbox diff --git a/src/anbox/graphics/rect.cpp b/src/anbox/graphics/rect.cpp index b98116a..d3306c5 100644 --- a/src/anbox/graphics/rect.cpp +++ b/src/anbox/graphics/rect.cpp @@ -16,10 +16,13 @@ */ #include "anbox/graphics/rect.h" +#include "anbox/utils.h" #include #include +#include + namespace anbox { namespace graphics { const Rect Rect::Invalid{-1, -1, -1, -1}; @@ -51,5 +54,34 @@ std::ostream &operator<<(std::ostream &out, const Rect &rect) { << "," << rect.bottom() << "} {" << rect.width() << "," << rect.height() << "}"; } + +std::istream& operator>>(std::istream& in, anbox::graphics::Rect &rect) +try { + std::string str; + in >> str; + auto tokens = anbox::utils::string_split(str, ','); + + switch (tokens.size()) { + case 2: { + rect = anbox::graphics::Rect(0, 0, + boost::lexical_cast(tokens[0]), + boost::lexical_cast(tokens[1])); + break; + } + case 4: + rect = anbox::graphics::Rect( + boost::lexical_cast(tokens[0]), + boost::lexical_cast(tokens[1]), + boost::lexical_cast(tokens[2]), + boost::lexical_cast(tokens[3])); + break; + default: + break; + } + + return in; +} catch (...) { + return in; +} } // namespace graphics } // namespace anbox diff --git a/src/anbox/graphics/rect.h b/src/anbox/graphics/rect.h index 8c3060e..3903727 100644 --- a/src/anbox/graphics/rect.h +++ b/src/anbox/graphics/rect.h @@ -75,6 +75,7 @@ class Rect { }; std::ostream &operator<<(std::ostream &out, const Rect &rect); +std::istream& operator>>(std::istream& in, anbox::graphics::Rect &rect); } // namespace graphics } // namespace anbox