Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcocoanativeinterface.mm
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#include <AppKit/AppKit.h>
6
8#include "qcocoawindow.h"
9#include "qcocoamenu.h"
10#include "qcocoansmenu.h"
11#include "qcocoamenubar.h"
12#include "qcocoahelpers.h"
16
17#include <qbytearray.h>
18#include <qwindow.h>
19#include <qpixmap.h>
20#include <qpa/qplatformwindow.h>
21#include <QtGui/qsurfaceformat.h>
22#ifndef QT_NO_OPENGL
23#include <qpa/qplatformopenglcontext.h>
24#include <QtGui/qopenglcontext.h>
26#endif
27#include <QtGui/qguiapplication.h>
28#include <qdebug.h>
29
30#include <QtGui/private/qmacmimeregistry_p.h>
31#include <QtGui/private/qcoregraphics_p.h>
32
33#if QT_CONFIG(vulkan)
34#include <MoltenVK/mvk_vulkan.h>
35#endif
36
38
39QCocoaNativeInterface::QCocoaNativeInterface()
40{
41}
42
43void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
44{
45 if (!window->handle())
46 return nullptr;
47
48 if (resourceString == "nsview") {
49 return static_cast<QCocoaWindow *>(window->handle())->m_view;
50 } else if (resourceString == "nswindow") {
51 return static_cast<QCocoaWindow *>(window->handle())->nativeWindow();
52#if QT_CONFIG(vulkan)
53 } else if (resourceString == "vkSurface") {
54 if (QVulkanInstance *instance = window->vulkanInstance())
55 return static_cast<QCocoaVulkanInstance *>(instance->handle())->surface(window);
56#endif
57 }
58 return nullptr;
59}
60
61QPlatformNativeInterface::NativeResourceForIntegrationFunction QCocoaNativeInterface::nativeResourceFunctionForIntegration(const QByteArray &resource)
62{
63 if (resource.toLower() == "registerdraggedtypes")
64 return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::registerDraggedTypes));
65 if (resource.toLower() == "registertouchwindow")
66 return NativeResourceForIntegrationFunction(QFunctionPointer(QCocoaNativeInterface::registerTouchWindow));
67 return nullptr;
68}
69
70void QCocoaNativeInterface::clearCurrentThreadCocoaEventDispatcherInterruptFlag()
71{
73}
74
75void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window)
76{
77 Q_UNUSED(window);
78 QCocoaMenuBar::updateMenuBarImmediately();
79}
80
81void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
82{
83 QMacMimeRegistry::registerDraggedTypes(types);
84}
85
86void QCocoaNativeInterface::registerTouchWindow(QWindow *window, bool enable)
87{
88 if (!window)
89 return;
90
91 QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
92 if (cocoaWindow)
93 cocoaWindow->registerTouch(enable);
94}
95
96QT_END_NAMESPACE
static void clearCurrentThreadCocoaEventDispatcherInterruptFlag()
Combined button and popup list for selecting options.