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) 2020 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 <QtGui/qopenglcontext.h>
6#include <QtGui/private/qguiapplication_p.h>
7#include <qpa/qplatformopenglcontext.h>
8#include <qpa/qplatformintegration.h>
9#include <qpa/qplatformwindow.h>
10#include <qpa/qplatformwindow_p.h>
11#include <qpa/qplatformscreen_p.h>
12
13QT_BEGIN_NAMESPACE
14
15using namespace QNativeInterface::Private;
16
17#ifndef QT_NO_OPENGL
18
19/*!
20 \class QNativeInterface::QWGLContext
21 \inheaderfile QOpenGLContext
22 \since 6.0
23 \brief Native interface to a WGL context on Windows.
24
25 Accessed through QOpenGLContext::nativeInterface().
26
27 \inmodule QtGui
28 \inheaderfile QOpenGLContext
29 \ingroup native-interfaces
30 \ingroup native-interfaces-qopenglcontext
31*/
32
33/*!
34 \fn QOpenGLContext *QNativeInterface::QWGLContext::fromNative(HGLRC context, HWND window, QOpenGLContext *shareContext = nullptr)
35
36 \brief Adopts an WGL \a context handle.
37
38 The \a window is needed because the its pixel format will be queried. When the
39 adoption is successful, QOpenGLContext::format() will return a QSurfaceFormat
40 describing this pixel format.
41
42 \note The window specified by \a window must have its pixel format set to a
43 format compatible with the context's. If no SetPixelFormat() call was made on
44 any device context belonging to the window, adopting the context will fail.
45
46 Ownership of the created QOpenGLContext \a shareContext is transferred to the
47 caller.
48*/
49
50/*!
51 \fn HGLRC QNativeInterface::QWGLContext::nativeContext() const
52
53 \return the underlying context handle.
54*/
55
56/*!
57 \fn HMODULE QNativeInterface::QWGLContext::openGLModuleHandle()
58
59 \return the handle for the OpenGL implementation that is currently in use.
60
61 \note This function requires that the QGuiApplication instance is already created.
62*/
63
66
67HMODULE QNativeInterface::QWGLContext::openGLModuleHandle()
68{
69 return QGuiApplicationPrivate::platformIntegration()->call<
70 &QWindowsGLIntegration::openGLModuleHandle>();
71}
72
73QOpenGLContext *QNativeInterface::QWGLContext::fromNative(HGLRC context, HWND window, QOpenGLContext *shareContext)
74{
75 return QGuiApplicationPrivate::platformIntegration()->call<
76 &QWindowsGLIntegration::createOpenGLContext>(context, window, shareContext);
77}
78
79#endif // QT_NO_OPENGL
80
81/*!
82 \class QNativeInterface::Private::QWindowsApplication
83 \since 6.0
84 \internal
85 \brief Native interface to QGuiApplication, to be retrieved from QPlatformIntegration.
86 \inmodule QtGui
87 \ingroup native-interfaces
88*/
89
91
92/*!
93 \class QNativeInterface::QWindowsScreen
94 \since 6.7
95 \brief Native interface to a screen.
96
97 Accessed through QScreen::nativeInterface().
98 \inmodule QtGui
99 \ingroup native-interfaces
100 \ingroup native-interfaces-qscreen
101*/
102/*!
103 * \fn HWMONITOR QNativeInterface::QWindowsScreen::handle() const;
104 * \return The underlying HWMONITOR of the screen.
105 */
107/*!
108 \enum QNativeInterface::Private::QWindowsApplication::TouchWindowTouchType
109
110 This enum represents the supported TouchWindow touch flags for registerTouchWindow().
111
112 \value NormalTouch
113 \value FineTouch
114 \value WantPalmTouch
115*/
116
117/*!
118 \fn void QNativeInterface::Private::QWindowsApplication::setTouchWindowTouchType(QNativeInterface::Private::QWindowsApplication::TouchWindowTouchTypes type)
119 \internal
120
121 Sets the touch window type for all windows to \a type.
122*/
123
124/*!
125 \fn QNativeInterface::Private::QWindowsApplication::TouchWindowTouchTypes QNativeInterface::Private::QWindowsApplication::touchWindowTouchType() const
126 \internal
127
128 Returns the currently set the touch window type.
129*/
130
131/*!
132 \enum QNativeInterface::Private::QWindowsApplication::WindowActivationBehavior
133
134 This enum specifies the behavior of QWidget::activateWindow() and
135 QWindow::requestActivate().
136
137 \value DefaultActivateWindow The window is activated according to the default
138 behavior of the Windows operating system. This means the window will not
139 be activated in some circumstances (most notably when the calling process
140 is not the active process); only the taskbar entry will be flashed.
141 \value AlwaysActivateWindow The window is always activated, even when the
142 calling process is not the active process.
143
144 \sa QWidget::activateWindow(), QWindow::requestActivate()
145*/
146
147/*!
148 \fn void QNativeInterface::Private::QWindowsApplication::setWindowActivationBehavior(QNativeInterface::Private::QWindowsApplication::WindowActivationBehavior behavior)
149 \internal
150
151 Sets the window activation behavior to \a behavior.
152
153 \sa QWidget::activateWindow(), QWindow::requestActivate()
154*/
155
156/*!
157 \fn QNativeInterface::Private::QWindowsApplication::WindowActivationBehavior QNativeInterface::Private::QWindowsApplication::windowActivationBehavior() const
158 \internal
159
160 Returns the currently set the window activation behavior.
161*/
162
163/*!
164 \fn bool QNativeInterface::Private::QWindowsApplication::isTabletMode() const
165 \internal
166
167 Returns \c true if Windows 10 operates in \e{Tablet Mode}.
168 In this mode, Windows forces all application main windows to open in maximized
169 state. Applications should then avoid resizing windows or restoring geometries
170 to non-maximized states.
171
172 \sa QWidget::showMaximized(), QWidget::saveGeometry(), QWidget::restoreGeometry()
173*/
174
175/*!
176 \enum QNativeInterface::Private::QWindowsApplication::DarkModeHandlingFlag
177
178 This enum specifies the behavior of the application when Windows
179 is configured to use dark mode for applications.
180
181 \value DarkModeWindowFrames The window frames will be switched to dark.
182 \value DarkModeStyle The Windows Vista style will be turned off and
183 a simple dark style will be used.
184
185 \sa setDarkModeHandling()
186*/
187
188/*!
189 \fn void QNativeInterface::Private::QWindowsApplication::setDarkModeHandling(DarkModeHandling handling) = 0
190 \internal
191
192 Sets the dark mode handling to \a handling.
193*/
194
195/*!
196 \fn QNativeInterface::Private::QWindowsApplication::DarkModeHandling QNativeInterface::Private::QWindowsApplication::darkModeHandling() const
197 \internal
198
199 Returns the currently set dark mode handling.
200*/
201
202/*!
203 \fn bool QNativeInterface::Private::QWindowsApplication::isWinTabEnabled() const = 0
204 \internal
205
206 Returns whether the \e{Tablet WinTab Driver} (\c Wintab32.dll) is used.
207*/
208
209/*!
210 \fn bool QNativeInterface::Private::QWindowsApplication::setWinTabEnabled(bool enabled)
211 \internal
212
213 Sets whether the \e{Tablet WinTab Driver} (\c Wintab32.dll) should be used to \a enabled.
214
215 Returns \c true on success, \c false otherwise.
216*/
217
218/*!
219 \fn bool QNativeInterface::Private::QWindowsApplication::registerMime(QWindowsMimeConverter *mime)
220 \internal
221
222 Registers the converter \a mime to the system.
223
224 \sa QWindowsMimeConverter, unregisterMime()
225*/
226
227/*!
228 \fn void QNativeInterface::Private::QWindowsApplication::unregisterMime(QWindowsMimeConverter *mime)
229 \internal
230
231 Unregisters the converter \a mime from the system.
232
233 \sa QWindowsMimeConverter, registerMime()
234*/
235
236/*!
237 \fn int QNativeInterface::Private::QWindowsApplication::registerMimeType(const QString &mime)
238 \internal
239
240 Registers the MIME type \a mime, and returns an ID number
241 identifying the format on Windows.
242*/
243
244/*!
245 \fn HWND QNativeInterface::Private::QWindowsApplication::createMessageWindow(const QString &, const QString &, QFunctionPointer) const
246 \internal
247*/
248
249/*!
250 \fn bool QNativeInterface::Private::QWindowsApplication::asyncExpose() const
251 \internal
252*/
253
254/*!
255 \fn void QNativeInterface::Private::QWindowsApplication::setAsyncExpose(bool)
256 \internal
257*/
258
259/*!
260 \fn QVariant QNativeInterface::Private::QWindowsApplication::gpu()
261 \internal
262*/
263
264/*!
265 \fn QVariant QNativeInterface::Private::QWindowsApplication::gpuList()
266 \internal
267*/
268
269/*!
270 \class QNativeInterface::Private::QWindowsWindow
271 \since 6.0
272 \internal
273 \brief Native interface to QPlatformWindow.
274 \inmodule QtGui
275 \ingroup native-interfaces
276*/
277
279
280/*!
281 \fn void QNativeInterface::Private::QWindowsWindow::setHasBorderInFullScreen(bool border)
282 \internal
283
284 Sets whether the WS_BORDER flag will be set for the window in full screen mode
285 to \a border.
286
287 See also \l [QtDoc] {Fullscreen OpenGL Based Windows}
288*/
289
290/*!
291 \fn bool QNativeInterface::Private::QWindowsWindow::hasBorderInFullScreen() const
292 \internal
293
294 Returns whether the WS_BORDER flag will be set for the window in full screen
295 mode.
296*/
297
298/*!
299 \fn QMargins QNativeInterface::Private::QWindowsWindow::customMargins() const
300 \internal
301
302 Returns the margin to be used when handling the \c WM_NCCALCSIZE message.
303*/
304
305/*!
306 \fn void QNativeInterface::Private::QWindowsWindow::setCustomMargins(const QMargins &margins)
307 \internal
308
309 Sets the\a margins to be used when handling the \c WM_NCCALCSIZE message. It is
310 possible to remove a frame border by specifying a negative value.
311*/
312
313QT_END_NAMESPACE
QT_DEFINE_NATIVE_INTERFACE(QWindowsScreen)
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWindowsWindow)
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWindowsGLIntegration)
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWindowsApplication)
QT_DEFINE_NATIVE_INTERFACE(QWGLContext)