Cleanup: cursor motion events now have value set to KM_NOTHING

In some cases value of cursor motion events was set from the last event
written to the wmWindow.eventstate. Avoid potential errors by ensuring
cursor motion events always have their value set to KM_NOTHING.
This commit is contained in:
Campbell Barton 2022-03-21 15:44:57 +11:00
parent 8ecaa2d624
commit 52af3b20d4
Notes: blender-bot 2023-02-14 11:25:11 +01:00
Referenced by commit 2580d2bab5, PyAPI: Expose event.type_prev, value_prev
Referenced by issue #99102, Regression: Information provided by event.value changed in 3.2
Referenced by issue #96828, Regression: GPencil primitives handlers not working
2 changed files with 10 additions and 0 deletions

View File

@ -194,6 +194,10 @@ void wm_event_free(wmEvent *event)
printf("%s: 'is_repeat=true' for non-keyboard event, this should not happen.\n", __func__);
WM_event_print(event);
}
if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && (event->val != KM_NOTHING)) {
printf("%s: 'val != NOTHING' for a cursor motion event, this should not happen.\n", __func__);
WM_event_print(event);
}
#endif
wm_event_custom_free(event);
@ -3879,6 +3883,7 @@ void wm_event_do_handlers(bContext *C)
wmEvent tevent = *(win->eventstate);
// printf("adding MOUSEMOVE %d %d\n", tevent.xy[0], tevent.xy[1]);
tevent.type = MOUSEMOVE;
tevent.val = KM_NOTHING;
tevent.prev_xy[0] = tevent.xy[0];
tevent.prev_xy[1] = tevent.xy[1];
tevent.flag = 0;
@ -4822,6 +4827,7 @@ static wmEvent *wm_event_add_mousemove_to_head(wmWindow *win)
}
tevent.type = MOUSEMOVE;
tevent.val = KM_NOTHING;
copy_v2_v2_int(tevent.prev_xy, tevent.xy);
wmEvent *event_new = wm_event_add(win, &tevent);
@ -4956,6 +4962,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
wm_tablet_data_from_ghost(&cd->tablet, &event.tablet);
event.type = MOUSEMOVE;
event.val = KM_NOTHING;
{
wmEvent *event_new = wm_event_add_mousemove(win, &event);
copy_v2_v2_int(event_state->xy, event_new->xy);
@ -4974,6 +4981,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
copy_v2_v2_int(event_other.xy, event.xy);
event_other.type = MOUSEMOVE;
event_other.val = KM_NOTHING;
{
wmEvent *event_new = wm_event_add_mousemove(win_other, &event_other);
copy_v2_v2_int(win_other->eventstate->xy, event_new->xy);

View File

@ -1215,6 +1215,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
wmEvent event;
wm_event_init_from_window(win, &event);
event.type = MOUSEMOVE;
event.val = KM_NOTHING;
copy_v2_v2_int(event.prev_xy, event.xy);
event.flag = 0;
@ -1346,6 +1347,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
/* activate region */
event.type = MOUSEMOVE;
event.val = KM_NOTHING;
copy_v2_v2_int(event.prev_xy, event.xy);
event.flag = 0;