From a05cae50c0a6c2f7e000833763210c1835d9d127 Mon Sep 17 00:00:00 2001 From: hobbs Date: Wed, 5 Dec 2007 19:18:08 +0000 Subject: * win/tkWinInt.h: remove CS_CLASSDC (not recommended for any apps now) * win/tkWinX.c: and simplify WNDCLASS to one style. * win/tkWinWm.c: Reduce wrapper update for exStyle to toolwindow change only and set WS_EX_LAYERED as sticky (once set on a window, do not remove it) to reduce alpha transition flicker. --- ChangeLog | 11 ++++++- win/tkWinInt.h | 3 +- win/tkWinWm.c | 90 ++++++++++++++++++++-------------------------------------- win/tkWinX.c | 16 +---------- 4 files changed, 43 insertions(+), 77 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee7c7a4..8953f21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-12-05 Jeff Hobbs + + * win/tkWinInt.h: remove CS_CLASSDC (not recommended for any apps now) + * win/tkWinX.c: and simplify WNDCLASS to one style. + * win/tkWinWm.c: Reduce wrapper update for exStyle to toolwindow + change only and set WS_EX_LAYERED as sticky (once set on a window, + do not remove it) to reduce alpha transition flicker. + + * win/tkWinDraw.c: Applied [Patch 1723362] for transparent bitmaps. + 2007-11-26 Kevin Kenny Backport from HEAD of [Bug #1822391]: @@ -8,7 +18,6 @@ * tests/imgPPM.test (imgPPM-4.1): Added test case that exercises [Bug #1822391]. - 2007-11-09 Daniel Steffen Backport from HEAD of Aqua changes from 2007-10-12 to 2007-11-09: diff --git a/win/tkWinInt.h b/win/tkWinInt.h index d041db0..9369062 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinInt.h,v 1.14.2.5 2004/09/23 01:49:08 hobbs Exp $ + * RCS: @(#) $Id: tkWinInt.h,v 1.14.2.6 2007/12/05 19:18:08 hobbs Exp $ */ #ifndef _TKWININT @@ -123,7 +123,6 @@ typedef struct { */ #define TK_WIN_TOPLEVEL_CLASS_NAME "TkTopLevel" -#define TK_WIN_TOPLEVEL_NOCDC_CLASS_NAME "TkTopLevelNoCDC" #define TK_WIN_CHILD_CLASS_NAME "TkChild" /* diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 72f1cb2..2cc885c 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWm.c,v 1.54.2.27 2007/06/10 00:15:35 hobbs Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.54.2.28 2007/12/05 19:18:09 hobbs Exp $ */ #include "tkWinInt.h" @@ -871,20 +871,7 @@ InitWindowClass(WinIconPtr titlebaricon) */ ZeroMemory(&class, sizeof(WNDCLASS)); - /* - * When threads are enabled, we cannot use CLASSDC because - * threads will then write into the same device context. - * - * This is a hack; we should add a subsystem that manages - * device context on a per-thread basis. See also tkWinX.c, - * which also initializes a WNDCLASS structure. - */ - -#ifdef TCL_THREADS class.style = CS_HREDRAW | CS_VREDRAW; -#else - class.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC; -#endif class.hInstance = Tk_GetHINSTANCE(); Tcl_WinUtfToTChar(TK_WIN_TOPLEVEL_CLASS_NAME, -1, &classString); class.lpszClassName = (LPCTSTR) Tcl_DStringValue(&classString); @@ -908,22 +895,6 @@ InitWindowClass(WinIconPtr titlebaricon) Tcl_Panic("Unable to register TkTopLevel class"); } -#ifndef TCL_THREADS - /* - * Use of WS_EX_LAYERED disallows CS_CLASSDC, as does - * TCL_THREADS usage, so only create this if necessary. - */ - if (setLayeredWindowAttributesProc != NULL) { - class.style = CS_HREDRAW | CS_VREDRAW; - Tcl_DStringFree(&classString); - Tcl_WinUtfToTChar(TK_WIN_TOPLEVEL_NOCDC_CLASS_NAME, - -1, &classString); - class.lpszClassName = (LPCTSTR) Tcl_DStringValue(&classString); - if (!(*tkWinProcs->registerClass)(&class)) { - Tcl_Panic("Unable to register TkTopLevelNoCDC class"); - } - } -#endif Tcl_DStringFree(&classString); } Tcl_MutexUnlock(&winWmMutex); @@ -1845,15 +1816,6 @@ TkWinWmCleanup(hInstance) tsdPtr->initialized = 0; UnregisterClass(TK_WIN_TOPLEVEL_CLASS_NAME, hInstance); -#ifndef TCL_THREADS - /* - * Clean up specialized class created for layered windows. - */ - if (setLayeredWindowAttributesProc != NULL) { - UnregisterClass(TK_WIN_TOPLEVEL_NOCDC_CLASS_NAME, hInstance); - setLayeredWindowAttributesProc = NULL; - } -#endif } /* @@ -2053,6 +2015,10 @@ UpdateWrapper(winPtr) * Compute the geometry of the parent and child windows. */ + if ((wmPtr->flags & WM_UPDATE_PENDING)) { + Tcl_CancelIdleCall(UpdateGeometryInfo, (ClientData) winPtr); + } + wmPtr->flags |= WM_CREATE_PENDING|WM_MOVE_PENDING; UpdateGeometryInfo((ClientData)winPtr); wmPtr->flags &= ~(WM_CREATE_PENDING|WM_MOVE_PENDING); @@ -2083,17 +2049,7 @@ UpdateWrapper(winPtr) tsdPtr->createWindow = winPtr; Tcl_WinUtfToTChar(((wmPtr->title != NULL) ? wmPtr->title : winPtr->nameUid), -1, &titleString); -#ifndef TCL_THREADS - /* - * Transparent windows require a non-CS_CLASSDC window class. - */ - if ((wmPtr->exStyleConfig & WS_EX_LAYERED) - && setLayeredWindowAttributesProc != NULL) { - Tcl_WinUtfToTChar(TK_WIN_TOPLEVEL_NOCDC_CLASS_NAME, - -1, &classString); - } else -#endif - Tcl_WinUtfToTChar(TK_WIN_TOPLEVEL_CLASS_NAME, -1, &classString); + Tcl_WinUtfToTChar(TK_WIN_TOPLEVEL_CLASS_NAME, -1, &classString); wmPtr->wrapper = (*tkWinProcs->createWindowEx)(wmPtr->exStyle, (LPCTSTR) Tcl_DStringValue(&classString), (LPCTSTR) Tcl_DStringValue(&titleString), @@ -2885,7 +2841,7 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv) register WmInfo *wmPtr = winPtr->wmInfoPtr; LONG style, exStyle, styleBit, *stylePtr; char *string; - int i, boolean, length; + int i, boolean, length, updatewrapper = 0; if ((objc < 3) || ((objc > 5) && ((objc%2) == 0))) { configArgs: @@ -2941,6 +2897,12 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv) && (strncmp(string, "-toolwindow", length) == 0)) { stylePtr = &exStyle; styleBit = WS_EX_TOOLWINDOW; + if (objc != 4) { + /* + * Changes to toolwindow style require an update + */ + updatewrapper = 1; + } } else if ((length > 3) && (strncmp(string, "-topmost", length) == 0)) { stylePtr = &exStyle; @@ -3010,10 +2972,14 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv) } } + /* + * Only ever add the WS_EX_LAYERED bit, as it can cause + * flashing to change this window style. This allows things + * like fading tooltips to avoid flash ugliness without + * forcing all window to be layered. + */ if ((wmPtr->alpha < 1.0) || (wmPtr->crefObj != NULL)) { *stylePtr |= styleBit; - } else { - *stylePtr &= ~styleBit; } if ((setLayeredWindowAttributesProc != NULL) && (wmPtr->wrapper != NULL)) { @@ -3023,6 +2989,10 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv) * wants an int (transparent) 0..255 (opaque), so do the * translation. Add the 0.5 to round the value. */ + if (!(wmPtr->exStyleConfig & WS_EX_LAYERED)) { + SetWindowLongPtr(wmPtr->wrapper, GWL_EXSTYLE, + *stylePtr); + } setLayeredWindowAttributesProc((HWND) wmPtr->wrapper, wmPtr->colorref, (BYTE) (wmPtr->alpha * 255 + 0.5), LWA_ALPHA | (wmPtr->crefObj ? LWA_COLORKEY : 0)); @@ -3067,13 +3037,15 @@ WmAttributesCmd(tkwin, winPtr, interp, objc, objv) } } if (wmPtr->exStyleConfig != exStyle) { - /* - * UpdateWrapper ensure that all effects are properly handled, - * such as TOOLWINDOW disappearing from the taskbar. - */ wmPtr->exStyleConfig = exStyle; - if (!(wmPtr->flags & WM_NEVER_MAPPED)) { - UpdateWrapper(winPtr); + if (updatewrapper) { + /* + * UpdateWrapper ensure that all effects are properly handled, + * such as TOOLWINDOW disappearing from the taskbar. + */ + if (!(wmPtr->flags & WM_NEVER_MAPPED)) { + UpdateWrapper(winPtr); + } } } return TCL_OK; diff --git a/win/tkWinX.c b/win/tkWinX.c index 28bfda3..d577466 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.25.2.8 2006/08/30 21:53:47 hobbs Exp $ + * RCS: @(#) $Id: tkWinX.c,v 1.25.2.9 2007/12/05 19:18:09 hobbs Exp $ */ #include "tkWinInt.h" @@ -258,21 +258,7 @@ TkWinXInit(hInstance) tkWinProcs = &asciiProcs; } - /* - * When threads are enabled, we cannot use CLASSDC because - * threads will then write into the same device context. - * - * This is a hack; we should add a subsystem that manages - * device context on a per-thread basis. See also tkWinWm.c, - * which also initializes a WNDCLASS structure. - */ - -#ifdef TCL_THREADS childClass.style = CS_HREDRAW | CS_VREDRAW; -#else - childClass.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC; -#endif - childClass.cbClsExtra = 0; childClass.cbWndExtra = 0; childClass.hInstance = hInstance; -- cgit v0.12