macOS: Rename m_contentView to m_view, to distinguish from [NSWindow contentView]
The contentView is the root view of a NSWindow, but our m_contentView is just the corresponding NSView of a QWindow, and doesn't always match the contentView property of the NSWindow. This is part of a multi part cleanup to the Cocoa platform plugin in preparation for improved foreign-window support. Change-Id: Ifaffb12f35544ec05e4a83964b346b47fa4b0576 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
parent
12bc984f65
commit
087b11e881
@ -255,7 +255,7 @@ void QCocoaGLContext::setActiveWindow(QWindow *window)
|
|||||||
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
|
QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
|
||||||
cocoaWindow->setCurrentContext(this);
|
cocoaWindow->setCurrentContext(this);
|
||||||
|
|
||||||
[(QNSView *) cocoaWindow->contentView() setQCocoaGLContext:this];
|
[(QNSView *) cocoaWindow->view() setQCocoaGLContext:this];
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCocoaGLContext::updateSurfaceFormat()
|
void QCocoaGLContext::updateSurfaceFormat()
|
||||||
|
@ -495,7 +495,7 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect,
|
|||||||
|
|
||||||
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
|
QPoint pos = QPoint(targetRect.left(), targetRect.top() + targetRect.height());
|
||||||
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0;
|
QCocoaWindow *cocoaWindow = parentWindow ? static_cast<QCocoaWindow *>(parentWindow->handle()) : 0;
|
||||||
NSView *view = cocoaWindow ? cocoaWindow->contentView() : nil;
|
NSView *view = cocoaWindow ? cocoaWindow->view() : nil;
|
||||||
NSMenuItem *nsItem = item ? ((QCocoaMenuItem *)item)->nsItem() : nil;
|
NSMenuItem *nsItem = item ? ((QCocoaMenuItem *)item)->nsItem() : nil;
|
||||||
|
|
||||||
QScreen *screen = 0;
|
QScreen *screen = 0;
|
||||||
|
@ -96,7 +96,7 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (resourceString == "nsview") {
|
if (resourceString == "nsview") {
|
||||||
return static_cast<QCocoaWindow *>(window->handle())->m_contentView;
|
return static_cast<QCocoaWindow *>(window->handle())->m_view;
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
} else if (resourceString == "nsopenglcontext") {
|
} else if (resourceString == "nsopenglcontext") {
|
||||||
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
|
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
|
||||||
@ -281,7 +281,7 @@ QImage QCocoaNativeInterface::cgImageToQImage(CGImageRef image)
|
|||||||
void QCocoaNativeInterface::setWindowContentView(QPlatformWindow *window, void *contentView)
|
void QCocoaNativeInterface::setWindowContentView(QPlatformWindow *window, void *contentView)
|
||||||
{
|
{
|
||||||
QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window);
|
QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window);
|
||||||
cocoaPlatformWindow->setContentView(reinterpret_cast<NSView *>(contentView));
|
cocoaPlatformWindow->setView(reinterpret_cast<NSView *>(contentView));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded)
|
void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded)
|
||||||
|
@ -182,8 +182,8 @@ public:
|
|||||||
WId winId() const Q_DECL_OVERRIDE;
|
WId winId() const Q_DECL_OVERRIDE;
|
||||||
void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
|
void setParent(const QPlatformWindow *window) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
NSView *contentView() const;
|
NSView *view() const;
|
||||||
void setContentView(NSView *contentView);
|
void setView(NSView *view);
|
||||||
QNSView *qtView() const;
|
QNSView *qtView() const;
|
||||||
NSWindow *nativeWindow() const;
|
NSWindow *nativeWindow() const;
|
||||||
|
|
||||||
@ -260,14 +260,14 @@ public: // for QNSView
|
|||||||
|
|
||||||
void removeMonitor();
|
void removeMonitor();
|
||||||
|
|
||||||
NSView *m_contentView;
|
NSView *m_view;
|
||||||
QNSView *m_qtView;
|
QNSView *m_qtView;
|
||||||
QCocoaNSWindow *m_nsWindow;
|
QCocoaNSWindow *m_nsWindow;
|
||||||
QPointer<QCocoaWindow> m_forwardWindow;
|
QPointer<QCocoaWindow> m_forwardWindow;
|
||||||
|
|
||||||
// TODO merge to one variable if possible
|
// 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_viewIsEmbedded; // true if the m_view 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
|
bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy
|
||||||
|
|
||||||
QCocoaWindow *m_parentCocoaWindow;
|
QCocoaWindow *m_parentCocoaWindow;
|
||||||
bool m_isNSWindowChild; // this window is a non-top level QWindow with a NSWindow.
|
bool m_isNSWindowChild; // this window is a non-top level QWindow with a NSWindow.
|
||||||
|
@ -351,11 +351,11 @@ const int QCocoaWindow::NoAlertRequest = -1;
|
|||||||
|
|
||||||
QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
||||||
: QPlatformWindow(tlw)
|
: QPlatformWindow(tlw)
|
||||||
, m_contentView(nil)
|
, m_view(nil)
|
||||||
, m_qtView(nil)
|
, m_qtView(nil)
|
||||||
, m_nsWindow(0)
|
, m_nsWindow(0)
|
||||||
, m_contentViewIsEmbedded(false)
|
, m_viewIsEmbedded(false)
|
||||||
, m_contentViewIsToBeEmbedded(false)
|
, m_viewIsToBeEmbedded(false)
|
||||||
, m_parentCocoaWindow(0)
|
, m_parentCocoaWindow(0)
|
||||||
, m_isNSWindowChild(false)
|
, m_isNSWindowChild(false)
|
||||||
, m_effectivelyMaximized(false)
|
, m_effectivelyMaximized(false)
|
||||||
@ -392,10 +392,10 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
|||||||
|
|
||||||
if (tlw->type() == Qt::ForeignWindow) {
|
if (tlw->type() == Qt::ForeignWindow) {
|
||||||
NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
|
NSView *foreignView = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>());
|
||||||
setContentView(foreignView);
|
setView(foreignView);
|
||||||
} else {
|
} else {
|
||||||
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
|
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
|
||||||
m_contentView = m_qtView;
|
m_view = m_qtView;
|
||||||
// Enable high-dpi OpenGL for retina displays. Enabling has the side
|
// Enable high-dpi OpenGL for retina displays. Enabling has the side
|
||||||
// effect that Cocoa will start calling glViewport(0, 0, width, height),
|
// effect that Cocoa will start calling glViewport(0, 0, width, height),
|
||||||
// overriding any glViewport calls in application code. This is usually not a
|
// overriding any glViewport calls in application code. This is usually not a
|
||||||
@ -404,11 +404,11 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
|||||||
if (tlw->supportsOpenGL()) {
|
if (tlw->supportsOpenGL()) {
|
||||||
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
|
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
|
||||||
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
|
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
|
||||||
[m_contentView setWantsBestResolutionOpenGLSurface:enable];
|
[m_view setWantsBestResolutionOpenGLSurface:enable];
|
||||||
}
|
}
|
||||||
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
|
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
|
||||||
"QT_MAC_WANTS_LAYER");
|
"QT_MAC_WANTS_LAYER");
|
||||||
[m_contentView setWantsLayer:enable];
|
[m_view setWantsLayer:enable];
|
||||||
}
|
}
|
||||||
setGeometry(tlw->geometry());
|
setGeometry(tlw->geometry());
|
||||||
recreateWindow(QPlatformWindow::parent());
|
recreateWindow(QPlatformWindow::parent());
|
||||||
@ -429,8 +429,8 @@ QCocoaWindow::~QCocoaWindow()
|
|||||||
if (m_isNSWindowChild) {
|
if (m_isNSWindowChild) {
|
||||||
if (m_parentCocoaWindow)
|
if (m_parentCocoaWindow)
|
||||||
m_parentCocoaWindow->removeChildWindow(this);
|
m_parentCocoaWindow->removeChildWindow(this);
|
||||||
} else if ([m_contentView superview]) {
|
} else if ([m_view superview]) {
|
||||||
[m_contentView removeFromSuperview];
|
[m_view removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
removeMonitor();
|
removeMonitor();
|
||||||
@ -460,7 +460,7 @@ QCocoaWindow::~QCocoaWindow()
|
|||||||
child->m_parentCocoaWindow = 0;
|
child->m_parentCocoaWindow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[m_contentView release];
|
[m_view release];
|
||||||
[m_nsWindow release];
|
[m_nsWindow release];
|
||||||
[m_windowCursor release];
|
[m_windowCursor release];
|
||||||
}
|
}
|
||||||
@ -501,12 +501,12 @@ QRect QCocoaWindow::geometry() const
|
|||||||
// QWindows that are embedded in a NSView hiearchy may be considered
|
// QWindows that are embedded in a NSView hiearchy may be considered
|
||||||
// top-level from Qt's point of view but are not from Cocoa's point
|
// top-level from Qt's point of view but are not from Cocoa's point
|
||||||
// of view. Embedded QWindows get global (screen) geometry.
|
// of view. Embedded QWindows get global (screen) geometry.
|
||||||
if (m_contentViewIsEmbedded) {
|
if (m_viewIsEmbedded) {
|
||||||
NSPoint windowPoint = [m_contentView convertPoint:NSMakePoint(0, 0) toView:nil];
|
NSPoint windowPoint = [m_view convertPoint:NSMakePoint(0, 0) toView:nil];
|
||||||
NSRect screenRect = [[m_contentView window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
|
NSRect screenRect = [[m_view window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
|
||||||
NSPoint screenPoint = screenRect.origin;
|
NSPoint screenPoint = screenRect.origin;
|
||||||
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
|
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
|
||||||
QSize size = QRectF::fromCGRect([m_contentView bounds]).toRect().size();
|
QSize size = QRectF::fromCGRect([m_view bounds]).toRect().size();
|
||||||
return QRect(position, size);
|
return QRect(position, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,7 +518,7 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
|
|||||||
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setCocoaGeometry" << window() << rect;
|
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setCocoaGeometry" << window() << rect;
|
||||||
QMacAutoReleasePool pool;
|
QMacAutoReleasePool pool;
|
||||||
|
|
||||||
if (m_contentViewIsEmbedded) {
|
if (m_viewIsEmbedded) {
|
||||||
if (m_qtView) {
|
if (m_qtView) {
|
||||||
[m_qtView setFrame:NSMakeRect(0, 0, rect.width(), rect.height())];
|
[m_qtView setFrame:NSMakeRect(0, 0, rect.width(), rect.height())];
|
||||||
} else {
|
} else {
|
||||||
@ -540,7 +540,7 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
|
|||||||
NSRect bounds = qt_mac_flipRect(rect);
|
NSRect bounds = qt_mac_flipRect(rect);
|
||||||
[m_nsWindow setFrame:[m_nsWindow frameRectForContentRect:bounds] display:YES animate:NO];
|
[m_nsWindow setFrame:[m_nsWindow frameRectForContentRect:bounds] display:YES animate:NO];
|
||||||
} else {
|
} else {
|
||||||
[m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
|
[m_view setFrame:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_qtView)
|
if (!m_qtView)
|
||||||
@ -568,7 +568,7 @@ void QCocoaWindow::clipWindow(const NSRect &clipRect)
|
|||||||
// Clipping top/left offsets the content. Move it back.
|
// Clipping top/left offsets the content. Move it back.
|
||||||
NSPoint contentViewOffset = NSMakePoint(qMax(CGFloat(0), NSMinX(clippedWindowRect) - NSMinX(windowFrame)),
|
NSPoint contentViewOffset = NSMakePoint(qMax(CGFloat(0), NSMinX(clippedWindowRect) - NSMinX(windowFrame)),
|
||||||
qMax(CGFloat(0), NSMaxY(windowFrame) - NSMaxY(clippedWindowRect)));
|
qMax(CGFloat(0), NSMaxY(windowFrame) - NSMaxY(clippedWindowRect)));
|
||||||
[m_contentView setBoundsOrigin:contentViewOffset];
|
[m_view setBoundsOrigin:contentViewOffset];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NSIsEmptyRect(clippedWindowRect)) {
|
if (NSIsEmptyRect(clippedWindowRect)) {
|
||||||
@ -739,8 +739,8 @@ void QCocoaWindow::setVisible(bool visible)
|
|||||||
// In some cases, e.g. QDockWidget, the content view is hidden before moving to its own
|
// In some cases, e.g. QDockWidget, the content view is hidden before moving to its own
|
||||||
// Cocoa window, and then shown again. Therefore, we test for the view being hidden even
|
// Cocoa window, and then shown again. Therefore, we test for the view being hidden even
|
||||||
// if it's attached to an NSWindow.
|
// if it's attached to an NSWindow.
|
||||||
if ([m_contentView isHidden])
|
if ([m_view isHidden])
|
||||||
[m_contentView setHidden:NO];
|
[m_view setHidden:NO];
|
||||||
} else {
|
} else {
|
||||||
// qDebug() << "close" << this;
|
// qDebug() << "close" << this;
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
@ -773,7 +773,7 @@ void QCocoaWindow::setVisible(bool visible)
|
|||||||
[mainWindow makeKeyWindow];
|
[mainWindow makeKeyWindow];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
[m_contentView setHidden:YES];
|
[m_view setHidden:YES];
|
||||||
}
|
}
|
||||||
removeMonitor();
|
removeMonitor();
|
||||||
|
|
||||||
@ -1163,7 +1163,7 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab)
|
|||||||
|
|
||||||
WId QCocoaWindow::winId() const
|
WId QCocoaWindow::winId() const
|
||||||
{
|
{
|
||||||
return WId(m_contentView);
|
return WId(m_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
|
void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
|
||||||
@ -1171,33 +1171,34 @@ void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
|
|||||||
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setParent" << window() << (parentWindow ? parentWindow->window() : 0);
|
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setParent" << window() << (parentWindow ? parentWindow->window() : 0);
|
||||||
|
|
||||||
// recreate the window for compatibility
|
// recreate the window for compatibility
|
||||||
bool unhideAfterRecreate = parentWindow && !m_contentViewIsToBeEmbedded && ![m_contentView isHidden];
|
bool unhideAfterRecreate = parentWindow && !m_viewIsToBeEmbedded && ![m_view isHidden];
|
||||||
recreateWindow(parentWindow);
|
recreateWindow(parentWindow);
|
||||||
if (unhideAfterRecreate)
|
if (unhideAfterRecreate)
|
||||||
[m_contentView setHidden:NO];
|
[m_view setHidden:NO];
|
||||||
setCocoaGeometry(geometry());
|
setCocoaGeometry(geometry());
|
||||||
}
|
}
|
||||||
|
|
||||||
NSView *QCocoaWindow::contentView() const
|
NSView *QCocoaWindow::view() const
|
||||||
{
|
{
|
||||||
return m_contentView;
|
return m_view;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCocoaWindow::setContentView(NSView *contentView)
|
// FIXME: Remove and replace with create() and destroy() on a QWindow level
|
||||||
|
void QCocoaWindow::setView(NSView *view)
|
||||||
{
|
{
|
||||||
// Remove and release the previous content view
|
// Remove and release the previous view
|
||||||
if (m_nsWindow)
|
if (m_nsWindow)
|
||||||
[m_nsWindow setContentView:nil];
|
[m_nsWindow setContentView:nil];
|
||||||
else
|
else
|
||||||
[m_contentView removeFromSuperview];
|
[m_view removeFromSuperview];
|
||||||
|
|
||||||
[m_contentView release];
|
[m_view release];
|
||||||
|
|
||||||
// Insert and retain the new content view
|
// Insert and retain the new view
|
||||||
[contentView retain];
|
[view retain];
|
||||||
m_contentView = contentView;
|
m_view = view;
|
||||||
m_qtView = 0; // The new content view is not a QNSView.
|
m_qtView = 0; // The new view is not a QNSView.
|
||||||
recreateWindow(QPlatformWindow::parent()); // Adds the content view to parent NSView
|
recreateWindow(QPlatformWindow::parent()); // Adds the view to parent NSView
|
||||||
}
|
}
|
||||||
|
|
||||||
QNSView *QCocoaWindow::qtView() const
|
QNSView *QCocoaWindow::qtView() const
|
||||||
@ -1212,7 +1213,7 @@ NSWindow *QCocoaWindow::nativeWindow() const
|
|||||||
|
|
||||||
void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
|
void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
|
||||||
{
|
{
|
||||||
m_contentViewIsToBeEmbedded = embedded;
|
m_viewIsToBeEmbedded = embedded;
|
||||||
// Release any previosly created NSWindow.
|
// Release any previosly created NSWindow.
|
||||||
[m_nsWindow closeAndRelease];
|
[m_nsWindow closeAndRelease];
|
||||||
m_nsWindow = 0;
|
m_nsWindow = 0;
|
||||||
@ -1358,7 +1359,7 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
|
|||||||
setNSWindow(m_nsWindow);
|
setNSWindow(m_nsWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_contentViewIsToBeEmbedded) {
|
if (m_viewIsToBeEmbedded) {
|
||||||
// An embedded window doesn't have its own NSWindow.
|
// An embedded window doesn't have its own NSWindow.
|
||||||
} else if (!parentWindow) {
|
} else if (!parentWindow) {
|
||||||
// QPlatformWindow subclasses must sync up with QWindow on creation:
|
// QPlatformWindow subclasses must sync up with QWindow on creation:
|
||||||
@ -1388,18 +1389,18 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Child windows have no NSWindow, link the NSViews instead.
|
// Child windows have no NSWindow, link the NSViews instead.
|
||||||
if ([m_contentView superview])
|
if ([m_view superview])
|
||||||
[m_contentView removeFromSuperview];
|
[m_view removeFromSuperview];
|
||||||
|
|
||||||
[m_parentCocoaWindow->m_contentView addSubview : m_contentView];
|
[m_parentCocoaWindow->m_view addSubview:m_view];
|
||||||
QRect rect = windowGeometry();
|
QRect rect = windowGeometry();
|
||||||
// Prevent setting a (0,0) window size; causes opengl context
|
// Prevent setting a (0,0) window size; causes opengl context
|
||||||
// "Invalid Drawable" warnings.
|
// "Invalid Drawable" warnings.
|
||||||
if (rect.isNull())
|
if (rect.isNull())
|
||||||
rect.setSize(QSize(1, 1));
|
rect.setSize(QSize(1, 1));
|
||||||
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
|
NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
[m_contentView setFrame:frame];
|
[m_view setFrame:frame];
|
||||||
[m_contentView setHidden: YES];
|
[m_view setHidden:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_nsWindow.ignoresMouseEvents =
|
m_nsWindow.ignoresMouseEvents =
|
||||||
@ -1430,9 +1431,9 @@ void QCocoaWindow::reinsertChildWindow(QCocoaWindow *child)
|
|||||||
|
|
||||||
void QCocoaWindow::requestActivateWindow()
|
void QCocoaWindow::requestActivateWindow()
|
||||||
{
|
{
|
||||||
NSWindow *window = [m_contentView window];
|
NSWindow *window = [m_view window];
|
||||||
[ window makeFirstResponder : m_contentView ];
|
[window makeFirstResponder:m_view];
|
||||||
[ window makeKeyWindow ];
|
[window makeKeyWindow];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QCocoaWindow::shouldUseNSPanel()
|
bool QCocoaWindow::shouldUseNSPanel()
|
||||||
@ -1517,14 +1518,14 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
|
|||||||
|
|
||||||
void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
|
void QCocoaWindow::setNSWindow(QCocoaNSWindow *window)
|
||||||
{
|
{
|
||||||
if (window.contentView != m_contentView) {
|
if (window.contentView != m_view) {
|
||||||
[m_contentView setPostsFrameChangedNotifications: NO];
|
[m_view setPostsFrameChangedNotifications:NO];
|
||||||
[m_contentView retain];
|
[m_view retain];
|
||||||
if (m_contentView.superview) // m_contentView comes from another NSWindow
|
if (m_view.superview) // m_view comes from another NSWindow
|
||||||
[m_contentView removeFromSuperview];
|
[m_view removeFromSuperview];
|
||||||
[window setContentView:m_contentView];
|
[window setContentView:m_view];
|
||||||
[m_contentView release];
|
[m_view release];
|
||||||
[m_contentView setPostsFrameChangedNotifications: YES];
|
[m_view setPostsFrameChangedNotifications:YES];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1582,7 +1583,7 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
|
|||||||
return;
|
return;
|
||||||
// if content view width or height is 0 then the window animations will crash so
|
// if content view width or height is 0 then the window animations will crash so
|
||||||
// do nothing except set the new state
|
// do nothing except set the new state
|
||||||
NSRect contentRect = [contentView() frame];
|
NSRect contentRect = m_view.frame;
|
||||||
if (contentRect.size.width <= 0 || contentRect.size.height <= 0) {
|
if (contentRect.size.width <= 0 || contentRect.size.height <= 0) {
|
||||||
qWarning("invalid window content view size, check your window geometry");
|
qWarning("invalid window content view size, check your window geometry");
|
||||||
m_synchedWindowState = newState;
|
m_synchedWindowState = newState;
|
||||||
@ -1703,9 +1704,9 @@ void QCocoaWindow::registerTouch(bool enable)
|
|||||||
{
|
{
|
||||||
m_registerTouchCount += enable ? 1 : -1;
|
m_registerTouchCount += enable ? 1 : -1;
|
||||||
if (enable && m_registerTouchCount == 1)
|
if (enable && m_registerTouchCount == 1)
|
||||||
[m_contentView setAcceptsTouchEvents:YES];
|
[m_view setAcceptsTouchEvents:YES];
|
||||||
else if (m_registerTouchCount == 0)
|
else if (m_registerTouchCount == 0)
|
||||||
[m_contentView setAcceptsTouchEvents:NO];
|
[m_view setAcceptsTouchEvents:NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness)
|
void QCocoaWindow::setContentBorderThickness(int topThickness, int bottomThickness)
|
||||||
@ -1805,7 +1806,7 @@ qreal QCocoaWindow::devicePixelRatio() const
|
|||||||
// methods such as [NSWindow backingScaleFacor] might not give the correct
|
// methods such as [NSWindow backingScaleFacor] might not give the correct
|
||||||
// result, for example if setWantsBestResolutionOpenGLSurface is not set or
|
// result, for example if setWantsBestResolutionOpenGLSurface is not set or
|
||||||
// or ignored by the OpenGL driver.
|
// or ignored by the OpenGL driver.
|
||||||
NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
|
NSSize backingSize = [m_view convertSizeToBacking:NSMakeSize(1.0, 1.0)];
|
||||||
return backingSize.height;
|
return backingSize.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1815,8 +1816,8 @@ bool QCocoaWindow::isWindowExposable()
|
|||||||
{
|
{
|
||||||
QSize size = geometry().size();
|
QSize size = geometry().size();
|
||||||
bool validGeometry = (size.width() > 0 && size.height() > 0);
|
bool validGeometry = (size.width() > 0 && size.height() > 0);
|
||||||
bool validScreen = ([[m_contentView window] screen] != 0);
|
bool validScreen = ([[m_view window] screen] != 0);
|
||||||
bool nonHiddenSuperView = ![[m_contentView superview] isHidden];
|
bool nonHiddenSuperView = ![[m_view superview] isHidden];
|
||||||
return (validGeometry && validScreen && nonHiddenSuperView);
|
return (validGeometry && validScreen && nonHiddenSuperView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1928,11 +1929,11 @@ QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffsetStatic(QWindow *window)
|
|||||||
|
|
||||||
QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffset() const
|
QPoint QCocoaWindow::bottomLeftClippedByNSWindowOffset() const
|
||||||
{
|
{
|
||||||
if (!m_contentView)
|
if (!m_view)
|
||||||
return QPoint();
|
return QPoint();
|
||||||
const NSPoint origin = [m_contentView isFlipped] ? NSMakePoint(0, [m_contentView frame].size.height)
|
const NSPoint origin = [m_view isFlipped] ? NSMakePoint(0, [m_view frame].size.height)
|
||||||
: NSMakePoint(0, 0);
|
: NSMakePoint(0, 0);
|
||||||
const NSRect visibleRect = [m_contentView visibleRect];
|
const NSRect visibleRect = [m_view visibleRect];
|
||||||
|
|
||||||
return QPoint(visibleRect.origin.x, -visibleRect.origin.y + (origin.y - visibleRect.size.height));
|
return QPoint(visibleRect.origin.x, -visibleRect.origin.y + (origin.y - visibleRect.size.height));
|
||||||
}
|
}
|
||||||
|
@ -267,16 +267,16 @@ static bool _q_dontOverrideCtrlLMB = false;
|
|||||||
|
|
||||||
- (void)viewDidMoveToSuperview
|
- (void)viewDidMoveToSuperview
|
||||||
{
|
{
|
||||||
if (!(m_platformWindow->m_contentViewIsToBeEmbedded))
|
if (!(m_platformWindow->m_viewIsToBeEmbedded))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ([self superview]) {
|
if ([self superview]) {
|
||||||
m_platformWindow->m_contentViewIsEmbedded = true;
|
m_platformWindow->m_viewIsEmbedded = true;
|
||||||
QWindowSystemInterface::handleGeometryChange(m_window, m_platformWindow->geometry());
|
QWindowSystemInterface::handleGeometryChange(m_window, m_platformWindow->geometry());
|
||||||
m_platformWindow->updateExposedGeometry();
|
m_platformWindow->updateExposedGeometry();
|
||||||
QWindowSystemInterface::flushWindowSystemEvents();
|
QWindowSystemInterface::flushWindowSystemEvents();
|
||||||
} else {
|
} else {
|
||||||
m_platformWindow->m_contentViewIsEmbedded = false;
|
m_platformWindow->m_viewIsEmbedded = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ static bool _q_dontOverrideCtrlLMB = false;
|
|||||||
NSRect rect = [self frame];
|
NSRect rect = [self frame];
|
||||||
NSRect windowRect = [[self window] 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);
|
geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height);
|
||||||
} else if (m_platformWindow->m_contentViewIsToBeEmbedded) {
|
} else if (m_platformWindow->m_viewIsToBeEmbedded) {
|
||||||
// embedded child window, use the frame rect ### merge with case below
|
// embedded child window, use the frame rect ### merge with case below
|
||||||
geometry = QRectF::fromCGRect([self bounds]).toRect();
|
geometry = QRectF::fromCGRect([self bounds]).toRect();
|
||||||
} else {
|
} else {
|
||||||
@ -368,7 +368,7 @@ static bool _q_dontOverrideCtrlLMB = false;
|
|||||||
// Don't send the geometry change if the QWindow is designated to be
|
// Don't send the geometry change if the QWindow is designated to be
|
||||||
// embedded in a foreign view hiearchy but has not actually been
|
// embedded in a foreign view hiearchy but has not actually been
|
||||||
// embedded yet - it's too early.
|
// embedded yet - it's too early.
|
||||||
if (m_platformWindow->m_contentViewIsToBeEmbedded && !m_platformWindow->m_contentViewIsEmbedded)
|
if (m_platformWindow->m_viewIsToBeEmbedded && !m_platformWindow->m_viewIsEmbedded)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Send a geometry change event to Qt, if it's ready to handle events
|
// Send a geometry change event to Qt, if it's ready to handle events
|
||||||
|
Loading…
Reference in New Issue
Block a user