diff options
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaintegration.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 55b3805df3..d842bed91e 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -59,6 +59,8 @@ #include <qpa/qplatformoffscreensurface.h> #include <QtCore/qcoreapplication.h> +#include <QtPlatformHeaders/qcocoanativecontext.h> + #include <QtGui/private/qcoregraphics_p.h> #ifdef QT_WIDGETS_LIB @@ -94,11 +96,11 @@ static QCocoaIntegration::Options parseOptions(const QStringList ¶mList) return options; } -QCocoaIntegration *QCocoaIntegration::mInstance = 0; +QCocoaIntegration *QCocoaIntegration::mInstance = nullptr; QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) : mOptions(parseOptions(paramList)) - , mFontDb(0) + , mFontDb(nullptr) #ifndef QT_NO_ACCESSIBILITY , mAccessibility(new QCocoaAccessibility) #endif @@ -110,7 +112,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) , mServices(new QCocoaServices) , mKeyboardMapper(new QCocoaKeyMapper) { - if (mInstance != 0) + if (mInstance) qWarning("Creating multiple Cocoa platform integrations is not supported"); mInstance = this; @@ -186,7 +188,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) QCocoaIntegration::~QCocoaIntegration() { - mInstance = 0; + mInstance = nullptr; qt_resetNSApplicationSendEvent(); @@ -196,7 +198,7 @@ QCocoaIntegration::~QCocoaIntegration() QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate]; [delegate removeAppleEventHandlers]; // reset the application delegate - [[NSApplication sharedApplication] setDelegate: 0]; + [[NSApplication sharedApplication] setDelegate:nil]; } #ifndef QT_NO_CLIPBOARD @@ -225,15 +227,13 @@ QCocoaIntegration::Options QCocoaIntegration::options() const return mOptions; } -Q_LOGGING_CATEGORY(lcCocoaScreen, "qt.qpa.cocoa.screens"); - /*! \brief Synchronizes the screen list, adds new screens, removes deleted ones */ void QCocoaIntegration::updateScreens() { - NSArray *scrs = [NSScreen screens]; - NSMutableArray *screens = [NSMutableArray arrayWithArray:scrs]; + NSArray<NSScreen *> *scrs = [NSScreen screens]; + NSMutableArray<NSScreen *> *screens = [NSMutableArray<NSScreen *> arrayWithArray:scrs]; if ([screens count] == 0) if ([NSScreen mainScreen]) [screens addObject:[NSScreen mainScreen]]; @@ -244,7 +244,7 @@ void QCocoaIntegration::updateScreens() uint screenCount = [screens count]; for (uint i = 0; i < screenCount; i++) { NSScreen* scr = [screens objectAtIndex:i]; - CGDirectDisplayID dpy = [[[scr deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + CGDirectDisplayID dpy = scr.qt_displayId; // If this screen is a mirror and is not the primary one of the mirror set, ignore it. // Exception: The NSScreen API has been observed to a return a screen list with one // mirrored, non-primary screen when Qt is running as a startup item. Always use the @@ -254,7 +254,7 @@ void QCocoaIntegration::updateScreens() if (primary != kCGNullDirectDisplay && primary != dpy) continue; } - QCocoaScreen* screen = NULL; + QCocoaScreen* screen = nullptr; foreach (QCocoaScreen* existingScr, mScreens) // NSScreen documentation says do not cache the array returned from [NSScreen screens]. // However in practice, we can identify a screen by its pointer: if resolution changes, @@ -265,12 +265,11 @@ void QCocoaIntegration::updateScreens() } if (screen) { remainingScreens.remove(screen); - screen->updateGeometry(); - qCDebug(lcCocoaScreen) << "Updated properties of" << screen; + screen->updateProperties(); } else { screen = new QCocoaScreen(i); mScreens.append(screen); - qCDebug(lcCocoaScreen) << "Adding" << screen; + qCDebug(lcQpaScreen) << "Adding" << screen; screenAdded(screen); } siblings << screen; @@ -287,7 +286,7 @@ void QCocoaIntegration::updateScreens() mScreens.removeOne(screen); // Prevent stale references to NSScreen during destroy screen->m_screenIndex = -1; - qCDebug(lcCocoaScreen) << "Removing" << screen; + qCDebug(lcQpaScreen) << "Removing" << screen; destroyScreen(screen); } } @@ -296,7 +295,7 @@ QCocoaScreen *QCocoaIntegration::screenForNSScreen(NSScreen *nsScreen) { NSUInteger index = [[NSScreen screens] indexOfObject:nsScreen]; if (index == NSNotFound) - return 0; + return nullptr; if (index >= unsigned(mScreens.count())) updateScreens(); @@ -306,7 +305,7 @@ QCocoaScreen *QCocoaIntegration::screenForNSScreen(NSScreen *nsScreen) return screen; } - return 0; + return nullptr; } bool QCocoaIntegration::hasCapability(QPlatformIntegration::Capability cap) const @@ -361,10 +360,8 @@ QPlatformOffscreenSurface *QCocoaIntegration::createPlatformOffscreenSurface(QOf #ifndef QT_NO_OPENGL QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const { - QCocoaGLContext *glContext = new QCocoaGLContext(context->format(), - context->shareHandle(), - context->nativeHandle()); - context->setNativeHandle(glContext->nativeHandle()); + QCocoaGLContext *glContext = new QCocoaGLContext(context); + context->setNativeHandle(QVariant::fromValue<QCocoaNativeContext>(glContext->nativeContext())); return glContext; } #endif @@ -379,6 +376,19 @@ QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const return new QCocoaEventDispatcher; } +#if QT_CONFIG(vulkan) +QPlatformVulkanInstance *QCocoaIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const +{ + mCocoaVulkanInstance = new QCocoaVulkanInstance(instance); + return mCocoaVulkanInstance; +} + +QCocoaVulkanInstance *QCocoaIntegration::getCocoaVulkanInstance() const +{ + return mCocoaVulkanInstance; +} +#endif + QCoreTextFontDatabase *QCocoaIntegration::fontDatabase() const { return mFontDb.data(); @@ -480,14 +490,14 @@ void QCocoaIntegration::pushPopupWindow(QCocoaWindow *window) QCocoaWindow *QCocoaIntegration::popPopupWindow() { if (m_popupWindowStack.isEmpty()) - return 0; + return nullptr; return m_popupWindowStack.takeLast(); } QCocoaWindow *QCocoaIntegration::activePopupWindow() const { if (m_popupWindowStack.isEmpty()) - return 0; + return nullptr; return m_popupWindowStack.front(); } |