diff options
author | culler <culler> | 2019-02-08 16:44:25 (GMT) |
---|---|---|
committer | culler <culler> | 2019-02-08 16:44:25 (GMT) |
commit | e4d80b4d45925dc8efdb80b5c9bfa8f2e057d78a (patch) | |
tree | a9fe4bdcafafcdc130174ca67b87fde54ec9c485 /macosx/tkMacOSXMenu.c | |
parent | 43fbfc9de2fc5eac324e919e0f04ac80c9a52589 (diff) | |
download | tk-e4d80b4d45925dc8efdb80b5c9bfa8f2e057d78a.zip tk-e4d80b4d45925dc8efdb80b5c9bfa8f2e057d78a.tar.gz tk-e4d80b4d45925dc8efdb80b5c9bfa8f2e057d78a.tar.bz2 |
Fix bug [1529659ff]: Embedded toplevel makes the outer toplevel menu inaccessible.
Diffstat (limited to 'macosx/tkMacOSXMenu.c')
-rw-r--r-- | macosx/tkMacOSXMenu.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index dfa3e53..316a8d7 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -985,26 +985,47 @@ TkpSetMainMenubar( { static Tcl_Interp *currentInterp = NULL; TKMenu *menu = nil; + TkWindow *winPtr = (TkWindow *) tkwin; + + /* + * We will be called when an embedded window receives an ActivationNotify + * event, but we should not change the menubar in that case. + */ + + if (Tk_IsEmbedded(winPtr)) { + return; + } if (menuName) { - TkWindow *winPtr = (TkWindow *) tkwin; + Tk_Window menubar = NULL; + if (winPtr->wmInfoPtr && + winPtr->wmInfoPtr->menuPtr && + winPtr->wmInfoPtr->menuPtr->masterMenuPtr) { + menubar = winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin; + } - if (winPtr->wmInfoPtr && winPtr->wmInfoPtr->menuPtr && - winPtr->wmInfoPtr->menuPtr->masterMenuPtr && - winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin && - !strcmp(menuName, Tk_PathName( - winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin))) { + /* + * Attempt to find the NSMenu directly. If that fails, ask Tk to find it. + */ + + if (menubar != NULL && strcmp(menuName, Tk_PathName(menubar)) == 0) { menu = (TKMenu *) winPtr->wmInfoPtr->menuPtr->platformData; } else { TkMenuReferences *menuRefPtr = TkFindMenuReferences(interp, menuName); - if (menuRefPtr && menuRefPtr->menuPtr && menuRefPtr->menuPtr->platformData) { menu = (TKMenu *) menuRefPtr->menuPtr->platformData; } } } + + /* + * If we couldn't find a menu, do nothing unless the window belongs + * to a different application. In that case, install the default + * menubar. + */ + if (menu || interp != currentInterp) { [NSApp tkSetMainMenu:menu]; } |