From 462a5450c6bd7d96a6051b37ceef1fd63426ddf8 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 14 Aug 2023 01:49:24 +0100 Subject: [PATCH] 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. --- flood.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/flood.c b/flood.c index ea4f5a5..e8ff167 100644 --- a/flood.c +++ b/flood.c @@ -830,11 +830,15 @@ static char *interpret_move(const game_state *state, game_ui *ui, { int w = state->w, h = state->h; int tx = -1, ty = -1, move = -1; + char *nullret = MOVE_NO_EFFECT; if (button == LEFT_BUTTON) { tx = FROMCOORD(x); ty = FROMCOORD(y); - ui->cursor_visible = false; + if (ui->cursor_visible) { + ui->cursor_visible = false; + nullret = MOVE_UI_UPDATE; + } } else if (IS_CURSOR_MOVE(button)) { return move_cursor(button, &ui->cx, &ui->cy, w, h, false, &ui->cursor_visible); @@ -858,7 +862,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, return dupstr(buf); } - return MOVE_NO_EFFECT; + return nullret; } static game_state *execute_move(const game_state *state, const char *move)