Make draw handle for board globally available
authorH.G. Muller <h.g.muller@hccnet.nl>
Wed, 10 Oct 2012 18:07:53 +0000 (20:07 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Sun, 21 Oct 2012 09:28:19 +0000 (11:28 +0200)
draw.c
draw.h
xboard.c

diff --git a/draw.c b/draw.c
index 7571850..668e4a5 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -111,7 +111,7 @@ extern char *getenv();
 #define OUTLINE 1
 Boolean cairoAnimate;
 Option *currBoard;
-static cairo_surface_t *csBoardWindow;
+cairo_surface_t *csBoardWindow;
 static cairo_surface_t *pngPieceImages[2][(int)BlackPawn+4];   // png 256 x 256 images
 static cairo_surface_t *pngPieceBitmaps[2][(int)BlackPawn];    // scaled pieces as used
 static cairo_surface_t *pngPieceBitmaps2[2][(int)BlackPawn+4]; // scaled pieces in store
@@ -430,10 +430,14 @@ void DrawSeekDot(int x, int y, int colorNr)
 }
 
 void
+InitDrawingHandle (Option *opt)
+{
+    csBoardWindow = DRAWABLE(opt);
+}
+
+void
 DrawSeekOpen ()
 {
-    csBoardWindow = (cairo_surface_t *) mainOptions[W_BOARD].choice;
-    currBoard = &mainOptions[W_BOARD];
 }
 
 void
diff --git a/draw.h b/draw.h
index 3ba9efe..a7bdfce 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -68,6 +68,7 @@ extern Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor
   highlightSquareColor, premoveHighlightColor;
 
 // defined in draw.c
+void InitDrawingHandle P((Option *opt));
 void CreateGCs P((int redo));
 void NewSurfaces P((void));
 void CreateAnyPieces P((void));
index 2ac676d..ede493d 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -1261,6 +1261,8 @@ main (int argc, char **argv)
 #else
                                                clockFontStruct);
 #endif
+    InitDrawingHandle(optList + W_BOARD);
+    currBoard        = &optList[W_BOARD];
     boardWidget      = optList[W_BOARD].handle;
     menuBarWidget    = optList[W_MENU].handle;
     dropMenu         = optList[W_DROP].handle;