From fc0267a0bf485c9a753b488bf4df90b62b555317 Mon Sep 17 00:00:00 2001
From: culler <culler>
Date: Tue, 11 Dec 2018 19:55:11 +0000
Subject: [PATCH 542/693] fix bug [18a4ba19bd]: winfo containing gives wrong
 answer on linux.

---
 unix/tkUnixWm.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 19ac86cb5..399916ff3 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -5855,16 +5855,15 @@ Tk_CoordsToWindow(
 	}
 	for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL;
 		wmPtr = wmPtr->nextPtr) {
-	    if (wmPtr->reparent == child) {
-		goto gotToplevel;
-	    }
-	    if (wmPtr->wrapperPtr != NULL) {
-		if (child == wmPtr->wrapperPtr->window) {
-		    goto gotToplevel;
-		}
-	    } else if (child == wmPtr->winPtr->window) {
-		goto gotToplevel;
-	    }
+            winPtr = wmPtr->winPtr;
+            if (wmPtr->winPtr == NULL) {
+                continue;
+            }
+            if (x >= winPtr->changes.x &&
+                x < winPtr->changes.x + winPtr->changes.width &&
+                y < winPtr->changes.y + winPtr->changes.height) {
+                goto gotToplevel;
+            }
 	}
 	x = childX;
 	y = childY;
@@ -5882,7 +5881,6 @@ Tk_CoordsToWindow(
 	Tk_DeleteErrorHandler(handler);
 	handler = NULL;
     }
-    winPtr = wmPtr->winPtr;
     if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) {
 	return NULL;
     }
@@ -5897,10 +5895,6 @@ Tk_CoordsToWindow(
 
     x = childX - winPtr->changes.x;
     y = childY - winPtr->changes.y;
-    if ((x < 0) || (x >= winPtr->changes.width)
-	    || (y >= winPtr->changes.height)) {
-	return NULL;
-    }
     if (y < 0) {
 	winPtr = (TkWindow *) wmPtr->menubar;
 	if (winPtr == NULL) {
-- 
2.19.1

