summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXWm.c
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2015-03-15 20:22:13 (GMT)
committerKevin Walzer <kw@codebykevin.com>2015-03-15 20:22:13 (GMT)
commit6d849d232afb87840ffe3c1f9055e400e0907a63 (patch)
treec3286f47ef4ef5e87529cdb80059521711740ad0 /macosx/tkMacOSXWm.c
parentc68ea4689ef059f8cb246200b048e574766e8b84 (diff)
downloadtk-6d849d232afb87840ffe3c1f9055e400e0907a63.zip
tk-6d849d232afb87840ffe3c1f9055e400e0907a63.tar.gz
tk-6d849d232afb87840ffe3c1f9055e400e0907a63.tar.bz2
Wish now launches in front when called from command line, and focus -force works correctly; thanks to Marc Culler for patch
Diffstat (limited to 'macosx/tkMacOSXWm.c')
-rw-r--r--macosx/tkMacOSXWm.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c
index 4f7b066..d81e8d6 100644
--- a/macosx/tkMacOSXWm.c
+++ b/macosx/tkMacOSXWm.c
@@ -53,7 +53,7 @@
/*Objects for use in setting background color and opacity of window.*/
NSColor *colorName = NULL;
-NSString *opaqueTag = NULL;
+BOOL opaqueTag = FALSE;
static const struct {
const UInt64 validAttrs, defaultAttrs, forceOnAttrs, forceOffAttrs;
@@ -786,13 +786,18 @@ TkWmDeadWindow(
[[window parentWindow] removeChildWindow:window];
[window setExcludedFromWindowsMenu:YES];
[window close];
- TkMacOSXUnregisterMacWindow(window);
- if (winPtr->window) {
- ((MacDrawable *) winPtr->window)->view = nil;
- }
- TkMacOSXMakeCollectableAndRelease(wmPtr->window);
+ TkMacOSXUnregisterMacWindow(window);
+ if (winPtr->window) {
+ ((MacDrawable *) winPtr->window)->view = nil;
+ }
+ TkMacOSXMakeCollectableAndRelease(wmPtr->window);
+ /* Activate the highest window left on the screen. */
+ NSArray *windows = [NSApp orderedWindows];
+ NSWindow *front = [windows objectAtIndex:0];
+ if ( front && [front canBecomeKeyWindow] ) {
+ [front makeKeyAndOrderFront:NSApp];
+ }
}
-
ckfree(wmPtr);
winPtr->wmInfoPtr = NULL;
}
@@ -5117,7 +5122,7 @@ TkUnsupported1ObjCmd(
colorName = [NSColor clearColor]; //use systemTransparent in Tk scripts to match
}
if (Tcl_StringMatch(Tcl_GetString(objv[i]), "*opacity*")) {
- opaqueTag = @"YES";
+ opaqueTag = YES;
}
}
@@ -5508,7 +5513,7 @@ TkMacOSXMakeRealWindowExist(
[window setBackgroundColor: colorName];
}
- if (opaqueTag != NULL) {
+ if (opaqueTag) {
#ifdef TK_GOT_AT_LEAST_SNOW_LEOPARD
[window setOpaque: opaqueTag];
#else
@@ -5916,15 +5921,21 @@ TkpChangeFocus(
* didn't originally belong to topLevelPtr's
* application. */
{
- /*
- * We don't really need to do anything on the Mac. Tk will keep all this
- * state for us.
- */
-
if (winPtr->atts.override_redirect) {
return 0;
}
+ if (Tk_IsTopLevel(winPtr) && !Tk_IsEmbedded(winPtr) ){
+ NSWindow *win = TkMacOSXDrawableWindow(winPtr->window);
+ TkWmRestackToplevel(winPtr, Above, NULL);
+ if (force ) {
+ [NSApp activateIgnoringOtherApps:YES];
+ }
+ if ( win && [win canBecomeKeyWindow] ) {
+ [win makeKeyAndOrderFront:NSApp];
+ }
+ }
+
/*
* Remember the current serial number for the X server and issue a dummy
* server request. This marks the position at which we changed the focus,