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
qwindowsnativeinterface.cpp
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
"qwindowsnativeinterface.h"
6
#
include
"qwindowswindow.h"
7
#
include
"qwindowsscreen.h"
8
#
include
"qwindowscontext.h"
9
#
include
"qwindowscursor.h"
10
#
include
"qwindowsopenglcontext.h"
11
#
include
"qwindowsintegration.h"
12
#
include
"qwindowstheme.h"
13
#
include
"qwin10helpers.h"
14
15
#
include
<
QtGui
/
qwindow
.
h
>
16
#
include
<
QtGui
/
qopenglcontext
.
h
>
17
#
include
<
QtGui
/
qscreen
.
h
>
18
#
include
<
qpa
/
qplatformscreen
.
h
>
19
20
QT_BEGIN_NAMESPACE
21
22
enum
ResourceType
{
23
RenderingContextType
,
24
HandleType
,
25
GlHandleType
,
26
GetDCType
,
27
ReleaseDCType
,
28
VkSurface
29
};
30
31
static
int
resourceType
(
const
QByteArray &key)
32
{
33
static
const
char
*names[] = {
// match ResourceType
34
"renderingcontext"
,
35
"handle"
,
36
"glhandle"
,
37
"getdc"
,
38
"releasedc"
,
39
"vkSurface"
40
};
41
const
char
**
const
end = names +
sizeof
(names) /
sizeof
(names[0]);
42
const
char
**result = std::find(names, end, key);
43
if
(result == end)
44
result = std::find(names, end, key.toLower());
45
return
int
(result - names);
46
}
47
48
void
*
QWindowsNativeInterface
::
nativeResourceForWindow
(
const
QByteArray &resource, QWindow *window)
49
{
50
if
(!window || !window->handle()) {
51
qWarning(
"%s: '%s' requested for null window or window without handle."
,
__FUNCTION__
, resource.constData());
52
return
nullptr
;
53
}
54
auto
*bw =
static_cast
<
QWindowsWindow
*>(window->handle());
55
int
type = resourceType(resource);
56
if
(type ==
HandleType
)
57
return
bw->handle();
58
switch
(window->surfaceType()) {
59
case
QWindow::RasterSurface:
60
if
(type ==
GetDCType
)
61
return
bw->getDC();
62
if
(type ==
ReleaseDCType
) {
63
bw->releaseDC();
64
return
nullptr
;
65
}
66
break
;
67
case
QWindow::VulkanSurface:
68
#
if
QT_CONFIG
(
vulkan
)
69
if
(type == VkSurface)
70
return
bw->surface(
nullptr
,
nullptr
);
// returns the address of the VkSurfaceKHR, not the value, as expected
71
#
endif
72
break
;
73
default
:
74
break
;
75
}
76
qWarning(
"%s: Invalid key '%s' requested."
,
__FUNCTION__
, resource.constData());
77
return
nullptr
;
78
}
79
80
void
*
QWindowsNativeInterface
::
nativeResourceForScreen
(
const
QByteArray &resource, QScreen *screen)
81
{
82
if
(!screen || !screen->handle()) {
83
qWarning(
"%s: '%s' requested for null screen or screen without handle."
,
__FUNCTION__
, resource.constData());
84
return
nullptr
;
85
}
86
auto
*bs =
static_cast
<
QWindowsScreen
*>(screen->handle());
87
int
type = resourceType(resource);
88
if
(type ==
HandleType
)
89
return
bs->handle();
90
91
qWarning(
"%s: Invalid key '%s' requested."
,
__FUNCTION__
, resource.constData());
92
return
nullptr
;
93
}
94
95
#
ifndef
QT_NO_CURSOR
96
void
*
QWindowsNativeInterface
::
nativeResourceForCursor
(
const
QByteArray &resource,
const
QCursor &cursor)
97
{
98
if
(resource == QByteArrayLiteral(
"hcursor"
)) {
99
if
(
const
QScreen *primaryScreen = QGuiApplication::primaryScreen()) {
100
if
(
const
QPlatformCursor *pCursor= primaryScreen->handle()->cursor())
101
return
static_cast
<
const
QWindowsCursor
*>(pCursor)->hCursor(cursor);
102
}
103
}
104
return
nullptr
;
105
}
106
#
endif
// !QT_NO_CURSOR
107
108
void
*
QWindowsNativeInterface
::nativeResourceForIntegration(
const
QByteArray &resource)
109
{
110
#
ifdef
QT_NO_OPENGL
111
Q_UNUSED(resource);
112
#
else
113
if
(resourceType(resource) ==
GlHandleType
) {
114
if
(
const
QWindowsStaticOpenGLContext
*sc =
QWindowsIntegration
::
staticOpenGLContext
(
)
)
115
return
sc
->
moduleHandle
(
)
;
116
}
117
#
endif
118
119
return
nullptr
;
120
}
121
122
#
ifndef
QT_NO_OPENGL
123
void
*
QWindowsNativeInterface
::
nativeResourceForContext
(
const
QByteArray &resource, QOpenGLContext *context)
124
{
125
if
(!context || !context->handle()) {
126
qWarning(
"%s: '%s' requested for null context or context without handle."
,
__FUNCTION__
, resource.constData());
127
return
nullptr
;
128
}
129
130
qWarning(
"%s: Invalid key '%s' requested."
,
__FUNCTION__
, resource.constData());
131
return
nullptr
;
132
}
133
#
endif
// !QT_NO_OPENGL
134
135
QT_END_NAMESPACE
QWindowsCursor
Platform cursor implementation.
Definition
qwindowscursor.h:66
QWindowsIntegration
Definition
qwindowsintegration.h:31
QWindowsIntegration::staticOpenGLContext
static QWindowsStaticOpenGLContext * staticOpenGLContext()
Definition
qwindowsintegration.cpp:462
QWindowsNativeInterface
Provides access to native handles.
Definition
qwindowsnativeinterface.h:28
QWindowsNativeInterface::nativeResourceForContext
void * nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override
Definition
qwindowsnativeinterface.cpp:123
QWindowsNativeInterface::nativeResourceForWindow
void * nativeResourceForWindow(const QByteArray &resource, QWindow *window) override
Definition
qwindowsnativeinterface.cpp:48
QWindowsNativeInterface::nativeResourceForCursor
void * nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) override
Definition
qwindowsnativeinterface.cpp:96
QWindowsNativeInterface::nativeResourceForScreen
void * nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override
Definition
qwindowsnativeinterface.cpp:80
QWindowsScreen
Windows screen.
Definition
qwindowsscreen.h:46
QWindowsStaticOpenGLContext
Definition
qwindowsopenglcontext.h:18
QWindowsStaticOpenGLContext::moduleHandle
virtual void * moduleHandle() const =0
QWindowsWindow
Raster or OpenGL Window.
Definition
qwindowswindow.h:188
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qrandomaccessasyncfile_darwin.mm:17
HandleType
@ HandleType
Definition
qwindowsnativeinterface.cpp:24
GetDCType
@ GetDCType
Definition
qwindowsnativeinterface.cpp:26
RenderingContextType
@ RenderingContextType
Definition
qwindowsnativeinterface.cpp:23
GlHandleType
@ GlHandleType
Definition
qwindowsnativeinterface.cpp:25
ReleaseDCType
@ ReleaseDCType
Definition
qwindowsnativeinterface.cpp:27
resourceType
static int resourceType(const QByteArray &key)
Definition
qwindowsnativeinterface.cpp:31
ResourceType
ResourceType
Definition
qeglfsintegration.cpp:248
VkSurface
@ VkSurface
Definition
qeglfsintegration.cpp:257
qtbase
src
plugins
platforms
windows
qwindowsnativeinterface.cpp
Generated on
for Qt by
1.16.1