Cleanse back-end code of all references to X11 types
[xboard.git] / draw.c
diff --git a/draw.c b/draw.c
index d90d0e9..03160f0 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -74,11 +74,8 @@ extern char *getenv();
 #include <locale.h>
 #endif
 
-
-// [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are.
 #include "common.h"
 
-#include "frontend.h"
 #include "backend.h"
 #include "xevalgraph.h"
 #include "board.h"
@@ -166,13 +163,11 @@ void
 InitDrawingSizes (BoardSize boardSize, int flags)
 {   // [HGM] resize is functional now, but for board format changes only (nr of ranks, files)
     int boardWidth, boardHeight;
-    int i;
     static int oldWidth, oldHeight;
     static VariantClass oldVariant;
     static int oldMono = -1, oldTwoBoards = 0;
-    extern Widget formWidget;
 
-    if(!formWidget) return;
+    if(!mainOptions[W_BOARD].handle) return;
 
     if(oldTwoBoards && !twoBoards) PopDown(DummyDlg);
     oldTwoBoards = twoBoards;
@@ -245,13 +240,13 @@ LoadSVG (char *dir, int color, int piece)
     char buf[MSG_SIZ];
   RsvgHandle *svg=svgPieces[color][piece];
   RsvgDimensionData svg_dimensions;
-  GError **svgerror=NULL;
+  GError *svgerror=NULL;
   cairo_surface_t *img;
   cairo_t *cr;
 
     snprintf(buf, MSG_SIZ, "%s/%s%s.svg", dir, color ? "Black" : "White", pngPieceNames[piece]);
 
-    if(svg || *dir && (svg = rsvg_handle_new_from_file(buf, svgerror))) {
+    if(svg || *dir && (svg = rsvg_handle_new_from_file(buf, &svgerror))) {
 
       rsvg_handle_get_dimensions(svg, &svg_dimensions);
       img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, squareSize,  squareSize);
@@ -267,6 +262,8 @@ LoadSVG (char *dir, int color, int piece)
 
       return svg;
     }
+    if(svgerror)
+       g_error_free(svgerror);
     return NULL;
 }
 
@@ -280,17 +277,15 @@ ScaleOnePiece (int color, int piece)
 
   g_type_init ();
 
-  if(!svgPieces[color][piece]) { // try to freshly render cached svg pieces first, to supply the source bitmap
-    svgPieces[color][piece] = LoadSVG("", color, piece); // this fills pngPieceImages if we had cached svg with bitmap of wanted size
-  }
+  svgPieces[color][piece] = LoadSVG("", color, piece); // this fills pngPieceImages if we had cached svg with bitmap of wanted size
 
   if(!pngPieceImages[color][piece]) { // we don't have cached bitmap (implying we did not have cached svg)
     if(*appData.pieceDirectory) { // user specified piece directory
       snprintf(buf, MSG_SIZ, "%s/%s%s.png", appData.pieceDirectory, color ? "Black" : "White", pngPieceNames[piece]);
-      pngPieceImages[color][piece] = img = cairo_image_surface_create_from_png (buf); // try if there are png pieces there
+      img = cairo_image_surface_create_from_png (buf); // try if there are png pieces there
       if(cairo_surface_status(img) != CAIRO_STATUS_SUCCESS) { // there were not
        svgPieces[color][piece] = LoadSVG(appData.pieceDirectory, color, piece); // so try if he has svg there
-      }
+      } else pngPieceImages[color][piece] = img;
     }
   }
 
@@ -773,7 +768,9 @@ DrawBlank (AnimNr anr, int x, int y, int startColor)
 void CopyRectangle (AnimNr anr, int srcBuf, int destBuf,
                 int srcX, int srcY, int width, int height, int destX, int destY)
 {
-       cairo_t *cr = cairo_create (c_animBufs[anr+destBuf]);
+       cairo_t *cr;
+       c_animBufs[anr+4] = csBoardWindow;
+       cr = cairo_create (c_animBufs[anr+destBuf]);
        cairo_set_source_surface (cr, c_animBufs[anr+srcBuf], destX - srcX, destY - srcY);
        cairo_rectangle (cr, destX, destY, width, height);
        cairo_fill (cr);