sculpt_manager: improved popup toggling

In a corner case, the toggling of the popup menu entered a state
where the menu could not be opened anymore by the user. Specifically
the following input sequence triggered this problem.

1. The user opens the menu
2. The user clicks on the menu and holds the button
3. While holding the button, the user moves the pointer to the
   outside of the popup (e.g., to the '+' button)
4. The user releases the button.

In this situation, the popup is closed but the hover information for the
popup contains still the original clicked-on item. Hence, all subsequent
clicks on the '+' appear as both a click on the '+' (opening the popup)
and a click on the "hovered" popup entry (closing the popup).

The patch explicitely clears the popup's hover information when closing
the popup.
This commit is contained in:
Norman Feske 2018-10-25 11:37:43 +02:00 committed by Christian Helmuth
parent 7f1974e9e8
commit 6c70a51d28
2 changed files with 19 additions and 0 deletions

View File

@ -347,6 +347,7 @@ struct Sculpt::Main : Input_event_handler,
&& !_graph.add_button_hovered()) {
_popup.state = Popup::OFF;
_popup_dialog.reset_hover();
/* de-select '+' button */
_graph._gen_graph_dialog();
@ -406,6 +407,7 @@ struct Sculpt::Main : Input_event_handler,
/* close popup menu */
_popup.state = Popup::OFF;
_popup_dialog.reset_hover();
_handle_window_layout();
/* reset state of the '+' button */

View File

@ -102,6 +102,23 @@ struct Sculpt::Popup_dialog
action.launch_global(_item._hovered);
}
/*
* XXX
*
* This method should not be needed. However, in some situations,
* the popup menu_view does not receive a leave event when the popup
* is closed, to the effect of maintaining stale hover information
* instead of generating an empty hover report. So from the sculpt-
* manager's point of view, the popup is still hovered even if it is
* actually closed. The 'reset_hover' shortcuts the regular hover
* update in this situation.
*/
void reset_hover()
{
_item._hovered = Hoverable_item::Id();
_hovered = false;
}
Popup_dialog(Env &env, Launchers const &launchers,
Runtime_info const &runtime_info)
: