From 5bea661715f1260760adbd0ddd58a6b3874932ac Mon Sep 17 00:00:00 2001 From: kleuter Date: Tue, 24 May 2016 21:16:22 +0200 Subject: [PATCH] 5.6.1 apply patch for https://bugreports.qt.io/browse/QTBUG-52023 --- .../plugins/platforms/cocoa/qcocoawindow.mm | 8 +++++-- .../src/plugins/platforms/cocoa/qnsview.h | 2 ++ .../src/plugins/platforms/cocoa/qnsview.mm | 24 +++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/5.6.1/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm b/5.6.1/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm index dd67946..09b71d3 100644 --- a/5.6.1/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/5.6.1/qtbase/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1658,8 +1658,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.1/qtbase/src/plugins/platforms/cocoa/qnsview.h b/5.6.1/qtbase/src/plugins/platforms/cocoa/qnsview.h index 2d4ad7a..0df70f6 100644 --- a/5.6.1/qtbase/src/plugins/platforms/cocoa/qnsview.h +++ b/5.6.1/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.1/qtbase/src/plugins/platforms/cocoa/qnsview.mm b/5.6.1/qtbase/src/plugins/platforms/cocoa/qnsview.mm index 438198f..e70453c 100644 --- a/5.6.1/qtbase/src/plugins/platforms/cocoa/qnsview.mm +++ b/5.6.1/qtbase/src/plugins/platforms/cocoa/qnsview.mm @@ -931,7 +931,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]; @@ -940,7 +940,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]; } @@ -2092,4 +2092,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