This commit is contained in:
kleuter 2016-05-24 21:16:22 +02:00
parent 5619775b7b
commit 5bea661715
3 changed files with 30 additions and 4 deletions

View File

@ -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];

View File

@ -140,6 +140,8 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
- (void)registerDragTypes;
- (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender;
- (NSWindow *)nsWindow;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView);

View File

@ -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<QNSV *>(parent)->m_platformWindow;
if (platformWindow)
win = platformWindow->m_nsWindow;
parent = parent.superview;
}
return win;
}
@end