summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-25 12:19:47 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-25 12:19:47 (GMT)
commitba34893472773623c15b6e7b5a6739213d6b4edf (patch)
treec70ccc1c14fdf986ba8530e11b5a1a69b08de298
parent370613fce55f62665cc953a771c99b4e46f06c76 (diff)
downloadtk-ba34893472773623c15b6e7b5a6739213d6b4edf.zip
tk-ba34893472773623c15b6e7b5a6739213d6b4edf.tar.gz
tk-ba34893472773623c15b6e7b5a6739213d6b4edf.tar.bz2
Simpify determination whether we are running on cygwin.
Export Tk_GetHINSTANCE, TkSetPixmapColormap and TkpPrintWindowId on the Cygwin dll. Fix "make genstubs" when cross-compiling on UNIX
-rw-r--r--ChangeLog9
-rw-r--r--generic/tkImgPhoto.c2
-rw-r--r--generic/tkInt.decls24
-rw-r--r--generic/tkIntPlatDecls.h69
-rw-r--r--generic/tkMain.c105
-rw-r--r--generic/tkStubInit.c174
-rw-r--r--generic/tkTextDisp.c2
-rw-r--r--generic/tkWindow.c20
-rw-r--r--unix/tkUnixPort.h53
-rw-r--r--win/Makefile.in25
10 files changed, 251 insertions, 232 deletions
diff --git a/ChangeLog b/ChangeLog
index 75cbd42..0b7dcec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-05-25 Jan Nijtmans <nijtmans@users.sf.net>
+
+ * generic/tkWindow.c: Simpify determination whether we are running on cygwin.
+ * generic/tkStubInit.c: Export Tk_GetHINSTANCE, TkSetPixmapColormap and
+ * generic/tkInt.decls: TkpPrintWindowId on the Cygwin dll, sync stub table
+ with Tk 8.6 win32 version.
+ * generic/tk*Decls.h: re-generated
+ * win/Makefile.in: Fix "make genstubs" when cross-compiling on UNIX
+
2012-05-24 Jan Nijtmans <nijtmans@users.sf.net>
* win/stubs.c: Change XSetCommand signature to match Xorg,
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index ffbb47c..23db11a 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -25,6 +25,8 @@
#ifdef __WIN32__
#include "tkWinInt.h"
+#elif defined(__CYGWIN__)
+#include "tkUnixInt.h"
#endif
/*
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index 61d5775..df2ad29 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -666,41 +666,31 @@ declare 36 win {
UINT message, WPARAM wParam, LPARAM lParam)
}
-# new for 8.4.20+, Cygwin only
+# new for 8.4.20+/8.5.12+, Cygwin only
declare 37 win {
void TkCreateXEventSource(void)
}
declare 38 win {
- void TkFreeWindowId(TkDisplay *dispPtr, Window w)
-}
-declare 39 win {
- void TkInitXId(TkDisplay *dispPtr)
-}
-declare 40 win {
int TkpCmapStressed(Tk_Window tkwin, Colormap colormap)
}
-declare 41 win {
+declare 39 win {
void TkpSync(Display *display)
}
-declare 42 win {
+declare 40 win {
Window TkUnixContainerId(TkWindow *winPtr)
}
-declare 43 win {
+declare 41 win {
int TkUnixDoOneXEvent(Tcl_Time *timePtr)
}
-declare 44 win {
+declare 42 win {
void TkUnixSetMenubar(Tk_Window tkwin, Tk_Window menubar)
}
-declare 45 win {
+declare 43 win {
void TkWmCleanup(TkDisplay *dispPtr)
}
-declare 46 win {
+declare 44 win {
void TkSendCleanup(TkDisplay *dispPtr)
}
-declare 47 win {
- void TkFreeXId(TkDisplay *dispPtr)
-}
-
################################
# Mac specific functions
diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h
index 14a1f7d..badb8b6 100644
--- a/generic/tkIntPlatDecls.h
+++ b/generic/tkIntPlatDecls.h
@@ -129,28 +129,21 @@ EXTERN LRESULT __stdcall TkWinChildProc _ANSI_ARGS_((HWND hwnd, UINT message,
/* 37 */
EXTERN void TkCreateXEventSource _ANSI_ARGS_((void));
/* 38 */
-EXTERN void TkFreeWindowId _ANSI_ARGS_((TkDisplay *dispPtr,
- Window w));
-/* 39 */
-EXTERN void TkInitXId _ANSI_ARGS_((TkDisplay *dispPtr));
-/* 40 */
EXTERN int TkpCmapStressed _ANSI_ARGS_((Tk_Window tkwin,
Colormap colormap));
-/* 41 */
+/* 39 */
EXTERN void TkpSync _ANSI_ARGS_((Display *display));
-/* 42 */
+/* 40 */
EXTERN Window TkUnixContainerId _ANSI_ARGS_((TkWindow *winPtr));
-/* 43 */
+/* 41 */
EXTERN int TkUnixDoOneXEvent _ANSI_ARGS_((Tcl_Time *timePtr));
-/* 44 */
+/* 42 */
EXTERN void TkUnixSetMenubar _ANSI_ARGS_((Tk_Window tkwin,
Tk_Window menubar));
-/* 45 */
+/* 43 */
EXTERN void TkWmCleanup _ANSI_ARGS_((TkDisplay *dispPtr));
-/* 46 */
+/* 44 */
EXTERN void TkSendCleanup _ANSI_ARGS_((TkDisplay *dispPtr));
-/* 47 */
-EXTERN void TkFreeXId _ANSI_ARGS_((TkDisplay *dispPtr));
#endif /* WIN */
#ifdef MAC_TCL
/* 0 */
@@ -490,16 +483,13 @@ typedef struct TkIntPlatStubs {
int (*tkWinGetPlatformTheme) _ANSI_ARGS_((void)); /* 35 */
LRESULT (__stdcall *tkWinChildProc) _ANSI_ARGS_((HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)); /* 36 */
void (*tkCreateXEventSource) _ANSI_ARGS_((void)); /* 37 */
- void (*tkFreeWindowId) _ANSI_ARGS_((TkDisplay *dispPtr, Window w)); /* 38 */
- void (*tkInitXId) _ANSI_ARGS_((TkDisplay *dispPtr)); /* 39 */
- int (*tkpCmapStressed) _ANSI_ARGS_((Tk_Window tkwin, Colormap colormap)); /* 40 */
- void (*tkpSync) _ANSI_ARGS_((Display *display)); /* 41 */
- Window (*tkUnixContainerId) _ANSI_ARGS_((TkWindow *winPtr)); /* 42 */
- int (*tkUnixDoOneXEvent) _ANSI_ARGS_((Tcl_Time *timePtr)); /* 43 */
- void (*tkUnixSetMenubar) _ANSI_ARGS_((Tk_Window tkwin, Tk_Window menubar)); /* 44 */
- void (*tkWmCleanup) _ANSI_ARGS_((TkDisplay *dispPtr)); /* 45 */
- void (*tkSendCleanup) _ANSI_ARGS_((TkDisplay *dispPtr)); /* 46 */
- void (*tkFreeXId) _ANSI_ARGS_((TkDisplay *dispPtr)); /* 47 */
+ int (*tkpCmapStressed) _ANSI_ARGS_((Tk_Window tkwin, Colormap colormap)); /* 38 */
+ void (*tkpSync) _ANSI_ARGS_((Display *display)); /* 39 */
+ Window (*tkUnixContainerId) _ANSI_ARGS_((TkWindow *winPtr)); /* 40 */
+ int (*tkUnixDoOneXEvent) _ANSI_ARGS_((Tcl_Time *timePtr)); /* 41 */
+ void (*tkUnixSetMenubar) _ANSI_ARGS_((Tk_Window tkwin, Tk_Window menubar)); /* 42 */
+ void (*tkWmCleanup) _ANSI_ARGS_((TkDisplay *dispPtr)); /* 43 */
+ void (*tkSendCleanup) _ANSI_ARGS_((TkDisplay *dispPtr)); /* 44 */
#endif /* WIN */
#ifdef MAC_TCL
void (*tkGenerateActivateEvents) _ANSI_ARGS_((TkWindow *winPtr, int active)); /* 0 */
@@ -807,45 +797,33 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr;
#define TkCreateXEventSource \
(tkIntPlatStubsPtr->tkCreateXEventSource) /* 37 */
#endif
-#ifndef TkFreeWindowId
-#define TkFreeWindowId \
- (tkIntPlatStubsPtr->tkFreeWindowId) /* 38 */
-#endif
-#ifndef TkInitXId
-#define TkInitXId \
- (tkIntPlatStubsPtr->tkInitXId) /* 39 */
-#endif
#ifndef TkpCmapStressed
#define TkpCmapStressed \
- (tkIntPlatStubsPtr->tkpCmapStressed) /* 40 */
+ (tkIntPlatStubsPtr->tkpCmapStressed) /* 38 */
#endif
#ifndef TkpSync
#define TkpSync \
- (tkIntPlatStubsPtr->tkpSync) /* 41 */
+ (tkIntPlatStubsPtr->tkpSync) /* 39 */
#endif
#ifndef TkUnixContainerId
#define TkUnixContainerId \
- (tkIntPlatStubsPtr->tkUnixContainerId) /* 42 */
+ (tkIntPlatStubsPtr->tkUnixContainerId) /* 40 */
#endif
#ifndef TkUnixDoOneXEvent
#define TkUnixDoOneXEvent \
- (tkIntPlatStubsPtr->tkUnixDoOneXEvent) /* 43 */
+ (tkIntPlatStubsPtr->tkUnixDoOneXEvent) /* 41 */
#endif
#ifndef TkUnixSetMenubar
#define TkUnixSetMenubar \
- (tkIntPlatStubsPtr->tkUnixSetMenubar) /* 44 */
+ (tkIntPlatStubsPtr->tkUnixSetMenubar) /* 42 */
#endif
#ifndef TkWmCleanup
#define TkWmCleanup \
- (tkIntPlatStubsPtr->tkWmCleanup) /* 45 */
+ (tkIntPlatStubsPtr->tkWmCleanup) /* 43 */
#endif
#ifndef TkSendCleanup
#define TkSendCleanup \
- (tkIntPlatStubsPtr->tkSendCleanup) /* 46 */
-#endif
-#ifndef TkFreeXId
-#define TkFreeXId \
- (tkIntPlatStubsPtr->tkFreeXId) /* 47 */
+ (tkIntPlatStubsPtr->tkSendCleanup) /* 44 */
#endif
#endif /* WIN */
#ifdef MAC_TCL
@@ -1314,4 +1292,11 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr;
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
+#ifdef __CYGWIN__
+ void TkFreeXId(TkDisplay *dispPtr);
+ void TkFreeWindowId(TkDisplay *dispPtr, Window w);
+ void TkInitXId(TkDisplay *dispPtr);
+#endif
+
+
#endif /* _TKINTPLATDECLS */
diff --git a/generic/tkMain.c b/generic/tkMain.c
index 65a42a6..af2448e 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -28,6 +28,7 @@
#endif
#ifdef __WIN32__
#include "tkWinInt.h"
+#include "../win/tclWinPort.h"
#endif
#ifdef MAC_OSX_TK
#include "tkMacOSXInt.h"
@@ -55,7 +56,45 @@ static Tcl_ThreadDataKey dataKey;
* some systems.
*/
-#if !defined(__WIN32__) && !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
+ * always claim to be running on a tty. This probably isn't the right
+ * way 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 ((handle == INVALID_HANDLE_VALUE) || (handle == 0)
+ || (GetFileType(handle) == FILE_TYPE_UNKNOWN)) {
+ /*
+ * If it's a bad or closed handle, then it's been connected
+ * to a wish console window.
+ */
+
+ return 1;
+ } else if (GetFileType(handle) == FILE_TYPE_CHAR) {
+ /*
+ * A character file handle is a tty by definition.
+ */
+
+ return 1;
+ } else {
+ return 0;
+ }
+}
+#else
#if !defined(MAC_TCL)
extern int isatty _ANSI_ARGS_((int fd));
#else
@@ -90,6 +129,8 @@ static void StdinProc _ANSI_ARGS_((ClientData clientData,
*
*----------------------------------------------------------------------
*/
+int LoadCygwinTk(Tcl_Interp *interp);
+
void
Tk_MainEx(argc, argv, appInitProc, interp)
int argc; /* Number of arguments. */
@@ -106,9 +147,6 @@ Tk_MainEx(argc, argv, appInitProc, interp)
Tcl_Channel inChannel, outChannel;
Tcl_DString appName;
ThreadSpecificData *tsdPtr;
-#ifdef __WIN32__
- HANDLE handle;
-#endif
/*
* Ensure that we are getting the matching version of Tcl. This is
@@ -119,6 +157,27 @@ Tk_MainEx(argc, argv, appInitProc, interp)
abort();
}
+#if defined(__WIN32__) && !defined(STATIC_BUILD)
+ if (tclStubsPtr->reserved9) {
+ /* We are running win32 Tk under Cygwin, so let's check
+ * whether the env("DISPLAY") variable or the -display
+ * argument is set. If so, we really want to run the
+ * Tk_MainEx function of libtk.dll, not this one. */
+ if (Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY)) {
+ loadCygwinTk:
+ Tcl_Panic("Should load libtk.dll now, not yet implemented");
+ } else {
+ int i;
+
+ for (i = 1; i < argc; ++i) {
+ if (!strcmp(argv[i], "-display")) {
+ goto loadCygwinTk;
+ }
+ }
+ }
+ }
+#endif
+
tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -126,7 +185,12 @@ Tk_MainEx(argc, argv, appInitProc, interp)
tsdPtr->interp = interp;
Tcl_Preserve((ClientData) interp);
-#if ((defined(__WIN32__) && !defined(__CYGWIN__)) || defined(MAC_TCL))
+#if defined(__WIN32__) && !defined(STATIC_BUILD)
+ if (!tclStubsPtr->reserved9) {
+ /* Only initialize console when not running under cygwin */
+ Tk_InitConsoleChannels(interp);
+ }
+#elif defined(__WIN32__) || defined(MAC_TCL)
Tk_InitConsoleChannels(interp);
#endif
@@ -194,37 +258,8 @@ Tk_MainEx(argc, argv, appInitProc, interp)
* Set the "tcl_interactive" variable.
*/
-#ifdef __WIN32__
- /*
- * 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
- * always claim to be running on a tty. This probably isn't the right
- * way to do it.
- */
-
- handle = GetStdHandle(STD_INPUT_HANDLE);
-
- if ((handle == INVALID_HANDLE_VALUE) || (handle == 0)
- || (GetFileType(handle) == FILE_TYPE_UNKNOWN)) {
- /*
- * If it's a bad or closed handle, then it's been connected
- * to a wish console window.
- */
-
- tsdPtr->tty = 1;
- } else if (GetFileType(handle) == FILE_TYPE_CHAR) {
- /*
- * A character file handle is a tty by definition.
- */
-
- tsdPtr->tty = 1;
- } else {
- tsdPtr->tty = 0;
- }
-
-#else
tsdPtr->tty = isatty(0);
-#endif
+
#if defined(MAC_OSX_TK)
/*
* On TkAqua, if we don't have a TTY and stdin is a special character file
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index e175a99..adaf319 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -49,14 +49,10 @@ doNothing(void)
/*
* Remove macros that will interfere with the definitions below.
*/
-# undef TkFreeWindowId
-# undef TkInitXId
# undef TkpCmapStressed
# undef TkpSync
-# define TkCreateXEventSource (void (*) (void)) doNothing
-# define TkFreeWindowId (void (*) (TkDisplay *, Window)) doNothing
-# define TkInitXId (void (*) (TkDisplay *)) doNothing
+# define TkCreateXEventSource (void (*) (void)) doNothing
# define TkpCmapStressed (int (*) (Tk_Window, Colormap)) doNothing
# define TkpSync (void (*) (Display *)) doNothing
# define TkUnixContainerId 0
@@ -64,40 +60,18 @@ doNothing(void)
# define TkUnixSetMenubar 0
# define TkWmCleanup (void (*) (TkDisplay *)) doNothing
# define TkSendCleanup (void (*) (TkDisplay *)) doNothing
-# define TkFreeXId (void (*) (TkDisplay *)) doNothing
-#else
-/*
- * Remove macros that will interfere with the definitions below.
- */
-# undef TkClipBox
-# undef TkCreateRegion
-# undef TkDestroyRegion
-# undef TkIntersectRegion
-# undef TkRectInRegion
-# undef TkSetRegion
-# undef TkUnionRectWithRegion
-# undef TkSubtractRegion
-# undef TkPutImage
-# undef TkSetPixmapColormap
-# undef TkpPrintWindowId
-# undef TkWinChildProc
+#else /* !__WIN32__ */
-/*
- * Make sure that extensions which call XParseColor through the stub
- * table, call TkParseColor instead. [Bug 3486474]
- */
-# define XParseColor TkParseColor
+# undef TkClipBox
+# undef TkCreateRegion
+# undef TkDestroyRegion
+# undef TkIntersectRegion
+# undef TkRectInRegion
+# undef TkSetRegion
+# undef TkUnionRectWithRegion
+# undef TkSubtractRegion
-# ifndef __CYGWIN__
-# define Tk_AttachHWND 0
-# define Tk_GetHWND 0
-# define Tk_HWNDToWindow 0
-# define Tk_PointerEvent 0
-# define Tk_TranslateWinEvent 0
-# define Tk_GetHINSTANCE 0
-# endif
-# if !defined(MAC_TCL) && !defined(MAC_OSX_TCL)
# define TkClipBox (void (*) _ANSI_ARGS_((TkRegion, XRectangle *))) XClipBox
# define TkCreateRegion (TkRegion (*) ()) XCreateRegion
# define TkDestroyRegion (void (*) _ANSI_ARGS_((TkRegion))) XDestroyRegion
@@ -107,22 +81,34 @@ doNothing(void)
# define TkUnionRectWithRegion (void (*) _ANSI_ARGS_((XRectangle *, TkRegion, TkRegion))) XUnionRectWithRegion
# define TkSubtractRegion (void (*) _ANSI_ARGS_((TkRegion, TkRegion, TkRegion))) XSubtractRegion
-# ifdef __CYGWIN__
-# define Tk_GetHINSTANCE TkPlatGetHINSTANCE
-# define TkSetPixmapColormap TkPlatSetPixmapColormap
-# define TkpPrintWindowId TkPlatpPrintWindowId
-
/*
- * Trick, so we don't have to include <windows.h> here, which in any
- * case lacks this function anyway.
+ * Make sure that extensions which call XParseColor through the stub
+ * table, call TkParseColor instead. [Bug 3486474]
*/
+# define XParseColor TkParseColor
+
+# ifdef __CYGWIN__
+
+ /*
+ * Remove macros that will interfere with the definitions below.
+ */
+# undef TkPutImage
+# undef TkSetPixmapColormap
+# undef TkpPrintWindowId
+# undef TkWinChildProc
+
+
+ /*
+ * Trick, so we don't have to include <windows.h> here, which in any
+ * case lacks this function anyway.
+ */
-#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
+# define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
int __stdcall GetModuleHandleExW(unsigned int, const char *, void *);
TkIntStubs tkIntStubs;
-static void *Tk_GetHINSTANCE()
+void *Tk_GetHINSTANCE()
{
void *hInstance = NULL;
@@ -131,14 +117,14 @@ static void *Tk_GetHINSTANCE()
return hInstance;
}
-static void
+void
TkSetPixmapColormap(pixmap, colormap)
Pixmap pixmap;
Colormap colormap;
{
}
-static void
+void
TkpPrintWindowId(buf, window)
char *buf; /* Pointer to string large enough to hold
* the hex representation of a pointer. */
@@ -147,47 +133,46 @@ TkpPrintWindowId(buf, window)
sprintf(buf, "%#08lx", (unsigned long) (window));
}
- /* TODO: To be implemented for Cygwin */
-# define Tk_AttachHWND 0
-# define Tk_GetHWND 0
-# define Tk_HWNDToWindow 0
-# define Tk_PointerEvent 0
-# define Tk_TranslateWinEvent 0
-# define TkAlignImageData 0
-# define TkGenerateActivateEvents 0
-# define TkpGetMS 0
-# define TkPointerDeadWindow 0
-# define TkpSetCapture 0
-# define TkpSetCursor 0
-# define TkWinCancelMouseTimer 0
-# define TkWinClipboardRender 0
-# define TkWinEmbeddedEventProc 0
-# define TkWinFillRect 0
-# define TkWinGetBorderPixels 0
-# define TkWinGetDrawableDC 0
-# define TkWinGetModifierState 0
-# define TkWinGetSystemPalette 0
-# define TkWinGetWrapperWindow 0
-# define TkWinHandleMenuEvent 0
-# define TkWinIndexOfColor 0
-# define TkWinReleaseDrawableDC 0
-# define TkWinResendEvent 0
-# define TkWinSelectPalette 0
-# define TkWinSetMenu 0
-# define TkWinSetWindowPos 0
-# define TkWinWmCleanup 0
-# define TkWinXCleanup 0
-# define TkWinXInit 0
-# define TkWinSetForegroundWindow 0
-# define TkWinDialogDebug 0
-# define TkWinGetMenuSystemDefault 0
-# define TkWinGetPlatformId 0
-# define TkWinSetHINSTANCE 0
-# define TkWinGetPlatformTheme 0
-# define TkWinChildProc 0
+ /* TODO: To be implemented for Cygwin */
+# define Tk_AttachHWND 0
+# define Tk_GetHWND 0
+# define Tk_HWNDToWindow 0
+# define Tk_PointerEvent 0
+# define Tk_TranslateWinEvent 0
+# define TkAlignImageData 0
+# define TkGenerateActivateEvents 0
+# define TkpGetMS 0
+# define TkPointerDeadWindow 0
+# define TkpSetCapture 0
+# define TkpSetCursor 0
+# define TkWinCancelMouseTimer 0
+# define TkWinClipboardRender 0
+# define TkWinEmbeddedEventProc 0
+# define TkWinFillRect 0
+# define TkWinGetBorderPixels 0
+# define TkWinGetDrawableDC 0
+# define TkWinGetModifierState 0
+# define TkWinGetSystemPalette 0
+# define TkWinGetWrapperWindow 0
+# define TkWinHandleMenuEvent 0
+# define TkWinIndexOfColor 0
+# define TkWinReleaseDrawableDC 0
+# define TkWinResendEvent 0
+# define TkWinSelectPalette 0
+# define TkWinSetMenu 0
+# define TkWinSetWindowPos 0
+# define TkWinWmCleanup 0
+# define TkWinXCleanup 0
+# define TkWinXInit 0
+# define TkWinSetForegroundWindow 0
+# define TkWinDialogDebug 0
+# define TkWinGetMenuSystemDefault 0
+# define TkWinGetPlatformId 0
+# define TkWinSetHINSTANCE 0
+# define TkWinGetPlatformTheme 0
+# define TkWinChildProc 0
# endif /* __CYGWIN__ */
-# endif /* !MAC_TCL && !MACC_OSX_TCL */
#endif /* !__WIN32__ */
/*
@@ -431,16 +416,13 @@ TkIntPlatStubs tkIntPlatStubs = {
TkWinGetPlatformTheme, /* 35 */
TkWinChildProc, /* 36 */
TkCreateXEventSource, /* 37 */
- TkFreeWindowId, /* 38 */
- TkInitXId, /* 39 */
- TkpCmapStressed, /* 40 */
- TkpSync, /* 41 */
- TkUnixContainerId, /* 42 */
- TkUnixDoOneXEvent, /* 43 */
- TkUnixSetMenubar, /* 44 */
- TkWmCleanup, /* 45 */
- TkSendCleanup, /* 46 */
- TkFreeXId, /* 47 */
+ TkpCmapStressed, /* 38 */
+ TkpSync, /* 39 */
+ TkUnixContainerId, /* 40 */
+ TkUnixDoOneXEvent, /* 41 */
+ TkUnixSetMenubar, /* 42 */
+ TkWmCleanup, /* 43 */
+ TkSendCleanup, /* 44 */
#endif /* WIN */
#ifdef MAC_TCL
TkGenerateActivateEvents, /* 0 */
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index 1e7ca88..cd5d90f 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -18,6 +18,8 @@
#ifdef __WIN32__
#include "tkWinInt.h"
+#elif defined(__CYGWIN__)
+#include "tkUnixInt.h"
#endif
#ifdef TK_NO_DOUBLE_BUFFERING
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 67db10c..21675d0 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -16,7 +16,9 @@
#include "tkPort.h"
#include "tkInt.h"
-#if !( defined(__WIN32__) || defined(MAC_TCL) || defined(MAC_OSX_TK))
+#ifdef __WIN32__
+#include "tkWinInt.h"
+#elif !(defined(MAC_TCL) || defined(MAC_OSX_TK))
#include "tkUnixInt.h"
#endif
@@ -852,9 +854,6 @@ TkCreateMainWindow(interp, screenName, baseName)
Tk_Window tkwin;
int dummy;
int isSafe;
-#if defined(__WIN32__) && !defined(STATIC_BUILD)
- int isWin32 = 0;
-#endif
Tcl_HashEntry *hPtr;
register TkMainInfo *mainPtr;
register TkWindow *winPtr;
@@ -862,14 +861,6 @@ TkCreateMainWindow(interp, screenName, baseName)
ClientData clientData;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-#if defined(__WIN32__) && !defined(STATIC_BUILD)
- Tcl_Obj *stringObjPtr = Tcl_GetVar2Ex(interp, "::tcl_platform", "platform", 0);
-
- if (stringObjPtr
- && !strcmp(Tcl_GetString(stringObjPtr), "windows")) {
- isWin32 = 1;
- }
-#endif
/*
* Panic if someone updated the TkWindow structure without
@@ -954,7 +945,8 @@ TkCreateMainWindow(interp, screenName, baseName)
Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs");
}
#if defined(__WIN32__) && !defined(STATIC_BUILD)
- if (!isWin32 && (cmdPtr->flags & WINMACONLY)) {
+ if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->reserved9) {
+ /* We are running on Cygwin, so don't use the win32 dialogs */
continue;
}
#endif
@@ -3209,9 +3201,7 @@ Initialize(interp)
Tcl_SetMainLoop(Tk_MainLoop);
}
-#ifdef Tk_InitStubs
#undef Tk_InitStubs
-#endif
Tk_InitStubs(interp, TK_VERSION, 1);
diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h
index f0affb8..6e03287 100644
--- a/unix/tkUnixPort.h
+++ b/unix/tkUnixPort.h
@@ -125,6 +125,31 @@
# define NBBY 8
#endif
+#ifdef __CYGWIN__
+# define UINT unsigned int
+# define HWND void *
+# define HDC void *
+# define HINSTANCE void *
+# define COLORREF void *
+# define HMENU void *
+# define TkWinDCState void
+# define HPALETTE void *
+# define WNDPROC void *
+# define WPARAM void *
+# define LPARAM void *
+# define LRESULT void *
+#endif /* This really should be an #else, as soon as the Xlib stubs are enabled for 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 */
+
/*
* These macros are just wrappers for the equivalent X Region calls.
*/
@@ -141,29 +166,7 @@
#define TkUnionRectWithRegion(rect, src, ret) XUnionRectWithRegion(rect, \
(Region) src, (Region) ret)
-/*
- * The TkPutImage macro strips off the color table information, which isn't
- * needed for X.
- */
-
-#define TkPutImage(colors, ncolors, display, pixels, gc, image, destx, desty, srcx, srcy, width, height) \
- XPutImage(display, pixels, gc, image, destx, desty, srcx, \
- srcy, width, height);
-
-#ifdef __CYGWIN__
-# define UINT unsigned int
-# define HWND void *
-# define HDC void *
-# define HINSTANCE void *
-# define COLORREF void *
-# define HMENU void *
-# define TkWinDCState void
-# define HPALETTE void *
-# define WNDPROC void *
-# define WPARAM void *
-# define LPARAM void *
-# define LRESULT void *
-#endif
+/* #endif */
/*
* Supply macros for seek offsets, if they're not already provided by
@@ -195,7 +198,9 @@
#define TkpButtonSetDefaults(specPtr) {}
#define TkpDestroyButton(butPtr) {}
#define TkSelUpdateClipboard(a,b) {}
+#ifndef __CYGWIN__
#define TkSetPixmapColormap(p,c) {}
+#endif
/*
* These calls implement native bitmaps which are not supported under
@@ -211,8 +216,10 @@
* This should perhaps use the real size of an XID.
*/
+#ifndef __CYGWIN__
#define TkpPrintWindowId(buf,w) \
sprintf((buf), "%#08lx", (unsigned long) (w))
+#endif
/*
* The following declaration is used to get access to a private Tcl interface
diff --git a/win/Makefile.in b/win/Makefile.in
index 9304b43..6612230 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -429,8 +429,13 @@ install-binaries: binaries
@(\
echo "if {[package vcompare [package provide Tcl]\
$(TCLVERSION)] != 0} { return }";\
- echo "package ifneeded Tk $(VERSION)\
+ echo "if {([info exists ::env(DISPLAY)] || [lsearch -exact \$$::argv -display] > -1)} {";\
+ echo " package ifneeded Tk $(VERSION)\
+ [list load [file join \$$dir .. .. bin libtk$(VERSION).dll] Tk]";\
+ echo "} else {";\
+ echo " package ifneeded Tk $(VERSION)\
[list load [file join \$$dir .. .. bin $(TK_DLL_FILE)] Tk]";\
+ echo "}";\
) > $(PKG_INDEX);
@for i in tkConfig.sh $(TK_LIB_FILE) $(TK_STUB_LIB_FILE); \
do \
@@ -642,7 +647,19 @@ $(GENERIC_DIR)/tkStubInit.c: $(GENERIC_DIR)/tk.decls \
@echo "This warning can be safely ignored, do not report as a bug!"
genstubs:
- $(TCL_EXE) "$(TCL_TOOL_DIR}\genStubs.tcl" \
+ $(TCL_EXE) "$(TCL_TOOL_DIR)/genStubs.tcl" \
"$(GENERIC_DIR_NATIVE)" \
- "$(GENERIC_DIR_NATIVE)\tk.decls" \
- "$(GENERIC_DIR_NATIVE)\tkInt.decls"
+ "$(GENERIC_DIR_NATIVE)/tk.decls" \
+ "$(GENERIC_DIR_NATIVE)/tkInt.decls"
+#
+# The list of all the targets that do not correspond to real files. This stops
+# 'make' from getting confused when someone makes an error in a rule.
+#
+
+.PHONY: all binaries libraries doc tkLibObjs objs tktest-real test test-classic
+.PHONY: test-ttk testlang runtest shell demo gdb install install-strip
+.PHONY: install-binaries install-libraries install-demos install-doc
+.PHONY: install-private-headers clean distclean depend genstubs checkstubs
+.PHONY: checkuchar checkexports rpm dist alldist allpatch html html-tcl html-tk
+
+# DO NOT DELETE THIS LINE -- make depend depends on it.