diff --git a/repos/gems/include/dialog/runtime.h b/repos/gems/include/dialog/runtime.h index b99c17bf86..a6b0d19044 100644 --- a/repos/gems/include/dialog/runtime.h +++ b/repos/gems/include/dialog/runtime.h @@ -91,9 +91,9 @@ class Dialog::Runtime : private Sandbox::State_handler struct View : Sandboxed_runtime::View { - View(Runtime &runtime, Top_level_dialog &dialog) + View(Runtime &runtime, Top_level_dialog &dialog, auto &&... args) : - Sandboxed_runtime::View(runtime._runtime, dialog) + Sandboxed_runtime::View(runtime._runtime, dialog, args...) { runtime._update_sandbox_config(); } @@ -105,6 +105,8 @@ class Dialog::Runtime : private Sandbox::State_handler Event_handler(Runtime &runtime, T &obj, void (T::*member)(Event const &)) : Sandboxed_runtime::Event_handler(runtime._runtime, obj, member) { } }; + + void update_view_config() { _update_sandbox_config(); } }; #endif /* _INCLUDE__DIALOG__RUNTIME_H_ */ diff --git a/repos/gems/include/dialog/sandboxed_runtime.h b/repos/gems/include/dialog/sandboxed_runtime.h index 4d6138a8a8..abe02ccb75 100644 --- a/repos/gems/include/dialog/sandboxed_runtime.h +++ b/repos/gems/include/dialog/sandboxed_runtime.h @@ -15,6 +15,7 @@ #define _INCLUDE__DIALOG__SANDBOXED_RUNTIME_H_ #include +#include #include #include #include @@ -186,8 +187,7 @@ class Dialog::Sandboxed_runtime::View : private Views::Element friend class Dictionary; friend class Avl_node; friend class Avl_tree; - - public: + friend class Sandboxed_runtime; Env &_env; @@ -295,20 +295,27 @@ class Dialog::Sandboxed_runtime::View : private Views::Element { using Start_name = String<128>; - Start_name const _name; - Ram_quota const _initial_ram; - Cap_quota const _initial_caps; + Start_name const name; + Ram_quota const initial_ram; + Cap_quota const initial_caps; - Ram_quota _ram = _initial_ram; - Cap_quota _caps = _initial_caps; + Ram_quota ram = initial_ram; + Cap_quota caps = initial_caps; - unsigned _version = 0; + int xpos = 0, ypos = 0; + + unsigned min_width = 0, min_height = 0; + + bool opaque = false; + Color background { }; + + unsigned version = 0; void trigger_restart() { - _version++; - _ram = _initial_ram; - _caps = _initial_caps; + version++; + ram = initial_ram; + caps = initial_caps; } /** @@ -325,27 +332,22 @@ class Dialog::Sandboxed_runtime::View : private Views::Element { bool result = false; - if (child.attribute_value("name", Start_name()) != _name) + if (child.attribute_value("name", Start_name()) != name) return false; if (child.has_sub_node("ram") && child.sub_node("ram").has_attribute("requested")) { - _ram.value *= 2; + ram.value *= 2; result = true; } if (child.has_sub_node("caps") && child.sub_node("caps").has_attribute("requested")) { - _caps.value += 100; + caps.value += 100; result = true; } return result; } - Menu_view_state(Top_level_dialog::Name const &name, Ram_quota ram, Cap_quota caps) - : - _name(name), _initial_ram(ram), _initial_caps(caps) - { } - void gen_start_node(Xml_generator &) const; } _menu_view_state; @@ -354,14 +356,37 @@ class Dialog::Sandboxed_runtime::View : private Views::Element public: - View(Sandboxed_runtime &runtime, Top_level_dialog &dialog) + int &xpos = _menu_view_state.xpos; + int &ypos = _menu_view_state.ypos; + unsigned &min_width = _menu_view_state.min_width; + unsigned &min_height = _menu_view_state.min_height; + bool &opaque = _menu_view_state.opaque; + Color &background = _menu_view_state.background; + + struct Attr + { + bool opaque; + Ram_quota initial_ram; + }; + + View(Sandboxed_runtime &runtime, Top_level_dialog &dialog, Attr const attr) : Views::Element(runtime._views, dialog.name), _env(runtime._env), _alloc(runtime._alloc), _global_seq_number(runtime._global_seq_number), _optional_event_handler(runtime._optional_event_handler), _dialog(dialog), - _menu_view_state(dialog.name, Ram_quota { 4*1024*1024 }, Cap_quota { 200 }) + _menu_view_state({ + .name = dialog.name, + .initial_ram = attr.initial_ram, + .initial_caps = Cap_quota { 200 } + }) + { } + + View(Sandboxed_runtime &runtime, Top_level_dialog &dialog) + : + View(runtime, dialog, Attr { .opaque = false, + .initial_ram = { 4*1024*1024 } }) { } ~View(); diff --git a/repos/gems/src/lib/dialog/sandboxed_runtime.cc b/repos/gems/src/lib/dialog/sandboxed_runtime.cc index fcaafe016b..ef76727cd5 100644 --- a/repos/gems/src/lib/dialog/sandboxed_runtime.cc +++ b/repos/gems/src/lib/dialog/sandboxed_runtime.cc @@ -266,13 +266,13 @@ void Sandboxed_runtime::View::Menu_view_state::gen_start_node(Xml_generator &xml { xml.node("start", [&] () { - xml.attribute("name", _name); - xml.attribute("version", _version); - xml.attribute("caps", _caps.value); + xml.attribute("name", name); + xml.attribute("version", version); + xml.attribute("caps", caps.value); xml.node("resource", [&] () { xml.attribute("name", "RAM"); - Number_of_bytes const bytes(_ram.value); + Number_of_bytes const bytes(ram.value); xml.attribute("quantum", String<64>(bytes)); }); xml.node("binary", [&] () { @@ -280,6 +280,14 @@ void Sandboxed_runtime::View::Menu_view_state::gen_start_node(Xml_generator &xml xml.node("config", [&] () { + if (xpos) xml.attribute("xpos", xpos); + if (ypos) xml.attribute("ypos", ypos); + if (min_width) xml.attribute("width", min_width); + if (min_height) xml.attribute("height", min_height); + if (opaque) xml.attribute("opaque", "yes"); + + xml.attribute("background", String<20>(background)); + xml.node("report", [&] () { xml.attribute("hover", "yes"); });