mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-13 04:38:20 +00:00
@ -60,7 +60,7 @@ struct Decorator::Main : Window_factory_base
|
|||||||
|
|
||||||
Window_base::Hover _hover;
|
Window_base::Hover _hover;
|
||||||
|
|
||||||
Reporter _hover_reporter = { "hover" };
|
Reporter _hover_reporter = { _env, "hover" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nitpicker connection used to sync animations
|
* Nitpicker connection used to sync animations
|
||||||
@ -73,9 +73,9 @@ struct Decorator::Main : Window_factory_base
|
|||||||
|
|
||||||
Heap _heap { _env.ram(), _env.rm() };
|
Heap _heap { _env.ram(), _env.rm() };
|
||||||
|
|
||||||
Theme _theme { _heap };
|
Theme _theme { _env.ram(), _env.rm(), _heap };
|
||||||
|
|
||||||
Reporter _decorator_margins_reporter = { "decorator_margins" };
|
Reporter _decorator_margins_reporter = { _env, "decorator_margins" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the update every 'frame_period' nitpicker sync signals. The
|
* Process the update every 'frame_period' nitpicker sync signals. The
|
||||||
@ -166,8 +166,8 @@ struct Decorator::Main : Window_factory_base
|
|||||||
Window_base *create(Xml_node window_node) override
|
Window_base *create(Xml_node window_node) override
|
||||||
{
|
{
|
||||||
return new (_heap)
|
return new (_heap)
|
||||||
Window(attribute(window_node, "id", 0UL), _nitpicker, _animator,
|
Window(_env, attribute(window_node, "id", 0UL), _nitpicker, _animator,
|
||||||
_env.ram(), _theme, _decorator_config);
|
_theme, _decorator_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,31 +36,33 @@ struct Texture_from_png_file
|
|||||||
typedef Genode::Texture<Genode::Pixel_rgb888> Texture;
|
typedef Genode::Texture<Genode::Pixel_rgb888> Texture;
|
||||||
|
|
||||||
File png_file;
|
File png_file;
|
||||||
Png_image png_image { png_file.data<void>() };
|
Png_image png_image;
|
||||||
Texture &texture { *png_image.texture<Genode::Pixel_rgb888>() };
|
Texture &texture { *png_image.texture<Genode::Pixel_rgb888>() };
|
||||||
|
|
||||||
Texture_from_png_file(char const *path, Genode::Allocator &alloc)
|
Texture_from_png_file(Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||||
|
Genode::Allocator &alloc, char const *path)
|
||||||
:
|
:
|
||||||
png_file(path, alloc)
|
png_file(path, alloc), png_image(ram, rm, alloc, png_file.data<void>())
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static Genode::Texture<Genode::Pixel_rgb888> const &
|
static Genode::Texture<Genode::Pixel_rgb888> const &
|
||||||
texture_by_id(Texture_id texture_id, Genode::Allocator &alloc)
|
texture_by_id(Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||||
|
Genode::Allocator &alloc, Texture_id texture_id)
|
||||||
{
|
{
|
||||||
if (texture_id == TEXTURE_ID_DEFAULT) {
|
if (texture_id == TEXTURE_ID_DEFAULT) {
|
||||||
static Texture_from_png_file texture("theme/default.png", alloc);
|
static Texture_from_png_file texture(ram, rm, alloc, "theme/default.png");
|
||||||
return texture.texture;
|
return texture.texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture_id == TEXTURE_ID_CLOSER) {
|
if (texture_id == TEXTURE_ID_CLOSER) {
|
||||||
static Texture_from_png_file texture("theme/closer.png", alloc);
|
static Texture_from_png_file texture(ram, rm, alloc, "theme/closer.png");
|
||||||
return texture.texture;
|
return texture.texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture_id == TEXTURE_ID_MAXIMIZER) {
|
if (texture_id == TEXTURE_ID_MAXIMIZER) {
|
||||||
static Texture_from_png_file texture("theme/maximizer.png", alloc);
|
static Texture_from_png_file texture(ram, rm, alloc, "theme/maximizer.png");
|
||||||
return texture.texture;
|
return texture.texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,14 +72,15 @@ texture_by_id(Texture_id texture_id, Genode::Allocator &alloc)
|
|||||||
|
|
||||||
|
|
||||||
static Genode::Texture<Genode::Pixel_rgb888> const &
|
static Genode::Texture<Genode::Pixel_rgb888> const &
|
||||||
texture_by_element_type(Decorator::Theme::Element_type type, Genode::Allocator &alloc)
|
texture_by_element_type(Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||||
|
Genode::Allocator &alloc, Decorator::Theme::Element_type type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case Decorator::Theme::ELEMENT_TYPE_CLOSER:
|
case Decorator::Theme::ELEMENT_TYPE_CLOSER:
|
||||||
return texture_by_id(TEXTURE_ID_CLOSER, alloc);
|
return texture_by_id(ram, rm, alloc, TEXTURE_ID_CLOSER);
|
||||||
|
|
||||||
case Decorator::Theme::ELEMENT_TYPE_MAXIMIZER:
|
case Decorator::Theme::ELEMENT_TYPE_MAXIMIZER:
|
||||||
return texture_by_id(TEXTURE_ID_MAXIMIZER, alloc);
|
return texture_by_id(ram, rm, alloc, TEXTURE_ID_MAXIMIZER);
|
||||||
}
|
}
|
||||||
struct Invalid_element_type { };
|
struct Invalid_element_type { };
|
||||||
throw Invalid_element_type();
|
throw Invalid_element_type();
|
||||||
@ -106,7 +109,8 @@ Decorator::Area Decorator::Theme::background_size() const
|
|||||||
if (decor_margins().none() && aura_margins().none())
|
if (decor_margins().none() && aura_margins().none())
|
||||||
return Decorator::Area(0, 0);
|
return Decorator::Area(0, 0);
|
||||||
|
|
||||||
Genode::Texture<Pixel_rgb888> const &texture = texture_by_id(TEXTURE_ID_DEFAULT, _alloc);
|
Genode::Texture<Pixel_rgb888> const &texture =
|
||||||
|
texture_by_id(_ram, _rm, _alloc, TEXTURE_ID_DEFAULT);
|
||||||
|
|
||||||
return texture.size();
|
return texture.size();
|
||||||
}
|
}
|
||||||
@ -150,7 +154,8 @@ Decorator::Rect Decorator::Theme::title_geometry() const
|
|||||||
|
|
||||||
|
|
||||||
static Decorator::Rect
|
static Decorator::Rect
|
||||||
element_geometry(Genode::Allocator &alloc, char const *sub_node_type,
|
element_geometry(Genode::Ram_session &ram, Genode::Region_map &rm,
|
||||||
|
Genode::Allocator &alloc, char const *sub_node_type,
|
||||||
Texture_id texture_id)
|
Texture_id texture_id)
|
||||||
{
|
{
|
||||||
using namespace Decorator;
|
using namespace Decorator;
|
||||||
@ -161,7 +166,7 @@ element_geometry(Genode::Allocator &alloc, char const *sub_node_type,
|
|||||||
return Rect(Point(0, 0), Area(0, 0));
|
return Rect(Point(0, 0), Area(0, 0));
|
||||||
|
|
||||||
return Rect(point_attribute(node.sub_node(sub_node_type)),
|
return Rect(point_attribute(node.sub_node(sub_node_type)),
|
||||||
texture_by_id(texture_id, alloc).size());
|
texture_by_id(ram, rm, alloc, texture_id).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,10 +174,10 @@ Decorator::Rect Decorator::Theme::element_geometry(Element_type type) const
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (type == ELEMENT_TYPE_CLOSER)
|
if (type == ELEMENT_TYPE_CLOSER)
|
||||||
return ::element_geometry(_alloc, "closer", TEXTURE_ID_CLOSER);
|
return ::element_geometry(_ram, _rm, _alloc, "closer", TEXTURE_ID_CLOSER);
|
||||||
|
|
||||||
if (type == ELEMENT_TYPE_MAXIMIZER)
|
if (type == ELEMENT_TYPE_MAXIMIZER)
|
||||||
return ::element_geometry(_alloc, "maximizer", TEXTURE_ID_MAXIMIZER);
|
return ::element_geometry(_ram, _rm, _alloc, "maximizer", TEXTURE_ID_MAXIMIZER);
|
||||||
|
|
||||||
struct Invalid_element_type { };
|
struct Invalid_element_type { };
|
||||||
throw Invalid_element_type();
|
throw Invalid_element_type();
|
||||||
@ -191,7 +196,8 @@ void Decorator::Theme::draw_background(Decorator::Pixel_surface pixel_surface,
|
|||||||
if (!background_size().valid())
|
if (!background_size().valid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Genode::Texture<Pixel_rgb888> const &texture = texture_by_id(TEXTURE_ID_DEFAULT, _alloc);
|
Genode::Texture<Pixel_rgb888> const &texture =
|
||||||
|
texture_by_id(_ram, _rm, _alloc, TEXTURE_ID_DEFAULT);
|
||||||
|
|
||||||
typedef Genode::Surface_base::Point Point;
|
typedef Genode::Surface_base::Point Point;
|
||||||
typedef Genode::Surface_base::Rect Rect;
|
typedef Genode::Surface_base::Rect Rect;
|
||||||
@ -280,7 +286,7 @@ void Decorator::Theme::draw_element(Decorator::Pixel_surface pixel_surface,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
Genode::Texture<Pixel_rgb888> const &texture =
|
Genode::Texture<Pixel_rgb888> const &texture =
|
||||||
texture_by_element_type(element_type, _alloc);
|
texture_by_element_type(_ram, _rm, _alloc, element_type);
|
||||||
|
|
||||||
Rect const surface_rect(Point(0, 0), pixel_surface.size());
|
Rect const surface_rect(Point(0, 0), pixel_surface.size());
|
||||||
Rect const element_rect = element_geometry(element_type);
|
Rect const element_rect = element_geometry(element_type);
|
||||||
|
@ -41,6 +41,8 @@ class Decorator::Theme
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Genode::Ram_session &_ram;
|
||||||
|
Genode::Region_map &_rm;
|
||||||
Genode::Allocator &_alloc;
|
Genode::Allocator &_alloc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -54,7 +56,8 @@ class Decorator::Theme
|
|||||||
|
|
||||||
enum Element_type { ELEMENT_TYPE_CLOSER, ELEMENT_TYPE_MAXIMIZER };
|
enum Element_type { ELEMENT_TYPE_CLOSER, ELEMENT_TYPE_MAXIMIZER };
|
||||||
|
|
||||||
Theme(Genode::Allocator &alloc) : _alloc(alloc) { }
|
Theme(Genode::Ram_session &ram, Genode::Region_map &rm, Genode::Allocator &alloc)
|
||||||
|
: _ram(ram), _rm(rm), _alloc(alloc) { }
|
||||||
|
|
||||||
Area background_size() const;
|
Area background_size() const;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class Decorator::Window : public Window_base, public Animator::Item
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Genode::Ram_session &_ram;
|
Genode::Env &_env;
|
||||||
|
|
||||||
Theme const &_theme;
|
Theme const &_theme;
|
||||||
|
|
||||||
@ -231,14 +231,14 @@ class Decorator::Window : public Window_base, public Animator::Item
|
|||||||
* Nitpicker session that contains the upper and lower window
|
* Nitpicker session that contains the upper and lower window
|
||||||
* decorations.
|
* decorations.
|
||||||
*/
|
*/
|
||||||
Nitpicker::Connection _nitpicker_top_bottom;
|
Nitpicker::Connection _nitpicker_top_bottom { _env };
|
||||||
Genode::Constructible<Nitpicker_buffer> _buffer_top_bottom;
|
Genode::Constructible<Nitpicker_buffer> _buffer_top_bottom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nitpicker session that contains the left and right window
|
* Nitpicker session that contains the left and right window
|
||||||
* decorations.
|
* decorations.
|
||||||
*/
|
*/
|
||||||
Nitpicker::Connection _nitpicker_left_right;
|
Nitpicker::Connection _nitpicker_left_right { _env };
|
||||||
Genode::Constructible<Nitpicker_buffer> _buffer_left_right;
|
Genode::Constructible<Nitpicker_buffer> _buffer_left_right;
|
||||||
|
|
||||||
Nitpicker_view _bottom_view { _nitpicker, _nitpicker_top_bottom },
|
Nitpicker_view _bottom_view { _nitpicker, _nitpicker_top_bottom },
|
||||||
@ -264,7 +264,8 @@ class Decorator::Window : public Window_base, public Animator::Item
|
|||||||
Framebuffer::Mode::RGB565),
|
Framebuffer::Mode::RGB565),
|
||||||
use_alpha);
|
use_alpha);
|
||||||
|
|
||||||
_buffer_top_bottom.construct(_nitpicker_top_bottom, size_top_bottom, _ram);
|
_buffer_top_bottom.construct(_nitpicker_top_bottom, size_top_bottom,
|
||||||
|
_env.ram(), _env.rm());
|
||||||
|
|
||||||
Area const size_left_right(outer_size.w() - inner_size.w(),
|
Area const size_left_right(outer_size.w() - inner_size.w(),
|
||||||
outer_size.h());
|
outer_size.h());
|
||||||
@ -274,7 +275,8 @@ class Decorator::Window : public Window_base, public Animator::Item
|
|||||||
Framebuffer::Mode::RGB565),
|
Framebuffer::Mode::RGB565),
|
||||||
use_alpha);
|
use_alpha);
|
||||||
|
|
||||||
_buffer_left_right.construct(_nitpicker_left_right, size_left_right, _ram);
|
_buffer_left_right.construct(_nitpicker_left_right, size_left_right,
|
||||||
|
_env.ram(), _env.rm());
|
||||||
}
|
}
|
||||||
|
|
||||||
void _repaint_decorations(Nitpicker_buffer &buffer)
|
void _repaint_decorations(Nitpicker_buffer &buffer)
|
||||||
@ -314,13 +316,12 @@ class Decorator::Window : public Window_base, public Animator::Item
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Window(unsigned id, Nitpicker::Session_client &nitpicker,
|
Window(Genode::Env &env, unsigned id, Nitpicker::Session_client &nitpicker,
|
||||||
Animator &animator, Genode::Ram_session &ram,
|
Animator &animator, Theme const &theme, Config const &config)
|
||||||
Theme const &theme, Config const &config)
|
|
||||||
:
|
:
|
||||||
Window_base(id),
|
Window_base(id),
|
||||||
Animator::Item(animator),
|
Animator::Item(animator),
|
||||||
_ram(ram), _theme(theme), _animator(animator),
|
_env(env),_theme(theme), _animator(animator),
|
||||||
_nitpicker(nitpicker), _config(config)
|
_nitpicker(nitpicker), _config(config)
|
||||||
{
|
{
|
||||||
_reallocate_nitpicker_buffers();
|
_reallocate_nitpicker_buffers();
|
||||||
|
Reference in New Issue
Block a user