Fix T44740: Tweak events stuck (ignored release)

Tweak event was being added to the end of the event queue (out of order),
meaning any mouse releases already in the queue wouldn't be used to exit the gesture.
Gestures could get stuck (mostly when the system wasn't able to handle events fast enough).

Now tweak events are now added in order.
This commit is contained in:
Campbell Barton 2015-05-26 19:57:52 +10:00
parent de68066c1c
commit 718bc078a8
Notes: blender-bot 2023-02-14 09:17:57 +01:00
Referenced by issue #44740, Press/Tweak Event Trigger Lag on Heavy Geo
3 changed files with 26 additions and 5 deletions

View File

@ -182,8 +182,15 @@ void WM_report_banner_show(const struct bContext *C);
void WM_report(const struct bContext *C, ReportType type, const char *message);
void WM_reportf(const struct bContext *C, ReportType type, const char *format, ...) ATTR_PRINTF_FORMAT(3, 4);
void wm_event_add(struct wmWindow *win, const struct wmEvent *event_to_add);
void wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
void wm_event_add_ex(
struct wmWindow *win, const struct wmEvent *event_to_add,
const struct wmEvent *event_to_add_after)
ATTR_NONNULL(1, 2);
void wm_event_add(
struct wmWindow *win, const struct wmEvent *event_to_add)
ATTR_NONNULL(1, 2);
void wm_event_init_from_window(struct wmWindow *win, struct wmEvent *event);
/* at maximum, every timestep seconds it triggers event_type events */

View File

@ -97,7 +97,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA
/* ************ event management ************** */
void wm_event_add(wmWindow *win, const wmEvent *event_to_add)
void wm_event_add_ex(wmWindow *win, const wmEvent *event_to_add, const wmEvent *event_to_add_after)
{
wmEvent *event = MEM_mallocN(sizeof(wmEvent), "wmEvent");
@ -105,7 +105,18 @@ void wm_event_add(wmWindow *win, const wmEvent *event_to_add)
update_tablet_data(win, event);
BLI_addtail(&win->queue, event);
if (event_to_add_after == NULL) {
BLI_addtail(&win->queue, event);
}
else {
/* note, strictly speaking this breaks const-correctness, however we're only changing 'next' member */
BLI_insertlinkafter(&win->queue, (void *)event_to_add_after, event);
}
}
void wm_event_add(wmWindow *win, const wmEvent *event_to_add)
{
wm_event_add_ex(win, event_to_add, NULL);
}
void wm_event_free(wmEvent *event)

View File

@ -3467,7 +3467,10 @@ static void tweak_gesture_modal(bContext *C, const wmEvent *event)
tevent.type = EVT_TWEAK_M;
tevent.val = val;
/* mouse coords! */
wm_event_add(window, &tevent);
/* important we add immediately after this event, so future mouse releases
* (which may be in the queue already), are handled in order, see T44740 */
wm_event_add_ex(window, &tevent, event);
WM_gesture_end(C, gesture); /* frees gesture itself, and unregisters from window */
}