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:
@@ -273,6 +273,7 @@ extern int extcmds_match(const char *, int, int **);
|
||||
extern const char *key2extcmddesc(uchar);
|
||||
extern boolean bind_specialkey(uchar, const char *);
|
||||
extern void parseautocomplete(char *, boolean);
|
||||
extern void lock_mouse_buttons(boolean);
|
||||
extern void reset_commands(boolean);
|
||||
extern void update_rest_on_space(void);
|
||||
extern void rhack(char *);
|
||||
|
||||
18
src/cmd.c
18
src/cmd.c
@@ -4280,6 +4280,24 @@ parseautocomplete(char *autocomplete, boolean condition)
|
||||
wait_synch();
|
||||
}
|
||||
|
||||
/* save&clear the mouse button actions, or restore the saved ones */
|
||||
void
|
||||
lock_mouse_buttons(boolean savebtns)
|
||||
{
|
||||
static const struct ext_func_tab *mousebtn[NUM_MOUSE_BUTTONS] = { 0 };
|
||||
int i;
|
||||
|
||||
if (savebtns) {
|
||||
for (i = 0; i < NUM_MOUSE_BUTTONS; i++) {
|
||||
mousebtn[i] = g.Cmd.mousebtn[i];
|
||||
g.Cmd.mousebtn[i] = NULL;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < NUM_MOUSE_BUTTONS; i++)
|
||||
g.Cmd.mousebtn[i] = mousebtn[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* called at startup and after number_pad is twiddled */
|
||||
void
|
||||
reset_commands(boolean initial)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user