summaryrefslogtreecommitdiffstats
path: root/macosx
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
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')
-rw-r--r--macosx/tkMacOSXMenu.c10
-rw-r--r--macosx/tkMacOSXSubwindows.c6
-rw-r--r--macosx/tkMacOSXWindowEvent.c4
-rw-r--r--macosx/tkMacOSXWm.c39
4 files changed, 38 insertions, 21 deletions
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 85e1d6c..ecdf1ab 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.c
@@ -830,11 +830,16 @@ TkpSetWindowMenuBar(
* Puts the menu associated with a window into the menubar. Should only
* be called when the window is in front.
*
+ * This is a no-op on all other platforms. On OS X it is a no-op when
+ * passed a NULL menuName or a nonexistent menuName, with an exception
+ * for the first call in a new interpreter. In that special case, passing a
+ * NULL menuName installs the default menu.
+ *
* Results:
* None.
*
* Side effects:
- * The menubar is changed.
+ * The menubar may be changed.
*
*----------------------------------------------------------------------
*/
@@ -843,8 +848,7 @@ void
TkpSetMainMenubar(
Tcl_Interp *interp, /* The interpreter of the application */
Tk_Window tkwin, /* The frame we are setting up */
- const char *menuName) /* The name of the menu to put in front. If
- * NULL, use the default menu bar. */
+ const char *menuName) /* The name of the menu to put in front. */
{
static Tcl_Interp *currentInterp = NULL;
TKMenu *menu = nil;
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index 1a71746..ee9167b 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -149,8 +149,10 @@ XMapWindow(
if (Tk_IsTopLevel(macWin->winPtr)) {
if (!Tk_IsEmbedded(macWin->winPtr)) {
NSWindow *win = TkMacOSXDrawableWindow(window);
-
- [win makeKeyAndOrderFront:NSApp];
+ [NSApp activateIgnoringOtherApps:YES];
+ if ( [win canBecomeKeyWindow] ) {
+ [win makeKeyAndOrderFront:NSApp];
+ }
[win windowRef];
TkMacOSXApplyWindowAttributes(macWin->winPtr, win);
}
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index 5f782c5..3e2a437 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -48,7 +48,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification;
#endif
#endif
-extern NSString *opaqueTag;
+extern BOOL opaqueTag;
@implementation TKApplication(TKWindowEvent)
@@ -935,7 +935,7 @@ ExposeRestrictProc(
{
NSWindow *w = [self window];
- if (opaqueTag != NULL) {
+ if (opaqueTag) {
return YES;
} else {
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,