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