From 94d04b724a8d098e16c231b7b33a9a65c7c4b8dd Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 18 Oct 2023 16:54:05 +0200 Subject: [PATCH] sculpt: add system-control in resource dialog This patch allows for the interactive assignment of the system-control role to a new component via the resource dialog. This is useful for integrating low-level components like the Intel frequency/power monitoring tool. Fixes #5033 --- .../src/app/sculpt_manager/model/component.h | 13 ++++-- .../app/sculpt_manager/model/runtime_state.h | 2 +- .../sculpt_manager/view/resource_dialog.cc | 18 +++++--- .../app/sculpt_manager/view/resource_dialog.h | 43 ++++++++++++++++++- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/repos/gems/src/app/sculpt_manager/model/component.h b/repos/gems/src/app/sculpt_manager/model/component.h index 401d171553..ee68af777f 100644 --- a/repos/gems/src/app/sculpt_manager/model/component.h +++ b/repos/gems/src/app/sculpt_manager/model/component.h @@ -48,9 +48,10 @@ struct Sculpt::Component : Noncopyable affinity_space.height() }; Priority priority = Priority::DEFAULT; - bool monitor { false }; - bool wait { false }; - bool wx { false }; + bool monitor { false }; + bool wait { false }; + bool wx { false }; + bool system_control { false }; struct Blueprint_info { @@ -175,6 +176,12 @@ struct Sculpt::Component : Noncopyable xml.attribute("priority", (int)priority); } + void gen_system_control(Xml_generator &xml) const + { + if (system_control) + xml.attribute("managing_system", "yes"); + } + void gen_affinity(Xml_generator &xml) const { bool const all_cpus = affinity_space.width() == affinity_location.width() diff --git a/repos/gems/src/app/sculpt_manager/model/runtime_state.h b/repos/gems/src/app/sculpt_manager/model/runtime_state.h index c10254bf2f..d7fcc5fa85 100644 --- a/repos/gems/src/app/sculpt_manager/model/runtime_state.h +++ b/repos/gems/src/app/sculpt_manager/model/runtime_state.h @@ -183,8 +183,8 @@ class Sculpt::Runtime_state : public Runtime_info xml.attribute("pkg", construction->path); construction->gen_priority(xml); + construction->gen_system_control(xml); construction->gen_affinity(xml); - construction->gen_monitor(xml); xml.node("route", [&] () { diff --git a/repos/gems/src/app/sculpt_manager/view/resource_dialog.cc b/repos/gems/src/app/sculpt_manager/view/resource_dialog.cc index 3756152f84..f97a3e755f 100644 --- a/repos/gems/src/app/sculpt_manager/view/resource_dialog.cc +++ b/repos/gems/src/app/sculpt_manager/view/resource_dialog.cc @@ -173,13 +173,12 @@ void Resource_dialog::_gen_priority_section(Xml_generator &xml) const void Resource_dialog::click(Component &component) { - if (component.affinity_space.total() <= 1) - return; - - Hoverable_item::Id const clicked_space = _space_item._hovered; - if (clicked_space.valid()) { - _click_space(component, clicked_space); - return; + if (component.affinity_space.total() > 1) { + Hoverable_item::Id const clicked_space = _space_item._hovered; + if (clicked_space.valid()) { + _click_space(component, clicked_space); + return; + } } Hoverable_item::Id const clicked_priority = _priority_item._hovered; @@ -187,6 +186,11 @@ void Resource_dialog::click(Component &component) _click_priority(component, clicked_priority); return; } + + if (_option_item.hovered("system_control")) { + _system_control = !_system_control; + component.system_control = _system_control; + } } diff --git a/repos/gems/src/app/sculpt_manager/view/resource_dialog.h b/repos/gems/src/app/sculpt_manager/view/resource_dialog.h index ffa504404e..e89407b0c0 100644 --- a/repos/gems/src/app/sculpt_manager/view/resource_dialog.h +++ b/repos/gems/src/app/sculpt_manager/view/resource_dialog.h @@ -34,6 +34,9 @@ struct Sculpt::Resource_dialog : Noncopyable, Deprecated_dialog Affinity::Location _location; Hoverable_item _space_item { }; Selectable_item _priority_item { }; + Hoverable_item _option_item { }; + + bool _system_control = false; static char const *_priority_id(Priority priority) { @@ -72,7 +75,9 @@ struct Sculpt::Resource_dialog : Noncopyable, Deprecated_dialog ), _priority_item.match(hover, "vbox", "float", "hbox", /* _gen_dialog_section */ - "vbox", "hbox", "float", "hbox", "name")); + "vbox", "hbox", "float", "hbox", "name"), + _option_item.match(hover, "vbox", "hbox", "name") + ); } void click(Component &); @@ -122,6 +127,38 @@ struct Sculpt::Resource_dialog : Noncopyable, Deprecated_dialog }); } + void _gen_option(Xml_generator &xml, auto const &name, auto const &text, bool selected) const + { + gen_named_node(xml, "hbox", name, [&] () { + + gen_named_node(xml, "float", "left", [&] () { + xml.attribute("west", "yes"); + + xml.node("hbox", [&] () { + + /* align with the "Resource assignment ..." dialog */ + gen_named_node(xml, "button", "left", [&] () { + xml.attribute("style", "invisible"); + xml.node("hbox", [&] () { }); }); + + gen_named_node(xml, "button", "button", [&] () { + + if (selected) + xml.attribute("selected", "yes"); + + xml.attribute("style", "checkbox"); + _option_item.gen_hovered_attr(xml, name); + xml.node("hbox", [&] () { }); + }); + gen_named_node(xml, "label", "name", [&] () { + xml.attribute("text", Path(" ", text)); }); + }); + }); + + gen_named_node(xml, "hbox", "right", [&] () { }); + }); + } + void generate(Xml_generator &xml) const override { auto gen_vspacer = [&] (auto id) { @@ -135,6 +172,8 @@ struct Sculpt::Resource_dialog : Noncopyable, Deprecated_dialog gen_vspacer("spacer2"); _gen_priority_section(xml); gen_vspacer("spacer3"); + _gen_option(xml, "system_control", "System control", _system_control); + gen_vspacer("spacer4"); }); } @@ -143,6 +182,8 @@ struct Sculpt::Resource_dialog : Noncopyable, Deprecated_dialog _space_item._hovered = Hoverable_item::Id(); _priority_item.reset(); _location = Affinity::Location(); + _system_control = false; + _option_item._hovered = Hoverable_item::Id(); } };