summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2017-11-24 17:21:30 (GMT)
committerculler <culler>2017-11-24 17:21:30 (GMT)
commit4d93c39841fcb541bd4bbb61c731c0444fabb2de (patch)
treee2c79dbcfb557a780795136f7bbceec85cc6df9e /macosx
parent2e89b1cbfa3c417a84208ac3449bc403b9bd4e01 (diff)
downloadtk-4d93c39841fcb541bd4bbb61c731c0444fabb2de.zip
tk-4d93c39841fcb541bd4bbb61c731c0444fabb2de.tar.gz
tk-4d93c39841fcb541bd4bbb61c731c0444fabb2de.tar.bz2
Remove calls to TransformProcessType. Avoid activating too early.
Prepare for cleanup of TkpInit. Fixes the basic menu bar problem.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXInit.c73
-rw-r--r--macosx/tkMacOSXSubwindows.c10
2 files changed, 41 insertions, 42 deletions
diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c
index 2bed5d1..29d68b2 100644
--- a/macosx/tkMacOSXInit.c
+++ b/macosx/tkMacOSXInit.c
@@ -110,12 +110,19 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
#endif
}
-- (void) _setupEventLoop
+-(void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [self finishLaunching];
- [self setWindowsNeedUpdate:YES];
- [pool drain];
+ /* Much of the NSApplication initialization should be moved here.*/
+}
+
+-(void)applicationDidFinishLaunching:(NSNotification *)notification
+{
+ /*
+ * It is not safe to force activation of the NSApp until this
+ * method is called. Activating too early can cause the menu
+ * bar to be unresponsive.
+ */
+ [NSApp activateIgnoringOtherApps: YES];
}
- (void) _setup: (Tcl_Interp *) interp
@@ -126,6 +133,7 @@ static void keyboardChanged(CFNotificationCenterRef center, void *observer, CFSt
_defaultMainMenu = nil;
[self _setupMenus];
[self setDelegate:self];
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
#ifdef TK_MAC_DEBUG_NOTIFICATIONS
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(_postedNotification:) name:nil object:nil];
@@ -284,20 +292,19 @@ TkpInit(
TkMacOSXDbgMsg("Tcl_MacOSXOpenVersionedBundleResources failed");
}
#endif
-
- {
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [[NSUserDefaults standardUserDefaults] registerDefaults:
- [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:YES],
- @"_NSCanWrapButtonTitles",
- [NSNumber numberWithInt:-1],
- @"NSStringDrawingTypesetterBehavior",
- nil]];
- [TKApplication sharedApplication];
- [pool drain];
- [NSApp _setup:interp];
- }
+
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ [[NSUserDefaults standardUserDefaults] registerDefaults:
+ [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithBool:YES],
+ @"_NSCanWrapButtonTitles",
+ [NSNumber numberWithInt:-1],
+ @"NSStringDrawingTypesetterBehavior",
+ nil]];
+ [TKApplication sharedApplication];
+ [pool drain];
+ [NSApp _setup:interp];
+
/* Check whether we are a bundled executable: */
bundleRef = CFBundleGetMainBundle();
@@ -334,34 +341,18 @@ TkpInit(
if (!bundledExecutable) {
/*
- * If we are loaded into an executable that is not a bundled
- * application, the window server does not let us come to the
- * foreground. For such an executable, notify the window server
- * that we are now a full GUI application.
- */
-
- OSStatus err = procNotFound;
- ProcessSerialNumber psn = { 0, kCurrentProcess };
-
- err = ChkErr(TransformProcessType, &psn,
- kProcessTransformToForegroundApplication);
-
- /*
* Set application icon to generic Tk icon, do it at idle time
* instead of now to ensure tk_library is setup.
*/
-
Tcl_DoWhenIdle(SetApplicationIcon, NULL);
}
- {
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- [NSApp _setupEventLoop];
- TkMacOSXInitAppleEvents(interp);
- TkMacOSXUseAntialiasedText(interp, -1);
- TkMacOSXInitCGDrawing(interp, TRUE, 0);
- [pool drain];
- }
+ pool = [NSAutoreleasePool new];
+ [NSApp finishLaunching];
+ TkMacOSXInitAppleEvents(interp);
+ TkMacOSXUseAntialiasedText(interp, -1);
+ TkMacOSXInitCGDrawing(interp, TRUE, 0);
+ [pool drain];
/*
* FIXME: Close stdin & stdout for remote debugging otherwise we will
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 12beb1b..2c036bb 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -149,7 +149,15 @@ XMapWindow(
if (Tk_IsTopLevel(macWin->winPtr)) {
if (!Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *win = TkMacOSXDrawableWindow(window);
- [NSApp activateIgnoringOtherApps:YES];
+ /*
+ * We want to activate Tk when a toplevel is mapped
+ * but we must not supply YES here. This is because
+ * during Tk initialization the root window is mapped
+ * before applicationDidFinishLaunching returns. Forcing
+ * the app to activate too early can make the menu bar
+ * unresponsive.
+ */
+ [NSApp activateIgnoringOtherApps:NO];
if ( [win canBecomeKeyWindow] ) {
[win makeKeyAndOrderFront:NSApp];
}