mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-18 15:18:20 +00:00
nit_fb: allow screen-relative initial_width/height
This change enables the use of negative values for the 'initial_width' and 'initial_height' attributes to specify values that are relative to the screen size. This is consistent with the meaning of the 'width' and 'height' attributes.
This commit is contained in:
@ -231,30 +231,40 @@ struct Nit_fb::Main : View_updater
|
|||||||
|
|
||||||
struct Initial_size
|
struct Initial_size
|
||||||
{
|
{
|
||||||
unsigned const width { 0 };
|
long const _width { 0 };
|
||||||
unsigned const height { 0 };
|
long const _height { 0 };
|
||||||
|
|
||||||
bool set { false };
|
bool set { false };
|
||||||
|
|
||||||
Initial_size(Genode::Xml_node config)
|
Initial_size(Genode::Xml_node config)
|
||||||
:
|
:
|
||||||
width(config.attribute_value("initial_width", 0u)),
|
_width (config.attribute_value("initial_width", 0L)),
|
||||||
height(config.attribute_value("initial_height", 0u))
|
_height(config.attribute_value("initial_height", 0L))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool valid() const { return width != 0 && height != 0; }
|
unsigned width(Framebuffer::Mode const &mode) const
|
||||||
|
{
|
||||||
|
if (_width > 0) return _width;
|
||||||
|
if (_width < 0) return mode.width() + _width;
|
||||||
|
return mode.width();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned height(Framebuffer::Mode const &mode) const
|
||||||
|
{
|
||||||
|
if (_height > 0) return _height;
|
||||||
|
if (_height < 0) return mode.height() + _height;
|
||||||
|
return mode.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool valid() const { return _width != 0 && _height != 0; }
|
||||||
|
|
||||||
} _initial_size { config_rom.xml() };
|
} _initial_size { config_rom.xml() };
|
||||||
|
|
||||||
Framebuffer::Mode _initial_mode()
|
Framebuffer::Mode _initial_mode()
|
||||||
{
|
{
|
||||||
unsigned const width = _initial_size.valid()
|
return Framebuffer::Mode(_initial_size.width (nitpicker.mode()),
|
||||||
? _initial_size.width
|
_initial_size.height(nitpicker.mode()),
|
||||||
: (unsigned)nitpicker.mode().width();
|
nitpicker.mode().format());
|
||||||
unsigned const height = _initial_size.valid()
|
|
||||||
? _initial_size.height
|
|
||||||
: (unsigned)nitpicker.mode().height();
|
|
||||||
|
|
||||||
return Framebuffer::Mode(width, height, nitpicker.mode().format());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -329,8 +339,8 @@ struct Nit_fb::Main : View_updater
|
|||||||
height = config.attribute_value("height", (long)nit_mode.height());
|
height = config.attribute_value("height", (long)nit_mode.height());
|
||||||
|
|
||||||
if (!_initial_size.set && _initial_size.valid()) {
|
if (!_initial_size.set && _initial_size.valid()) {
|
||||||
width = _initial_size.width;
|
width = _initial_size.width (nit_mode);
|
||||||
height = _initial_size.height;
|
height = _initial_size.height(nit_mode);
|
||||||
|
|
||||||
_initial_size.set = true;
|
_initial_size.set = true;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user