aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2012-01-22 15:12:56 +0000
committerSimon Tatham <anakin@pobox.com>2012-01-22 15:12:56 +0000
commite406092a0e8f32728b8743193c57119e667ce424 (patch)
tree07f0082bb8bda2ce39ddf53a12c736921b8bfdcd
parentb16eece9fc502afb9dfb0aca9fd7bfba2239d3e3 (diff)
downloadpuzzles-e406092a0e8f32728b8743193c57119e667ce424.zip
puzzles-e406092a0e8f32728b8743193c57119e667ce424.tar.gz
puzzles-e406092a0e8f32728b8743193c57119e667ce424.tar.bz2
puzzles-e406092a0e8f32728b8743193c57119e667ce424.tar.xz
Tweak right-click processing to be less finicky.
[originally from svn r9381]
-rw-r--r--pearl.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/pearl.c b/pearl.c
index c018d5a..02a43db 100644
--- a/pearl.c
+++ b/pearl.c
@@ -1907,7 +1907,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
int gx = FROMCOORD(x), gy = FROMCOORD(y), i;
char tmpbuf[80];
- if (button == LEFT_BUTTON) {
+ if (IS_MOUSE_DOWN(button)) {
if (!INGRID(state, gx, gy)) return NULL;
ui->clickx = x; ui->clicky = y;
@@ -1917,7 +1917,7 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
return "";
}
- if (IS_MOUSE_DRAG(button)) {
+ if (button == LEFT_DRAG) {
update_ui_drag(state, ui, gx, gy);
return "";
}
@@ -1953,11 +1953,25 @@ static char *interpret_move(game_state *state, game_ui *ui, game_drawstate *ds,
return buf ? buf : "";
} else {
- /* Click (or tiny drag). Work out which edge we were closest to. */
- int cx = COORD(gx) + TILE_SIZE/2, cy = COORD(gy) + TILE_SIZE/2;
+ /* Click (or tiny drag). Work out which edge we were
+ * closest to. */
+ int cx, cy;
int gx2, gy2, l1, l2, ismark = (button == RIGHT_RELEASE);
char movec = ismark ? 'M' : 'F';
+ /*
+ * We process clicks based on the mouse-down location,
+ * because that's more natural for a user to carefully
+ * control than the mouse-up.
+ */
+ x = ui->clickx;
+ y = ui->clicky;
+
+ gx = FROMCOORD(x);
+ gy = FROMCOORD(y);
+ cx = COORD(gx) + TILE_SIZE/2;
+ cy = COORD(gy) + TILE_SIZE/2;
+
if (!INGRID(state, gx, gy)) return "";
if (max(abs(x-cx),abs(y-cy)) < TILE_SIZE/4) {