diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-12 14:43:02 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-08-13 16:44:24 +0100 |
| commit | 20bd61bf4931396cc74265046a0f1bb4a3c57fd4 (patch) | |
| tree | 3fac79e913c184d08787f73c2ef8be528cbd7a5c | |
| parent | be9e4f89579331eea8df13d8ef3ef7366a4cffab (diff) | |
| download | puzzles-20bd61bf4931396cc74265046a0f1bb4a3c57fd4.zip puzzles-20bd61bf4931396cc74265046a0f1bb4a3c57fd4.tar.gz puzzles-20bd61bf4931396cc74265046a0f1bb4a3c57fd4.tar.bz2 puzzles-20bd61bf4931396cc74265046a0f1bb4a3c57fd4.tar.xz | |
Unruly: correctly handle clicks that only hide cursor
If you clicked somewhere that had no effect (on an immutable square or
a middle click on an empty square), interpret_move() would return 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-- | unruly.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -1612,6 +1612,8 @@ static char *interpret_move(const game_state *state, game_ui *ui, int w2 = state->w2, h2 = state->h2; + char *nullret = MOVE_NO_EFFECT; + button &= ~MOD_MASK; /* Mouse click */ @@ -1621,7 +1623,10 @@ static char *interpret_move(const game_state *state, game_ui *ui, && oy >= (ds->tilesize / 2) && gy < h2) { hx = gx; hy = gy; - ui->cursor = false; + if (ui->cursor) { + ui->cursor = false; + nullret = MOVE_UI_UPDATE; + } } else return NULL; } @@ -1641,7 +1646,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, char c, i; if (state->common->immutable[hy * w2 + hx]) - return NULL; + return nullret; c = '-'; i = state->grid[hy * w2 + hx]; @@ -1661,7 +1666,7 @@ static char *interpret_move(const game_state *state, game_ui *ui, if (state->grid[hy * w2 + hx] == (c == '0' ? N_ZERO : c == '1' ? N_ONE : EMPTY)) - return NULL; /* don't put no-ops on the undo chain */ + return nullret; /* don't put no-ops on the undo chain */ sprintf(buf, "P%c,%d,%d", c, hx, hy); |