Make draw handle for board globally available
[xboard.git] / xboard.c
index 3b97fca..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;
@@ -1315,12 +1317,13 @@ main (int argc, char **argv)
     XtGetValues(shellWidget, shellArgs, 2);
     shellArgs[4].value = shellArgs[2].value = w;
     shellArgs[5].value = shellArgs[3].value = h;
-    if(!CreateAnyPieces()) XtSetValues(shellWidget, &shellArgs[2], 4);
+//    XtSetValues(shellWidget, &shellArgs[2], 4);
     marginW =  w - boardWidth; // [HGM] needed to set new shellWidget size when we resize board
     marginH =  h - boardHeight;
 
     CatchDeleteWindow(shellWidget, "QuitProc");
 
+    CreateAnyPieces();
     CreateGrid();
 
     if(appData.logoSize)
@@ -1668,7 +1671,6 @@ SetupDropMenu ()
     }
 }
 
-
 static void
 do_flash_delay (unsigned long msec)
 {
@@ -1737,10 +1739,9 @@ ReSize (WindowPlacement *wp)
        if(sqy < sqx) sqx = sqy;
        if(sqx != squareSize) {
            squareSize = sqx; // adopt new square size
-           NewSurfaces();
            CreatePNGPieces(); // make newly scaled pieces
            InitDrawingSizes(0, 0); // creates grid etc.
-       }
+       } else ResizeBoardWindow(BOARD_WIDTH * (squareSize + lineGap) + lineGap, BOARD_HEIGHT * (squareSize + lineGap) + lineGap, 0);
 }
 
 static XtIntervalId delayedDragID = 0;
@@ -1905,7 +1906,7 @@ ModeHighlight ()
     /* Maybe all the enables should be handled here, not just this one */
     EnableNamedMenuItem("Mode.Training", gameMode == Training || gameMode == PlayFromGameFile);
 
-    DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
+    DisplayLogos(&optList[W_WHITE-1], &optList[W_BLACK+1]);
 }
 
 
@@ -2553,7 +2554,7 @@ UpdateLogos (int displ)
     if(optList[W_WHITE-1].handle == NULL) return;
     LoadLogo(&first, 0, 0);
     LoadLogo(&second, 1, appData.icsActive);
-    if(displ) DisplayLogos(optList[W_WHITE-1].handle, optList[W_BLACK+1].handle);
+    if(displ) DisplayLogos(&optList[W_WHITE-1], &optList[W_BLACK+1]);
     return;
 }