summaryrefslogtreecommitdiff
path: root/src/ui/widget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-08 12:25:17 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-08 12:25:53 +0200
commitd961d957e26f5c0c1b2603a9a0d98305147c15fb (patch)
tree5a2caecc01918c8f54afb68c5bbd121a89740c11 /src/ui/widget.c
parent2fb1f5bed356520bc0b668f2a8ffef6c8d0318d2 (diff)
Fine-tuning touch behavior
Avoid mouse motion events to prevent spurious hover states in the UI.
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r--src/ui/widget.c8
1 files changed, 6 insertions, 2 deletions
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) {
557 if (!d->parent) { 557 if (!d->parent) {
558 if (ev->type == SDL_MOUSEMOTION) { 558 if (ev->type == SDL_MOUSEMOTION) {
559 /* Hover widget may change. */ 559 /* Hover widget may change. */
560 rootData_.hover = NULL; 560 setHover_Widget(NULL);
561 } 561 }
562 if (rootData_.focus && isKeyboardEvent_(ev)) { 562 if (rootData_.focus && isKeyboardEvent_(ev)) {
563 /* Root dispatches keyboard events directly to the focused widget. */ 563 /* Root dispatches keyboard events directly to the focused widget. */
@@ -577,7 +577,7 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) {
577 flags_Widget(d) & hover_WidgetFlag && ~flags_Widget(d) & hidden_WidgetFlag && 577 flags_Widget(d) & hover_WidgetFlag && ~flags_Widget(d) & hidden_WidgetFlag &&
578 ~flags_Widget(d) & disabled_WidgetFlag) { 578 ~flags_Widget(d) & disabled_WidgetFlag) {
579 if (contains_Widget(d, init_I2(ev->motion.x, ev->motion.y))) { 579 if (contains_Widget(d, init_I2(ev->motion.x, ev->motion.y))) {
580 rootData_.hover = d; 580 setHover_Widget(d);
581 } 581 }
582 } 582 }
583 if (filterEvent_Widget_(d, ev)) { 583 if (filterEvent_Widget_(d, ev)) {
@@ -1034,6 +1034,10 @@ iWidget *focus_Widget(void) {
1034 return rootData_.focus; 1034 return rootData_.focus;
1035} 1035}
1036 1036
1037void setHover_Widget(iWidget *d) {
1038 rootData_.hover = d;
1039}
1040
1037iWidget *hover_Widget(void) { 1041iWidget *hover_Widget(void) {
1038 return rootData_.hover; 1042 return rootData_.hover;
1039} 1043}