diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index 050a2e69d1..45c35cccbf 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -73,9 +73,12 @@ NSImage *qt_mac_cgimage_to_nsimage(CGImageRef iamge); NSImage *qt_mac_create_nsimage(const QPixmap &pm); NSSize qt_mac_toNSSize(const QSize &qtSize); +NSRect qt_mac_toNSRect(const QRect &rect); +QRect qt_mac_toQRect(const NSRect &rect); QColor qt_mac_toQColor(const NSColor *color); + // Creates a mutable shape, it's the caller's responsibility to release. HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion ®ion); diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 8841a65844..743c78ed05 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -159,6 +159,16 @@ NSSize qt_mac_toNSSize(const QSize &qtSize) return NSMakeSize(qtSize.width(), qtSize.height()); } +NSRect qt_mac_toNSRect(const QRect &rect) +{ + return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); +} + +QRect qt_mac_toQRect(const NSRect &rect) +{ + return QRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height); +} + QColor qt_mac_toQColor(const NSColor *color) { QColor qtColor; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f23fd3045f..a953b25d84 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -129,22 +129,29 @@ static QTouchDevice *touchDevice = 0; - (void)updateGeometry { - NSRect rect = [self frame]; - NSRect windowRect = [[self window] frame]; - QRect geo(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height); + QRect geometry; + if (m_platformWindow->m_nsWindow) { + // top level window, get window rect and flip y. + NSRect rect = [self frame]; + NSRect windowRect = [[self window] frame]; + geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height); + } else { + // child window, use the frame rect + geometry = qt_mac_toQRect([self frame]); + } #ifdef QT_COCOA_ENABLE_WINDOW_DEBUG - qDebug() << "QNSView::udpateGeometry" << geo; + qDebug() << "QNSView::udpateGeometry" << m_platformWindow << geometry; #endif // Call setGeometry on QPlatformWindow. (not on QCocoaWindow, // doing that will initiate a geometry change it and possibly create // an infinite loop when this notification is triggered again.) - m_platformWindow->QPlatformWindow::setGeometry(geo); + m_platformWindow->QPlatformWindow::setGeometry(geometry); // Send a geometry change event to Qt, if it's ready to handle events if (!m_platformWindow->m_inConstructor) { - QWindowSystemInterface::handleGeometryChange(m_window, geo); + QWindowSystemInterface::handleGeometryChange(m_window, geometry); QWindowSystemInterface::flushWindowSystemEvents(); } }