Cocoa: Add improved cursor updating code path.
It's possible to use the cursorRect API in the cases where QCocoaWindow has a NSWindow. This is true for all top-level QCococaWindows today. Task-number: QTBUG-35659 Change-Id: Iefb2c1c022448e19a9c005a808e0c81abe9281ea Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>bb10
parent
d084590d2b
commit
9e6f0f16ab
|
|
@ -1314,12 +1314,18 @@ void QCocoaWindow::setWindowCursor(NSCursor *cursor)
|
|||
// it should be accociated with the window until a different
|
||||
// cursor is set.
|
||||
|
||||
// Cocoa has different abstractions. We can set the cursor *now*:
|
||||
if (m_windowUnderMouse)
|
||||
[cursor set];
|
||||
// or we can set the cursor on mouse enter/leave using tracking
|
||||
// areas. This is done in QNSView, save the cursor:
|
||||
m_windowCursor = cursor;
|
||||
|
||||
// Use the built in cursor rect API if the QCocoaWindow has a NSWindow.
|
||||
// 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];
|
||||
} else {
|
||||
if (m_windowUnderMouse)
|
||||
[cursor set];
|
||||
}
|
||||
}
|
||||
|
||||
void QCocoaWindow::registerTouch(bool enable)
|
||||
|
|
|
|||
|
|
@ -706,8 +706,18 @@ static QTouchDevice *touchDevice = 0;
|
|||
-(void)cursorUpdate:(NSEvent *)theEvent
|
||||
{
|
||||
Q_UNUSED(theEvent)
|
||||
if (m_platformWindow->m_windowCursor)
|
||||
// Set the cursor manually if there is no NSWindow.
|
||||
if (!m_platformWindow->m_nsWindow && m_platformWindow->m_windowCursor)
|
||||
[m_platformWindow->m_windowCursor set];
|
||||
else
|
||||
[super cursorUpdate:theEvent];
|
||||
}
|
||||
|
||||
-(void)resetCursorRects
|
||||
{
|
||||
// Use the cursor rect API if there is a NSWindow
|
||||
if (m_platformWindow->m_nsWindow && m_platformWindow->m_windowCursor)
|
||||
[self addCursorRect:[self visibleRect] cursor:m_platformWindow->m_windowCursor];
|
||||
}
|
||||
|
||||
- (void)mouseMoved:(NSEvent *)theEvent
|
||||
|
|
|
|||
Loading…
Reference in New Issue