diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2001-04-03 14:36:35 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2001-04-03 14:36:35 (GMT) |
commit | 216b8707d9927473fd645dec37becc2e7f4951f7 (patch) | |
tree | 4612fea3792ca245e2ef007e9403efc7c067bca3 | |
parent | c951bf91283996587246328c49e4b1909883db8c (diff) | |
download | cpython-216b8707d9927473fd645dec37becc2e7f4951f7.zip cpython-216b8707d9927473fd645dec37becc2e7f4951f7.tar.gz cpython-216b8707d9927473fd645dec37becc2e7f4951f7.tar.bz2 |
If the frontmost window is not a Tk window exit the event handling code early. This fixes that using Tk once used to disable cmd-. processing. It may also influence Tk/IDE interaction, I'm not sure.
-rw-r--r-- | Mac/tclmods/tclMacNotify.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Mac/tclmods/tclMacNotify.c b/Mac/tclmods/tclMacNotify.c index 8fc313a..3d2695c 100644 --- a/Mac/tclmods/tclMacNotify.c +++ b/Mac/tclmods/tclMacNotify.c @@ -83,6 +83,22 @@ static void NotifierExitHandler _ANSI_ARGS_(( ClientData clientData)); /* +** Routine to determine whether Tk is the "main event handler" at the moment or +** something else (MacPython, IDE) is. +** Currently we only check that the frontmost window is Tk based, it may be better +** to also check whether we're inside a Tk mainloop(). +*/ +static int +TkIsTheBoss(void) +{ + WindowRef windowRef; + + windowRef = FrontWindow(); + if ( windowRef && !TkMacGetXWindow(windowRef) ) { + return 0; + } +} +/* *---------------------------------------------------------------------- * * InitNotifier -- @@ -156,6 +172,8 @@ HandleMacEvents(void) WindowRef windowRef; Rect mouseRect; + if ( !TkIsTheBoss() ) + return 0; /* * Check for mouse moved events. These events aren't placed on the * system event queue unless we call WaitNextEvent. @@ -191,11 +209,13 @@ HandleMacEvents(void) */ while (needsUpdate || (GetEvQHdr()->qHead != NULL)) { + /* Give Python command-. handling a chance */ + PyMac_DoYield(0, 0); + GetGlobalMouse(¤tMouse); SetRect(&mouseRect, currentMouse.h, currentMouse.v, currentMouse.h + 1, currentMouse.v + 1); RectRgn(notifier.utilityRgn, &mouseRect); - WaitNextEvent(everyEvent, &theEvent, 5, notifier.utilityRgn); needsUpdate = 0; if ((notifier.eventProcPtr != NULL) @@ -327,6 +347,8 @@ Tcl_WaitForEvent( found = 1; } + if ( !TkIsTheBoss() ) + found = 1; /* * Check for window events. We may receive a NULL event for * various reasons. 1) the timer has expired, 2) a mouse moved |