diff --git a/radio/src/thirdparty/libopenui/src/window.cpp b/radio/src/thirdparty/libopenui/src/window.cpp index 9e3640d37..4dc918e2d 100644 --- a/radio/src/thirdparty/libopenui/src/window.cpp +++ b/radio/src/thirdparty/libopenui/src/window.cpp @@ -134,10 +134,19 @@ static void window_event_cb(lv_event_t * e) } else if (code == LV_EVENT_FOCUSED) { if (inhibit_focus) return; + bool focused = ((Window *)target->user_data)->hasFocus(); TRACE_WINDOWS("FOCUSED[%d] %s", focused, window->getWindowDebugString().c_str()); - if (!focused) { window->setFocus(); } + + if (!focused) { + SetFocusFlag flag = SET_FOCUS_DEFAULT; + lv_indev_type_t indev_type = lv_indev_get_type(lv_indev_get_act()); + if(indev_type == LV_INDEV_TYPE_POINTER) { + flag = SET_FOCUS_NO_SCROLL; + } + window->setFocus(flag); + } } } @@ -383,7 +392,9 @@ void Window::setFocus(uint8_t flag, Window * from) // scroll before calling focusHandler so that the window can adjust the // scroll position if needed - lv_obj_scroll_to_view_recursive(lvobj, LV_ANIM_OFF); + if (flag != SET_FOCUS_NO_SCROLL) { + lv_obj_scroll_to_view_recursive(lvobj, LV_ANIM_OFF); + } clearFocus(); focusWindow = this; diff --git a/radio/src/thirdparty/libopenui/src/window.h b/radio/src/thirdparty/libopenui/src/window.h index dae741aa5..8513a6089 100644 --- a/radio/src/thirdparty/libopenui/src/window.h +++ b/radio/src/thirdparty/libopenui/src/window.h @@ -53,10 +53,11 @@ constexpr WindowFlags WINDOW_FLAGS_LAST = PUSH_FRONT; enum SetFocusFlag { - SET_FOCUS_DEFAULT, - SET_FOCUS_FORWARD, - SET_FOCUS_BACKWARD, - SET_FOCUS_FIRST + SET_FOCUS_DEFAULT = 0, + SET_FOCUS_FORWARD = 1, + SET_FOCUS_BACKWARD = 2, + SET_FOCUS_FIRST = 3, + SET_FOCUS_NO_SCROLL= 4 }; typedef lv_obj_t *(*LvglCreate)(lv_obj_t *);