summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-01-17 14:40:35 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-19 11:31:22 +0100
commita84d893bae6b282381f9e1c55a34cd223d7351ed (patch)
tree7af52d91463db5507269eefd82b2da28c13df272
parente87813bfa239e2083bda5ecc8172753ecc8de5f1 (diff)
Add "nswindow" resource to the Cocoa native interface implementation
This will return the NSWindow* for the given QWindow*. Port the QWidget autotest helper to use the native interface and the "nswindow" resource. Change-Id: I754b7e9288690ac3c99c3ec65c5526d5fe121234 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.mm17
2 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 426ac1e494..2f393cb1b9 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -61,6 +61,8 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
} else if (resourceString == "nsview") {
return static_cast<QCocoaWindow *>(window->handle())->m_contentView;
+ } else if (resourceString == "nswindow") {
+ return static_cast<QCocoaWindow *>(window->handle())->m_nsWindow;
}
return 0;
}
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.mm b/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.mm
index 8d828dd5a7..0d93f7528b 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.mm
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget_mac_helpers.mm
@@ -40,23 +40,28 @@
****************************************************************************/
#include "tst_qwidget_mac_helpers.h"
-#include <private/qt_mac_p.h>
-#include <private/qt_cocoa_helpers_mac_p.h>
+#include <QApplication>
+#include <QPlatformNativeInterface>
+#include <private/qcore_mac_p.h>
+#include <Cocoa/Cocoa.h>
QString nativeWindowTitle(QWidget *window, Qt::WindowState state)
{
- OSWindowRef windowRef = qt_mac_window_for(window);
+ QWindow *qwindow = window->windowHandle();
+ NSWindow *nswindow = (NSWindow *) qApp->platformNativeInterface()->nativeResourceForWindow("nswindow", qwindow);
QCFString macTitle;
if (state == Qt::WindowMinimized) {
- macTitle = reinterpret_cast<CFStringRef>([[windowRef miniwindowTitle] retain]);
+ macTitle = reinterpret_cast<CFStringRef>([[nswindow miniwindowTitle] retain]);
} else {
- macTitle = reinterpret_cast<CFStringRef>([[windowRef title] retain]);
+ macTitle = reinterpret_cast<CFStringRef>([[nswindow title] retain]);
}
return macTitle;
}
bool nativeWindowModified(QWidget *widget)
{
- return [qt_mac_window_for(widget) isDocumentEdited];
+ QWindow *qwindow = widget->windowHandle();
+ NSWindow *nswindow = (NSWindow *) qApp->platformNativeInterface()->nativeResourceForWindow("nswindow", qwindow);
+ return [nswindow isDocumentEdited];
}