From d961d957e26f5c0c1b2603a9a0d98305147c15fb Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 8 Mar 2021 12:25:17 +0200 Subject: Fine-tuning touch behavior Avoid mouse motion events to prevent spurious hover states in the UI. --- src/ui/widget.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ui/widget.c') diff --git a/src/ui/widget.c b/src/ui/widget.c index 011f63d7..2d964445 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c @@ -557,7 +557,7 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) { if (!d->parent) { if (ev->type == SDL_MOUSEMOTION) { /* Hover widget may change. */ - rootData_.hover = NULL; + setHover_Widget(NULL); } if (rootData_.focus && isKeyboardEvent_(ev)) { /* Root dispatches keyboard events directly to the focused widget. */ @@ -577,7 +577,7 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) { flags_Widget(d) & hover_WidgetFlag && ~flags_Widget(d) & hidden_WidgetFlag && ~flags_Widget(d) & disabled_WidgetFlag) { if (contains_Widget(d, init_I2(ev->motion.x, ev->motion.y))) { - rootData_.hover = d; + setHover_Widget(d); } } if (filterEvent_Widget_(d, ev)) { @@ -1034,6 +1034,10 @@ iWidget *focus_Widget(void) { return rootData_.focus; } +void setHover_Widget(iWidget *d) { + rootData_.hover = d; +} + iWidget *hover_Widget(void) { return rootData_.hover; } -- cgit v1.2.3