Cleanse back-end code of all references to X11 types
authorH.G. Muller <h.g.muller@hccnet.nl>
Sun, 14 Oct 2012 12:34:09 +0000 (14:34 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Tue, 6 Nov 2012 11:45:09 +0000 (12:45 +0100)
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.

14 files changed:
Makefile.am
board.c
dialogs.c
dialogs.h
draw.c
draw.h
nengineoutput.c
nhistory.c
usystem.h
xaw/xboard.c
xboard.c
xboard.h
xboard2.h [new file with mode: 0644]
xoptions.c

index abce9f8..4dfe409 100644 (file)
@@ -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 (file)
--- 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"
index f5166b2..db7e249 100644 (file)
--- 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"
index 22e368c..2c3e993 100644 (file)
--- 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 (file)
--- a/draw.c
+++ b/draw.c
@@ -74,8 +74,6 @@ extern char *getenv();
 #include <locale.h>
 #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 (file)
--- 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));
index 31bdbe5..f494a7e 100644 (file)
@@ -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();
 }
index aadae07..2cddab6 100644 (file)
@@ -28,7 +28,6 @@
 #include "common.h"
 #include "backend.h"
 #include "xhistory.h"
-#include "xboard.h"
 #include "dialogs.h"
 #include "gettext.h"
 
index 51fd307..0aa18fe 100644 (file)
--- 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));
index a834adf..0961db5 100644 (file)
@@ -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)
 {
index 6bc77cc..f430375 100644 (file)
--- 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
index 5a6587e..ca2a705 100644 (file)
--- 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 (file)
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;
+
index cd18a57..b3bea5a 100644 (file)
@@ -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"