summaryrefslogtreecommitdiffstats
path: root/generic/tkWindow.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-08 21:22:17 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-06-08 21:22:17 (GMT)
commit79fa64792bbab42e97785552b9a9cf75fa126695 (patch)
tree310a9dbc7cc3e084b145ba3775dfb36cf198c278 /generic/tkWindow.c
parent2240ad9def4214ab61204d7fb4d7e81868984a25 (diff)
parentfdeacfff80a809cc26b4720c429274a5ed6331b4 (diff)
downloadtk-79fa64792bbab42e97785552b9a9cf75fa126695.zip
tk-79fa64792bbab42e97785552b9a9cf75fa126695.tar.gz
tk-79fa64792bbab42e97785552b9a9cf75fa126695.tar.bz2
Implement TkCygwinMainEx for loading Cygwin's Tk_MainEx from the Tk dll
Diffstat (limited to 'generic/tkWindow.c')
-rw-r--r--generic/tkWindow.c65
1 files changed, 65 insertions, 0 deletions
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);
}