Cocoa: Simplify native view access.
Use NSWindow and NSView accessors on QCocoaWindow instead of QGuiApplication and nativeResourceForWindow. Change-Id: Iabee1e42dd119726d932f89c66a90810463d70db Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>bb10
parent
c0241d982b
commit
daf4e1e140
|
|
@ -75,6 +75,7 @@
|
|||
|
||||
#include "qcocoaeventdispatcher.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoawindow.h"
|
||||
|
||||
#include "qcocoahelpers.h"
|
||||
#include "qguiapplication.h"
|
||||
|
|
@ -621,7 +622,7 @@ NSModalSession QCocoaEventDispatcherPrivate::currentModalSession()
|
|||
|
||||
if (!info.session) {
|
||||
QCocoaAutoReleasePool pool;
|
||||
NSWindow *nswindow = static_cast<NSWindow *>(QGuiApplication::platformNativeInterface()->nativeResourceForWindow("nswindow", info.window));
|
||||
NSWindow *nswindow = static_cast<QCocoaWindow *>(info.window->handle())->nativeWindow();
|
||||
if (!nswindow)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
#include "qcocoainputcontext.h"
|
||||
#include "qcocoanativeinterface.h"
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoawindow.h"
|
||||
|
||||
#include <QtCore/QRect>
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
|
@ -98,13 +99,12 @@ void QCocoaInputContext::reset()
|
|||
{
|
||||
QPlatformInputContext::reset();
|
||||
|
||||
if (!mWindow) return;
|
||||
if (!mWindow)
|
||||
return;
|
||||
|
||||
QCocoaNativeInterface *nativeInterface = qobject_cast<QCocoaNativeInterface *>(QGuiApplication::platformNativeInterface());
|
||||
if (!nativeInterface) return;
|
||||
|
||||
QNSView *view = static_cast<QNSView *>(nativeInterface->nativeResourceForWindow("nsview", mWindow));
|
||||
if (!view) return;
|
||||
QNSView *view = static_cast<QCocoaWindow *>(mWindow->handle())->qtView();
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
QCocoaAutoReleasePool pool;
|
||||
NSInputManager *currentIManager = [NSInputManager currentInputManager];
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ public:
|
|||
|
||||
NSView *contentView() const;
|
||||
void setContentView(NSView *contentView);
|
||||
QNSView *qtView() const;
|
||||
NSWindow *nativeWindow() const;
|
||||
|
||||
void setEmbeddedInForeignView(bool subwindow);
|
||||
|
||||
|
|
|
|||
|
|
@ -947,6 +947,16 @@ void QCocoaWindow::setContentView(NSView *contentView)
|
|||
recreateWindow(parent()); // Adds the content view to parent NSView
|
||||
}
|
||||
|
||||
QNSView *QCocoaWindow::qtView() const
|
||||
{
|
||||
return m_qtView;
|
||||
}
|
||||
|
||||
NSWindow *QCocoaWindow::nativeWindow() const
|
||||
{
|
||||
return m_nsWindow;
|
||||
}
|
||||
|
||||
void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
|
||||
{
|
||||
m_contentViewIsToBeEmbedded = embedded;
|
||||
|
|
|
|||
Loading…
Reference in New Issue