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
This commit is contained in:
Norman Feske 2023-10-18 16:54:05 +02:00 committed by Christian Helmuth
parent b3a9a2eb4e
commit 94d04b724a
4 changed files with 64 additions and 12 deletions

View File

@ -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()

View File

@ -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", [&] () {

View File

@ -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;
}
}

View File

@ -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();
}
};