From: H.G. Muller Date: Sun, 14 Oct 2012 12:34:09 +0000 (+0200) Subject: Cleanse back-end code of all references to X11 types X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=21a44c336aa8cd16a38f3c682386528c8f112650;p=xboard.git Cleanse back-end code of all references to X11 types When compiling for X11, common.h #included X11/Intrinsics.h so that X11-specific data types could still be used throughout the back-end part not shared with WinBoard. By temporarily disabling this, error messages could be generated on all such occurrences, and were then solved. This included the following: The InputSource struct is not uses in usystem.c at all, and its definition could be moved to xboard.c. InputSourceRef, which logically should heve been defined as (InputSource *), is in reality (void *), so the back-end can pass it around. Some non-platform-dependent stuff of general interest had prototypes (or external vars) in xboard.h. This is now moved to a new header xboard2.h, to allow it to be shared without bringing in X11 dependence. The EngineOutputProc was defined inconsistently, but the header was not sufficiently shared to flag this error. This has been repaired now, by moving the template to menus.h. --- diff --git a/Makefile.am b/Makefile.am index abce9f8..4dfe409 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,7 +35,7 @@ backendsources = backend.c backend.h backendz.h \ parser.c parser.h \ pgntags.c \ uci.c \ - args.h \ + args.h xboard2.h \ board.c board.h \ draw.c draw.h \ dialogs.c dialogs.h \ diff --git a/board.c b/board.c index 8b266a2..6abbabb 100644 --- a/board.c +++ b/board.c @@ -96,6 +96,7 @@ extern char *getenv(); #include "common.h" #include "frontend.h" #include "backend.h" +#include "xboard2.h" #include "moves.h" #include "board.h" #include "draw.h" diff --git a/dialogs.c b/dialogs.c index f5166b2..db7e249 100644 --- a/dialogs.c +++ b/dialogs.c @@ -50,7 +50,7 @@ extern char *getenv(); #include "common.h" #include "frontend.h" #include "backend.h" -#include "xboard.h" +#include "xboard2.h" #include "menus.h" #include "dialogs.h" #include "gettext.h" diff --git a/dialogs.h b/dialogs.h index 22e368c..2c3e993 100644 --- a/dialogs.h +++ b/dialogs.h @@ -119,7 +119,7 @@ typedef int OKCallback(int n); extern char commentTranslations[]; extern char historyTranslations[]; -extern Pixel timerBackgroundPixel; +//extern Pixel timerBackgroundPixel; extern int values[]; extern ChessProgramState *currentCps; extern int dialogError; @@ -139,7 +139,7 @@ int PopDown P((DialogClass n)); void MarkMenu P((char *item, int dlgNr)); int AppendText P((Option *opt, char *s)); void SetColor P((char *colorName, Option *box)); -void ColorChanged P((Widget w, XtPointer data, XEvent *event, Boolean *b)); +//void ColorChanged P((Widget w, XtPointer data, XEvent *event, Boolean *b)); void SetInsertPos P((Option *opt, int pos)); void HardSetFocus P((Option *opt)); void GetWidgetText P((Option *opt, char **buf)); diff --git a/draw.c b/draw.c index 4e7b6ac..03160f0 100644 --- a/draw.c +++ b/draw.c @@ -74,8 +74,6 @@ extern char *getenv(); #include #endif - -// [HGM] bitmaps: put before incuding the bitmaps / pixmaps, to know how many piece types there are. #include "common.h" #include "backend.h" @@ -168,9 +166,8 @@ InitDrawingSizes (BoardSize boardSize, int flags) static int oldWidth, oldHeight; static VariantClass oldVariant; static int oldMono = -1, oldTwoBoards = 0; - extern Widget formWidget; - if(!formWidget) return; + if(!mainOptions[W_BOARD].handle) return; if(oldTwoBoards && !twoBoards) PopDown(DummyDlg); oldTwoBoards = twoBoards; diff --git a/draw.h b/draw.h index cbf77f4..a54735f 100644 --- a/draw.h +++ b/draw.h @@ -56,15 +56,8 @@ void ResizeBoardWindow P((int w, int h, int inhibit)); void CreateGrid P((void)); void CreateGCs P((int redo)); void DelayedDrag P((void)); -void ReadBitmap P((Pixmap *pm, String name, unsigned char bits[], - u_int wreq, u_int hreq)); -extern XFontStruct *coordFontStruct, *countFontStruct; -extern Font coordFontID, countFontID; -extern int xScreen; extern int lineGap, squareSize; -extern Pixel lightSquareColor, darkSquareColor, whitePieceColor, blackPieceColor, - highlightSquareColor, premoveHighlightColor; // defined in draw.c void CreateGCs P((int redo)); diff --git a/nengineoutput.c b/nengineoutput.c index 31bdbe5..f494a7e 100644 --- a/nengineoutput.c +++ b/nengineoutput.c @@ -52,6 +52,7 @@ extern char *getenv(); #include "frontend.h" #include "backend.h" #include "dialogs.h" +#include "menus.h" #include "engineoutput.h" #include "gettext.h" @@ -153,7 +154,7 @@ EngineOutputDialogExists () } void -EngineOutputProc (Widget w, XEvent *event, String *prms, Cardinal *nprms) +EngineOutputProc () { if (!PopDown(EngOutDlg)) EngineOutputPopUp(); } diff --git a/nhistory.c b/nhistory.c index aadae07..2cddab6 100644 --- a/nhistory.c +++ b/nhistory.c @@ -28,7 +28,6 @@ #include "common.h" #include "backend.h" #include "xhistory.h" -#include "xboard.h" #include "dialogs.h" #include "gettext.h" diff --git a/usystem.h b/usystem.h index 51fd307..0aa18fe 100644 --- a/usystem.h +++ b/usystem.h @@ -67,19 +67,6 @@ typedef struct { int fdTo, fdFrom; } ChildProc; -#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; - extern char *oldICSInteractionTitle; char *ExpandPathName P((char *path)); diff --git a/xaw/xboard.c b/xaw/xboard.c index a834adf..0961db5 100644 --- a/xaw/xboard.c +++ b/xaw/xboard.c @@ -2402,6 +2402,19 @@ SetClockIcon (int color) } } +#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; + void DoInputCallback (caddr_t closure, int *source, XtInputId *xid) { diff --git a/xboard.c b/xboard.c index 6bc77cc..f430375 100644 --- a/xboard.c +++ b/xboard.c @@ -199,11 +199,11 @@ 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" @@ -322,6 +322,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 diff --git a/xboard.h b/xboard.h index 5a6587e..ca2a705 100644 --- a/xboard.h +++ b/xboard.h @@ -135,9 +135,6 @@ int AppendText P((Option *opt, char *s)); void NewCommentPopup P((char *title, char *text, int index)); void CatchDeleteWindow(Widget w, String procname); void GenericPopDown P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); -void InitDrawingSizes P((int i, int j)); -void SendToICS P((char *buf)); -void SendToProgram P((char *message, ChessProgramState *cps)); void SetFocus(Widget w, XtPointer data, XEvent *event, Boolean *b); // from xoptions.c void TypeInProc P((Widget w, XEvent *event, String *prms, Cardinal *nprms)); Widget CreateMenuItem P((Widget menu, char *msg, XtCallbackProc CB, int n)); @@ -161,11 +158,8 @@ extern int squareSize; extern Pixmap xMarkPixmap, wIconPixmap, bIconPixmap; extern char *layoutName; extern Pixel timerForegroundPixel, timerBackgroundPixel, dialogColor, buttonColor; -extern int searchTime; extern Atom wm_delete_window; -extern int squareSize, lineGap, defaultLineGap, useImages, useImageSqs; -extern int startedFromPositionFile; -extern char *icsTextMenuString; +extern int useImages, useImageSqs; extern char ICSInputTranslations[]; extern char *selected_fen_position; extern GC coordGC; diff --git a/xboard2.h b/xboard2.h new file mode 100644 index 0000000..98aec80 --- /dev/null +++ b/xboard2.h @@ -0,0 +1,9 @@ +void SendToProgram P((char *message, ChessProgramState *cps)); +void SendToICS P((char *buf)); +void InitDrawingSizes P((int i, int j)); + +extern int searchTime; +extern int squareSize, lineGap, defaultLineGap; +extern int startedFromPositionFile; +extern char *icsTextMenuString; + diff --git a/xoptions.c b/xoptions.c index cd18a57..b3bea5a 100644 --- a/xoptions.c +++ b/xoptions.c @@ -74,6 +74,7 @@ extern char *getenv(); #include "common.h" #include "backend.h" #include "xboard.h" +#include "xboard2.h" #include "dialogs.h" #include "menus.h" #include "gettext.h"