summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorculler <culler>2019-02-08 17:21:21 (GMT)
committerculler <culler>2019-02-08 17:21:21 (GMT)
commit062d578e1ddbd93e8b49ae48baef4d9fa30ecb29 (patch)
tree0d08a898965e27bfef49f0e350a49424839368c0
parent422f0f5d203bfb7aad77106e2239a60eb7c0ccc0 (diff)
parente4d80b4d45925dc8efdb80b5c9bfa8f2e057d78a (diff)
downloadtk-062d578e1ddbd93e8b49ae48baef4d9fa30ecb29.zip
tk-062d578e1ddbd93e8b49ae48baef4d9fa30ecb29.tar.gz
tk-062d578e1ddbd93e8b49ae48baef4d9fa30ecb29.tar.bz2
Fix bug [1529659ff]: Embedded toplevel makes the outer toplevel menu inaccessible.
-rw-r--r--macosx/tkMacOSXMenu.c35
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];
}