diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-01-09 02:36:53 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-01-09 02:36:53 +0300 |
commit | 99c798b8a623fdf40d592a2b48304ebe77040f4a (patch) | |
tree | cf2e92e8cdc1197093df74a842e831f7c11b179c /source | |
parent | 533d146f48d1a12c75506c4fca38f577902b79bf (diff) |
Cleanup: centralize WM_gesture_end call
Prepare for adding extra logic on free (next).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture_ops.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c index 5dd67355f54..4bd87b33a23 100644 --- a/source/blender/windowmanager/intern/wm_gesture_ops.c +++ b/source/blender/windowmanager/intern/wm_gesture_ops.c @@ -466,16 +466,17 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event) wmWindow *window = CTX_wm_window(C); wmGesture *gesture = window->tweak; rcti *rect = gesture->customdata; - int val; + bool gesture_end = false; switch (event->type) { case MOUSEMOVE: - case INBETWEEN_MOUSEMOVE: + case INBETWEEN_MOUSEMOVE: { rect->xmax = event->x - gesture->winrct.xmin; rect->ymax = event->y - gesture->winrct.ymin; - if ((val = wm_gesture_evaluate(gesture, event))) { + const int val = wm_gesture_evaluate(gesture, event); + if (val != 0) { wmEvent tevent; wm_event_init_from_window(window, &tevent); @@ -499,16 +500,17 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event) * (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 */ + gesture_end = true; } break; + } case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: if (gesture->event_type == event->type) { - WM_gesture_end(C, gesture); + gesture_end = true; /* when tweak fails we should give the other keymap entries a chance */ @@ -518,10 +520,15 @@ static void gesture_tweak_modal(bContext *C, const wmEvent *event) break; default: if (!ISTIMER(event->type) && event->type != EVENT_NONE) { - WM_gesture_end(C, gesture); + gesture_end = true; } break; } + + if (gesture_end) { + /* Frees gesture itself, and unregisters from window. */ + WM_gesture_end(C, gesture); + } } /* standard tweak, called after window handlers passed on event */ |