From 055622ed48888d5a38ee8f2314c252c96dc34e84 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 16 Sep 2014 11:07:24 +0200 Subject: [PATCH] OS X: Fix positioning of popup menus in case of native NSWindows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code transformed the coordinates from the view to the window's content view, and since that content view is flipped in the pure Qt world (content view == QNSView), it manually flipped the coordinates to transform from that to window coordinates. Instead just directly transform the view coordinates to window coordinates using standard Cocoa methods, which then works with any kind of content view and NSWindow configuration. Task-number: QTBUG-40958 Change-Id: Idddd327fe9cff3309606379d0e04ee8b4bd5eece Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index a89979a8ea..3d0201e1a0 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -463,9 +463,8 @@ 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]; + // convert coordinates from view to the view's window + nsPos = [view convertPoint:nsPos toView:nil]; } else if (!QGuiApplication::screens().isEmpty()) { QScreen *screen = QGuiApplication::screens().at(0); nsPos.y = screen->availableVirtualSize().height() - nsPos.y;