sculpt: fix interplay of popup with old dialogs

This is a follow-up fix for commit "sculpt: apply Dialog API to diag,
panel, and graph", which happened to render the legacy dialogs (network
and settings) inaccessible.

The patch avoids the use of clack seq numbers for the 'popup_opened'
condition (which happens on click, not clack). It also overrides old
click information on the arrival of a new click, avoiding the evaluation
of stale click sequence numbers in distant_runtime.cc. Furthermore, it
reduces the rate of 'Distant_runtime::_try_handle_click_and_clack'.

Issue #5008
This commit is contained in:
Norman Feske 2023-10-17 12:32:14 +02:00 committed by Christian Helmuth
parent eb2843de33
commit d3e5e5c286
2 changed files with 27 additions and 16 deletions

View File

@ -93,7 +93,10 @@ void Distant_runtime::route_input_event(Event::Seq_number seq_number, Input::Eve
if (event.absolute_motion()) _hover_observable_without_click = true;
if (event.touch()) _hover_observable_without_click = false;
if (click(event) && !_click_seq_number.constructed()) {
bool const new_click_seq = !_click_seq_number.constructed()
|| _click_seq_number->value != _global_seq_number.value;
if (click(event) && new_click_seq) {
_click_seq_number.construct(_global_seq_number);
_click_delivered = false;
}
@ -101,7 +104,8 @@ void Distant_runtime::route_input_event(Event::Seq_number seq_number, Input::Eve
if (clack(event))
_clack_seq_number.construct(_global_seq_number);
_try_handle_click_and_clack();
if (click(event) || clack(event))
_try_handle_click_and_clack();
}

View File

@ -677,47 +677,52 @@ struct Sculpt::Main : Input_event_handler,
/* used to detect clicks outside the popup dialog (for closing it) */
bool popup_dialog_clicked = false;
bool const popup_opened = (_popup_opened_seq_number.value == seq.value);
bool click_consumed = false;
if (_popup_menu_view.hovered(seq)) {
_popup_dialog.click(*this);
click_consumed = true;
_popup_menu_view.generate();
_clicked_seq_number.destruct();
popup_dialog_clicked = true;
}
else if (_settings_menu_view.hovered(seq)) {
_settings_dialog.click(*this);
click_consumed = true;
_settings_menu_view.generate();
_clicked_seq_number.destruct();
}
else if (_system_menu_view.hovered(seq)) {
_system_dialog.click();
click_consumed = true;
_system_menu_view.generate();
_clicked_seq_number.destruct();
}
else if (_network_menu_view.hovered(seq)) {
_network.dialog.click(_network);
click_consumed = true;
_network_menu_view.generate();
_clicked_seq_number.destruct();
}
else if (_file_browser_menu_view.hovered(seq)) {
_file_browser_dialog.click(*this);
click_consumed = true;
_file_browser_menu_view.generate();
_clicked_seq_number.destruct();
}
/* remove popup dialog when clicking somewhere outside */
if (!popup_dialog_clicked && !_popup_menu_view._hovered && !popup_opened) {
_popup.state = Popup::OFF;
_popup_dialog.reset();
discard_construction();
if (_popup.state == Popup::VISIBLE) {
_popup.state = Popup::OFF;
_popup_dialog.reset();
discard_construction();
/* de-select '+' button */
_graph_view.refresh();
/* de-select '+' button */
_graph_view.refresh();
/* remove popup window from window layout */
_handle_window_layout();
_clicked_seq_number.destruct();
/* remove popup window from window layout */
_handle_window_layout();
}
}
if (click_consumed)
_clicked_seq_number.destruct();
}
void _try_handle_clack()
@ -911,7 +916,9 @@ struct Sculpt::Main : Input_event_handler,
if (_popup.state == Popup::VISIBLE)
return;
_popup_opened_seq_number = _global_input_seq_number;
if (_clicked_seq_number.constructed())
_popup_opened_seq_number = *_clicked_seq_number;
_popup_menu_view.generate();
_popup.anchor = anchor;
_popup.state = Popup::VISIBLE;