mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-21 16:39:39 +00:00
committed by
Christian Helmuth
parent
3c4372210e
commit
eb90d92009
@ -13,10 +13,10 @@
|
|||||||
|
|
||||||
/* Genode includes */
|
/* Genode includes */
|
||||||
#include <base/log.h>
|
#include <base/log.h>
|
||||||
#include <base/signal.h>
|
#include <base/component.h>
|
||||||
#include <os/attached_rom_dataspace.h>
|
#include <base/heap.h>
|
||||||
|
#include <base/attached_rom_dataspace.h>
|
||||||
#include <os/reporter.h>
|
#include <os/reporter.h>
|
||||||
#include <os/server.h>
|
|
||||||
|
|
||||||
/* decorator includes */
|
/* decorator includes */
|
||||||
#include <decorator/window_stack.h>
|
#include <decorator/window_stack.h>
|
||||||
@ -34,46 +34,48 @@ namespace Decorator {
|
|||||||
|
|
||||||
struct Decorator::Main : Window_factory_base
|
struct Decorator::Main : Window_factory_base
|
||||||
{
|
{
|
||||||
Server::Entrypoint &ep;
|
Env &_env;
|
||||||
|
|
||||||
Window_stack window_stack = { *this };
|
Window_stack _window_stack = { *this };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install handler for responding to window-layout changes
|
* Handler for responding to window-layout changes
|
||||||
*/
|
*/
|
||||||
void handle_window_layout_update(unsigned);
|
void _handle_window_layout_update();
|
||||||
|
|
||||||
Signal_rpc_member<Main> window_layout_dispatcher = {
|
Signal_handler<Main> _window_layout_handler = {
|
||||||
ep, *this, &Main::handle_window_layout_update };
|
_env.ep(), *this, &Main::_handle_window_layout_update };
|
||||||
|
|
||||||
Attached_rom_dataspace window_layout { "window_layout" };
|
Attached_rom_dataspace _window_layout { _env, "window_layout" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install handler for responding to pointer-position updates
|
* Handler for responding to pointer-position updates
|
||||||
*/
|
*/
|
||||||
void handle_pointer_update(unsigned);
|
void _handle_pointer_update();
|
||||||
|
|
||||||
Signal_rpc_member<Main> pointer_dispatcher = {
|
Signal_handler<Main> _pointer_handler = {
|
||||||
ep, *this, &Main::handle_pointer_update };
|
_env.ep(), *this, &Main::_handle_pointer_update };
|
||||||
|
|
||||||
Lazy_volatile_object<Attached_rom_dataspace> pointer;
|
Lazy_volatile_object<Attached_rom_dataspace> _pointer;
|
||||||
|
|
||||||
Window_base::Hover hover;
|
Window_base::Hover _hover;
|
||||||
|
|
||||||
Reporter hover_reporter = { "hover" };
|
Reporter _hover_reporter = { "hover" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nitpicker connection used to sync animations
|
* Nitpicker connection used to sync animations
|
||||||
*/
|
*/
|
||||||
Nitpicker::Connection nitpicker;
|
Nitpicker::Connection _nitpicker { _env };
|
||||||
|
|
||||||
bool window_layout_update_needed = false;
|
bool _window_layout_update_needed = false;
|
||||||
|
|
||||||
Animator animator;
|
Animator _animator;
|
||||||
|
|
||||||
Theme theme { *Genode::env()->heap() };
|
Heap _heap { _env.ram(), _env.rm() };
|
||||||
|
|
||||||
Reporter decorator_margins_reporter = { "decorator_margins" };
|
Theme _theme { _heap };
|
||||||
|
|
||||||
|
Reporter _decorator_margins_reporter = { "decorator_margins" };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process the update every 'frame_period' nitpicker sync signals. The
|
* Process the update every 'frame_period' nitpicker sync signals. The
|
||||||
@ -86,28 +88,30 @@ struct Decorator::Main : Window_factory_base
|
|||||||
* 'frame_period' of 2 results in an update rate of 1000/20 = 50 frames per
|
* 'frame_period' of 2 results in an update rate of 1000/20 = 50 frames per
|
||||||
* second.
|
* second.
|
||||||
*/
|
*/
|
||||||
unsigned frame_cnt = 0;
|
unsigned _frame_cnt = 0;
|
||||||
unsigned frame_period = 2;
|
unsigned _frame_period = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Install handler for responding to nitpicker sync events
|
* Install handler for responding to nitpicker sync events
|
||||||
*/
|
*/
|
||||||
void handle_nitpicker_sync(unsigned);
|
void _handle_nitpicker_sync();
|
||||||
|
|
||||||
Signal_rpc_member<Main> nitpicker_sync_dispatcher = {
|
Signal_handler<Main> _nitpicker_sync_handler = {
|
||||||
ep, *this, &Main::handle_nitpicker_sync };
|
_env.ep(), *this, &Main::_handle_nitpicker_sync };
|
||||||
|
|
||||||
Config config;
|
Attached_rom_dataspace _config { _env, "config" };
|
||||||
|
|
||||||
void handle_config(unsigned);
|
Config _decorator_config;
|
||||||
|
|
||||||
Signal_rpc_member<Main> config_dispatcher = {
|
void _handle_config();
|
||||||
ep, *this, &Main::handle_config};
|
|
||||||
|
Signal_handler<Main> _config_handler = {
|
||||||
|
_env.ep(), *this, &Main::_handle_config};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
Main(Server::Entrypoint &ep) : ep(ep)
|
Main(Env &env) : _env(env)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Eagerly upgrade the session quota in order to be able to create a
|
* Eagerly upgrade the session quota in order to be able to create a
|
||||||
@ -118,31 +122,31 @@ struct Decorator::Main : Window_factory_base
|
|||||||
* and view_handle operations. Currently, these exceptions will
|
* and view_handle operations. Currently, these exceptions will
|
||||||
* abort the decorator.
|
* abort the decorator.
|
||||||
*/
|
*/
|
||||||
nitpicker.upgrade_ram(256*1024);
|
_nitpicker.upgrade_ram(256*1024);
|
||||||
|
|
||||||
Genode::config()->sigh(config_dispatcher);
|
_config.sigh(_config_handler);
|
||||||
handle_config(0);
|
_handle_config();
|
||||||
|
|
||||||
window_layout.sigh(window_layout_dispatcher);
|
_window_layout.sigh(_window_layout_handler);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pointer.construct("pointer");
|
_pointer.construct(_env, "pointer");
|
||||||
pointer->sigh(pointer_dispatcher);
|
_pointer->sigh(_pointer_handler);
|
||||||
} catch (Genode::Rom_connection::Rom_connection_failed) {
|
} catch (Genode::Rom_connection::Rom_connection_failed) {
|
||||||
Genode::log("pointer information unavailable");
|
Genode::log("pointer information unavailable");
|
||||||
}
|
}
|
||||||
|
|
||||||
nitpicker.framebuffer()->sync_sigh(nitpicker_sync_dispatcher);
|
_nitpicker.framebuffer()->sync_sigh(_nitpicker_sync_handler);
|
||||||
|
|
||||||
hover_reporter.enabled(true);
|
_hover_reporter.enabled(true);
|
||||||
|
|
||||||
decorator_margins_reporter.enabled(true);
|
_decorator_margins_reporter.enabled(true);
|
||||||
|
|
||||||
Genode::Reporter::Xml_generator xml(decorator_margins_reporter, [&] ()
|
Genode::Reporter::Xml_generator xml(_decorator_margins_reporter, [&] ()
|
||||||
{
|
{
|
||||||
xml.node("floating", [&] () {
|
xml.node("floating", [&] () {
|
||||||
|
|
||||||
Theme::Margins const margins = theme.decor_margins();
|
Theme::Margins const margins = _theme.decor_margins();
|
||||||
|
|
||||||
xml.attribute("top", margins.top);
|
xml.attribute("top", margins.top);
|
||||||
xml.attribute("bottom", margins.bottom);
|
xml.attribute("bottom", margins.bottom);
|
||||||
@ -152,8 +156,8 @@ struct Decorator::Main : Window_factory_base
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* import initial state */
|
/* import initial state */
|
||||||
handle_pointer_update(0);
|
_handle_pointer_update();
|
||||||
handle_window_layout_update(0);
|
_handle_window_layout_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -161,9 +165,9 @@ struct Decorator::Main : Window_factory_base
|
|||||||
*/
|
*/
|
||||||
Window_base *create(Xml_node window_node) override
|
Window_base *create(Xml_node window_node) override
|
||||||
{
|
{
|
||||||
return new (env()->heap())
|
return new (_heap)
|
||||||
Window(attribute(window_node, "id", 0UL), nitpicker, animator,
|
Window(attribute(window_node, "id", 0UL), _nitpicker, _animator,
|
||||||
*env()->ram_session(), theme, config);
|
_env.ram(), _theme, _decorator_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -171,21 +175,21 @@ struct Decorator::Main : Window_factory_base
|
|||||||
*/
|
*/
|
||||||
void destroy(Window_base *window) override
|
void destroy(Window_base *window) override
|
||||||
{
|
{
|
||||||
Genode::destroy(env()->heap(), static_cast<Window *>(window));
|
Genode::destroy(_heap, static_cast<Window *>(window));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void Decorator::Main::handle_config(unsigned)
|
void Decorator::Main::_handle_config()
|
||||||
{
|
{
|
||||||
Genode::config()->reload();
|
_config.update();
|
||||||
|
|
||||||
/* notify all windows to consider the updated policy */
|
/* notify all windows to consider the updated policy */
|
||||||
window_stack.for_each_window([&] (Window_base &window) {
|
_window_stack.for_each_window([&] (Window_base &window) {
|
||||||
static_cast<Window &>(window).adapt_to_changed_config(); });
|
static_cast<Window &>(window).adapt_to_changed_config(); });
|
||||||
|
|
||||||
/* trigger redraw of the window stack */
|
/* trigger redraw of the window stack */
|
||||||
handle_window_layout_update(0);
|
_handle_window_layout_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,29 +241,29 @@ static void update_hover_report(Genode::Xml_node pointer_node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Decorator::Main::handle_window_layout_update(unsigned)
|
void Decorator::Main::_handle_window_layout_update()
|
||||||
{
|
{
|
||||||
window_layout.update();
|
_window_layout.update();
|
||||||
|
|
||||||
window_layout_update_needed = true;
|
_window_layout_update_needed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Decorator::Main::handle_nitpicker_sync(unsigned)
|
void Decorator::Main::_handle_nitpicker_sync()
|
||||||
{
|
{
|
||||||
if (frame_cnt++ < frame_period)
|
if (_frame_cnt++ < _frame_period)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
frame_cnt = 0;
|
_frame_cnt = 0;
|
||||||
|
|
||||||
bool model_updated = false;
|
bool model_updated = false;
|
||||||
|
|
||||||
if (window_layout_update_needed && window_layout.valid()) {
|
if (_window_layout_update_needed && _window_layout.valid()) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Xml_node xml(window_layout.local_addr<char>(),
|
Xml_node xml(_window_layout.local_addr<char>(),
|
||||||
window_layout.size());
|
_window_layout.size());
|
||||||
window_stack.update_model(xml);
|
_window_stack.update_model(xml);
|
||||||
|
|
||||||
model_updated = true;
|
model_updated = true;
|
||||||
|
|
||||||
@ -267,9 +271,9 @@ void Decorator::Main::handle_nitpicker_sync(unsigned)
|
|||||||
* A decorator element might have appeared or disappeared under
|
* A decorator element might have appeared or disappeared under
|
||||||
* the pointer.
|
* the pointer.
|
||||||
*/
|
*/
|
||||||
if (pointer.constructed() && pointer->valid())
|
if (_pointer.constructed() && _pointer->valid())
|
||||||
update_hover_report(Xml_node(pointer->local_addr<char>()),
|
update_hover_report(Xml_node(_pointer->local_addr<char>()),
|
||||||
window_stack, hover, hover_reporter);
|
_window_stack, _hover, _hover_reporter);
|
||||||
|
|
||||||
} catch (Xml_node::Invalid_syntax) {
|
} catch (Xml_node::Invalid_syntax) {
|
||||||
|
|
||||||
@ -277,54 +281,40 @@ void Decorator::Main::handle_nitpicker_sync(unsigned)
|
|||||||
* An error occured with processing the XML model. Flush the
|
* An error occured with processing the XML model. Flush the
|
||||||
* internal representation.
|
* internal representation.
|
||||||
*/
|
*/
|
||||||
window_stack.flush();
|
_window_stack.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
window_layout_update_needed = false;
|
_window_layout_update_needed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool const windows_animated = window_stack.schedule_animated_windows();
|
bool const windows_animated = _window_stack.schedule_animated_windows();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To make the perceived animation speed independent from the setting of
|
* To make the perceived animation speed independent from the setting of
|
||||||
* 'frame_period', we update the animation as often as the nitpicker
|
* 'frame_period', we update the animation as often as the nitpicker
|
||||||
* sync signal occurs.
|
* sync signal occurs.
|
||||||
*/
|
*/
|
||||||
for (unsigned i = 0; i < frame_period; i++)
|
for (unsigned i = 0; i < _frame_period; i++)
|
||||||
animator.animate();
|
_animator.animate();
|
||||||
|
|
||||||
if (!model_updated && !windows_animated)
|
if (!model_updated && !windows_animated)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window_stack.update_nitpicker_views();
|
_window_stack.update_nitpicker_views();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Decorator::Main::handle_pointer_update(unsigned)
|
void Decorator::Main::_handle_pointer_update()
|
||||||
{
|
{
|
||||||
if (!pointer.constructed())
|
if (!_pointer.constructed())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pointer->update();
|
_pointer->update();
|
||||||
|
|
||||||
if (pointer->valid())
|
if (_pointer->valid())
|
||||||
update_hover_report(Xml_node(pointer->local_addr<char>()),
|
update_hover_report(Xml_node(_pointer->local_addr<char>()),
|
||||||
window_stack, hover, hover_reporter);
|
_window_stack, _hover, _hover_reporter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************
|
void Component::construct(Genode::Env &env) { static Decorator::Main main(env); }
|
||||||
** Server **
|
|
||||||
************/
|
|
||||||
|
|
||||||
namespace Server {
|
|
||||||
|
|
||||||
char const *name() { return "decorator_ep"; }
|
|
||||||
|
|
||||||
size_t stack_size() { return 8*1024*sizeof(long); }
|
|
||||||
|
|
||||||
void construct(Entrypoint &ep)
|
|
||||||
{
|
|
||||||
static Decorator::Main main(ep);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
TARGET = themed_decorator
|
TARGET = themed_decorator
|
||||||
SRC_CC = main.cc theme.cc window.cc
|
SRC_CC = main.cc theme.cc window.cc
|
||||||
LIBS = base config server libc libpng zlib blit file
|
LIBS = base libc libpng zlib blit file
|
||||||
INC_DIR += $(PRG_DIR)
|
INC_DIR += $(PRG_DIR)
|
||||||
|
|
||||||
.PHONY: plain_decorator_theme.tar
|
.PHONY: plain_decorator_theme.tar
|
||||||
|
Reference in New Issue
Block a user