Allow user to specify a different window size
This commit is contained in:
parent
aba9939a8c
commit
2d1cfea345
4 changed files with 41 additions and 2 deletions
|
|
@ -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<ubuntu::PlatformPolicy>(input_manager, display_frame, single_window_);
|
||||
// FIXME this needs to be removed and solved differently behind the scenes
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <core/dbus/bus.h>
|
||||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -16,10 +16,13 @@
|
|||
*/
|
||||
|
||||
#include "anbox/graphics/rect.h"
|
||||
#include "anbox/utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
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<std::int32_t>(tokens[0]),
|
||||
boost::lexical_cast<std::int32_t>(tokens[1]));
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
rect = anbox::graphics::Rect(
|
||||
boost::lexical_cast<std::int32_t>(tokens[0]),
|
||||
boost::lexical_cast<std::int32_t>(tokens[1]),
|
||||
boost::lexical_cast<std::int32_t>(tokens[2]),
|
||||
boost::lexical_cast<std::int32_t>(tokens[3]));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return in;
|
||||
} catch (...) {
|
||||
return in;
|
||||
}
|
||||
} // namespace graphics
|
||||
} // namespace anbox
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue