--- tkPointer.c.1	2024-02-18 09:46:05.000000000 +0100
+++ tkPointer.c.2	2024-02-18 13:54:03.000000000 +0100
@@ -115,7 +115,8 @@
  *	enter/leave events that are needed.
  *
  * Results:
- *	Returns 1 if enter/leave events were generated.
+ *	Returns a boolean value indicating whether the pointer crossed
+ *	a window boundary.
  *
  * Side effects:
  *	May insert events into the Tk event queue.
@@ -129,7 +130,7 @@
     int x, int y,		/* Current mouse position in root coords. */
     int state)			/* State flags. */
 {
-    int crossed = 0;		/* 1 if mouse crossed a window boundary */
+    int crossed = 0;
     ThreadSpecificData *tsdPtr =
 	    Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
     TkWindow *restrictWinPtr = tsdPtr->restrictWinPtr;
@@ -188,12 +189,10 @@
 			state, detail);
 		Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
 	    }
-
 	} else {
 	    TkWindow *targetPtr;
 
-	    if ((lastWinPtr == NULL)
-		|| (lastWinPtr->window == None)) {
+	    if ((lastWinPtr == NULL) || (lastWinPtr->window == None)) {
 		targetPtr = winPtr;
 	    } else {
 		targetPtr = lastWinPtr;
@@ -208,15 +207,15 @@
 		 */
 
 		InitializeEvent(&event, targetPtr, LeaveNotify, x, y, state,
-			NotifyNormal);
+			NotifyAncestor);
 
 		TkInOutEvents(&event, lastWinPtr, winPtr, LeaveNotify,
 			EnterNotify, TCL_QUEUE_TAIL);
-		crossed = 1;
 	    }
 	}
 
 	tsdPtr->lastWinPtr = winPtr;
+	crossed = 1;
     }
 
     return crossed;
