diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-14 01:49:24 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-14 01:49:24 +0100 |
| commit | 462a5450c6bd7d96a6051b37ceef1fd63426ddf8 (patch) | |
| tree | e5aa0ea44f4f74b7da190d28137aecf6114eb5b9 | |
| parent | 3c6493e7b363400479fc163970acd930b0f5db59 (diff) | |
| download | puzzles-462a5450c6bd7d96a6051b37ceef1fd63426ddf8.zip puzzles-462a5450c6bd7d96a6051b37ceef1fd63426ddf8.tar.gz puzzles-462a5450c6bd7d96a6051b37ceef1fd63426ddf8.tar.bz2 puzzles-462a5450c6bd7d96a6051b37ceef1fd63426ddf8.tar.xz | |
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.
| -rw-r--r-- | flood.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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) |