From 7e7d40eeb77ee3b4029a8f90c14df6373f082692 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 7 May 2013 13:56:48 +0200 Subject: [PATCH] Cocoa: Add support for ForeignWindow window type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Necessary to make QWindow::fromWinId() work on Mac. Change-Id: I0dc3a1b0d63cff61d484693aee711dc54fea6b2f Reviewed-by: Samuel Rødal --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 1 + src/plugins/platforms/cocoa/qcocoawindow.mm | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 821e10de52..45038ee578 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -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); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 8e9fcc443b..62c8d25695 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -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()); + setContentView(foreignView); + } else { + m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this]; + m_contentView = m_qtView; + } setGeometry(tlw->geometry()); recreateWindow(parent()); tlw->setGeometry(geometry());