diff --git a/5.6.2/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm b/5.6.2/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm index c0d5904..ee3ebf5 100644 --- a/5.6.2/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/5.6.2/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1660,8 +1660,12 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor) // Othervise, set the cursor if this window is under the mouse. In // this case QNSView::cursorUpdate will set the cursor as the pointer // moves. - if (m_nsWindow && m_qtView) { - [m_nsWindow invalidateCursorRectsForView : m_qtView]; + NSWindow *nsWindow = m_nsWindow; + if (!nsWindow) + nsWindow = [m_qtView nsWindow]; + + if (nsWindow && m_qtView) { + [nsWindow invalidateCursorRectsForView : m_qtView]; } else { if (m_windowUnderMouse) [cursor set]; diff --git a/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.h b/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.h index 2d4ad7a..0df70f6 100644 --- a/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.h +++ b/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.h @@ -140,6 +140,8 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); - (void)registerDragTypes; - (NSDragOperation)handleDrag:(id )sender; +- (NSWindow *)nsWindow; + @end QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView); diff --git a/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.mm b/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.mm index 66d114c..81f2111 100644 --- a/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.mm +++ b/5.6.2/qtbase/src/plugins/platforms/cocoa/qnsview.mm @@ -938,7 +938,7 @@ QT_WARNING_POP { Q_UNUSED(theEvent) // Set the cursor manually if there is no NSWindow. - if (!m_platformWindow->m_nsWindow && m_platformWindow->m_windowCursor) + if (![self nsWindow] && m_platformWindow->m_windowCursor) [m_platformWindow->m_windowCursor set]; else [super cursorUpdate:theEvent]; @@ -947,7 +947,7 @@ QT_WARNING_POP -(void)resetCursorRects { // Use the cursor rect API if there is a NSWindow - if (m_platformWindow->m_nsWindow && m_platformWindow->m_windowCursor) + if ([self nsWindow] && m_platformWindow->m_windowCursor) [self addCursorRect:[self visibleRect] cursor:m_platformWindow->m_windowCursor]; } @@ -2114,4 +2114,24 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin QWindowSystemInterface::handleMouseEvent(target, mapWindowCoordinates(m_window, target, qtWindowPoint), qtScreenPoint, m_buttons); } +- (NSWindow *)nsWindow +{ + typedef QT_MANGLE_NAMESPACE(QNSView) QNSV; + + NSWindow *win = m_platformWindow->m_nsWindow; + NSView *parent = self.superview; + while (!win) { + if (![parent isKindOfClass:[QNSV class]]) + break; + + QCocoaWindow *platformWindow = static_cast(parent)->m_platformWindow; + if (platformWindow) + win = platformWindow->m_nsWindow; + + parent = parent.superview; + } + + return win; +} + @end