Cocoa: Add support for ForeignWindow window type

Necessary to make QWindow::fromWinId() work on Mac.

Change-Id: I0dc3a1b0d63cff61d484693aee711dc54fea6b2f
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
Gabriel de Dietrich 2013-05-07 13:56:48 +02:00 committed by The Qt Project
parent bdebec4e2e
commit 7e7d40eeb7
2 changed files with 10 additions and 2 deletions

View File

@ -352,6 +352,7 @@ bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) cons
case BufferQueueingOpenGL:
case WindowMasks:
case MultipleWindows:
case ForeignWindows:
return true;
default:
return QPlatformIntegration::hasCapability(cap);

View File

@ -192,6 +192,8 @@ const int QCocoaWindow::NoAlertRequest = -1;
QCocoaWindow::QCocoaWindow(QWindow *tlw)
: QPlatformWindow(tlw)
, m_contentView(nil)
, m_qtView(nil)
, m_nsWindow(0)
, m_contentViewIsEmbedded(false)
, m_contentViewIsToBeEmbedded(false)
@ -212,8 +214,13 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
#endif
QCocoaAutoReleasePool pool;
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
m_contentView = m_qtView;
if (tlw->type() == Qt::ForeignWindow) {
NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
setContentView(foreignView);
} else {
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
m_contentView = m_qtView;
}
setGeometry(tlw->geometry());
recreateWindow(parent());
tlw->setGeometry(geometry());