21#if QT_CONFIG(sessionmanager)
26#include <qpa/qplatforminputcontextfactory_p.h>
27#include <qpa/qplatformaccessibility.h>
28#include <qpa/qplatforminputcontextfactory_p.h>
29#include <qpa/qplatformoffscreensurface.h>
30#include <QtCore/qcoreapplication.h>
31#include <QtGui/qpointingdevice.h>
33#include <QtCore/private/qcore_mac_p.h>
34#include <QtGui/private/qcoregraphics_p.h>
35#include <QtGui/private/qmacmimeregistry_p.h>
37# include <QtGui/private/qopenglcontext_p.h>
39#include <QtGui/private/qrhibackingstore_p.h>
40#include <QtGui/private/qfontengine_coretext_p.h>
42#include <IOKit/graphics/IOGraphicsLib.h>
43#include <UniformTypeIdentifiers/UTCoreTypes.h>
60 if (!lcQpa().isInfoEnabled())
69 qCInfo(lcQpa,
"Loading macOS (Cocoa) platform plugin for Qt " QT_VERSION_STR
", running on macOS %d.%d.%d\n\n" \
70 " Component SDK version Deployment target \n" \
71 " ------------- ------------- -------------------\n" \
72 " Qt " QT_VERSION_STR
" %d.%d.%d %d.%d.%d\n" \
73 " Application %d.%d.%d %d.%d.%d\n",
74 osVersion.majorVersion(), osVersion.minorVersion(), osVersion.microVersion(),
75 qtBuildSDK.majorVersion(), qtBuildSDK.minorVersion(), qtBuildSDK.microVersion(),
76 qtDeploymentTarget.majorVersion(), qtDeploymentTarget.minorVersion(), qtDeploymentTarget.microVersion(),
77 appBuildSDK.majorVersion(), appBuildSDK.minorVersion(), appBuildSDK.microVersion(),
78 appDeploymentTarget.majorVersion(), appDeploymentTarget.minorVersion(), appDeploymentTarget.microVersion());
87 QCocoaIntegration::Options options;
90 if (
param ==
"fontengine=freetype"_L1)
105 , mAccessibility(new QCocoaAccessibility)
107#ifndef QT_NO_CLIPBOARD
118 qWarning(
"Creating multiple Cocoa platform integrations is not supported");
121#ifndef QT_NO_FREETYPE
123 mFontDb.
reset(
new QCoreTextFontDatabaseEngineFactory<QFontEngineFT>);
126 mFontDb.
reset(
new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>);
135 NSApplication *cocoaApplication = [
QNSApplication sharedApplication];
153 [newDelegate setReflectionDelegate:[cocoaApplication delegate]];
154 [cocoaApplication setDelegate:newDelegate];
158 [cocoaApplication setMenu:[qtMenuLoader
menu]];
161 QCocoaScreen::initializeScreens();
170 this, &QCocoaIntegration::focusWindowChanged);
183 [delegate removeAppleEventHandlers];
185 [[NSApplication sharedApplication] setDelegate:nil];
191#ifndef QT_NO_CLIPBOARD
195 delete mCocoaClipboard;
199 QCocoaScreen::cleanupScreens();
212#if QT_CONFIG(sessionmanager)
266 bool isValid()
const override {
return true; }
286 context->setShareContext(shareContext);
297 if (!platformWindow) {
298 qWarning() <<
window <<
"must be created before being used with a backingstore";
302 switch (
window->surfaceType()) {
314 if (
window->inherits(
"QWidgetWindow"))
334 return mCocoaVulkanInstance;
339 return mCocoaVulkanInstance;
345 return mFontDb.
data();
350 return mNativeInterface.
data();
355 return mInputContext.
data();
358#if QT_CONFIG(accessibility)
359QCocoaAccessibility *QCocoaIntegration::accessibility()
const
361 return mAccessibility.data();
365#ifndef QT_NO_CLIPBOARD
368 return mCocoaClipboard;
374 return mCocoaDrag.
data();
391 return mServices.
data();
411 return mKeyboardMapper.
data();
417 auto fallbackSize = NSApp.dockTile.size.width *
qGuiApp->devicePixelRatio();
418 NSApp.applicationIconImage = [NSImage imageFromQIcon:
icon withSize:fallbackSize];
423 NSApp.dockTile.badgeLabel =
number ? [NSString stringWithFormat:
@"%" PRId64,
number] : nil;
433 qCDebug(lcQpaApplication) <<
"Terminating application";
434 [NSApp terminate:nil];
437void QCocoaIntegration::focusWindowChanged(
QWindow *focusWindow)
443 static bool hasDefaultApplicationIcon = [](){
444 NSImage *genericApplicationIcon = [NSWorkspace.sharedWorkspace
445 iconForContentType:UTTypeApplicationBundle];
446 NSImage *applicationIcon = [NSImage imageNamed:NSImageNameApplicationIcon];
448 NSRect
rect = NSMakeRect(0, 0, 32, 32);
449 return [applicationIcon CGImageForProposedRect:&
rect context:nil hints:nil]
450 == [genericApplicationIcon CGImageForProposedRect:&
rect context:nil hints:nil];
454 if (!hasDefaultApplicationIcon)
458 if (!
qGuiApp->windowIcon().isNull())
466#include "moc_qcocoaintegration.cpp"
Cocoa Input context implementation.
QPlatformWindow * createForeignWindow(QWindow *window, WId nativeHandle) const override
QPlatformBackingStore * createPlatformBackingStore(QWindow *widget) const override
Factory function for QPlatformBackingStore.
QVariant styleHint(StyleHint hint) const override
static QCocoaIntegration * instance()
bool hasCapability(QPlatformIntegration::Capability cap) const override
void setApplicationIcon(const QIcon &icon) const override
QPlatformOpenGLContext * createPlatformOpenGLContext(QOpenGLContext *context) const override
Factory function for QPlatformOpenGLContext.
QCocoaClipboard * clipboard() const override
Accessor for the platform integration's clipboard.
QCocoaServices * services() const override
QCocoaDrag * drag() const override
void quit() const override
void setApplicationBadge(qint64 number) override
QOpenGLContext * createOpenGLContext(NSOpenGLContext *, QOpenGLContext *shareContext) const override
QPlatformOffscreenSurface * createPlatformOffscreenSurface(QOffscreenSurface *surface) const override
Factory function for QOffscreenSurface.
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
void beep() const override
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QPlatformTheme * createPlatformTheme(const QString &name) const override
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
QCocoaNativeInterface * nativeInterface() const override
QPlatformKeyMapper * keyMapper() const override
Accessor for the platform integration's key mapper.
QCocoaIntegration(const QStringList ¶mList)
QStringList themeNames() const override
QCoreTextFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
static void initializeMimeTypes()
bool isValid() const override
Returns true if the platform offscreen surface has been allocated.
QSurfaceFormat format() const override
Returns the actual surface format of the offscreen surface.
QCocoaOffscreenSurface(QOffscreenSurface *offscreenSurface)
static void removePopupMonitor()
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
static qreal fontSmoothingGamma()
void focusWindowChanged(QWindow *focusWindow)
This signal is emitted when the focused window changes.
The QIcon class provides scalable icons in different modes and states.
static QOperatingSystemVersion deploymentTarget(VersionTarget target=ApplicationBinary)
static QOperatingSystemVersion currentRuntime()
static QOperatingSystemVersion buildSDK(VersionTarget target=ApplicationBinary)
Native interface for QPlatformWindow on \macos. \inmodule QtGui.
Native interface to an NSOpenGLContext on \macos.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QSurfaceFormat requestedFormat() const
Returns the requested surfaceformat of this offscreen surface.
static QOpenGLContextPrivate * get(QOpenGLContext *context)
static QPlatformInputContext * create()
static QStringList requested()
The QPlatformInputContext class abstracts the input method dependent data and composing state.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
static void setPlatformSynthesizesMouse(bool v)
static void registerInputDevice(const QInputDevice *device)
void initializeMimeTypes()
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE void qt_redirectNSApplicationSendEvent()
void qt_resetNSApplicationSendEvent()
void qt_mac_transformProccessToForegroundApplication()
static void initResources()
static void logVersionInformation()
QList< QString > QStringList
Constructs a string list that contains the given string, str.
#define Q_LOGGING_CATEGORY(name,...)
#define qCInfo(category,...)
#define qCDebug(category,...)
GLenum const GLint * param
static void initResources()
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept
#define Q_INIT_RESOURCE(name)
if(qFloatDistance(a, b)<(1<< 7))
[0]