decorator: use modern list-model interface

Issue #4317
This commit is contained in:
Norman Feske 2023-10-27 16:46:43 +02:00 committed by Christian Helmuth
parent c9938e424b
commit 47ac55e9c5
2 changed files with 19 additions and 35 deletions

View File

@ -195,6 +195,19 @@ class Decorator::Window_base : private Genode::List_model<Window_base>::Element
* model has not changed
*/
virtual bool animated() const { return false; }
/**
* List_model::Element
*/
bool matches(Xml_node const &node) const
{
return _id == node.attribute_value("id", ~0UL);
}
/**
* List_model::Element
*/
static bool type_matches(Xml_node const &) { return true; }
};
#endif /* _INCLUDE__DECORATOR__WINDOW_H_ */

View File

@ -192,32 +192,14 @@ void Decorator::Window_stack::update_model(Genode::Xml_node root_node,
{
Abandoned_windows _abandoned_windows { };
struct Update_policy : List_model<Window_base>::Update_policy
{
Abandoned_windows &_abandoned_windows;
Window_factory_base &_window_factory;
Dirty_rect &_dirty_rect;
update_list_model_from_xml(_windows, root_node,
Update_policy(Abandoned_windows &abandoned_windows,
Window_factory_base &window_factory,
Dirty_rect &dirty_rect)
:
_abandoned_windows(abandoned_windows),
_window_factory(window_factory),
_dirty_rect(dirty_rect)
{ }
[&] (Xml_node const &node) -> Window_base & {
return *_window_factory.create(node); },
void destroy_element(Window_base &window)
{
window.abandon(_abandoned_windows);
}
[&] (Window_base &window) { window.abandon(_abandoned_windows); },
Window_base &create_element(Xml_node node)
{
return *_window_factory.create(node);
}
void update_element(Window_base &window, Xml_node node)
[&] (Window_base &window, Xml_node const &node)
{
Rect const orig_geometry = window.outer_geometry();
@ -226,18 +208,7 @@ void Decorator::Window_stack::update_model(Genode::Xml_node root_node,
_dirty_rect.mark_as_dirty(window.outer_geometry());
}
}
static bool element_matches_xml_node(Window_base const &elem, Xml_node node)
{
return elem.id() == node.attribute_value("id", ~0UL);
}
static bool node_is_element(Xml_node) { return true; }
};
Update_policy policy { _abandoned_windows, _window_factory, _dirty_rect };
_windows.update_from_xml(policy, root_node);
);
unsigned long new_front_most_id = ~0UL;
if (root_node.has_sub_node("window"))