Repeat Last and Repeat History do what I want, but too much:
1. Get last tool
2. Use last tool exactly the same way (mouse movement etc)
Difference is History gives you a list of previous operations to choose from.
All I want is the last tool, not the performance afterwards. I can have a single key that will give me the last tool used. It is a great thing. It saves my left arm from repeating a zillion multikey shortcuts, and my right arm from repeated mouse movement back and forth through toolbars, pie menus, and quick favorites.
Having trouble finding where the magic happens. The part that says, “First, get the last tool. Second, do a bunch of mousey garbage you don’t want 90% of the time.”
I could either create a new thing called Last Tool or modify Repeat Last. At this point, I don’t even care about the stuff that happens after giving me the previous tool. I use previous tool way more often than previous tool + identical performance. I have no problem sacrificing that for the short term while a more elegant solution is created.
After a few hours of digging, this is where I am:
screen_ops.c — “blender-git\blender\source\blender\editors\screen”
Line 3409 for Repeat Last:
WM_operator_repeat_interactive(C, lastop);
Line 3470 for Repeat History:
WM_operator_repeat(C, op);
These lead to:
wm_event_system.c — “blender-git\blender\source\blender\windowmanager\intern”
Lines 1050-1057:
int WM_operator_repeat(bContext *C, wmOperator *op)
{
return wm_operator_exec(C, op, true, true, true);
}
int WM_operator_repeat_interactive(bContext *C, wmOperator *op)
{
return wm_operator_exec(C, op, true, false, true);
}
Lines 952-1004:
static int wm_operator_exec(
bContext *C, wmOperator *op,
const bool repeat, const bool use_repeat_op_flag, const bool store)
{
wmWindowManager *wm = CTX_wm_manager(C);
int retval = OPERATOR_CANCELLED;
CTX_wm_operator_poll_msg_set(C, NULL);
if (op == NULL || op->type == NULL)
return retval;
if (0 == WM_operator_poll(C, op->type))
return retval;
if (op->type->exec) {
if (op->type->flag & OPTYPE_UNDO) {
wm->op_undo_depth++;
}
if (repeat && use_repeat_op_flag) {
op->flag |= OP_IS_REPEAT;
}
retval = op->type->exec(C, op);
OPERATOR_RETVAL_CHECK(retval);
if (repeat && use_repeat_op_flag) {
op->flag &= ~OP_IS_REPEAT;
}
if (op->type->flag & OPTYPE_UNDO && CTX_wm_manager(C) == wm) {
wm->op_undo_depth--;
}
}
/* XXX Disabled the repeat check to address part 2 of #31840.
* Carefully checked all calls to wm_operator_exec and WM_operator_repeat, don't see any reason
* why this was needed, but worth to note it in case something turns bad. (mont29) */
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED) /* && repeat == 0 */)
wm_operator_reports(C, op, retval, false);
if (retval & OPERATOR_FINISHED) {
wm_operator_finished(C, op, repeat, store && wm->op_undo_depth == 0);
}
else if (repeat == 0) {
/* warning: modal from exec is bad practice, but avoid crashing. */
if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) {
WM_operator_free(op);
}
}
return retval | OPERATOR_HANDLED;
}
Where to go from here? I’ve looked a bit at a bunch of similar-ish scripts like wm_event_system.h and wm_event_types.h. Going to go through the #include section(s) again, but I’m already helpless enough.
I don’t even know what’s going on here, but can kinda follow where things lead to. Any help is greatly appreciated.
My guess? Operators have the post-tool mouse movement built into them. Which probably makes a solution for just the tool, without the mouse movement, pretty annoying. Hoping that I’m wrong.