Cocoa: Fix geometry for embedded QWindows.
Report for correct geometry for QMacNativeWidget and other QWindows that are embedded in a NSView hierarchy. This also makes mapFrom/ToGlobal work. The implementation is different than for the other cases: Add a QCoocaWindow::geometry() overload and query the geometry there, instead of using a geometry change notification which sets the geometry on the QWindow. Task-number: QTBUG-36322 Change-Id: Iab5f0c96b89610c8a4b4a7de49887b0683d551dd Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
3b8b47db6a
commit
b76612979c
@ -142,6 +142,7 @@ public:
|
||||
~QCocoaWindow();
|
||||
|
||||
void setGeometry(const QRect &rect);
|
||||
QRect geometry() const;
|
||||
void setCocoaGeometry(const QRect &rect);
|
||||
void clipChildWindows();
|
||||
void clipWindow(const NSRect &clipRect);
|
||||
|
@ -462,6 +462,22 @@ void QCocoaWindow::setGeometry(const QRect &rectIn)
|
||||
setCocoaGeometry(rect);
|
||||
}
|
||||
|
||||
QRect QCocoaWindow::geometry() const
|
||||
{
|
||||
// QWindows that are embedded in a NSView hiearchy may be considered
|
||||
// top-level from Qt's point of view but are not from Cocoa's point
|
||||
// of view. Embedded QWindows get global (screen) geometry.
|
||||
if (m_contentViewIsEmbedded) {
|
||||
NSPoint windowPoint = [m_contentView convertPoint:NSMakePoint(0, 0) toView:nil];
|
||||
NSPoint screenPoint = [[m_contentView window] convertBaseToScreen:windowPoint]; // ### use convertRectToScreen after 10.6 removal
|
||||
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
|
||||
QSize size = qt_mac_toQRect([m_contentView bounds]).size();
|
||||
return QRect(position, size);
|
||||
}
|
||||
|
||||
return QPlatformWindow::geometry();
|
||||
}
|
||||
|
||||
void QCocoaWindow::setCocoaGeometry(const QRect &rect)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
|
Loading…
Reference in New Issue
Block a user