summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qnsview.mm
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2013-10-09 08:43:34 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-01 09:38:12 +0100
commitd1114669e301e35cc4e9b2e4c8c4b9476180fb56 (patch)
treed96efc96e6f119a2433b9baaccec15871c11b25b /src/plugins/platforms/cocoa/qnsview.mm
parentd0f8ba748e4ee93b4b2a205421a0340b2d146ce5 (diff)
Cocoa: Improve cursor setting.
Implement cursor setting in terms of [NSCursor set] and [NSView cursorUpdate] using the window tracking area. Refactor cursor conversion into QCocoaCursor:: convertCursor. Rename QCoocaWindow::m_underMouseWindow to m_enterLeaveTargetWindow since it's set according to spesific enter/leave logic. Add m_windowUnderMouse which tracks mouseEntered/mouseExited state. Task-number: QTBUG-33961 Change-Id: Id5e12594f5db365e09c9926a4c08d748a9afb935 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview.mm')
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 8f839384df..71c4de3b69 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -671,7 +671,7 @@ static QTouchDevice *touchDevice = 0;
// mouse moves delivered to it (Apple recommends keeping it OFF because there
// is a performance hit). So it goes.
NSUInteger trackingOptions = NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp
- | NSTrackingInVisibleRect | NSTrackingMouseMoved;
+ | NSTrackingInVisibleRect | NSTrackingMouseMoved | NSTrackingCursorUpdate;
NSTrackingArea *ta = [[[NSTrackingArea alloc] initWithRect:[self frame]
options:trackingOptions
owner:self
@@ -680,6 +680,13 @@ static QTouchDevice *touchDevice = 0;
[self addTrackingArea:ta];
}
+-(void)cursorUpdate:(NSEvent *)theEvent
+{
+ Q_UNUSED(theEvent)
+ if (m_platformWindow->m_windowCursor)
+ [m_platformWindow->m_windowCursor set];
+}
+
- (void)mouseMoved:(NSEvent *)theEvent
{
if (m_window->flags() & Qt::WindowTransparentForInput)
@@ -696,9 +703,9 @@ static QTouchDevice *touchDevice = 0;
// handling mouseEnter and mouseLeave envents, since they are sent
// individually to different views.
if (m_platformWindow->m_nsWindow && childWindow) {
- if (childWindow != m_platformWindow->m_underMouseWindow) {
- QWindowSystemInterface::handleEnterLeaveEvent(childWindow, m_platformWindow->m_underMouseWindow, windowPoint, screenPoint);
- m_platformWindow->m_underMouseWindow = childWindow;
+ if (childWindow != m_platformWindow->m_enterLeaveTargetWindow) {
+ QWindowSystemInterface::handleEnterLeaveEvent(childWindow, m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
+ m_platformWindow->m_enterLeaveTargetWindow = childWindow;
}
}
@@ -712,6 +719,8 @@ static QTouchDevice *touchDevice = 0;
- (void)mouseEntered:(NSEvent *)theEvent
{
+ m_platformWindow->m_windowUnderMouse = true;
+
if (m_window->flags() & Qt::WindowTransparentForInput)
return [super mouseEntered:theEvent];
@@ -722,12 +731,14 @@ static QTouchDevice *touchDevice = 0;
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- m_platformWindow->m_underMouseWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
- QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_underMouseWindow, windowPoint, screenPoint);
+ m_platformWindow->m_enterLeaveTargetWindow = m_platformWindow->childWindowAt(windowPoint.toPoint());
+ QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint);
}
- (void)mouseExited:(NSEvent *)theEvent
{
+ m_platformWindow->m_windowUnderMouse = false;
+
if (m_window->flags() & Qt::WindowTransparentForInput)
return [super mouseExited:theEvent];
Q_UNUSED(theEvent);
@@ -736,8 +747,8 @@ static QTouchDevice *touchDevice = 0;
if (!m_platformWindow->m_nsWindow)
return;
- QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_underMouseWindow);
- m_platformWindow->m_underMouseWindow = 0;
+ QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_enterLeaveTargetWindow);
+ m_platformWindow->m_enterLeaveTargetWindow = 0;
}
- (void)rightMouseDown:(NSEvent *)theEvent