From 0ad4cbd7bd60324dc875c7d8f472096589c2b024 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 31 May 2012 09:30:22 +0000 Subject: Implement XFlush and various others for win32 as stubs, so win32 extensions using those can run under CYGWIN as well. Allow tk86.dll to cooperate with the cygwin console. --- ChangeLog | 4 +++ generic/tk.h | 2 +- generic/tkInt.decls | 25 ++++++++++++++++++ generic/tkIntXlibDecls.h | 57 +++++++++++++++++++++++++++++++++++++--- generic/tkMain.c | 10 ++++++- generic/tkStubInit.c | 12 ++++++--- unix/tkUnixPort.h | 18 ------------- win/Makefile.in | 7 ++++- win/stubs.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ win/tkWinPort.h | 21 --------------- 10 files changed, 176 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index d43f6f6..66f2aac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,10 @@ * generic/tk*Decls.h: re-generated * win/Makefile.in: Fix "make genstubs" when cross-compiling on UNIX + * win/stubs.c: Implement XFlush and various others for win32 as stubs, + * win/tkWinPort.h: so win32 extensions using those can run under CYGWIN as well. + * generic/tkMain.c: Allow tk86.dll to cooperate with the cygwin console. + 2012-05-29 Donal K. Fellows * generic/tkInt.decls (TkMacOSXDrawable): Added OSX-specific mechanism diff --git a/generic/tk.h b/generic/tk.h index a9b96e3..a44cfa8 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -1471,7 +1471,7 @@ typedef struct Tk_ElementSpec { #define Tk_Release Tcl_Release /* Removed Tk_Main, use macro instead */ -#ifdef _WIN32 +#if defined(__WIN32__) || defined(__CYGWIN__) #define Tk_Main(argc, argv, proc) Tk_MainEx(argc, argv, proc, \ (Tcl_FindExecutable(0), (Tcl_CreateInterp)())) #else diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 66a11c6..6709493 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1412,6 +1412,31 @@ declare 105 win { void XWarpPointer(Display *d, Window s, Window dw, int sx, int sy, unsigned int sw, unsigned int sh, int dx, int dy) } +# New in Tk 8.6 +declare 107 win { + int XFlush(Display *display) +} +declare 108 win { + int XGrabServer(Display *display) +} +declare 109 win { + int XUngrabServer(Display *display) +} +declare 110 win { + int XFree(void *data) +} +declare 111 win { + int XNoOp(Display *display) +} +declare 112 win { + int XSynchronize(Display *display, Bool onoff) +} +declare 113 win { + int XSync(Display *display, Bool discard) +} +declare 114 win { + VisualID XVisualIDFromVisual(Visual *visual) +} ################################ # X functions for Aqua diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index bd899bf..a613cf1 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -36,7 +36,7 @@ * Exported function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(__WIN32__) /* WIN */ /* 0 */ EXTERN void XSetDashes(Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); @@ -332,6 +332,22 @@ EXTERN void XWarpPointer(Display *d, Window s, Window dw, int sx, EXTERN void XFillRectangle(Display *display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); +/* 107 */ +EXTERN int XFlush(Display *display); +/* 108 */ +EXTERN int XGrabServer(Display *display); +/* 109 */ +EXTERN int XUngrabServer(Display *display); +/* 110 */ +EXTERN int XFree(void *data); +/* 111 */ +EXTERN int XNoOp(Display *display); +/* 112 */ +EXTERN int XSynchronize(Display *display, Bool onoff); +/* 113 */ +EXTERN int XSync(Display *display, Bool discard); +/* 114 */ +EXTERN VisualID XVisualIDFromVisual(Visual *visual); #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ /* 0 */ @@ -602,7 +618,7 @@ typedef struct TkIntXlibStubs { int magic; const struct TkIntXlibStubHooks *hooks; -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(__WIN32__) /* WIN */ void (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */ XModifierKeymap * (*xGetModifierMapping) (Display *d); /* 1 */ XImage * (*xCreateImage) (Display *d, Visual *v, unsigned int ui1, int i1, int i2, char *cp, unsigned int ui2, unsigned int ui3, int i3, int i4); /* 2 */ @@ -710,6 +726,14 @@ typedef struct TkIntXlibStubs { void (*xDrawLine) (Display *d, Drawable dr, GC g, int x1, int y1, int x2, int y2); /* 104 */ void (*xWarpPointer) (Display *d, Window s, Window dw, int sx, int sy, unsigned int sw, unsigned int sh, int dx, int dy); /* 105 */ void (*xFillRectangle) (Display *display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); /* 106 */ + int (*xFlush) (Display *display); /* 107 */ + int (*xGrabServer) (Display *display); /* 108 */ + int (*xUngrabServer) (Display *display); /* 109 */ + int (*xFree) (void *data); /* 110 */ + int (*xNoOp) (Display *display); /* 111 */ + int (*xSynchronize) (Display *display, Bool onoff); /* 112 */ + int (*xSync) (Display *display, Bool discard); /* 113 */ + VisualID (*xVisualIDFromVisual) (Visual *visual); /* 114 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ void (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */ @@ -821,7 +845,7 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; * Inline function declarations: */ -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(__WIN32__) /* WIN */ #define XSetDashes \ (tkIntXlibStubsPtr->xSetDashes) /* 0 */ #define XGetModifierMapping \ @@ -1035,6 +1059,22 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; (tkIntXlibStubsPtr->xWarpPointer) /* 105 */ #define XFillRectangle \ (tkIntXlibStubsPtr->xFillRectangle) /* 106 */ +#define XFlush \ + (tkIntXlibStubsPtr->xFlush) /* 107 */ +#define XGrabServer \ + (tkIntXlibStubsPtr->xGrabServer) /* 108 */ +#define XUngrabServer \ + (tkIntXlibStubsPtr->xUngrabServer) /* 109 */ +#define XFree \ + (tkIntXlibStubsPtr->xFree) /* 110 */ +#define XNoOp \ + (tkIntXlibStubsPtr->xNoOp) /* 111 */ +#define XSynchronize \ + (tkIntXlibStubsPtr->xSynchronize) /* 112 */ +#define XSync \ + (tkIntXlibStubsPtr->xSync) /* 113 */ +#define XVisualIDFromVisual \ + (tkIntXlibStubsPtr->xVisualIDFromVisual) /* 114 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ #define XSetDashes \ @@ -1230,4 +1270,15 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT +#if !(defined(__WIN32__) || defined(__CYGWIN__)) +/* + * The TkPutImage macro strips off the color table information, which isn't + * needed for X. + */ + +#define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \ + XPutImage(display, pixels, gc, image, srcx, srcy, destx, \ + desty, width, height); +#endif + #endif /* _TKINTXLIBDECLS */ diff --git a/generic/tkMain.c b/generic/tkMain.c index 4932d36..03e74b0 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -53,6 +53,7 @@ * to strcmp here. */ #ifdef __WIN32__ +# include "tclInt.h" # include "tkWinInt.h" #else # define TCHAR char @@ -92,10 +93,11 @@ * it will conflict with a declaration elsewhere on some systems. */ -#if defined(_WIN32) +#if defined(__WIN32__) || defined(_WIN32) #define isatty WinIsTty static int WinIsTty(int fd) { HANDLE handle; + /* * For now, under Windows, we assume we are not running as a console mode * app, so we need to use the GUI console. In order to enable this, we @@ -103,6 +105,12 @@ static int WinIsTty(int fd) { * to do it. */ +#if !defined(STATIC_BUILD) + if (tclStubsPtr->reserved9 && TclpIsAtty) { + /* We are running on Cygwin */ + return TclpIsAtty(fd); + } +#endif handle = GetStdHandle(STD_INPUT_HANDLE + fd); /* * If it's a bad or closed handle, then it's been connected to a wish diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index de5e00e..13ab403 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -80,8 +80,6 @@ TkpSync(Display *display) #define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004 int __stdcall GetModuleHandleExW(unsigned int, const char *, void *); -TkIntStubs tkIntStubs; - void *Tk_GetHINSTANCE() { void *hInstance = NULL; @@ -580,7 +578,7 @@ static const TkIntPlatStubs tkIntPlatStubs = { static const TkIntXlibStubs tkIntXlibStubs = { TCL_STUB_MAGIC, 0, -#if defined(__WIN32__) || defined(__CYGWIN__) /* WIN */ +#if defined(__WIN32__) /* WIN */ XSetDashes, /* 0 */ XGetModifierMapping, /* 1 */ XCreateImage, /* 2 */ @@ -688,6 +686,14 @@ static const TkIntXlibStubs tkIntXlibStubs = { XDrawLine, /* 104 */ XWarpPointer, /* 105 */ XFillRectangle, /* 106 */ + XFlush, /* 107 */ + XGrabServer, /* 108 */ + XUngrabServer, /* 109 */ + XFree, /* 110 */ + XNoOp, /* 111 */ + XSynchronize, /* 112 */ + XSync, /* 113 */ + XVisualIDFromVisual, /* 114 */ #endif /* WIN */ #ifdef MAC_OSX_TK /* AQUA */ XSetDashes, /* 0 */ diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index 12010f4..93422cf 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -126,25 +126,7 @@ # define WPARAM void * # define LPARAM void * # define LRESULT void * -#else -/* - * The TkPutImage macro strips off the color table information, which isn't - * needed for X. - */ - -#define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \ - XPutImage(display, pixels, gc, image, srcx, srcy, destx, \ - desty, width, height); - #endif - /* - * The TkPutImage macro strips off the color table information, which isn't - * needed for X. - */ - -# define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \ - XPutImage(display, pixels, gc, image, srcx, srcy, destx, \ - desty, width, height); /* * Supply macros for seek offsets, if they're not already provided by diff --git a/win/Makefile.in b/win/Makefile.in index 247e183..04e3d85 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -94,6 +94,10 @@ TCL_BIN_DIR = @TCL_BIN_DIR@ # been replaced by the configure script): TCL_GENERIC_DIR = @TCL_SRC_DIR@/generic +# The directory containing the platform specific Tcl sources and headers +# appropriate for this version of Tk: +TCL_PLATFORM_DIR = @TCL_SRC_DIR@/win + TCL_TOOL_DIR = @TCL_SRC_DIR@/tools # Converts a POSIX path to a Windows native path. @@ -120,6 +124,7 @@ BITMAP_DIR_NATIVE = $(ROOT_DIR_NATIVE)/bitmaps XLIB_DIR_NATIVE = $(ROOT_DIR_NATIVE)/xlib RC_DIR_NATIVE = $(WIN_DIR_NATIVE)/rc TCL_GENERIC_NATIVE = $(shell $(CYGPATH) '$(TCL_GENERIC_DIR)' | sed 's!\\!/!g') +TCL_PLATFORM_NATIVE = $(shell $(CYGPATH) '$(TCL_PLATFORM_DIR)' | sed 's!\\!/!g') TCL_SRC_DIR_NATIVE = $(shell $(CYGPATH) '$(TCL_SRC_DIR)' | sed 's!\\!/!g') DLLSUFFIX = @DLLSUFFIX@ @@ -208,7 +213,7 @@ TCL_EXE = @TCLSH_PROG@ CC_SWITCHES = ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \ -I"${GENERIC_DIR_NATIVE}" -I"${WIN_DIR_NATIVE}" \ -I"${XLIB_DIR_NATIVE}" -I"${BITMAP_DIR_NATIVE}" \ --I"${TCL_GENERIC_NATIVE}" ${AC_FLAGS} -DUSE_TCL_STUBS +-I"${TCL_GENERIC_NATIVE}" -I"${TCL_PLATFORM_NATIVE}" ${AC_FLAGS} -DUSE_TCL_STUBS CC_OBJNAME = @CC_OBJNAME@ CC_EXENAME = @CC_EXENAME@ diff --git a/win/stubs.c b/win/stubs.c index 00030d1..3cd8327 100644 --- a/win/stubs.c +++ b/win/stubs.c @@ -386,3 +386,71 @@ XGetWindowProperty( *prop_return = NULL; return BadValue; } + +/* + * The following functions were implemented as macros under Windows. + */ + +int +XFlush( + Display *display) +{ + return 0; +} + +int +XGrabServer( + Display *display) +{ + return 0; +} + +int +XUngrabServer( + Display *display) +{ + return 0; +} + +int +XFree( + void *data) +{ + if ((data) != NULL) { + ckfree(data); + } + return 0; +} + +int +XNoOp( + Display *display) +{ + display->request++; + return 0; +} + +int +XSynchronize( + Display *display, + Bool bool) +{ + display->request++; + return 0; +} + +int +XSync( + Display *display, + Bool bool) +{ + display->request++; + return 0; +} + +VisualID +XVisualIDFromVisual( + Visual *visual) +{ + return visual->visualid; +} diff --git a/win/tkWinPort.h b/win/tkWinPort.h index 75c7d22..fe31609 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -98,27 +98,6 @@ #endif /* _MSC_VER */ /* - * The following stubs implement various calls that don't do anything - * under Windows. - */ - -#define TkFreeWindowId(dispPtr,w) -#define TkInitXId(dispPtr) -#define XFlush(display) -#define XGrabServer(display) -#define XUngrabServer(display) - -/* - * The following functions are implemented as macros under Windows. - */ - -#define XFree(data) {if ((data) != NULL) ckfree(data);} -#define XNoOp(display) {display->request++;} -#define XSynchronize(display, bool) {display->request++;} -#define XSync(display, bool) {display->request++;} -#define XVisualIDFromVisual(visual) (visual->visualid) - -/* * The following Tk functions are implemented as macros under Windows. */ -- cgit v0.12