]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
If the frontmost window is not a Tk window exit the event handling code early. This...
authorJack Jansen <jack.jansen@cwi.nl>
Tue, 3 Apr 2001 14:36:35 +0000 (14:36 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Tue, 3 Apr 2001 14:36:35 +0000 (14:36 +0000)
Mac/tclmods/tclMacNotify.c

index 8fc313aee252a1853da48cbf2b1eb0eac173500e..3d2695cf01095425a856ef706292b60f163e73b6 100644 (file)
@@ -82,6 +82,22 @@ static void          InitNotifier _ANSI_ARGS_((void));
 static void            NotifierExitHandler _ANSI_ARGS_((
                            ClientData clientData));
 \f
+/*
+** 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;
+    }
+}
 /*
  *----------------------------------------------------------------------
  *
@@ -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(&currentMouse);
        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