sculpt: prevent disabling the hovered display

Issue #5370
This commit is contained in:
Norman Feske 2024-10-28 16:37:57 +01:00 committed by Christian Helmuth
parent da6124c087
commit c9015d6076
5 changed files with 23 additions and 10 deletions

View File

@ -650,6 +650,8 @@ struct Sculpt::Main : Input_event_handler,
bool _leitzentrale_visible = false;
Fb_connectors::Name _hovered_display { };
Color const _background_color { 62, 62, 67, 255 };
Affinity::Space _affinity_space { 1, 1 };
@ -812,7 +814,7 @@ struct Sculpt::Main : Input_event_handler,
_graph { Id { "graph" },
_runtime_state, _cached_runtime_config, _storage._storage_devices,
_storage._selected_target, _storage._ram_fs_state, _fb_connectors,
_fb_config, _popup.state, _deploy._children };
_fb_config, _hovered_display, _popup.state, _deploy._children };
Conditional_widget<Network_widget>
_network_widget { Conditional_widget<Network_widget>::Attr { .centered = true },

View File

@ -101,7 +101,7 @@ void Graph::_view_selected_node_content(Scope<Depgraph, Frame, Vbox> &s,
s.widget(_ram_fs_widget, _selected_target, _ram_fs_state);
if (name == "intel_fb")
s.widget(_fb_widget, _fb_connectors, _fb_config);
s.widget(_fb_widget, _fb_connectors, _fb_config, _hovered_display);
String<100> const
ram (Capacity{info.assigned_ram - info.avail_ram}, " / ",

View File

@ -45,6 +45,7 @@ struct Sculpt::Graph : Widget<Depgraph>
Ram_fs_state const &_ram_fs_state;
Fb_connectors const &_fb_connectors;
Fb_config const &_fb_config;
Fb_connectors::Name const &_hovered_display;
Popup::State const &_popup_state;
Depot_deploy::Children const &_deploy_children;
@ -89,14 +90,15 @@ struct Sculpt::Graph : Widget<Depgraph>
Ram_fs_state const &ram_fs_state,
Fb_connectors const &fb_connectors,
Fb_config const &fb_config,
Fb_connectors::Name const &hovered_display,
Popup::State const &popup_state,
Depot_deploy::Children const &deploy_children)
:
_runtime_state(runtime_state), _runtime_config(runtime_config),
_storage_devices(storage_devices), _selected_target(selected_target),
_ram_fs_state(ram_fs_state), _fb_connectors(fb_connectors),
_fb_config(fb_config), _popup_state(popup_state),
_deploy_children(deploy_children)
_fb_config(fb_config), _hovered_display(hovered_display),
_popup_state(popup_state), _deploy_children(deploy_children)
{ }
void view(Scope<Depgraph> &) const;

View File

@ -763,6 +763,8 @@ struct Sculpt::Main : Input_event_handler,
Constructible<Gui::Point> _pointer_pos { };
Fb_connectors::Name _hovered_display { };
void _handle_nitpicker_hover(Xml_node const &hover)
{
if (hover.has_attribute("xpos"))
@ -1769,7 +1771,7 @@ struct Sculpt::Main : Input_event_handler,
Graph _graph { _runtime_state, _cached_runtime_config, _storage._storage_devices,
_storage._selected_target, _storage._ram_fs_state, _fb_connectors,
_fb_config, _popup.state, _deploy._children };
_fb_config, _hovered_display, _popup.state, _deploy._children };
struct Graph_dialog : Dialog::Top_level_dialog
{
@ -2097,7 +2099,8 @@ void Sculpt::Main::_handle_gui_mode()
_panorama = _gui.panorama();
/* place leitzentrale at pointed display */
Rect const orig_screen_rect { _screen_pos, _screen_size };
Rect const orig_screen_rect { _screen_pos, _screen_size };
Fb_connectors::Name const orig_hovered_display = _hovered_display;
{
Rect rect { };
@ -2111,8 +2114,11 @@ void Sculpt::Main::_handle_gui_mode()
info.for_each_sub_node("capture", [&] (Xml_node const &capture) {
Rect const display = Rect::from_xml(capture);
if (display.contains(at))
if (display.contains(at)) {
rect = display;
Session_label label { capture.attribute_value("name", String<64>()) };
_hovered_display = label.last_element();
}
});
});
@ -2120,7 +2126,8 @@ void Sculpt::Main::_handle_gui_mode()
_screen_size = rect.area;
}
bool const screen_changed = (orig_screen_rect != Rect { _screen_pos, _screen_size });
bool const screen_changed = (orig_screen_rect != Rect { _screen_pos, _screen_size })
|| (orig_hovered_display != _hovered_display);
if (screen_changed) {
_gui_fb_config.generate([&] (Xml_generator &xml) {

View File

@ -70,7 +70,8 @@ struct Sculpt::Fb_widget : Widget<Vbox>
using Hosted_brightness = Hosted<Bar>;
void view(Scope<Vbox> &s, Fb_connectors const &connectors, Fb_config const &config) const
void view(Scope<Vbox> &s, Fb_connectors const &connectors, Fb_config const &config,
Fb_connectors::Name const &hovered_display) const
{
auto view_connector = [&] (Connector const &conn)
{
@ -102,7 +103,8 @@ struct Sculpt::Fb_widget : Widget<Vbox>
s.widget(Mode_radio { Id { mode.id }, mode.id },
selected_mode, text);
});
s.widget(Mode_radio { Id { "off" }, "off" }, selected_mode, "off");
if (conn.name != hovered_display)
s.widget(Mode_radio { Id { "off" }, "off" }, selected_mode, "off");
});
};