macOS: Propagate mouse enter/exit for windows embedded into foreign windows
Similar to the isEmbedded() case, when the parent of a QWindow is a foreign window, created via QWindow::fromWinId(), we don't have a QNSView parent that will handle mouse enter/exit on our behalf. Longer term we probably want to fold this case into the isEmbedded() case, but as that function is used other places too this requires some more research, so for now let's fix hover events. Fixes: QTBUG-114605 Pick-to: 6.5 6.6 Change-Id: Ib61aefc84ed080417a6820a4a365555424b208be Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
dae24df07f
commit
21f3a6d8c5
@ -543,6 +543,30 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
|
||||
[self handleMouseEvent: theEvent];
|
||||
}
|
||||
|
||||
- (BOOL)shouldPropagateMouseEnterExit
|
||||
{
|
||||
Q_ASSERT(m_platformWindow);
|
||||
|
||||
// We send out enter and leave events mainly from mouse move events (mouseMovedImpl),
|
||||
// but in some case (see mouseEnteredImpl:) we also want to propagate enter/leave
|
||||
// events from the platform. We only do this for windows that themselves are not
|
||||
// handled by another parent QWindow.
|
||||
|
||||
if (m_platformWindow->isContentView())
|
||||
return true;
|
||||
|
||||
// Windows manually embedded into a native view does not have a QWindow parent
|
||||
if (m_platformWindow->isEmbedded())
|
||||
return true;
|
||||
|
||||
// Windows embedded via fromWinId do, but the parent isn't a QNSView
|
||||
QPlatformWindow *parentWindow = m_platformWindow->QPlatformWindow::parent();
|
||||
if (parentWindow && parentWindow->isForeignWindow())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
- (void)mouseEnteredImpl:(NSEvent *)theEvent
|
||||
{
|
||||
Q_UNUSED(theEvent);
|
||||
@ -566,8 +590,7 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
|
||||
// in time (s_windowUnderMouse). The latter is also used to also send out enter/leave
|
||||
// events when the application is activated/deactivated.
|
||||
|
||||
// Root (top level or embedded) windows generate enter events for sub-windows
|
||||
if (!m_platformWindow->isContentView() && !m_platformWindow->isEmbedded())
|
||||
if (![self shouldPropagateMouseEnterExit])
|
||||
return;
|
||||
|
||||
QPointF windowPoint;
|
||||
@ -593,8 +616,7 @@ static const QPointingDevice *pointingDeviceFor(qint64 deviceID)
|
||||
if (!m_platformWindow)
|
||||
return;
|
||||
|
||||
// Root (top level or embedded) windows generate enter events for sub-windows
|
||||
if (!m_platformWindow->isContentView() && !m_platformWindow->isEmbedded())
|
||||
if (![self shouldPropagateMouseEnterExit])
|
||||
return;
|
||||
|
||||
QCocoaWindow *windowToLeave = QCocoaWindow::s_windowUnderMouse;
|
||||
|
Loading…
Reference in New Issue
Block a user