aboutsummaryrefslogtreecommitdiff
path: root/mosaic.c
diff options
context:
space:
mode:
authorChris Boyle <chris@boyle.name>2022-05-09 22:22:19 +0100
committerBen Harris <bjh21@bjh21.me.uk>2023-02-18 14:18:40 +0000
commit85cf484e7a1abd57339edd4f18ccbe85cc7c9918 (patch)
tree73d390d443068b2debdb68bcc1664389fbd8356a /mosaic.c
parentb91f9824b6f73290051025317f3387c7212fa05f (diff)
downloadpuzzles-85cf484e7a1abd57339edd4f18ccbe85cc7c9918.zip
puzzles-85cf484e7a1abd57339edd4f18ccbe85cc7c9918.tar.gz
puzzles-85cf484e7a1abd57339edd4f18ccbe85cc7c9918.tar.bz2
puzzles-85cf484e7a1abd57339edd4f18ccbe85cc7c9918.tar.xz
Mosaic: ignore taps above/left of the grid
Thanks to Larry Hastings for the patch (tweaked to include drag/release). (cherry picked from Android port, commit 377e61b144c518a3d9efba66be08bf00ff6596e8)
Diffstat (limited to 'mosaic.c')
-rw-r--r--mosaic.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/mosaic.c b/mosaic.c
index 39d368a..3e54ba0 100644
--- a/mosaic.c
+++ b/mosaic.c
@@ -1056,8 +1056,9 @@ static char *interpret_move(const game_state *state, game_ui *ui,
const game_drawstate *ds, int x, int y,
int button)
{
- int gameX, gameY, i, srcX = ui->last_x, srcY =
- ui->last_y, dirX, dirY, diff;
+ int srcX = ui->last_x, srcY = ui->last_y;
+ int offsetX, offsetY, gameX, gameY, i;
+ int dirX, dirY, diff;
char move_type;
char move_desc[80];
char *ret = NULL;
@@ -1066,8 +1067,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
if (state->not_completed_clues == 0 && !IS_CURSOR_MOVE(button)) {
return NULL;
}
- gameX = (x - (ds->tilesize / 2)) / ds->tilesize;
- gameY = (y - (ds->tilesize / 2)) / ds->tilesize;
+ offsetX = x - (ds->tilesize / 2);
+ offsetY = y - (ds->tilesize / 2);
+ gameX = offsetX / ds->tilesize;
+ gameY = offsetY / ds->tilesize;
+ if ((IS_MOUSE_DOWN(button) || IS_MOUSE_DRAG(button) || IS_MOUSE_RELEASE(button))
+ && ((offsetX < 0) || (offsetY < 0)))
+ return NULL;
if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
cell_state =
get_coords(state, state->cells_contents, gameX, gameY);