From 7ddd685d9afb4397ba47bb464c385ef27f3d31ed Mon Sep 17 00:00:00 2001 From: hobbs Date: Mon, 14 Sep 2009 23:40:42 +0000 Subject: * generic/tkMenuDraw.c (TkPostSubmenu): Fix reposting of submenu in * win/tkWinMenu.c (TkWinHandleMenuEvent): torn off Windows menu. [Bug 873613] (DrawMenuEntryArrow): Draw Win menu arrow after being torn off. [Bug 873608] --- ChangeLog | 8 ++++++++ generic/tkMenuDraw.c | 8 ++++++-- win/tkWinMenu.c | 25 +++++++++++++++++++++---- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 922c8ec..44e959f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-09-14 Jeff Hobbs + + * generic/tkMenuDraw.c (TkPostSubmenu): Fix reposting of submenu in + * win/tkWinMenu.c (TkWinHandleMenuEvent): torn off Windows menu. + [Bug 873613] + (DrawMenuEntryArrow): Draw Win menu arrow after being torn + off. [Bug 873608] + 2009-09-10 Donal K. Fellows * unix/tkUnixRFont.c (InitFont): Move pattern disposal in error case diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index 0956b3d..61d03e4 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.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: tkMenuDraw.c,v 1.10 2007/12/13 15:24:16 dgp Exp $ + * RCS: @(#) $Id: tkMenuDraw.c,v 1.10.2.1 2009/09/14 23:40:42 hobbs Exp $ */ #include "tkInt.h" @@ -984,11 +984,15 @@ TkPostSubmenu( * attempt to match Motif behavior). * * The menu has to redrawn so that the entry can change relief. + * + * Set postedCascade early to ensure tear-off submenus work on + * Windows. [Bug 873613] */ Tk_GetRootCoords(menuPtr->tkwin, &x, &y); AdjustMenuCoords(menuPtr, mePtr, &x, &y); + menuPtr->postedCascade = mePtr; subary[0] = mePtr->namePtr; subary[1] = Tcl_NewStringObj("post", -1); subary[2] = Tcl_NewIntObj(x); @@ -1001,9 +1005,9 @@ TkPostSubmenu( Tcl_DecrRefCount(subary[2]); Tcl_DecrRefCount(subary[3]); if (result != TCL_OK) { + menuPtr->postedCascade = NULL; return result; } - menuPtr->postedCascade = mePtr; TkEventuallyRedrawMenu(menuPtr, mePtr); } return TCL_OK; diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 84bd49d..6b9bad9 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.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: tkWinMenu.c,v 1.59.2.2 2009/05/21 23:01:33 patthoyts Exp $ + * RCS: @(#) $Id: tkWinMenu.c,v 1.59.2.3 2009/09/14 23:40:42 hobbs Exp $ */ #define OEMRESOURCE @@ -50,6 +50,10 @@ #define MENU_SYSTEM_MENU MENU_PLATFORM_FLAG1 #define MENU_RECONFIGURE_PENDING MENU_PLATFORM_FLAG2 +#ifndef WM_UNINITMENUPOPUP +#define WM_UNINITMENUPOPUP 0x0125 +#endif + static int indicatorDimensions[2]; /* The dimensions of the indicator space in a * menu entry. Calculated at init time to save @@ -992,6 +996,19 @@ TkWinHandleMenuEvent( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); switch (*pMessage) { + case WM_UNINITMENUPOPUP: + hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, + (char *) *pwParam); + if (hashEntryPtr != NULL) { + menuPtr = (TkMenu *) Tcl_GetHashValue(hashEntryPtr); + if ((menuPtr->menuRefPtr != NULL) + && (menuPtr->menuRefPtr->parentEntryPtr != NULL)) { + TkPostSubmenu(menuPtr->interp, + menuPtr->menuRefPtr->parentEntryPtr->menuPtr, NULL); + } + } + break; + case WM_INITMENU: TkMenuInit(); hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, @@ -1775,8 +1792,7 @@ DrawMenuEntryArrow( COLORREF oldBgColor; RECT rect; - if (!drawArrow || (mePtr->type != CASCADE_ENTRY) - || (mePtr->state != ENTRY_DISABLED)) { + if (!drawArrow || (mePtr->type != CASCADE_ENTRY)) { return; } @@ -1795,7 +1811,8 @@ DrawMenuEntryArrow( gc->background = activeBgColor->pixel; } - gc->foreground = GetSysColor(COLOR_GRAYTEXT); + gc->foreground = GetSysColor((mePtr->state == ENTRY_DISABLED) ? + COLOR_GRAYTEXT : COLOR_MENUTEXT); rect.top = y + GetSystemMetrics(SM_CYBORDER); rect.bottom = y + height - GetSystemMetrics(SM_CYBORDER); -- cgit v0.12