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.
This commit is contained in:
Norman Feske 2018-06-06 14:33:02 +02:00 committed by Christian Helmuth
parent 9334f6c05d
commit ff1d3425b1
2 changed files with 18 additions and 12 deletions

View File

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

View File

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