summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2014-01-29 17:29:39 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-06 07:52:26 +0100
commit9e6f0f16ab9d6c5fca1ded90dd6b3feb953712e1 (patch)
tree1e39cf53fa274f9f84df2a9947ca9931ceb3c185 /src/plugins/platforms
parentd084590d2bfbd60a58aceee7228eddca608f1893 (diff)
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>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm16
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm12
2 files changed, 22 insertions, 6 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 17f5f4888d..8becfb1cc2 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -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)
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 7cd74c6725..b272b4920b 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -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