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>
This commit is contained in:
parent
4135951ae8
commit
f144d538fd
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user