window: do not scroll on touch-focus

This commit is contained in:
Raphael Coeffic
2022-06-11 15:13:11 +02:00
committed by Raphael Coeffic
parent 170fa8152e
commit ff080ff3d8
2 changed files with 18 additions and 6 deletions
+13 -2
View File
@@ -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;
+5 -4
View File
@@ -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 *);