fix(indev) pass indev_act to the indev related events

This commit is contained in:
Gabor Kiss-Vamosi
2021-05-05 17:14:11 +02:00
parent c529644100
commit 744a974104

View File

@@ -403,14 +403,14 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
/*Send the ENTER as a normal KEY*/
lv_group_send_data(g, LV_KEY_ENTER);
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, indev_act);
if(indev_reset_check(&i->proc)) return;
}
else if(data->key == LV_KEY_ESC) {
/*Send the ESC as a normal KEY*/
lv_group_send_data(g, LV_KEY_ESC);
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, NULL);
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, indev_act);
if(indev_reset_check(&i->proc)) return;
}
/*Move the focus on NEXT*/
@@ -434,7 +434,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
else if(data->state == LV_INDEV_STATE_PRESSED && prev_state == LV_INDEV_STATE_PRESSED) {
if(data->key == LV_KEY_ENTER) {
lv_event_send(indev_obj_act, LV_EVENT_PRESSING, NULL);
lv_event_send(indev_obj_act, LV_EVENT_PRESSING, indev_act);
if(indev_reset_check(&i->proc)) return;
}
@@ -443,7 +443,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.long_pr_sent = 1;
if(data->key == LV_KEY_ENTER) {
i->proc.longpr_rep_timestamp = lv_tick_get();
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, indev_act);
if(indev_reset_check(&i->proc)) return;
}
}
@@ -455,7 +455,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
/*Send LONG_PRESS_REP on ENTER*/
if(data->key == LV_KEY_ENTER) {
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, indev_act);
if(indev_reset_check(&i->proc)) return;
}
/*Move the focus on NEXT again*/
@@ -484,15 +484,15 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data)
data->key = prev_key;
if(data->key == LV_KEY_ENTER) {
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, indev_act);
if(indev_reset_check(&i->proc)) return;
if(i->proc.long_pr_sent == 0) {
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, indev_act);
if(indev_reset_check(&i->proc)) return;
}
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, indev_act);
if(indev_reset_check(&i->proc)) return;
}
@@ -549,7 +549,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
bool editable = lv_obj_is_editable(indev_obj_act);
if(lv_group_get_editing(g) == true || editable == false) {
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, indev_act);
if(indev_reset_check(&i->proc)) return;
}
}
@@ -565,7 +565,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
/*Send the ESC as a normal KEY*/
lv_group_send_data(g, LV_KEY_ESC);
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, NULL);
lv_event_send(indev_obj_act, LV_EVENT_CANCEL, indev_act);
if(indev_reset_check(&i->proc)) return;
}
/*Just send other keys to the object (e.g. 'A' or `LV_GROUP_KEY_RIGHT`)*/
@@ -594,7 +594,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
}
/*If not editable then just send a long press Call the ancestor's event handler*/
else {
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, indev_act);
if(indev_reset_check(&i->proc)) return;
}
}
@@ -607,7 +607,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
i->proc.longpr_rep_timestamp = lv_tick_get();
if(data->key == LV_KEY_ENTER) {
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, indev_act);
if(indev_reset_check(&i->proc)) return;
}
else if(data->key == LV_KEY_LEFT) {
@@ -635,13 +635,13 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
/*The button was released on a non-editable object. Just send enter*/
if(editable == false) {
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, indev_act);
if(indev_reset_check(&i->proc)) return;
if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
if(i->proc.long_pr_sent == 0) lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, indev_act);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, indev_act);
if(indev_reset_check(&i->proc)) return;
}
@@ -649,13 +649,13 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
else if(g->editing) {
/*Ignore long pressed enter release because it comes from mode switch*/
if(!i->proc.long_pr_sent || _lv_ll_get_len(&g->obj_ll) <= 1) {
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, indev_act);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, indev_act);
if(indev_reset_check(&i->proc)) return;
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, indev_act);
if(indev_reset_check(&i->proc)) return;
@@ -805,7 +805,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
/*Save the obj because in special cases `act_obj` can change in the Call the ancestor's event handler function*/
lv_obj_t * last_obj = proc->types.pointer.act_obj;
lv_event_send(last_obj, LV_EVENT_PRESS_LOST, NULL);
lv_event_send(last_obj, LV_EVENT_PRESS_LOST, indev_act);
if(indev_reset_check(proc)) return;
}
@@ -826,7 +826,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
proc->types.pointer.vect.y = 0;
/*Call the ancestor's event handler about the press*/
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, indev_act);
if(indev_reset_check(proc)) return;
if(indev_act->proc.wait_until_release) return;
@@ -865,7 +865,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
if(proc->types.pointer.scroll_obj == NULL && proc->long_pr_sent == 0) {
/*Call the ancestor's event handler about the long press if enough time elapsed*/
if(lv_tick_elaps(proc->pr_timestamp) > indev_act->driver->long_press_time) {
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED, indev_act);
if(indev_reset_check(proc)) return;
/*Mark the Call the ancestor's event handler sending to do not send it again*/
@@ -880,7 +880,7 @@ static void indev_proc_press(lv_indev_proc_t * proc)
if(proc->types.pointer.scroll_obj == NULL && proc->long_pr_sent == 1) {
/*Call the ancestor's event handler about the long press repeat if enough time elapsed*/
if(lv_tick_elaps(proc->longpr_rep_timestamp) > indev_act->driver->long_press_repeat_time) {
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, NULL);
lv_event_send(indev_obj_act, LV_EVENT_LONG_PRESSED_REPEAT, indev_act);
if(indev_reset_check(proc)) return;
proc->longpr_rep_timestamp = lv_tick_get();
}
@@ -909,17 +909,17 @@ static void indev_proc_release(lv_indev_proc_t * proc)
LV_LOG_INFO("released");
/*Send RELEASE Call the ancestor's event handler and event*/
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, indev_act);
if(indev_reset_check(proc)) return;
/*Send CLICK if no scrolling*/
if(scroll_obj == NULL) {
if(proc->long_pr_sent == 0) {
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_SHORT_CLICKED, indev_act);
if(indev_reset_check(proc)) return;
}
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, NULL);
lv_event_send(indev_obj_act, LV_EVENT_CLICKED, indev_act);
if(indev_reset_check(proc)) return;
}
@@ -988,11 +988,11 @@ static void indev_click_focus(lv_indev_proc_t * proc)
/*The object are not in group*/
else {
if(proc->types.pointer.last_pressed) {
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, NULL);
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
if(indev_reset_check(proc)) return;
}
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, NULL);
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, indev_act);
if(indev_reset_check(proc)) return;
}
}
@@ -1000,7 +1000,7 @@ static void indev_click_focus(lv_indev_proc_t * proc)
else {
/*If the prev. obj. is not in a group then defocus it.*/
if(g_prev == NULL && proc->types.pointer.last_pressed) {
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, NULL);
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
if(indev_reset_check(proc)) return;
}
/*Focus on a non-group object*/
@@ -1008,12 +1008,12 @@ static void indev_click_focus(lv_indev_proc_t * proc)
if(proc->types.pointer.last_pressed) {
/*If the prev. object also wasn't in a group defocus it*/
if(g_prev == NULL) {
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, NULL);
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
if(indev_reset_check(proc)) return;
}
/*If the prev. object also was in a group at least "LEAVE" it instead of defocus*/
else {
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_LEAVE, NULL);
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_LEAVE, indev_act);
if(indev_reset_check(proc)) return;
}
}
@@ -1025,7 +1025,7 @@ static void indev_click_focus(lv_indev_proc_t * proc)
if(indev_reset_check(proc)) return;
}
else {
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, NULL);
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, indev_act);
if(indev_reset_check(proc)) return;
}
}
@@ -1081,7 +1081,7 @@ void indev_gesture(lv_indev_proc_t * proc)
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_TOP;
}
lv_event_send(gesture_obj, LV_EVENT_GESTURE, NULL);
lv_event_send(gesture_obj, LV_EVENT_GESTURE, indev_act);
if(indev_reset_check(proc)) return;
}
}