Prevent getpos queueing mouse commands

My change to allow binding the mouse buttons made getpos
push the mouse commands into a command queue, so when you
were asked for a map location, clicked on it with a mouse,
you'd first get the expected effect, and then (most likely)
immediately traveled there.

Change getpos to clear the commands bound to the mouse buttons,
and restore the binds afterwards.
This commit is contained in:
Pasi Kallinen
2022-08-24 14:21:24 +03:00
parent 282b2a7bbe
commit 7c8ccb8ccd
3 changed files with 24 additions and 1 deletions

View File

@@ -751,6 +751,7 @@ getpos(coord *ccp, boolean force, const char *goal)
#ifdef MAC
lock_mouse_cursor(TRUE);
#endif
lock_mouse_buttons(TRUE);
for (;;) {
if (show_goal_msg) {
pline("Move cursor to %s:", goal);
@@ -769,7 +770,8 @@ getpos(coord *ccp, boolean force, const char *goal)
c = cmdq->key;
} else {
cmdq_clear(CQ_CANNED);
return -1;
result = -1;
goto exitgetpos;
}
free(cmdq);
} else {
@@ -1036,9 +1038,11 @@ getpos(coord *ccp, boolean force, const char *goal)
curs(WIN_MAP, cx, cy);
flush_screen(0);
}
exitgetpos:
#ifdef MAC
lock_mouse_cursor(FALSE);
#endif
lock_mouse_buttons(FALSE);
if (msg_given)
clear_nhwindow(WIN_MESSAGE);
ccp->x = cx;