chiark / gitweb /
We should turn off the dragging variables in the UI _whenever_
authorSimon Tatham <anakin@pobox.com>
Tue, 11 May 2004 18:32:48 +0000 (18:32 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 11 May 2004 18:32:48 +0000 (18:32 +0000)
`enddrag' is TRUE, not just when the end of the drag was within a
sensible range.

[originally from svn r4210]

rect.c

diff --git a/rect.c b/rect.c
index b6e71d2dafeea032d76798a9c9ce7cae26fb5884..c145e9b8c841e374ee38226a9d70dcbd43f4dd8d 100644 (file)
--- a/rect.c
+++ b/rect.c
@@ -1009,38 +1009,45 @@ game_state *make_move(game_state *from, game_ui *ui, int x, int y, int button)
         active = TRUE;
     }
 
-    if (enddrag && (xc >= 0 && xc <= 2*from->w &&
-                    yc >= 0 && yc <= 2*from->h)) {
-        ret = dup_game(from);
-
-        if (ui->dragged) {
-            ui_draw_rect(ret, ui, ret->hedge, ret->vedge, 1);
-        } else {
-            if ((xc & 1) && !(yc & 1) && HRANGE(from,xc/2,yc/2)) {
-                hedge(ret,xc/2,yc/2) = !hedge(ret,xc/2,yc/2);
-            }
-            if ((yc & 1) && !(xc & 1) && VRANGE(from,xc/2,yc/2)) {
-                vedge(ret,xc/2,yc/2) = !vedge(ret,xc/2,yc/2);
-            }
-        }
+    ret = NULL;
+
+    if (enddrag) {
+       if (xc >= 0 && xc <= 2*from->w &&
+           yc >= 0 && yc <= 2*from->h) {
+           ret = dup_game(from);
+
+           if (ui->dragged) {
+               ui_draw_rect(ret, ui, ret->hedge, ret->vedge, 1);
+           } else {
+               if ((xc & 1) && !(yc & 1) && HRANGE(from,xc/2,yc/2)) {
+                   hedge(ret,xc/2,yc/2) = !hedge(ret,xc/2,yc/2);
+               }
+               if ((yc & 1) && !(xc & 1) && VRANGE(from,xc/2,yc/2)) {
+                   vedge(ret,xc/2,yc/2) = !vedge(ret,xc/2,yc/2);
+               }
+           }
 
-        ui->drag_start_x = -1;
-        ui->drag_start_y = -1;
-        ui->drag_end_x = -1;
-        ui->drag_end_y = -1;
-        ui->dragged = FALSE;
-        active = TRUE;
+           if (!memcmp(ret->hedge, from->hedge, from->w*from->h) &&
+               !memcmp(ret->vedge, from->vedge, from->w*from->h)) {
+               free_game(ret);
+               ret = NULL;
+           }
+       }
 
-        if (!memcmp(ret->hedge, from->hedge, from->w*from->h) &&
-            !memcmp(ret->vedge, from->vedge, from->w*from->h)) {
-            free_game(ret);
-        } else
-            return ret;                /* a move has been made */
+       ui->drag_start_x = -1;
+       ui->drag_start_y = -1;
+       ui->drag_end_x = -1;
+       ui->drag_end_y = -1;
+       ui->dragged = FALSE;
+       active = TRUE;
     }
 
-    if (active)
+    if (ret)
+       return ret;                    /* a move has been made */
+    else if (active)
         return from;                   /* UI activity has occurred */
-    return NULL;
+    else
+       return NULL;
 }
 
 /* ----------------------------------------------------------------------