From 86f8bee96b658d1712733477e26e70a1fd723102 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 3 Sep 2013 16:25:53 +0200 Subject: OSX: clicking outside a popup: don't propagate the event elsewhere If you click outside a popup window, it only closes the popup; any other widget that was under the cursor at that time should not get the event. The bug was about the popup list on a combobox, but this patch assumes that this rule is universal; can't think of any exceptions at this time. (E.g. a tooltip is not a popup) Clicking on the application menubar still does not close the popup though. Task-number: QTBUG-33241 Change-Id: I2444b7cfd40cf75ff7b70e3fecfeceb2fd4623bf Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4505f8b8cf..c6dce8b6f6 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -600,6 +600,7 @@ static QTouchDevice *touchDevice = 0; QWindowSystemInterface::handleCloseEvent(m_platformWindow->m_activePopupWindow); QWindowSystemInterface::flushWindowSystemEvents(); m_platformWindow->m_activePopupWindow = 0; + return; } if ([self hasMarkedText]) { NSInputManager* inputManager = [NSInputManager currentInputManager]; -- cgit v1.2.3 From a2bdda8e3ba324a51620d9e758e444d02c4fd061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 30 Aug 2013 14:20:21 +0200 Subject: Fix event delivery for apps with native widgets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Native widgets, which have a NSView but not a NSWindow, must be created in the hidden state to prevent Cocoa from selecting them for event delivery. Change-Id: I741e52729047ad4e03959f2244abe5b14b5df46b Reviewed-by: Gabriel de Dietrich Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 86f12e0e5f..a3797682a3 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -792,6 +792,7 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) QRect rect = window()->geometry(); NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); [m_contentView setFrame:frame]; + [m_contentView setHidden: YES]; } const qreal opacity = qt_window_private(window())->opacity; -- cgit v1.2.3 From 8fd71914b43350a21c0c05051c1a6e24e9d8cb85 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 20 Aug 2013 16:55:17 +0200 Subject: Cocoa: Unregister view from window's notifications only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the view will miss its own frame change notifications. And we must unregister from all the notifications during dealloc. This would also reveal a bug where we would expose an NSView before its super view is visible, leading to those "invalid drawable" warnings when using QQuickViews. Therefore, we add this extra check in QCocoaWindow::exposeWindow(). Task-number: QTBUG-32826 Change-Id: I69018cb6f199b242768d114b2aa34c7f2d243196 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 +++-- src/plugins/platforms/cocoa/qnsview.mm | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index a3797682a3..c239aedb05 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -911,7 +911,8 @@ void QCocoaWindow::clearNSWindow(NSWindow *window) [window setContentView:nil]; [window setDelegate:nil]; [window clearPlatformWindow]; - [[NSNotificationCenter defaultCenter] removeObserver:m_contentView]; + [[NSNotificationCenter defaultCenter] removeObserver:m_contentView + name:nil object:window]; } // Returns the current global screen geometry for the nswindow associated with this window. @@ -1023,7 +1024,7 @@ qreal QCocoaWindow::devicePixelRatio() const void QCocoaWindow::exposeWindow() { - if (!m_isExposed) { + if (!m_isExposed && ![[m_contentView superview] isHidden]) { m_isExposed = true; QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index c6dce8b6f6..c2ffe96f8c 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -107,12 +107,9 @@ static QTouchDevice *touchDevice = 0; m_maskImage = 0; m_maskData = 0; m_window = 0; - if (m_subscribesForGlobalFrameNotifications) { - m_subscribesForGlobalFrameNotifications = false; - [[NSNotificationCenter defaultCenter] removeObserver:self - name:NSViewGlobalFrameDidChangeNotification - object:self]; -} + m_subscribesForGlobalFrameNotifications = false; + [[NSNotificationCenter defaultCenter] removeObserver:self]; + delete currentCustomDragTypes; [super dealloc]; -- cgit v1.2.3 From 9554088557571d5c6b96c710424e591ab8db4e0d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 3 Sep 2013 14:23:33 +0200 Subject: Cocoa: Fix NSMenu popup coordinates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those should be in window coordinates (or rather, its content view) not view coordinates. Task-number: QTBUG-32826 Change-Id: I52dddeccf17b359163ad477ce4299b934633b4fa Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins/platforms/cocoa') diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index f9e033d21b..2e53000596 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -455,7 +455,9 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf // Else, we need to transform 'pos' to window or screen coordinates. NSPoint nsPos = NSMakePoint(pos.x() - 1, pos.y()); if (view) { + // Flip y-coordinate first, the convert to content view space. nsPos.y = view.frame.size.height - nsPos.y; + nsPos = [view convertPoint:nsPos toView:view.window.contentView]; } else if (!QGuiApplication::screens().isEmpty()) { QScreen *screen = QGuiApplication::screens().at(0); nsPos.y = screen->availableVirtualSize().height() - nsPos.y; -- cgit v1.2.3