summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorten Johan Sorvig <morten.sorvig@nokia.com>2012-10-16 14:00:50 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-16 15:29:15 +0200
commitf144d538fdb3efd475c55b8af3a99555e448c924 (patch)
treeddeb7b54c26ce984d15acb101680d9194bc8aa21 /src
parent4135951ae8162c4f8ca557eefb8cd2db39f759b0 (diff)
Cocoa: Set platform window geometry correctly.
Handle the non-toplevel child window case, where QWindow has a parent NSView instead of a parent NSWindow. QWindow geometry is then equivalent to the frame geometry Task-number: QTBUG-26972 Change-Id: Ie7cedb3ec1a564ce55b72e8269d4853962e073ce Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm10
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm19
3 files changed, 26 insertions, 6 deletions
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 &region);
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();
}
}