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);
|
NSImage *qt_mac_create_nsimage(const QPixmap &pm);
|
||||||
|
|
||||||
NSSize qt_mac_toNSSize(const QSize &qtSize);
|
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);
|
QColor qt_mac_toQColor(const NSColor *color);
|
||||||
|
|
||||||
|
|
||||||
// Creates a mutable shape, it's the caller's responsibility to release.
|
// Creates a mutable shape, it's the caller's responsibility to release.
|
||||||
HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion ®ion);
|
HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion ®ion);
|
||||||
|
|
||||||
|
@ -159,6 +159,16 @@ NSSize qt_mac_toNSSize(const QSize &qtSize)
|
|||||||
return NSMakeSize(qtSize.width(), qtSize.height());
|
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 qt_mac_toQColor(const NSColor *color)
|
||||||
{
|
{
|
||||||
QColor qtColor;
|
QColor qtColor;
|
||||||
|
@ -129,22 +129,29 @@ static QTouchDevice *touchDevice = 0;
|
|||||||
|
|
||||||
- (void)updateGeometry
|
- (void)updateGeometry
|
||||||
{
|
{
|
||||||
NSRect rect = [self frame];
|
QRect geometry;
|
||||||
NSRect windowRect = [[self window] frame];
|
if (m_platformWindow->m_nsWindow) {
|
||||||
QRect geo(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height);
|
// 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
|
#ifdef QT_COCOA_ENABLE_WINDOW_DEBUG
|
||||||
qDebug() << "QNSView::udpateGeometry" << geo;
|
qDebug() << "QNSView::udpateGeometry" << m_platformWindow << geometry;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Call setGeometry on QPlatformWindow. (not on QCocoaWindow,
|
// Call setGeometry on QPlatformWindow. (not on QCocoaWindow,
|
||||||
// doing that will initiate a geometry change it and possibly create
|
// doing that will initiate a geometry change it and possibly create
|
||||||
// an infinite loop when this notification is triggered again.)
|
// 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
|
// Send a geometry change event to Qt, if it's ready to handle events
|
||||||
if (!m_platformWindow->m_inConstructor) {
|
if (!m_platformWindow->m_inConstructor) {
|
||||||
QWindowSystemInterface::handleGeometryChange(m_window, geo);
|
QWindowSystemInterface::handleGeometryChange(m_window, geometry);
|
||||||
QWindowSystemInterface::flushWindowSystemEvents();
|
QWindowSystemInterface::flushWindowSystemEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user