diff options
author | nijtmans@users.sourceforge.net <jan.nijtmans> | 2012-06-08 21:22:17 (GMT) |
---|---|---|
committer | nijtmans@users.sourceforge.net <jan.nijtmans> | 2012-06-08 21:22:17 (GMT) |
commit | 42d3d7fbdc838acd00088a3fbd16094e75f73c07 (patch) | |
tree | 310a9dbc7cc3e084b145ba3775dfb36cf198c278 | |
parent | 67e62210d60c53b8ea85b5bb308af37416523b04 (diff) | |
parent | 4d17789f6ff24efaba0dc590e0667f3b37f8b6b1 (diff) | |
download | tk-42d3d7fbdc838acd00088a3fbd16094e75f73c07.zip tk-42d3d7fbdc838acd00088a3fbd16094e75f73c07.tar.gz tk-42d3d7fbdc838acd00088a3fbd16094e75f73c07.tar.bz2 |
Implement TkCygwinMainEx for loading Cygwin's Tk_MainEx from the Tk dll
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | generic/tkInt.decls | 2 | ||||
-rw-r--r-- | generic/tkIntXlibDecls.h | 4 | ||||
-rw-r--r-- | generic/tkMain.c | 13 | ||||
-rw-r--r-- | generic/tkWindow.c | 65 |
5 files changed, 82 insertions, 7 deletions
@@ -1,3 +1,8 @@ +2012-06-08 Jan Nijtmans <nijtmans@users.sf.net> + + * generic/tkMain.c: Implement TkCygwinMainEx for loading + * generic/tkWindow.c: Cygwin's Tk_MainEx from the Tk dll. + 2012-06-07 Jan Nijtmans <nijtmans@users.sf.net> * generic/tkInt.decls: Change XChangeWindowAttributes signature and diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 309532b..45cc31b 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1628,7 +1628,7 @@ declare 80 aqua { XSegment *segments, int nsegments) } declare 81 aqua { - int XForceScreenSaver(Display *display, int mode) + void XForceScreenSaver(Display *display, int mode) } declare 82 aqua { int XDrawLine(Display *d, Drawable dr, GC g, int x1, int y1, diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 07ad01e..9ccfe8d 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -1122,7 +1122,7 @@ EXTERN void XDrawSegments(Display *display, Drawable d, GC gc, #ifndef XForceScreenSaver_TCL_DECLARED #define XForceScreenSaver_TCL_DECLARED /* 81 */ -EXTERN int XForceScreenSaver(Display *display, int mode); +EXTERN void XForceScreenSaver(Display *display, int mode); #endif #ifndef XDrawLine_TCL_DECLARED #define XDrawLine_TCL_DECLARED @@ -1383,7 +1383,7 @@ typedef struct TkIntXlibStubs { void (*xSetWMClientMachine) (Display *display, Window w, XTextProperty *text_prop); /* 78 */ Status (*xStringListToTextProperty) (char **list, int count, XTextProperty *text_prop_return); /* 79 */ void (*xDrawSegments) (Display *display, Drawable d, GC gc, XSegment *segments, int nsegments); /* 80 */ - int (*xForceScreenSaver) (Display *display, int mode); /* 81 */ + void (*xForceScreenSaver) (Display *display, int mode); /* 81 */ int (*xDrawLine) (Display *d, Drawable dr, GC g, int x1, int y1, int x2, int y2); /* 82 */ int (*xFillRectangle) (Display *display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); /* 83 */ void (*xClearWindow) (Display *d, Window w); /* 84 */ diff --git a/generic/tkMain.c b/generic/tkMain.c index c6d5238..99caf27 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -139,15 +139,20 @@ Tk_MainEx( abort(); } -#if defined(__WIN32__) && !defined(STATIC_BUILD) +#if defined(__WIN32__) && !defined(__WIN64__) && !defined(STATIC_BUILD) + extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *); + 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)) { + * Tk_MainEx function of libtk8.?.dll, not this one. */ + if (Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY)) { loadCygwinTk: - Tcl_Panic("Should load libtk.dll now, not yet implemented"); + if (TkCygwinMainEx(argc, argv, appInitProc, interp)) { + /* Should never reach here. */ + return; + } } else { int i; diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 6892360..995f71f 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -2831,6 +2831,51 @@ DeleteWindowsExitProc( tsdPtr->initialized = 0; } +#if defined(__WIN32__) && !defined(__WIN64__) + +static HMODULE tkcygwindll = NULL; + +/* + * Run Tk_MainEx from libtk8.?.dll + * + * This function is only ever called from wish8.4.exe, the cygwin + * port of Tcl. This means that the system encoding is utf-8, + * so we don't have to do any encoding conversions. + */ +int +TkCygwinMainEx(argc, argv, appInitProc, interp) + int argc; /* Number of arguments. */ + char **argv; /* Array of argument strings. */ + Tcl_AppInitProc *appInitProc; /* Application-specific initialization + * procedure to call after most + * initialization but before starting + * to execute commands. */ + Tcl_Interp *interp; +{ + char name[MAX_PATH]; + int len; + void (*sym)(int, char **, Tcl_AppInitProc *, Tcl_Interp *); + + /* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */ + len = GetModuleFileName(Tk_GetHINSTANCE(), name, MAX_PATH); + name[len-2] = '.'; + name[len-1] = name[len-5]; + strcpy(name+len, ".dll"); + memcpy(name+len-8, "libtk8", 6); + + tkcygwindll = LoadLibrary(name); + if (!tkcygwindll) { + /* dll is not present */ + return 0; + } + sym = (void (*)(int, char **, Tcl_AppInitProc *, Tcl_Interp *)) GetProcAddress(tkcygwindll, "Tk_MainEx"); + if (!sym) { + return 0; + } + sym(argc, argv, appInitProc, interp); + return 1; +} +#endif /* *---------------------------------------------------------------------- * @@ -2858,6 +2903,16 @@ int Tk_Init( Tcl_Interp *interp) /* Interpreter to initialize. */ { +#if defined(__WIN32__) && !defined(__WIN64__) + if (tkcygwindll) { + int (*sym)(Tcl_Interp *); + + sym = (int (*)(Tcl_Interp *)) GetProcAddress(tkcygwindll, "Tk_Init"); + if (sym) { + return sym(interp); + } + } +#endif return Initialize(interp); } @@ -2921,6 +2976,16 @@ Tk_SafeInit( * checked at several places to differentiate the two initialisations. */ +#if defined(__WIN32__) && !defined(__WIN64__) + if (tkcygwindll) { + int (*sym)(Tcl_Interp *); + + sym = (int (*)(Tcl_Interp *)) GetProcAddress(tkcygwindll, "Tk_SafeInit"); + if (sym) { + return sym(interp); + } + } +#endif return Initialize(interp); } |