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>
59 if (!lcQpa().isInfoEnabled())
68 qCInfo(lcQpa,
"Loading macOS (Cocoa) platform plugin for Qt " QT_VERSION_STR
", running on macOS %d.%d.%d\n\n" \
69 " Component SDK version Deployment target \n" \
70 " ------------- ------------- -------------------\n" \
71 " Qt " QT_VERSION_STR
" %d.%d.%d %d.%d.%d\n" \
72 " Application %d.%d.%d %d.%d.%d\n",
73 osVersion.majorVersion(), osVersion.minorVersion(), osVersion.microVersion(),
74 qtBuildSDK.majorVersion(), qtBuildSDK.minorVersion(), qtBuildSDK.microVersion(),
75 qtDeploymentTarget.majorVersion(), qtDeploymentTarget.minorVersion(), qtDeploymentTarget.microVersion(),
76 appBuildSDK.majorVersion(), appBuildSDK.minorVersion(), appBuildSDK.microVersion(),
77 appDeploymentTarget.majorVersion(), appDeploymentTarget.minorVersion(), appDeploymentTarget.microVersion());
86 QCocoaIntegration::Options options;
89 if (
param ==
"fontengine=freetype"_L1)
104 , mAccessibility(new QCocoaAccessibility)
106#ifndef QT_NO_CLIPBOARD
117 qWarning(
"Creating multiple Cocoa platform integrations is not supported");
120#ifndef QT_NO_FREETYPE
134 NSApplication *cocoaApplication = [
QNSApplication sharedApplication];
152 [cocoaApplication activateIgnoringOtherApps : YES];
162 [newDelegate setReflectionDelegate:[cocoaApplication delegate]];
163 [cocoaApplication setDelegate:newDelegate];
167 [cocoaApplication setMenu:[qtMenuLoader
menu]];
170 QCocoaScreen::initializeScreens();
179 this, &QCocoaIntegration::focusWindowChanged);
192 [delegate removeAppleEventHandlers];
194 [[NSApplication sharedApplication] setDelegate:nil];
197#ifndef QT_NO_CLIPBOARD
201 delete mCocoaClipboard;
205 QCocoaScreen::cleanupScreens();
218#if QT_CONFIG(sessionmanager)
271 bool isValid()
const override {
return true; }
291 context->setShareContext(shareContext);
302 if (!platformWindow) {
303 qWarning() <<
window <<
"must be created before being used with a backingstore";
307 switch (
window->surfaceType()) {
327 return mCocoaVulkanInstance;
332 return mCocoaVulkanInstance;
338 return mFontDb.
data();
343 return mNativeInterface.
data();
348 return mInputContext.
data();
351#if QT_CONFIG(accessibility)
352QCocoaAccessibility *QCocoaIntegration::accessibility()
const
354 return mAccessibility.data();
358#ifndef QT_NO_CLIPBOARD
361 return mCocoaClipboard;
367 return mCocoaDrag.
data();
384 return mServices.
data();
415 auto fallbackSize = NSApp.dockTile.size.width *
qGuiApp->devicePixelRatio();
416 NSApp.applicationIconImage = [NSImage imageFromQIcon:
icon withSize:fallbackSize];
421 NSApp.dockTile.badgeLabel =
number ? [NSString stringWithFormat:
@"%" PRId64,
number] : nil;
431 qCDebug(lcQpaApplication) <<
"Terminating application";
432 [NSApp terminate:nil];
435void QCocoaIntegration::focusWindowChanged(
QWindow *focusWindow)
441 static bool hasDefaultApplicationIcon = [](){
442 NSImage *genericApplicationIcon = [[NSWorkspace sharedWorkspace]
443 iconForFileType:NSFileTypeForHFSTypeCode(kGenericApplicationIcon)];
444 NSImage *applicationIcon = [NSImage imageNamed:NSImageNameApplicationIcon];
446 NSRect
rect = NSMakeRect(0, 0, 32, 32);
447 return [applicationIcon CGImageForProposedRect:&
rect context:nil hints:nil]
448 == [genericApplicationIcon CGImageForProposedRect:&
rect context:nil hints:nil];
452 if (!hasDefaultApplicationIcon)
456 if (!
qGuiApp->windowIcon().isNull())
464#include "moc_qcocoaintegration.cpp"
QList< int > possibleKeys(const QKeyEvent *event) const
static Qt::KeyboardModifiers queryKeyboardModifiers()
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
QList< int > possibleKeys(const QKeyEvent *event) const override
Should be used to obtain a list of possible shortcuts for the given key event.
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
Qt::KeyboardModifiers queryKeyboardModifiers() const 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
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 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.
The QKeyEvent class describes a key event.
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 constexpr QOperatingSystemVersionBase MacOSSierra
\variable QOperatingSystemVersion::MacOSSierra
static QOperatingSystemVersion current()
[0]
static QString requested()
static QPlatformInputContext * create()
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
bool isNull() const
Returns true if this string is null; otherwise returns false.
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()
#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]