summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--macosx/tkMacOSXInt.h3
-rw-r--r--macosx/tkMacOSXSubwindows.c27
-rw-r--r--macosx/tkMacOSXWindowEvent.c10
3 files changed, 32 insertions, 8 deletions
diff --git a/macosx/tkMacOSXInt.h b/macosx/tkMacOSXInt.h
index 978f12a..395ccbc 100644
--- a/macosx/tkMacOSXInt.h
+++ b/macosx/tkMacOSXInt.h
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXInt.h,v 1.5 2004/11/11 01:24:32 das Exp $
+ * RCS: @(#) $Id: tkMacOSXInt.h,v 1.6 2005/03/12 00:28:09 wolfsuit Exp $
*/
#ifndef _TKMACINT
@@ -154,6 +154,7 @@ extern int TkMacOSXUseAntialiasedText(Tcl_Interp *interp, int enable);
extern void TkMacOSXInitCarbonEvents (Tcl_Interp *interp);
extern int TkMacOSXInitCGDrawing(Tcl_Interp *interp, int enable, int antiAlias);
extern void TkMacOSXDefaultStartupScript(void);
+extern int TkMacOSXGenerateFocusEvent( Window window, int activeFlag);
#include "tkIntPlatDecls.h"
diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c
index f1f4cb1..43bbd77 100644
--- a/macosx/tkMacOSXSubwindows.c
+++ b/macosx/tkMacOSXSubwindows.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.6 2004/11/11 01:24:32 das Exp $
+ * RCS: @(#) $Id: tkMacOSXSubwindows.c,v 1.7 2005/03/12 00:28:09 wolfsuit Exp $
*/
#include "tkInt.h"
@@ -68,6 +68,31 @@ XDestroyWindow(
if (Tk_IsTopLevel(macWin->winPtr)) {
+ WindowRef winRef;
+ /*
+ * We are relying on the Activate Mac OS event to pass the
+ * focus away from a window that is getting Destroyed to the
+ * Front non-floating window. BUT we don't get activate events
+ * when a floating window is destroyed - since the front non-floating
+ * window doesn't in fact get activated... So maybe we can check here
+ * and if we are destroying a floating window, we can pass the focus
+ * back to the front non-floating window...
+ */
+
+ if (macWin->grafPtr != NULL) {
+ TkWindow *focusPtr = TkGetFocusWin(macWin->winPtr);
+ if (focusPtr == NULL || (focusPtr->mainPtr->winPtr == macWin->winPtr)) {
+ winRef = GetWindowFromPort(macWin->grafPtr);
+ if (TkpIsWindowFloating (winRef)) {
+ Window window;
+
+ window = TkMacOSXGetXWindow(FrontNonFloatingWindow());
+ if (window != None) {
+ TkMacOSXGenerateFocusEvent(window, 1);
+ }
+ }
+ }
+ }
DisposeRgn(macWin->clipRgn);
DisposeRgn(macWin->aboveClipRgn);
diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c
index f718d08..dbb94cc 100644
--- a/macosx/tkMacOSXWindowEvent.c
+++ b/macosx/tkMacOSXWindowEvent.c
@@ -75,8 +75,6 @@ static RgnHandle visRgn;
static int GenerateUpdateEvent( Window window);
static void GenerateUpdates( RgnHandle updateRgn, TkWindow *winPtr);
static int GenerateActivateEvents( Window window, int activeFlag);
-static int GenerateFocusEvent( Window window, int activeFlag);
-
/*
@@ -172,11 +170,11 @@ TkMacOSXProcessWindowEvent(
switch (eventPtr->eKind) {
case kEventWindowActivated:
eventFound |= GenerateActivateEvents(window, 1);
- eventFound |= GenerateFocusEvent(window, 1);
+ eventFound |= TkMacOSXGenerateFocusEvent(window, 1);
break;
case kEventWindowDeactivated:
eventFound |= GenerateActivateEvents(window, 0);
- eventFound |= GenerateFocusEvent(window, 0);
+ eventFound |= TkMacOSXGenerateFocusEvent(window, 0);
break;
case kEventWindowUpdate:
if (GenerateUpdateEvent(window)) {
@@ -382,7 +380,7 @@ GenerateActivateEvents(
/*
*----------------------------------------------------------------------
*
- * GenerateFocusEvent --
+ * TkMacOSXGenerateFocusEvent --
*
* Given a Macintosh window activate event this function generates all the
* X Focus events needed by Tk.
@@ -397,7 +395,7 @@ GenerateActivateEvents(
*/
int
-GenerateFocusEvent(
+TkMacOSXGenerateFocusEvent(
Window window, /* Root X window for event. */
int activeFlag )
{