From 1a4aca1b6941a7cede14f2efc68c83fde20ba972 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Sep 2018 23:20:04 +1000 Subject: WM: move mousemove out of internal undo function This causes a feedback loop in 2.8x, where gizmo redo caused fake mousemove that executed gizmo again. Move the mousemove into the undo/redo operator. --- source/blender/editors/undo/ed_undo.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'source/blender/editors/undo') diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 621c5d73d5a..e0a1faf04b8 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -105,8 +105,6 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) { CLOG_INFO(&LOG, 1, "name='%s', step=%d", undoname, step); wmWindowManager *wm = CTX_wm_manager(C); - wmWindow *win = CTX_wm_window(C); - // Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); /* undo during jobs are running can easily lead to freeing data using by jobs, @@ -166,10 +164,6 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_WM | ND_UNDO, NULL); - if (win) { - win->addmousemove = true; - } - return OPERATOR_FINISHED; } @@ -247,7 +241,12 @@ static int ed_undo_exec(bContext *C, wmOperator *UNUSED(op)) { /* "last operator" should disappear, later we can tie this with undo stack nicer */ WM_operator_stack_clear(CTX_wm_manager(C)); - return ed_undo_step(C, 1, NULL); + int ret = ed_undo_step(C, 1, NULL); + if (ret & OPERATOR_FINISHED) { + /* Keep button under the cursor active. */ + WM_event_add_mousemove(C); + } + return ret; } static int ed_undo_push_exec(bContext *C, wmOperator *op) @@ -260,14 +259,24 @@ static int ed_undo_push_exec(bContext *C, wmOperator *op) static int ed_redo_exec(bContext *C, wmOperator *UNUSED(op)) { - return ed_undo_step(C, -1, NULL); + int ret = ed_undo_step(C, -1, NULL); + if (ret & OPERATOR_FINISHED) { + /* Keep button under the cursor active. */ + WM_event_add_mousemove(C); + } + return ret; } static int ed_undo_redo_exec(bContext *C, wmOperator *UNUSED(op)) { wmOperator *last_op = WM_operator_last_redo(C); - const int ret = ED_undo_operator_repeat(C, last_op); - return ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + int ret = ED_undo_operator_repeat(C, last_op); + ret = ret ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + if (ret & OPERATOR_FINISHED) { + /* Keep button under the cursor active. */ + WM_event_add_mousemove(C); + } + return ret; } static bool ed_undo_redo_poll(bContext *C) -- cgit v1.2.3