Flood: correctly handle clicks that only hide cursor

If you clicked somewhere that had no effect (outside the grid or on a
square matching the colour of the top-left corner), interpret_move()
would return MOVE_NO_EFFECT (previously NULL) even though it had unset
ui->cursor.  So the keyboard cursor would remain visible until the
next window resize (or similar) when it would vanish.  Now
interpret_move() correctly returns MOVE_UI_UPDATE in these cases, so
the cursor vanishes immediately.
This commit is contained in:
Ben Harris
2023-08-14 01:49:24 +01:00
parent 3c6493e7b3
commit 462a5450c6

View File

@ -830,11 +830,15 @@ static char *interpret_move(const game_state *state, game_ui *ui,
{ {
int w = state->w, h = state->h; int w = state->w, h = state->h;
int tx = -1, ty = -1, move = -1; int tx = -1, ty = -1, move = -1;
char *nullret = MOVE_NO_EFFECT;
if (button == LEFT_BUTTON) { if (button == LEFT_BUTTON) {
tx = FROMCOORD(x); tx = FROMCOORD(x);
ty = FROMCOORD(y); ty = FROMCOORD(y);
if (ui->cursor_visible) {
ui->cursor_visible = false; ui->cursor_visible = false;
nullret = MOVE_UI_UPDATE;
}
} else if (IS_CURSOR_MOVE(button)) { } else if (IS_CURSOR_MOVE(button)) {
return move_cursor(button, &ui->cx, &ui->cy, w, h, false, return move_cursor(button, &ui->cx, &ui->cy, w, h, false,
&ui->cursor_visible); &ui->cursor_visible);
@ -858,7 +862,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
return dupstr(buf); return dupstr(buf);
} }
return MOVE_NO_EFFECT; return nullret;
} }
static game_state *execute_move(const game_state *state, const char *move) static game_state *execute_move(const game_state *state, const char *move)