X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=a42ef8a99dc237878fbc0602a5bd15402f4dcf94;hb=aa694af0138b799c4de3e031d15c2a9be3112b6c;hp=4f3066eabbd6c0d4ddf26d2d82c08040a991f83f;hpb=4784281f00844c4aa5bbe86c1eb59ccb24c603da;p=xboard.git diff --git a/xboard.c b/xboard.c index 4f3066e..a42ef8a 100644 --- a/xboard.c +++ b/xboard.c @@ -199,11 +199,10 @@ extern char *getenv(); #include "backendz.h" #include "moves.h" #include "xboard.h" +#include "xboard2.h" #include "childio.h" #include "xgamelist.h" #include "xhistory.h" -#include "xevalgraph.h" -#include "xedittags.h" #include "menus.h" #include "board.h" #include "dialogs.h" @@ -275,8 +274,6 @@ int xtVersion = XtSpecificationRelease; int xScreen; Display *xDisplay; Window xBoardWindow; -Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor, - highlightSquareColor, premoveHighlightColor; // used in graphics Pixel lowTimeWarningColor, dialogColor, buttonColor; // used in widgets Pixmap iconPixmap, wIconPixmap, bIconPixmap, xMarkPixmap; Widget shellWidget, formWidget, boardWidget, titleWidget, dropMenu, menuBarWidget; @@ -324,6 +321,19 @@ WindowPlacement wpEngineOutput; WindowPlacement wpGameList; WindowPlacement wpTags; +#define INPUT_SOURCE_BUF_SIZE 8192 + +typedef struct { + CPKind kind; + int fd; + int lineByLine; + char *unused; + InputCallback func; + XtInputId xid; + char buf[INPUT_SOURCE_BUF_SIZE]; + VOIDSTAR closure; +} InputSource; + /* This magic number is the number of intermediate frames used in each half of the animation. For short moves it's reduced @@ -911,12 +921,6 @@ MakeColors () { // [HGM] taken out of main(), so it can be called from BoardOptions dialog int forceMono = False; - forceMono |= MakeOneColor(appData.lightSquareColor, &lightSquareColor); - forceMono |= MakeOneColor(appData.darkSquareColor, &darkSquareColor); - forceMono |= MakeOneColor(appData.whitePieceColor, &whitePieceColor); - forceMono |= MakeOneColor(appData.blackPieceColor, &blackPieceColor); - forceMono |= MakeOneColor(appData.highlightSquareColor, &highlightSquareColor); - forceMono |= MakeOneColor(appData.premoveHighlightColor, &premoveHighlightColor); if (appData.lowTimeWarning) forceMono |= MakeOneColor(appData.lowTimeWarningColor, &lowTimeWarningColor); if(appData.dialogColor[0]) MakeOneColor(appData.dialogColor, &dialogColor); @@ -1207,24 +1211,6 @@ main (int argc, char **argv) // [HGM] font: use defaults from settings file if available and not overruled } - /* Now, using squareSize as a hint, find a good XPM/XIM set size */ - if (strlen(appData.pixmapDirectory) > 0) { - p = ExpandPathName(appData.pixmapDirectory); - if (!p) { - fprintf(stderr, _("Error expanding path name \"%s\"\n"), - appData.pixmapDirectory); - exit(1); - } - if (appData.debugMode) { - fprintf(stderr, _("\ -XBoard square size (hint): %d\n\ -%s fulldir:%s:\n"), squareSize, IMAGE_EXT, p); - } - squareSize = xpm_closest_to(p, squareSize, IMAGE_EXT); - if (appData.debugMode) { - fprintf(stderr, _("Closest %s size: %d\n"), IMAGE_EXT, squareSize); - } - } defaultLineGap = lineGap; if(appData.overrideLineGap >= 0) lineGap = appData.overrideLineGap; @@ -1279,6 +1265,8 @@ XBoard square size (hint): %d\n\ #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; @@ -1333,13 +1321,13 @@ XBoard square size (hint): %d\n\ 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"); - CreateGCs(False); + CreateAnyPieces(); CreateGrid(); if(appData.logoSize) @@ -1599,45 +1587,6 @@ FindFont (char *pattern, int targetPxlSize) void ReadBitmap (Pixmap *pm, String name, unsigned char bits[], u_int wreq, u_int hreq) { - int x_hot, y_hot; - u_int w, h; - int errcode; - char msg[MSG_SIZ], fullname[MSG_SIZ]; - - if (*appData.bitmapDirectory != NULLCHAR) { - safeStrCpy(fullname, appData.bitmapDirectory, sizeof(fullname)/sizeof(fullname[0]) ); - strncat(fullname, "/", MSG_SIZ - strlen(fullname) - 1); - strncat(fullname, name, MSG_SIZ - strlen(fullname) - 1); - errcode = XReadBitmapFile(xDisplay, xBoardWindow, fullname, - &w, &h, pm, &x_hot, &y_hot); - fprintf(stderr, "load %s\n", name); - if (errcode != BitmapSuccess) { - switch (errcode) { - case BitmapOpenFailed: - snprintf(msg, sizeof(msg), _("Can't open bitmap file %s"), fullname); - break; - case BitmapFileInvalid: - snprintf(msg, sizeof(msg), _("Invalid bitmap in file %s"), fullname); - break; - case BitmapNoMemory: - snprintf(msg, sizeof(msg), _("Ran out of memory reading bitmap file %s"), - fullname); - break; - default: - snprintf(msg, sizeof(msg), _("Unknown XReadBitmapFile error %d on file %s"), - errcode, fullname); - break; - } - fprintf(stderr, _("%s: %s...using built-in\n"), - programName, msg); - } else if (w != wreq || h != hreq) { - fprintf(stderr, - _("%s: Bitmap %s is %dx%d, not %dx%d...using built-in\n"), - programName, fullname, w, h, wreq, hreq); - } else { - return; - } - } if (bits != NULL) { *pm = XCreateBitmapFromData(xDisplay, xBoardWindow, (char *) bits, wreq, hreq); @@ -1645,18 +1594,6 @@ ReadBitmap (Pixmap *pm, String name, unsigned char bits[], u_int wreq, u_int hre } void -MarkMenuItem (char *menuRef, int state) -{ - MenuItem *item = MenuNameToItem(menuRef); - - if(item) { - Arg args[2]; - XtSetArg(args[0], XtNleftBitmap, state ? xMarkPixmap : None); - XtSetValues(item->handle, args, 1); - } -} - -void EnableNamedMenuItem (char *menuRef, int state) { MenuItem *item = MenuNameToItem(menuRef); @@ -1726,7 +1663,6 @@ SetupDropMenu () } } - static void do_flash_delay (unsigned long msec) { @@ -1788,17 +1724,20 @@ CoDrag (Widget sh, WindowPlacement *wp) void ReSize (WindowPlacement *wp) { - int sqx, sqy; + int sqx, sqy, w, h; if(wp->width == wpMain.width && wp->height == wpMain.height) return; // not sized sqx = (wp->width - lineGap - marginW) / BOARD_WIDTH - lineGap; sqy = (wp->height - lineGap - marginH) / BOARD_HEIGHT - lineGap; 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); + w = BOARD_WIDTH * (squareSize + lineGap) + lineGap; + h = BOARD_HEIGHT * (squareSize + lineGap) + lineGap; + if(optList[W_BOARD].max > w) optList[W_BOARD].max = w; + if(optList[W_BOARD].value > h) optList[W_BOARD].value = h; } static XtIntervalId delayedDragID = 0; @@ -1832,7 +1771,7 @@ DelayedDrag () { if(delayedDragID) XtRemoveTimeOut(delayedDragID); // cancel pending delayedDragID = - XtAppAddTimeOut(appContext, 100, (XtTimerCallbackProc) DragProc, (XtPointer) 0); // and schedule new one 50 msec later + XtAppAddTimeOut(appContext, 200, (XtTimerCallbackProc) DragProc, (XtPointer) 0); // and schedule new one 50 msec later } void @@ -1963,7 +1902,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]); } @@ -2611,7 +2550,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; }