From ff1d3425b1f2b7e47f7bf77ea6a5ec1cb50a6885 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 6 Jun 2018 14:33:02 +0200 Subject: [PATCH] sculpt: more robust discovery intervention Sculpt's discovery of the default storage target can be intercepted by user input (i.e., pointer movements) at boot time. The patch makes this intervention mechanism robust for the case where nitpicker's first hover report arrives after all storage devices were already scanned. --- repos/gems/src/app/sculpt_manager/main.cc | 19 +++++++++---------- .../sculpt_manager/model/discovery_state.h | 11 +++++++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index ba741b840d..487e276926 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -74,8 +74,6 @@ struct Sculpt::Main : Input_event_handler, _input_filter_config.try_generate_manually_managed(); } - bool _first_hover_report = true; - Attached_rom_dataspace _nitpicker_hover { _env, "nitpicker_hover" }; Signal_handler
_nitpicker_hover_handler { @@ -438,23 +436,24 @@ void Sculpt::Main::_handle_hover() void Sculpt::Main::_handle_nitpicker_hover() { - if (!_first_hover_report) - return; - if (!_storage._discovery_state.discovery_in_progress()) return; + /* check if initial user activity has already been evaluated */ + if (_storage._discovery_state.user_state != Discovery_state::USER_UNKNOWN) + return; + _nitpicker_hover.update(); - Xml_node const hover = _nitpicker_hover.xml(); - if (!hover.has_type("hover")) return; - _first_hover_report = false; + _storage._discovery_state.user_state = hover.attribute_value("active", false) + ? Discovery_state::USER_INTERVENED + : Discovery_state::USER_IDLE; - if (hover.attribute_value("active", false) == true) - _storage._discovery_state.user_intervention = true; + /* trigger re-evaluation of default storage target */ + _storage.handle_storage_devices_update(); } diff --git a/repos/gems/src/app/sculpt_manager/model/discovery_state.h b/repos/gems/src/app/sculpt_manager/model/discovery_state.h index 1a60c6e30f..9619cb7b2a 100644 --- a/repos/gems/src/app/sculpt_manager/model/discovery_state.h +++ b/repos/gems/src/app/sculpt_manager/model/discovery_state.h @@ -26,7 +26,9 @@ namespace Sculpt { struct Discovery_state; } struct Sculpt::Discovery_state { - bool user_intervention = false; + enum User_state { USER_UNKNOWN, USER_IDLE, USER_INTERVENED }; + + User_state user_state { USER_UNKNOWN }; bool _done = false; @@ -39,9 +41,14 @@ struct Sculpt::Discovery_state return Storage_target { }; /* user intervention disarms the built-in selection policy */ - if (user_intervention) + if (user_state == USER_UNKNOWN) return Storage_target { }; + if (user_state == USER_INTERVENED) { + _done = true; + return Storage_target { }; + } + /* defer decision until the low-level device enumeration is complete */ if (!devices.all_devices_enumerated()) return Storage_target { };