Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#include <AppKit/AppKit.h>
5
7#include "qcocoawindow.h"
8#include "qcocoamenu.h"
9#include "qcocoansmenu.h"
10#include "qcocoamenubar.h"
11#include "qcocoahelpers.h"
13#include "qcocoaintegration.h"
15
16#include <qbytearray.h>
17#include <qwindow.h>
18#include <qpixmap.h>
19#include <qpa/qplatformwindow.h>
20#include <QtGui/qsurfaceformat.h>
21#ifndef QT_NO_OPENGL
22#include <qpa/qplatformopenglcontext.h>
23#include <QtGui/qopenglcontext.h>
24#include "qcocoaglcontext.h"
25#endif
26#include <QtGui/qguiapplication.h>
27#include <qdebug.h>
28
29#include <QtGui/private/qmacmimeregistry_p.h>
30#include <QtGui/private/qcoregraphics_p.h>
31
32#if QT_CONFIG(vulkan)
33#include <MoltenVK/mvk_vulkan.h>
34#endif
35
37
41
43{
44 if (!window->handle())
45 return nullptr;
46
47 if (resourceString == "nsview") {
48 return static_cast<QCocoaWindow *>(window->handle())->m_view;
49 } else if (resourceString == "nswindow") {
50 return static_cast<QCocoaWindow *>(window->handle())->nativeWindow();
51#if QT_CONFIG(vulkan)
52 } else if (resourceString == "vkSurface") {
53 if (QVulkanInstance *instance = window->vulkanInstance())
54 return static_cast<QCocoaVulkanInstance *>(instance->handle())->surface(window);
55#endif
56 }
57 return nullptr;
58}
59
61{
62 if (resource.toLower() == "registerdraggedtypes")
63 return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerDraggedTypes);
64 if (resource.toLower() == "registertouchwindow")
65 return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerTouchWindow);
66 if (resource.toLower() == "setembeddedinforeignview")
67 return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setEmbeddedInForeignView);
68 if (resource.toLower() == "registercontentborderarea")
69 return NativeResourceForIntegrationFunction(QCocoaNativeInterface::registerContentBorderArea);
70 if (resource.toLower() == "setcontentborderareaenabled")
71 return NativeResourceForIntegrationFunction(QCocoaNativeInterface::setContentBorderAreaEnabled);
72 if (resource.toLower() == "testcontentborderposition")
73 return NativeResourceForIntegrationFunction(QCocoaNativeInterface::testContentBorderPosition);
74
75 return nullptr;
76}
77
78void QCocoaNativeInterface::clearCurrentThreadCocoaEventDispatcherInterruptFlag()
79{
81}
82
88
89void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
90{
92}
93
94void QCocoaNativeInterface::setEmbeddedInForeignView(QPlatformWindow *window, bool embedded)
95{
96 Q_UNUSED(embedded); // "embedded" state is now automatically detected
97 QCocoaWindow *cocoaPlatformWindow = static_cast<QCocoaWindow *>(window);
98 cocoaPlatformWindow->setEmbeddedInForeignView();
99}
100
101void QCocoaNativeInterface::registerTouchWindow(QWindow *window, bool enable)
102{
103 if (!window)
104 return;
105
106 QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
107 if (cocoaWindow)
108 cocoaWindow->registerTouch(enable);
109}
110
111void QCocoaNativeInterface::registerContentBorderArea(QWindow *window, quintptr identifier, int upper, int lower)
112{
113 if (!window)
114 return;
115
116 QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
117 if (cocoaWindow)
118 cocoaWindow->registerContentBorderArea(identifier, upper, lower);
119}
120
121void QCocoaNativeInterface::setContentBorderAreaEnabled(QWindow *window, quintptr identifier, bool enable)
122{
123 if (!window)
124 return;
125
126 QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
127 if (cocoaWindow)
128 cocoaWindow->setContentBorderAreaEnabled(identifier, enable);
129}
130
131bool QCocoaNativeInterface::testContentBorderPosition(QWindow *window, int position)
132{
133 if (!window)
134 return false;
135
136 QCocoaWindow *cocoaWindow = static_cast<QCocoaWindow *>(window->handle());
137 if (cocoaWindow)
138 return cocoaWindow->testContentBorderAreaPosition(position);
139 return false;
140}
141
\inmodule QtCore
Definition qbytearray.h:57
QByteArray toLower() const &
Definition qbytearray.h:254
static void clearCurrentThreadCocoaEventDispatcherInterruptFlag()
static void updateMenuBarImmediately()
void * nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) override
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) override
void onAppFocusWindowChanged(QWindow *window)
void setContentBorderAreaEnabled(quintptr identifier, bool enable)
bool testContentBorderAreaPosition(int position) const
void registerTouch(bool enable)
void registerContentBorderArea(quintptr identifier, int upper, int lower)
void setEmbeddedInForeignView()
The QPlatformWindow class provides an abstraction for top-level windows.
\inmodule QtCore
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
\inmodule QtGui
Definition qwindow.h:63
void registerDraggedTypes(const QStringList &types)
Combined button and popup list for selecting options.
GLsizei GLenum GLenum * types
GLboolean enable
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
#define Q_UNUSED(x)
size_t quintptr
Definition qtypes.h:167
static QWindowsDirect2DWindow * nativeWindow(QWindow *window)
aWidget window() -> setWindowTitle("New Window Title")
[2]