From 0f06fad706024a9db31826a2ee06035f256c1edd Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Tue, 25 Jan 2022 19:19:34 +0100 Subject: [PATCH] Fix touch events --- radio/src/thirdparty/libopenui/src/window.cpp | 38 +++---------------- radio/src/thirdparty/libopenui/src/window.h | 1 - 2 files changed, 6 insertions(+), 33 deletions(-) diff --git a/radio/src/thirdparty/libopenui/src/window.cpp b/radio/src/thirdparty/libopenui/src/window.cpp index 0ff9571c5..9309cf3d5 100644 --- a/radio/src/thirdparty/libopenui/src/window.cpp +++ b/radio/src/thirdparty/libopenui/src/window.cpp @@ -573,42 +573,16 @@ void Window::onEvent(event_t event) #if defined(HARDWARE_TOUCH) bool Window::onTouchStart(coord_t x, coord_t y) { - for (auto it = children.rbegin(); it != children.rend(); ++it) { - auto child = *it; - if (child->rect.contains(x, y)) { - if (child->onTouchStart(x - child->rect.x + child->scrollPositionX, y - child->rect.y + child->scrollPositionY)) { - return true; - } - } - } - - return false; -} - -bool Window::forwardTouchEnd(coord_t x, coord_t y) -{ - if (capturedWindow != nullptr) - { - capturedWindow->onTouchEnd(x, y); - capturedWindow = nullptr; - return true; - } - - for (auto it = children.rbegin(); it != children.rend(); ++it) { - auto child = *it; - if (child->rect.contains(x, y)) { - if (child->onTouchEnd(x - child->rect.x + child->scrollPositionX, y - child->rect.y + child->scrollPositionY)) { - return true; - } - } - } - - return false; + if (parent) + return parent->onTouchStart(x, y); + return true; } bool Window::onTouchEnd(coord_t x, coord_t y) { - return forwardTouchEnd(x, y) ? true : (windowFlags & OPAQUE); + if (parent && !(windowFlags & OPAQUE)) + return parent->onTouchEnd(x, y); + return true; } bool Window::onTouchSlide(coord_t x, coord_t y, coord_t startX, coord_t startY, coord_t slideX, coord_t slideY) diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index 0bfc0eaa1..5a3d9339e 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -484,7 +484,6 @@ class Window coord_t startY, coord_t slideX, coord_t slideY); #endif - bool forwardTouchEnd(coord_t x, coord_t y); bool hasOpaqueRect(const rect_t & testRect) const; };