From 5361513ec812c545ca2cedea6c8a30c362cb8e5d Mon Sep 17 00:00:00 2001 From: Christoph Schleifenbaum Date: Mon, 25 Nov 2013 19:45:06 +0100 Subject: Cocoa: Mouse enter events on window activation. This patch tells the window system that it should create a mouse enter event if a window was activated when the mouse was inside. This wasn't working and was a regression. Task-number: QTBUG-35109 [ChangeLog][Cocoa] Fix enterEvent not being called on activate. Change-Id: I4e4662b4a4c58dafa8d0a2c09458ab88f678d243 Reviewed-by: Liang Qi --- src/plugins/platforms/cocoa/qnsview.h | 2 ++ src/plugins/platforms/cocoa/qnswindowdelegate.h | 1 + src/plugins/platforms/cocoa/qnswindowdelegate.mm | 11 +++++++++++ 3 files changed, 14 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index ca2a15a1cc..403f8dc78a 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -93,6 +93,8 @@ QT_END_NAMESPACE - (BOOL)hasMask; - (BOOL)isOpaque; +- (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint; + - (void)resetMouseButtons; - (void)handleMouseEvent:(NSEvent *)theEvent; diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index 06e11fffbb..5717551cc3 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -53,6 +53,7 @@ - (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow; +- (void)windowDidBecomeKey:(NSNotification *)notification; - (void)windowDidResize:(NSNotification *)notification; - (void)windowDidMove:(NSNotification *)notification; - (void)windowWillMove:(NSNotification *)notification; diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 10536bd5f4..c9b3d69381 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -56,6 +56,17 @@ return self; } +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + Q_UNUSED(notification); + if (m_cocoaWindow->m_windowUnderMouse) { + QPointF windowPoint; + QPointF screenPoint; + [m_cocoaWindow->m_qtView convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + QWindowSystemInterface::handleEnterEvent(m_cocoaWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint); + } +} + - (void)windowDidResize:(NSNotification *)notification { Q_UNUSED(notification); -- cgit v1.2.3