fix(indev): swap the order of sending indev events and obj events (#6636)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: Gabor Kiss-Vamosi <kisvegabor@gmail.com>
This commit is contained in:
@@ -380,6 +380,13 @@ void * lv_indev_get_driver_data(const lv_indev_t * indev)
|
||||
return indev->driver_data;
|
||||
}
|
||||
|
||||
bool lv_indev_get_press_moved(const lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return false;
|
||||
|
||||
return indev->pointer.press_moved;
|
||||
}
|
||||
|
||||
void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
|
||||
{
|
||||
if(indev) {
|
||||
@@ -395,6 +402,12 @@ void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
|
||||
}
|
||||
}
|
||||
|
||||
void lv_indev_stop_processing(lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return;
|
||||
indev->stop_processing_query = 1;
|
||||
}
|
||||
|
||||
void lv_indev_reset_long_press(lv_indev_t * indev)
|
||||
{
|
||||
indev->long_pr_sent = 0;
|
||||
@@ -1199,6 +1212,7 @@ static void indev_proc_press(lv_indev_t * indev)
|
||||
indev->pointer.gesture_sent = 0;
|
||||
indev->pointer.gesture_sum.x = 0;
|
||||
indev->pointer.gesture_sum.y = 0;
|
||||
indev->pointer.press_moved = 0;
|
||||
indev->pointer.vect.x = 0;
|
||||
indev->pointer.vect.y = 0;
|
||||
|
||||
@@ -1228,6 +1242,10 @@ static void indev_proc_press(lv_indev_t * indev)
|
||||
|
||||
indev->pointer.scroll_throw_vect_ori = indev->pointer.scroll_throw_vect;
|
||||
|
||||
if(LV_ABS(indev->pointer.vect.x) > indev->scroll_limit || LV_ABS(indev->pointer.vect.y) > indev->scroll_limit) {
|
||||
indev->pointer.press_moved = 1;
|
||||
}
|
||||
|
||||
if(indev_obj_act) {
|
||||
const bool is_enabled = !lv_obj_has_state(indev_obj_act, LV_STATE_DISABLED);
|
||||
|
||||
@@ -1449,6 +1467,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev)
|
||||
indev->pointer.gesture_sum.x = 0;
|
||||
indev->pointer.gesture_sum.y = 0;
|
||||
indev->reset_query = 0;
|
||||
indev->stop_processing_query = 0;
|
||||
indev_obj_act = NULL;
|
||||
}
|
||||
}
|
||||
@@ -1589,6 +1608,16 @@ static bool indev_reset_check(lv_indev_t * indev)
|
||||
return indev->reset_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the stop_processing_query flag has been set. If so, do not send any events to the object
|
||||
* @param indev pointer to an input device
|
||||
* @return true if indev should stop processing the event.
|
||||
*/
|
||||
static bool indev_stop_processing_check(lv_indev_t * indev)
|
||||
{
|
||||
return indev->stop_processing_query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the indev and send event to active obj and scroll obj
|
||||
* @param indev pointer to an input device
|
||||
@@ -1636,19 +1665,28 @@ static void indev_reset_core(lv_indev_t * indev, lv_obj_t * obj)
|
||||
|
||||
static lv_result_t send_event(lv_event_code_t code, void * param)
|
||||
{
|
||||
lv_obj_send_event(indev_obj_act, code, param);
|
||||
if(indev_reset_check(indev_act)) return LV_RESULT_INVALID;
|
||||
lv_indev_t * indev = indev_act;
|
||||
|
||||
if(code == LV_EVENT_PRESSED ||
|
||||
code == LV_EVENT_SHORT_CLICKED ||
|
||||
code == LV_EVENT_CLICKED ||
|
||||
code == LV_EVENT_RELEASED ||
|
||||
code == LV_EVENT_LONG_PRESSED ||
|
||||
code == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
code == LV_EVENT_ROTARY) {
|
||||
lv_indev_send_event(indev_act, code, indev_obj_act);
|
||||
if(indev_reset_check(indev_act)) return LV_RESULT_INVALID;
|
||||
lv_indev_send_event(indev, code, indev_obj_act);
|
||||
if(indev_reset_check(indev)) return LV_RESULT_INVALID;
|
||||
|
||||
if(indev_stop_processing_check(indev)) {
|
||||
/* Not send event to the object if stop processing query is set */
|
||||
indev->stop_processing_query = 0;
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_send_event(indev_obj_act, code, param);
|
||||
if(indev_reset_check(indev)) return LV_RESULT_INVALID;
|
||||
|
||||
return LV_RESULT_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +201,13 @@ void * lv_indev_get_user_data(const lv_indev_t * indev);
|
||||
*/
|
||||
void * lv_indev_get_driver_data(const lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Get whether indev is moved while pressed
|
||||
* @param indev pointer to an input device
|
||||
* @return true: indev is moved while pressed; false: indev is not moved while pressed
|
||||
*/
|
||||
bool lv_indev_get_press_moved(const lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Reset one or all input devices
|
||||
* @param indev pointer to an input device to reset or NULL to reset all of them
|
||||
@@ -208,6 +215,13 @@ void * lv_indev_get_driver_data(const lv_indev_t * indev);
|
||||
*/
|
||||
void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Touch and key related events are sent to the input device first and to the widget after that.
|
||||
* If this functions called in an indev event, the event won't be sent to the widget.
|
||||
* @param indev pointer to an input device
|
||||
*/
|
||||
void lv_indev_stop_processing(lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Reset the long press state of an input device
|
||||
* @param indev pointer to an input device
|
||||
|
||||
@@ -38,6 +38,7 @@ struct lv_indev_t {
|
||||
uint8_t reset_query : 1;
|
||||
uint8_t enabled : 1;
|
||||
uint8_t wait_until_release : 1;
|
||||
uint8_t stop_processing_query : 1;
|
||||
|
||||
uint32_t pr_timestamp; /**< Pressed time stamp*/
|
||||
uint32_t longpr_rep_timestamp; /**< Long press repeat time stamp*/
|
||||
@@ -94,6 +95,7 @@ struct lv_indev_t {
|
||||
uint8_t scroll_dir : 4;
|
||||
uint8_t gesture_dir : 4;
|
||||
uint8_t gesture_sent : 1;
|
||||
uint8_t press_moved : 1;
|
||||
} pointer;
|
||||
struct {
|
||||
/*Keypad data*/
|
||||
|
||||
Reference in New Issue
Block a user