diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-09-11 14:04:51 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2017-09-26 12:50:05 +0000 |
commit | 49154acde3c2c5f45a50dfd5d011c47db8b761f9 (patch) | |
tree | e8f11e976382ba09de684045140f8b8e32d59e77 /tests | |
parent | 44c304cefb6e9f53c16eec278999ac19f2572a03 (diff) |
macOS: Deliver NSWindow notifications to all windows, not just top level
Child QWindows (or in the case of QWindows embedded in native applications:
top level QWindows where the corresponding NSView is a child of another
view, so not being the contentView of its window), still need some of the
NSWindow notifications to e.g. update their exposed state when the window
becomes visible.
We make sure to send the notification to all QCococaWindow children of
the relevant NSWindow, and let each callback decide if it should only
apply to content views.
This fixes an issue where a QWindow would never be exposed if the window
was a child NSView and added to a NSWindow that was yet to be shown.
Change-Id: I7f7df8bc5f4ca3ac553a2c146f8c3229b197c059
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/cocoa/qt_on_cocoa/main.mm | 13 | ||||
-rw-r--r-- | tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp | 5 |
2 files changed, 13 insertions, 5 deletions
diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm index 5e3b8fcd39..805ef0d7c2 100644 --- a/tests/manual/cocoa/qt_on_cocoa/main.mm +++ b/tests/manual/cocoa/qt_on_cocoa/main.mm @@ -87,8 +87,6 @@ options:NSTrackingActiveInActiveApp | NSTrackingInVisibleRect | NSTrackingCursorUpdate owner:contentView userInfo:nil]]; - window.contentView = contentView; - // Create the QWindow, add its NSView to the content view m_window = new RasterWindow; m_window->setObjectName("RasterWindow"); @@ -104,10 +102,15 @@ NSTextField *textField = [[NSTextField alloc] initWithFrame:NSMakeRect(10, 10, 80, 25)]; [(NSView*)childWindow->winId() addSubview:textField]; - [window.contentView addSubview:reinterpret_cast<NSView *>(m_window->winId())]; + [contentView addSubview:reinterpret_cast<NSView *>(m_window->winId())]; + + window.contentView = contentView; - // Show the NSWindow - [window makeKeyAndOrderFront:NSApp]; + // Show the NSWindow delayed, so that we can verify that Qt picks up the right + // notifications to expose the window when it does become visible. + dispatch_async(dispatch_get_main_queue(), ^{ + [window makeKeyAndOrderFront:NSApp]; + }); } - (void)applicationWillTerminate:(NSNotification *)notification diff --git a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp index dca39839dd..6d7cb3e305 100644 --- a/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp +++ b/tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp @@ -148,6 +148,11 @@ bool RasterWindow::event(QEvent *e) void RasterWindow::render() { + if (!isExposed()) { + qDebug() << "Skipping render, not exposed"; + return; + } + QRect rect(QPoint(), geometry().size()); m_backingStore->resize(rect.size()); |