From c9015d607606556ba5e32d2c3848f94773d0bc17 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 28 Oct 2024 16:37:57 +0100 Subject: [PATCH] sculpt: prevent disabling the hovered display Issue #5370 --- repos/gems/src/app/phone_manager/main.cc | 4 +++- repos/gems/src/app/sculpt_manager/graph.cc | 2 +- repos/gems/src/app/sculpt_manager/graph.h | 6 ++++-- repos/gems/src/app/sculpt_manager/main.cc | 15 +++++++++++---- .../gems/src/app/sculpt_manager/view/fb_widget.h | 6 ++++-- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/repos/gems/src/app/phone_manager/main.cc b/repos/gems/src/app/phone_manager/main.cc index 8d74ab0351..a754205a45 100644 --- a/repos/gems/src/app/phone_manager/main.cc +++ b/repos/gems/src/app/phone_manager/main.cc @@ -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 { Conditional_widget::Attr { .centered = true }, diff --git a/repos/gems/src/app/sculpt_manager/graph.cc b/repos/gems/src/app/sculpt_manager/graph.cc index c9c86fa674..48cfaf540c 100644 --- a/repos/gems/src/app/sculpt_manager/graph.cc +++ b/repos/gems/src/app/sculpt_manager/graph.cc @@ -101,7 +101,7 @@ void Graph::_view_selected_node_content(Scope &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}, " / ", diff --git a/repos/gems/src/app/sculpt_manager/graph.h b/repos/gems/src/app/sculpt_manager/graph.h index 5bd5c6cb33..5a71cea8a7 100644 --- a/repos/gems/src/app/sculpt_manager/graph.h +++ b/repos/gems/src/app/sculpt_manager/graph.h @@ -45,6 +45,7 @@ struct Sculpt::Graph : Widget 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 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 &) const; diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index c702667269..ca2847ba01 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -763,6 +763,8 @@ struct Sculpt::Main : Input_event_handler, Constructible _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) { diff --git a/repos/gems/src/app/sculpt_manager/view/fb_widget.h b/repos/gems/src/app/sculpt_manager/view/fb_widget.h index 6b1de2815f..3f22e53ae3 100644 --- a/repos/gems/src/app/sculpt_manager/view/fb_widget.h +++ b/repos/gems/src/app/sculpt_manager/view/fb_widget.h @@ -70,7 +70,8 @@ struct Sculpt::Fb_widget : Widget using Hosted_brightness = Hosted; - void view(Scope &s, Fb_connectors const &connectors, Fb_config const &config) const + void view(Scope &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 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"); }); };