From 381c0050c12965edc0a44ef7eae0bf6d7388a15a Mon Sep 17 00:00:00 2001
From: Shawn Rutledge <shawn.rutledge@digia.com>
Date: Thu, 16 May 2013 16:13:09 +0200
Subject: [PATCH] Ignore mouse enter/leave on non-exposed windows

If you put two OpenGL widgets in two tabs, you will have several
QNSViews on the Mac (because using OpenGL forces a lot of the widgets
to be non-alien).  The GL widget on the non-visible tab will not be
exposed, but QCocoaWindow::childWindowAt is recursive and was returning
the last window found which contained the mouse location; but the
children are not reordered when switching tabs.  It should ignore
the invisible windows and report that the mouse entered the
one which is visible.

Task-number: QTBUG-30934
Change-Id: Iae28db56e15815671bf39e1b1f382c8c285532bd
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
---
 src/plugins/platforms/cocoa/qcocoawindow.mm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index d4aa32b821d..17bc8b5ca1e 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -998,7 +998,8 @@ QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint)
         if (QWindow *childWindow = qobject_cast<QWindow *>(child)) {
             if (childWindow->geometry().contains(windowPoint)) {
                 QCocoaWindow* platformWindow = static_cast<QCocoaWindow*>(childWindow->handle());
-                targetWindow = platformWindow->childWindowAt(windowPoint - childWindow->position());
+                if (platformWindow->isExposed())
+                    targetWindow = platformWindow->childWindowAt(windowPoint - childWindow->position());
             }
         }
     }
-- 
GitLab