demo: avoid using deprecated APIs

Issue #1987
Issue #3125
This commit is contained in:
Norman Feske
2019-01-21 14:27:12 +01:00
parent 6b94e65a95
commit 954aff7002
21 changed files with 177 additions and 284 deletions

View File

@ -79,7 +79,8 @@ static long config_fb_y = 260;
/**
* Window title
*/
static const char *config_title = "Liquid Framebuffer";
typedef Genode::String<128> Title;
static Title config_title { "Liquid Framebuffer" };
/**
* Resize handle
@ -94,63 +95,16 @@ static bool config_decoration = true;
/**
* Parse configuration
*/
static void read_config(Genode::Xml_node config_node)
static void read_config(Genode::Xml_node node)
{
using namespace Genode;
try {
char buf[16];
config_node.attribute("animate").value(buf, sizeof(buf));
if (!strcmp("off", buf)) config_animate = false;
else if (!strcmp("on", buf)) config_animate = true;
else
Genode::printf("Warning: invalid value for animate declaration,\n"
" valid values are 'on', 'off.\n'");
} catch (Xml_node::Nonexistent_attribute) { }
config_alpha = config_animate;
try { config_node.attribute("xpos").value(&config_fb_x); }
catch (Xml_node::Nonexistent_attribute) { }
try { config_node.attribute("ypos").value(&config_fb_y); }
catch (Xml_node::Nonexistent_attribute) { }
try { config_node.attribute("width").value(&config_fb_width); }
catch (Xml_node::Nonexistent_attribute) { }
try { config_node.attribute("height").value(&config_fb_height); }
catch (Xml_node::Nonexistent_attribute) { }
try {
static char buf[64];
config_node.attribute("title").value(buf, sizeof(buf));
config_title = buf;
} catch (Xml_node::Nonexistent_attribute) { }
try {
char buf[16];
config_node.attribute("decoration").value(buf, sizeof(buf));
if (!strcmp("off", buf)) config_decoration = false;
else if (!strcmp("on", buf)) config_decoration = true;
else
Genode::printf("Warning: invalid value for decoration declaration,\n"
" valid values are 'on', 'off.\n'");
} catch (Xml_node::Nonexistent_attribute) { }
try {
char buf[16];
config_node.attribute("resize_handle").value(buf, sizeof(buf));
if (!strcmp("off", buf)) config_resize_handle = false;
else if (!strcmp("on", buf)) config_resize_handle = true;
else
Genode::printf("Warning: invalid value for resize_handle declaration,\n"
" valid values are 'on', 'off.\n'");
} catch (Xml_node::Nonexistent_attribute) { }
config_fb_x = node.attribute_value("xpos", config_fb_x);
config_fb_y = node.attribute_value("ypos", config_fb_y);
config_fb_width = node.attribute_value("width", config_fb_width);
config_fb_height = node.attribute_value("height", config_fb_height);
config_title = node.attribute_value("title", config_title);
config_animate = node.attribute_value("animate", true);
config_decoration = node.attribute_value("decoration", true);
config_resize_handle = node.attribute_value("resize_handle", true);
}
@ -218,7 +172,7 @@ class Liquid_fb::Main : public Scout::Event_handler
Framebuffer_window<Pixel_rgb565>
_fb_win { _graphics_backend, window_content(),
_initial_position, _initial_size, _max_size,
config_title, config_alpha,
config_title.string(), config_alpha,
config_resize_handle, config_decoration };
/* create background animator if configured */
@ -260,7 +214,7 @@ class Liquid_fb::Main : public Scout::Event_handler
try { read_config(_config.xml()); } catch (...) { }
_fb_win.name(config_title);
_fb_win.name(config_title.string());
_fb_win.config_alpha(config_alpha);
_fb_win.config_resize_handle(config_resize_handle);
_fb_win.config_decoration(config_decoration);

View File

@ -85,7 +85,7 @@ class Window_content : public Scout::Element
unsigned char *alpha;
Genode::Texture<Genode::Pixel_rgb565> texture;
Fb_texture(Genode::Ram_session &ram, Genode::Region_map &local_rm,
Fb_texture(Genode::Ram_allocator &ram, Genode::Region_map &local_rm,
Genode::Allocator &alloc,
unsigned w, unsigned h, bool config_alpha)
:
@ -128,7 +128,7 @@ class Window_content : public Scout::Element
};
Genode::Ram_session &_ram;
Genode::Ram_allocator &_ram;
Genode::Region_map &_rm;
Genode::Allocator &_alloc;
bool _config_alpha;
@ -157,7 +157,7 @@ class Window_content : public Scout::Element
public:
Window_content(Genode::Ram_session &ram, Genode::Region_map &rm,
Window_content(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc, unsigned fb_w, unsigned fb_h,
Input::Session_component &input_session,
bool config_alpha)
@ -270,7 +270,7 @@ class Framebuffer::Session_component : public Genode::Rpc_object<Session>
};
void init_window_content(Genode::Ram_session &ram, Genode::Region_map &rm,
void init_window_content(Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc,
Input::Session_component &input_component,
unsigned fb_w, unsigned fb_h, bool config_alpha)

View File

@ -21,7 +21,7 @@
#include "elements.h"
extern Scout::Element *window_content();
extern void init_window_content(Genode::Ram_session &, Genode::Region_map &,
extern void init_window_content(Genode::Ram_allocator &, Genode::Region_map &,
Genode::Allocator &, Input::Session_component &,
unsigned fb_w, unsigned fb_h, bool config_alpha);
extern void init_services(Genode::Env &, Input::Session_component &);