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