X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=xboard.c;h=2178163f8f45341d12c9ed1851cc0df1cea1a64c;hb=e9a0808a5551217eb4fd29d949f3c7672545c168;hp=d8faa0992c6fcc68addc77731c57af5d532133a0;hpb=67e15f886057db1a570ab8e29e7a8a6277736fb3;p=xboard.git diff --git a/xboard.c b/xboard.c index d8faa09..2178163 100644 --- a/xboard.c +++ b/xboard.c @@ -261,6 +261,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, @@ -322,6 +323,7 @@ void CopyPositionProc P((Widget w, XEvent *event, String *prms, void PastePositionProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void CopyGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); +void CopyGameListProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void PasteGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void SaveGameProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); void SavePositionProc P((Widget w, XEvent *event, @@ -364,6 +366,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)); @@ -618,6 +621,7 @@ MenuItem fileMenu[] = { MenuItem editMenu[] = { {N_("Copy Game Ctrl+C"), "Copy Game", CopyGameProc}, {N_("Copy Position Ctrl+Shift+C"), "Copy Position", CopyPositionProc}, + {N_("Copy Game List"), "Copy Game List", CopyGameListProc}, {"----", NULL, NothingProc}, {N_("Paste Game Ctrl+V"), "Paste Game", PasteGameProc}, {N_("Paste Position Ctrl+Shift+V"), "Paste Position", PastePositionProc}, @@ -913,6 +917,7 @@ XtActionsRec boardActions[] = { { "CopyPositionProc", CopyPositionProc }, { "PastePositionProc", PastePositionProc }, { "CopyGameProc", CopyGameProc }, + { "CopyGameListProc", CopyGameListProc }, { "PasteGameProc", PasteGameProc }, { "SaveGameProc", SaveGameProc }, { "SavePositionProc", SavePositionProc }, @@ -947,6 +952,7 @@ XtActionsRec boardActions[] = { { "AdjuWhiteProc", AdjuWhiteProc }, { "AdjuBlackProc", AdjuBlackProc }, { "AdjuDrawProc", AdjuDrawProc }, + { "TypeInProc", TypeInProc }, { "EnterKeyProc", EnterKeyProc }, { "UpKeyProc", UpKeyProc }, { "DownKeyProc", DownKeyProc }, @@ -1503,7 +1509,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 @@ -2578,6 +2584,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 ) { @@ -2614,7 +2622,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 @@ -3054,7 +3063,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, "--"); @@ -5581,20 +5589,10 @@ SendGameSelection(Widget w, Atom *selection, Atom *target, } } -/* note: when called from menu all parameters are NULL, so no clue what the - * Widget which was clicked on was, or what the click event was - */ -void CopyGameProc(w, event, prms, nprms) - Widget w; - XEvent *event; - String *prms; - Cardinal *nprms; +void CopySomething() { int ret; - ret = SaveGameToFile(gameCopyFilename, FALSE); - if (!ret) return; - /* * Set both PRIMARY (the selection) and CLIPBOARD, since we don't * have a notion of a game that is selected but not copied. @@ -5612,6 +5610,33 @@ void CopyGameProc(w, event, prms, nprms) NULL/* transfer_done_proc */); } +/* note: when called from menu all parameters are NULL, so no clue what the + * Widget which was clicked on was, or what the click event was + */ +void CopyGameProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + int ret; + + ret = SaveGameToFile(gameCopyFilename, FALSE); + if (!ret) return; + + CopySomething(); +} + +void CopyGameListProc(w, event, prms, nprms) + Widget w; + XEvent *event; + String *prms; + Cardinal *nprms; +{ + if(!SaveGameListAsText(fopen(gameCopyFilename, "w"))) return; + CopySomething(); +} + /* function called when the data to Paste is ready */ static void PasteGameCB(Widget w, XtPointer client_data, Atom *selection, @@ -5780,11 +5805,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) @@ -8534,6 +8556,16 @@ DragPieceBegin(x, y) } } +void +ChangeDragPiece(ChessSquare piece) +{ + Pixmap mask; + player.dragPiece = piece; + /* The piece will be drawn using its own bitmap as a matte */ + SelectGCMask(piece, &player.pieceGC, &player.outlineGC, &mask); + XSetClipMask(xDisplay, player.pieceGC, mask); +} + static void DragPieceMove(x, y) int x; int y;