aboutsummaryrefslogtreecommitdiff
path: root/rect.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2012-01-31 08:38:42 +0000
committerSimon Tatham <anakin@pobox.com>2012-01-31 08:38:42 +0000
commited63f9c50efeb26f3decade7dc50c7b0efa008ae (patch)
tree6b46f080e9c60791218ed19be22cc00b0a2d3c49 /rect.c
parentf3168895c89e706c53c881f53ba3dfc0fc1150ec (diff)
downloadpuzzles-ed63f9c50efeb26f3decade7dc50c7b0efa008ae.zip
puzzles-ed63f9c50efeb26f3decade7dc50c7b0efa008ae.tar.gz
puzzles-ed63f9c50efeb26f3decade7dc50c7b0efa008ae.tar.bz2
puzzles-ed63f9c50efeb26f3decade7dc50c7b0efa008ae.tar.xz
Sort out a bit of confusion between mouse- and keyboard-driven drags
in Rectangles. Mouse drags now take priority - you can't start a keyboard drag while the mouse is held down, and starting a mouse drag instantly cancels an unfinished keyboard drag - and also I've fixed an assertion failure which would come up if you had the keyboard cursor visible at the end of a mouse drag (by pressing arrow keys while the mouse was held down). [originally from svn r9393]
Diffstat (limited to 'rect.c')
-rw-r--r--rect.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/rect.c b/rect.c
index 0a93638..72a00e1 100644
--- a/rect.c
+++ b/rect.c
@@ -2377,13 +2377,31 @@ static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
coord_round(FROMCOORD((float)x), FROMCOORD((float)y), &xc, &yc);
if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
+ if (ui->drag_start_x >= 0 && ui->cur_dragging) {
+ /*
+ * If a keyboard drag is in progress, unceremoniously
+ * cancel it.
+ */
+ ui->drag_start_x = -1;
+ ui->drag_start_y = -1;
+ ui->drag_end_x = -1;
+ ui->drag_end_y = -1;
+ ui->x1 = -1;
+ ui->y1 = -1;
+ ui->x2 = -1;
+ ui->y2 = -1;
+ ui->dragged = FALSE;
+ }
startdrag = TRUE;
ui->cur_visible = ui->cur_dragging = FALSE;
active = TRUE;
erasing = (button == RIGHT_BUTTON);
} else if (button == LEFT_RELEASE || button == RIGHT_RELEASE) {
/* We assert we should have had a LEFT_BUTTON first. */
- assert(!ui->cur_visible);
+ if (ui->cur_visible) {
+ ui->cur_visible = FALSE;
+ active = TRUE;
+ }
assert(!ui->cur_dragging);
enddrag = TRUE;
erasing = (button == RIGHT_RELEASE);
@@ -2394,6 +2412,13 @@ static char *interpret_move(game_state *from, game_ui *ui, game_drawstate *ds,
if (!ui->cur_dragging) return "";
coord_round((float)ui->cur_x + 0.5F, (float)ui->cur_y + 0.5F, &xc, &yc);
} else if (IS_CURSOR_SELECT(button)) {
+ if (ui->drag_start_x >= 0 && !ui->cur_dragging) {
+ /*
+ * If a mouse drag is in progress, ignore attempts to
+ * start a keyboard one.
+ */
+ return NULL;
+ }
if (!ui->cur_visible) {
assert(!ui->cur_dragging);
ui->cur_visible = TRUE;