Fix highlighting bug in XBoard
authorH.G. Muller <h.g.muller@hccnet.nl>
Fri, 5 Feb 2010 19:36:50 +0000 (20:36 +0100)
committerArun Persaud <arun@nubati.net>
Sun, 7 Feb 2010 20:05:17 +0000 (12:05 -0800)
The from-square was drawn before the to-square was erased, which led to
a missing highlight line if they shared an edge or corner.

xboard.c

index 4a47133..d4d8369 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -4549,14 +4549,18 @@ SetHighlights(fromX, fromY, toX, toY)
        if (hi1X >= 0 && hi1Y >= 0) {
            drawHighlight(hi1X, hi1Y, lineGC);
        }
+    } // [HGM] first erase both, then draw new!
+    if (hi2X != toX || hi2Y != toY) {
+       if (hi2X >= 0 && hi2Y >= 0) {
+           drawHighlight(hi2X, hi2Y, lineGC);
+       }
+    }
+    if (hi1X != fromX || hi1Y != fromY) {
        if (fromX >= 0 && fromY >= 0) {
            drawHighlight(fromX, fromY, highlineGC);
        }
     }
     if (hi2X != toX || hi2Y != toY) {
-       if (hi2X >= 0 && hi2Y >= 0) {
-           drawHighlight(hi2X, hi2Y, lineGC);
-       }
        if (toX >= 0 && toY >= 0) {
            drawHighlight(toX, toY, highlineGC);
        }