summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXMenu.c
diff options
context:
space:
mode:
authorwolfsuit <wolfsuit>2003-03-12 05:56:21 (GMT)
committerwolfsuit <wolfsuit>2003-03-12 05:56:21 (GMT)
commit413da068905437f950c4f16ac5f0c699724fb5b4 (patch)
treeb00a57fe2641e2716944ca46b11e7191cef01b97 /macosx/tkMacOSXMenu.c
parent50813805a9b54deccdeee4e0dc5f0dca3ac730c1 (diff)
downloadtk-413da068905437f950c4f16ac5f0c699724fb5b4.zip
tk-413da068905437f950c4f16ac5f0c699724fb5b4.tar.gz
tk-413da068905437f950c4f16ac5f0c699724fb5b4.tar.bz2
2003-03-11 Jim Ingham <jingham@apple.com>
* macosx/tkMacOSXMenu.c (EventuallyInvokeMenu): New function, used to invoke menu commands at idle time. (TkMacOSXDispatchMenuEvent): Don't immediately dispatch menu commands, wait till the idle loop to do so. This is more like what is done on Windows, and avoids the crash from destroying a menu in it's command. * macosx/tkMacOSXHLEvents.c (ReallyKillMe): Don't force the shell to exit. According to the OS X HI guidelines, it should be possible to cancel an attempt to quit, and if we force the kill, here, it would not be possible to implement this.
Diffstat (limited to 'macosx/tkMacOSXMenu.c')
-rw-r--r--macosx/tkMacOSXMenu.c54
1 files changed, 49 insertions, 5 deletions
diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c
index 0f853f9..bfaff7e 100644
--- a/macosx/tkMacOSXMenu.c
+++ b/macosx/tkMacOSXMenu.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: tkMacOSXMenu.c,v 1.7 2003/03/08 02:15:46 wolfsuit Exp $
+ * RCS: @(#) $Id: tkMacOSXMenu.c,v 1.8 2003/03/12 05:56:21 wolfsuit Exp $
*/
#include "tkMacOSXInt.h"
#include "tkMenuButton.h"
@@ -200,6 +200,11 @@ static struct TearoffSelect {
* when we are in this menu */
} tearoffStruct;
+struct MenuCommandHandlerData { /* This is the ClientData we pass to */
+ TkMenu *menuPtr; /* Tcl_DoWhenIdle to move handling */
+ int index; /* menu commands to the event loop. */
+};
+
static RgnHandle totalMenuRgn = NULL;
/* Used to update windows which have been
* obscured by menus. */
@@ -257,6 +262,7 @@ static void DrawTearoffEntry _ANSI_ARGS_((TkMenu *menuPtr,
TkMenuEntry *mePtr, Drawable d, GC gc,
Tk_Font tkfont, CONST Tk_FontMetrics *fmPtr,
int x, int y, int width, int height));
+static void EventuallyInvokeMenu (ClientData data);
static void GetEntryText _ANSI_ARGS_((TkMenuEntry *mePtr,
Tcl_DString *dStringPtr));
static void GetMenuAccelGeometry _ANSI_ARGS_((TkMenu *menuPtr,
@@ -2071,7 +2077,36 @@ TkpSetWindowMenuBar(
listPtr->menuPtr = menuPtr;
}
}
-
+
+static void
+/*
+ *----------------------------------------------------------------------
+ *
+ * EventuallyInvokeMenu --
+ *
+ * This IdleTime callback actually invokes the menu command
+ * scheduled in TkMacOSXDispatchMenuEvent.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Commands get executed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+EventuallyInvokeMenu (ClientData data)
+{
+ struct MenuCommandHandlerData *realData
+ = (struct MenuCommandHandlerData *) data;
+
+ Tcl_Release(realData->menuPtr->interp);
+ Tcl_Release(realData->menuPtr);
+ TkInvokeMenu(realData->menuPtr->interp, realData->menuPtr,
+ realData->index);
+}
+
/*
*----------------------------------------------------------------------
*
@@ -2084,7 +2119,7 @@ TkpSetWindowMenuBar(
* None.
*
* Side effects:
- * Commands get executed.
+ * Commands for the event are scheduled for execution at idle time.
*
*----------------------------------------------------------------------
*/
@@ -2127,7 +2162,16 @@ TkMacOSXDispatchMenuEvent(
GetMenuItemText(GetMenuHandle(menuID), index, itemText);
result = TCL_OK;
} else {
- result = TkInvokeMenu(menuPtr->interp, menuPtr, index - 1);
+ struct MenuCommandHandlerData *data
+ = (struct MenuCommandHandlerData *)
+ ckalloc(sizeof(struct MenuCommandHandlerData));
+ Tcl_Preserve(menuPtr->interp);
+ Tcl_Preserve(menuPtr);
+ data->menuPtr = menuPtr;
+ data->index = index - 1;
+ Tcl_DoWhenIdle (EventuallyInvokeMenu,
+ (ClientData) data);
+ /* result = TkInvokeMenu(menuPtr->interp, menuPtr, index - 1); */
}
} else {
return TCL_ERROR;
@@ -2136,7 +2180,7 @@ TkMacOSXDispatchMenuEvent(
}
return result;
}
-
+
/*
*----------------------------------------------------------------------
*