X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=449f5b3cdc3daa721273b76fc8d444f0fc8e65ab;hb=6e81557cc7a3d288c2b0860675b83d2c50d672e9;hp=5b0d6b225a9adaa2f1a65c5d24ee6c02acd8bc37;hpb=ca63c52d91e298f2b7d70535b8e5a923e4f956ac;p=xboard.git diff --git a/xboard.c b/xboard.c index 5b0d6b2..449f5b3 100644 --- a/xboard.c +++ b/xboard.c @@ -243,6 +243,7 @@ RETSIGTYPE CmailSigHandler P((int sig)); RETSIGTYPE IntSigHandler P((int sig)); RETSIGTYPE TermSizeSigHandler P((int sig)); void CreateGCs P((int redo)); +void CreateAnyPieces P((void)); void CreateXIMPieces P((void)); void CreateXPMPieces P((void)); void CreateXPMBoard P((char *s, int n)); @@ -261,6 +262,7 @@ void CreateGrid P((void)); int EventToSquare P((int x, int limit)); void DrawSquare P((int row, int column, ChessSquare piece, int do_flash)); void EventProc P((Widget widget, caddr_t unused, XEvent *event)); +void MoveTypeInProc P((Widget widget, caddr_t unused, XEvent *event)); void HandleUserMove P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void AnimateUserMove P((Widget w, XEvent * event, @@ -365,6 +367,7 @@ void ResignProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void AdjuWhiteProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void AdjuBlackProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void AdjuDrawProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void TypeInProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void EnterKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void UpKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void DownKeyProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); @@ -950,6 +953,7 @@ XtActionsRec boardActions[] = { { "AdjuWhiteProc", AdjuWhiteProc }, { "AdjuBlackProc", AdjuBlackProc }, { "AdjuDrawProc", AdjuDrawProc }, + { "TypeInProc", TypeInProc }, { "EnterKeyProc", EnterKeyProc }, { "UpKeyProc", UpKeyProc }, { "DownKeyProc", DownKeyProc }, @@ -1506,7 +1510,7 @@ SaveFontArg(FILE *f, ArgDescriptor *ad) break; } for(i=0; iargName, i, fontTable[n][i]); + fprintf(f, OPTCHAR "%s" SEPCHAR "\"size%d:%s\"\n", ad->argName, i, fontTable[n][i]); } void @@ -1895,6 +1899,28 @@ int MakeColors() return forceMono; } +void +CreateAnyPieces() +{ // [HGM] taken out of main +#if HAVE_LIBXPM + if (appData.monoMode && // [HGM] no sense to go on to certain doom + (appData.bitmapDirectory == NULL || appData.bitmapDirectory[0] == NULLCHAR)) + appData.bitmapDirectory = DEF_BITMAP_DIR; + + if (appData.bitmapDirectory[0] != NULLCHAR) { + CreatePieces(); + } else { + CreateXPMPieces(); + CreateXPMBoard(appData.liteBackTextureFile, 1); + CreateXPMBoard(appData.darkBackTextureFile, 0); + } +#else + CreateXIMPieces(); + /* Create regular pieces */ + if (!useImages) CreatePieces(); +#endif +} + int main(argc, argv) int argc; @@ -2135,10 +2161,7 @@ XBoard square size (hint): %d\n\ if (forceMono) { fprintf(stderr, _("%s: too few colors available; trying monochrome mode\n"), programName); - - if (appData.bitmapDirectory == NULL || - appData.bitmapDirectory[0] == NULLCHAR) - appData.bitmapDirectory = DEF_BITMAP_DIR; + appData.monoMode = True; } if (appData.lowTimeWarning && !appData.monoMode) { @@ -2548,19 +2571,7 @@ XBoard square size (hint): %d\n\ CreateGCs(False); CreateGrid(); -#if HAVE_LIBXPM - if (appData.bitmapDirectory[0] != NULLCHAR) { - CreatePieces(); - } else { - CreateXPMPieces(); - CreateXPMBoard(appData.liteBackTextureFile, 1); - CreateXPMBoard(appData.darkBackTextureFile, 0); - } -#else - CreateXIMPieces(); - /* Create regular pieces */ - if (!useImages) CreatePieces(); -#endif + CreateAnyPieces(); CreatePieceMenus(); @@ -2581,6 +2592,8 @@ XBoard square size (hint): %d\n\ XtAddEventHandler(boardWidget, ExposureMask|PointerMotionMask, False, (XtEventHandler) EventProc, NULL); /* end why */ + XtAddEventHandler(formWidget, KeyPressMask, False, + (XtEventHandler) MoveTypeInProc, NULL); /* [AS] Restore layout */ if( wpMoveHistory.visible ) { @@ -2617,7 +2630,8 @@ XBoard square size (hint): %d\n\ } gameInfo.boardWidth = 0; // [HGM] pieces: kludge to ensure InitPosition() calls InitDrawingSizes() InitPosition(TRUE); - XtSetKeyboardFocus(shellWidget, formWidget); +// XtSetKeyboardFocus(shellWidget, formWidget); + XSetInputFocus(xDisplay, XtWindow(formWidget), RevertToPointerRoot, CurrentTime); XtAppMainLoop(appContext); if (appData.debugMode) fclose(debugFP); // [DM] debug @@ -3057,7 +3071,6 @@ FindFont(pattern, targetPxlSize) char *def_string, *base_fnt_lst, strInt[3]; XFontSet fntSet; XFontStruct **fnt_list; - base_fnt_lst = calloc(1, strlen(pattern) + 3); snprintf(strInt, sizeof(strInt)/sizeof(strInt[0]), "%d", targetPxlSize); p = strstr(pattern, "--"); @@ -5800,11 +5813,8 @@ void MatchProc(w, event, prms, nprms) Cardinal *nprms; { if(gameMode != BeginningOfGame) { DisplayError(_("You can only start a match from the initial position."), 0); return; } - matchMode = 2; // This is back-end, really - appData.matchGames = appData.defaultMatchGames; - matchGame = 1; - first.matchWins = second.matchWins = 0; - TwoMachinesEvent(); + appData.matchGames = appData.defaultMatchGames; + MatchEvent(2); } void IcsClientProc(w, event, prms, nprms) @@ -8008,8 +8018,7 @@ CreateAnimVars () /* For XPM pieces, we need bitmaps to use as masks. */ if (useImages) - CreateAnimMasks(info.depth); - xpmDone = 1; + CreateAnimMasks(info.depth), xpmDone = 1; } #ifndef HAVE_USLEEP