diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-04-24 10:59:45 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-26 12:08:24 +0200 |
commit | 9f1b64766b64fac2df8dd112d2801c15a781bdf9 (patch) | |
tree | ddfabc5f1c270773cd9bbf3b8cd089690544fc44 | |
parent | 2e69015d74a903d7319dec164214b9f443980a08 (diff) |
Don't use the SubWindow flag for windows embedded in foreign windows
Instead, add QCocoaWindow::setEmbeddedInForeignView which can be called
via QPlatformNativeInterface::NativeResourceForIntegrationFunction
Task-number: QTBUG-30805
Change-Id: I05861e80ca664ddb430216388cf0fec573a4d32b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoanativeinterface.mm | 8 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 7 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 11 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 8 |
5 files changed, 30 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.h b/src/plugins/platforms/cocoa/qcocoanativeinterface.h index c344ebc42c..2e5e65f577 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.h +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.h @@ -115,6 +115,9 @@ private: // Embedding NSViews as child QWindows static void setWindowContentView(QPlatformWindow *window, void *nsViewContentView); + // Set a QWindow as a "guest" (subwindow) of a non-QWindow + static void setEmbeddedInForeignView(QPlatformWindow *window, bool embedded); + // Register if a window should deliver touch events. Enabling // touch events has implications for delivery of other events, // for example by causing scrolling event lag. diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm index 64e2b619c1..873fa3eed9 100644 --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm @@ -120,6 +120,8 @@ QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInter return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setWindowContentView); if (resource.toLower() == "registertouchwindow") return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerTouchWindow); + if (resource.toLower() == "setembeddedinforeignview") + return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setEmbeddedInForeignView); return 0; } @@ -229,6 +231,12 @@ void QCocoaNativeInterface::setWindowContentView(QPlatformWindow *window, void * cocoaPlatformWindow->setContentView(reinterpret_cast<NSView *>(contentView)); } +void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded) +{ + QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window); + cocoaPlatformWindow->setEmbeddedInForeignView(embedded); +} + void QCocoaNativeInterface::registerTouchWindow(QWindow *window, bool enable) { if (!window) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index ff7f99f96a..b2657b7725 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -127,6 +127,8 @@ public: NSView *contentView() const; void setContentView(NSView *contentView); + void setEmbeddedInForeignView(bool subwindow); + void windowWillMove(); void windowDidMove(); void windowDidResize(); @@ -175,7 +177,10 @@ public: // for QNSView NSView *m_contentView; QNSView *m_qtView; NSWindow *m_nsWindow; - bool m_contentViewIsEmbedded; // true if the m_contentView is embedded in a "foregin" NSView hiearchy + + // TODO merge to one variable if possible + bool m_contentViewIsEmbedded; // true if the m_contentView is actually embedded in a "foreign" NSView hiearchy + bool m_contentViewIsToBeEmbedded; // true if the m_contentView is intended to be embedded in a "foreign" NSView hiearchy QNSWindowDelegate *m_nsWindowDelegate; Qt::WindowFlags m_windowFlags; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 5cfcec8e54..14b9b66c92 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -194,6 +194,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) : QPlatformWindow(tlw) , m_nsWindow(0) , m_contentViewIsEmbedded(false) + , m_contentViewIsToBeEmbedded(false) , m_nsWindowDelegate(0) , m_synchedWindowState(Qt::WindowActive) , m_windowModality(Qt::NonModal) @@ -654,6 +655,12 @@ void QCocoaWindow::setContentView(NSView *contentView) recreateWindow(parent()); // Adds the content view to parent NSView } +void QCocoaWindow::setEmbeddedInForeignView(bool embedded) +{ + m_contentViewIsToBeEmbedded = embedded; + recreateWindow(0); // destroy what was already created +} + void QCocoaWindow::windowWillMove() { // Close any open popups on window move @@ -715,8 +722,8 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) m_nsWindowDelegate = 0; } - if (window()->type() == Qt::SubWindow) { - // Subwindows don't have a NSWindow. + if (m_contentViewIsToBeEmbedded) { + // An embedded window doesn't have its own NSWindow. } else if (!parentWindow) { // Create a new NSWindow if this is a top-level window. m_nsWindow = createNSWindow(); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index d1dd939600..a53d6c4e44 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -172,7 +172,7 @@ static QTouchDevice *touchDevice = 0; - (void)viewDidMoveToSuperview { - if (!(m_window->type() & Qt::SubWindow)) + if (!(m_platformWindow->m_contentViewIsToBeEmbedded)) return; if ([self superview]) { @@ -208,7 +208,7 @@ static QTouchDevice *touchDevice = 0; 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 if (m_window->type() & Qt::SubWindow) { + } else if (m_platformWindow->m_contentViewIsToBeEmbedded) { // embedded child window, use the frame rect ### merge with case below geometry = qt_mac_toQRect([self bounds]); } else { @@ -229,9 +229,9 @@ static QTouchDevice *touchDevice = 0; m_platformWindow->QPlatformWindow::setGeometry(geometry); // Don't send the geometry change if the QWindow is designated to be - // embedded in a foregin view hiearchy but has not actually been + // embedded in a foreign view hiearchy but has not actually been // embedded yet - it's too early. - if ((m_window->type() & Qt::SubWindow) && !m_platformWindow->m_contentViewIsEmbedded) + if (m_platformWindow->m_contentViewIsToBeEmbedded && !m_platformWindow->m_contentViewIsEmbedded) return; // Send a geometry change event to Qt, if it's ready to handle events |