From 9ba6b47ef626dc8248e5fcd5a420d332baeaae53 Mon Sep 17 00:00:00 2001 From: hobbs Date: Sun, 8 Dec 2002 00:46:51 +0000 Subject: * generic/tkInt.decls: add TkWinSetHINSTANCE decl * generic/tkIntPlatDecls.h: regen * generic/tkStubInit.c: regen * win/tkWinInit.c (TkpInit): While init and cleanup aren't correct * win/tkWinX.c (TkWinXInit): in DllMain, we had to specify the * win/tkWin32Dll.c (DllMain): true HINSTANCE or the resources of a dynamic Tk weren't being loaded correctly. Created a new function TkWinSetHINSTANCE for this purpose. --- ChangeLog | 52 ++++++++++++++++++++++++++---------------------- generic/tkInt.decls | 8 +++++++- generic/tkIntPlatDecls.h | 9 ++++++++- generic/tkStubInit.c | 3 ++- win/tkWin32Dll.c | 18 ++++++++++++----- win/tkWinInit.c | 9 ++++----- win/tkWinX.c | 33 ++++++++++++++++++++++++++---- 7 files changed, 91 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8b93609..f7353b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-12-07 Jeff Hobbs + + * generic/tkInt.decls: add TkWinSetHINSTANCE decl + * generic/tkIntPlatDecls.h: regen + * generic/tkStubInit.c: regen + * win/tkWinInit.c (TkpInit): While init and cleanup aren't correct + * win/tkWinX.c (TkWinXInit): in DllMain, we had to specify the + * win/tkWin32Dll.c (DllMain): true HINSTANCE or the resources of a + dynamic Tk weren't being loaded correctly. Created a new function + TkWinSetHINSTANCE for this purpose. + 2002-12-06 Jeff Hobbs * win/tkWinX.c (TkWinXInit): Move cleanup into an exit handler @@ -7,22 +18,19 @@ 2002-12-01 Mo DeJong - * tests/event.test (_keypress, _text_ind_to_x_y): - Force focus to widget in _keypress method to - avoid problems with window managers that - use focus follows mouse. [Bug 526209] + * tests/event.test (_keypress, _text_ind_to_x_y): Force focus to + widget in _keypress method to avoid problems with window managers + that use focus follows mouse. [Bug 526209] 2002-12-01 Mo DeJong - * tests/wm.test: Add wm-transient-6.3 to - check that a transient remains withdrawn - when it is first withdrawn and then turned - into a transient. + * tests/wm.test: Add wm-transient-6.3 to check that a transient + remains withdrawn when it is first withdrawn and then turned into + a transient. * unix/tkUnixWm.c: - * win/tkWinWm.c: Replace WM_TRANSIENT_WITHDRAWN - with WM_WITHDRAWN and set this flag whenever - a window is explicitly withdrawn. This fixes - the test case added above. [Bug 644356] + * win/tkWinWm.c: Replace WM_TRANSIENT_WITHDRAWN with WM_WITHDRAWN + and set this flag whenever a window is explicitly withdrawn. This + fixes the test case added above. [Bug 644356] 2002-11-22 Jeff Hobbs @@ -46,18 +54,14 @@ 2002-11-14 Mo DeJong - * generic/tkWindow.c (Tk_DestroyWindow, - DeleteWindowsExitProc): Add TkHalfdeadWindow - type and halfdeadWindowList to keep track - of windows that were only partially deallocated - before a call to exit. Finnish cleaning up - these windows in DeleteWindowsExitProc. - Keep track of cleanup status in Tk_DestroyWindow - so that a window with a Destroy binding which - calls exit will get fully destroyed. - * tests/window.test: Add Tk_DestroyWindow tests - for an assortment of half dead window cases. - [Bug 630533] + * generic/tkWindow.c (Tk_DestroyWindow, DeleteWindowsExitProc): + Add TkHalfdeadWindow type and halfdeadWindowList to keep track of + windows that were only partially deallocated before a call to + exit. Finnish cleaning up these windows in DeleteWindowsExitProc. + Keep track of cleanup status in Tk_DestroyWindow so that a window + with a Destroy binding which calls exit will get fully destroyed. + * tests/window.test: Add Tk_DestroyWindow tests for an assortment + of half dead window cases. [Bug 630533] 2002-11-10 Daniel Steffen diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 0a51233..1b105ae 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tkInt.decls,v 1.31 2002/10/09 11:56:28 das Exp $ +# RCS: @(#) $Id: tkInt.decls,v 1.32 2002/12/08 00:46:51 hobbs Exp $ library tk @@ -873,6 +873,12 @@ declare 33 win { int TkWinGetPlatformId(void) } +# new for 8.4.1 + +declare 34 win { + void TkWinSetHINSTANCE (HINSTANCE hInstance) +} + ######################## # Mac specific functions diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index 8b54b75..6719448 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -9,7 +9,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.14 2002/08/31 06:12:20 das Exp $ + * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.15 2002/12/08 00:46:51 hobbs Exp $ */ #ifndef _TKINTPLATDECLS @@ -121,6 +121,8 @@ EXTERN Tcl_Obj * TkWinGetMenuSystemDefault _ANSI_ARGS_(( CONST char * className)); /* 33 */ EXTERN int TkWinGetPlatformId _ANSI_ARGS_((void)); +/* 34 */ +EXTERN void TkWinSetHINSTANCE _ANSI_ARGS_((HINSTANCE hInstance)); #endif /* __WIN32__ */ #ifdef MAC_TCL /* 0 */ @@ -459,6 +461,7 @@ typedef struct TkIntPlatStubs { void (*tkWinDialogDebug) _ANSI_ARGS_((int debug)); /* 31 */ Tcl_Obj * (*tkWinGetMenuSystemDefault) _ANSI_ARGS_((Tk_Window tkwin, CONST char * dbName, CONST char * className)); /* 32 */ int (*tkWinGetPlatformId) _ANSI_ARGS_((void)); /* 33 */ + void (*tkWinSetHINSTANCE) _ANSI_ARGS_((HINSTANCE hInstance)); /* 34 */ #endif /* __WIN32__ */ #ifdef MAC_TCL void (*tkGenerateActivateEvents) _ANSI_ARGS_((TkWindow * winPtr, int active)); /* 0 */ @@ -750,6 +753,10 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkWinGetPlatformId \ (tkIntPlatStubsPtr->tkWinGetPlatformId) /* 33 */ #endif +#ifndef TkWinSetHINSTANCE +#define TkWinSetHINSTANCE \ + (tkIntPlatStubsPtr->tkWinSetHINSTANCE) /* 34 */ +#endif #endif /* __WIN32__ */ #ifdef MAC_TCL #ifndef TkGenerateActivateEvents diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index a8e5981..e2bc17a 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubInit.c,v 1.39 2002/10/09 11:57:09 das Exp $ + * RCS: @(#) $Id: tkStubInit.c,v 1.40 2002/12/08 00:46:51 hobbs Exp $ */ #include "tkInt.h" @@ -368,6 +368,7 @@ TkIntPlatStubs tkIntPlatStubs = { TkWinDialogDebug, /* 31 */ TkWinGetMenuSystemDefault, /* 32 */ TkWinGetPlatformId, /* 33 */ + TkWinSetHINSTANCE, /* 34 */ #endif /* __WIN32__ */ #ifdef MAC_TCL TkGenerateActivateEvents, /* 0 */ diff --git a/win/tkWin32Dll.c b/win/tkWin32Dll.c index c8e03c1..4570a5a 100644 --- a/win/tkWin32Dll.c +++ b/win/tkWin32Dll.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWin32Dll.c,v 1.5 2002/12/06 23:29:37 hobbs Exp $ + * RCS: @(#) $Id: tkWin32Dll.c,v 1.6 2002/12/08 00:46:51 hobbs Exp $ */ #include "tkWinInt.h" @@ -52,10 +52,10 @@ DllEntryPoint(hInst, reason, reserved) * * DllMain -- * - * DLL entry point. It is not necessary to do anything here as - * Tk will initialize and clean up after itself through other - * methods, in order to be consistent whether the build is static - * or dynamic. + * DLL entry point. It is only necessary to specify our dll here so + * that resources are found correctly. Otherwise Tk will initialize + * and clean up after itself through other methods, in order to be + * consistent whether the build is static or dynamic. * * Results: * Always TRUE. @@ -72,5 +72,13 @@ DllMain(hInstance, reason, reserved) DWORD reason; LPVOID reserved; { + /* + * If we are attaching to the DLL from a new process, tell Tk about + * the hInstance to use. + */ + + if (reason == DLL_PROCESS_ATTACH) { + TkWinSetHINSTANCE(hInstance); + } return (TRUE); } diff --git a/win/tkWinInit.c b/win/tkWinInit.c index fec211b..1ec2642 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinInit.c,v 1.9 2002/04/12 07:18:49 hobbs Exp $ + * RCS: @(#) $Id: tkWinInit.c,v 1.10 2002/12/08 00:46:51 hobbs Exp $ */ #include "tkWinInt.h" @@ -44,11 +44,10 @@ TkpInit(interp) Tcl_Interp *interp; { /* - * This is necessary for static initialization, and is ok - * otherwise because TkWinXInit flips a static bit to do - * its work just once. + * This is necessary for static initialization, and is ok otherwise + * because TkWinXInit flips a static bit to do its work just once. */ - TkWinXInit(GetModuleHandle(NULL)); + TkWinXInit(Tk_GetHINSTANCE()); return Tcl_Eval(interp, initScript); } diff --git a/win/tkWinX.c b/win/tkWinX.c index f97db04..ae21e4b 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinX.c,v 1.24 2002/12/06 23:29:37 hobbs Exp $ + * RCS: @(#) $Id: tkWinX.c,v 1.25 2002/12/08 00:46:51 hobbs Exp $ */ #include "tkWinInt.h" @@ -76,7 +76,7 @@ TkWinProcs *tkWinProcs; */ static char winScreenName[] = ":0"; /* Default name of windows display. */ -static HINSTANCE tkInstance; /* Application instance handle. */ +static HINSTANCE tkInstance = NULL; /* Application instance handle. */ static int childClassInitialized; /* Registered child class? */ static WNDCLASS childClass; /* Window class for child windows. */ static int tkPlatformId = 0; /* version of Windows platform */ @@ -171,12 +171,39 @@ TkGetServerInfo(interp, tkwin) HINSTANCE Tk_GetHINSTANCE() { + if (tkInstance == NULL) { + tkInstance = GetModuleHandle(NULL); + } return tkInstance; } /* *---------------------------------------------------------------------- * + * TkWinSetHINSTANCE -- + * + * Sets the global instance handle used by the Tk library. + * This should be called by DllMain. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +void +TkWinSetHINSTANCE(hInstance) + HINSTANCE hInstance; +{ + tkInstance = hInstance; +} + +/* + *---------------------------------------------------------------------- + * * TkWinXInit -- * * Initialize Xlib emulation layer. @@ -214,8 +241,6 @@ TkWinXInit(hInstance) tkWinProcs = &asciiProcs; } - tkInstance = hInstance; - /* * When threads are enabled, we cannot use CLASSDC because * threads will then write into the same device context. -- cgit v0.12