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
qwindowsintegration.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
6#include "qwindowswindow.h"
7#include "qwindowscontext.h"
8#include "qwin10helpers.h"
9#include "qwindowsmenu.h"
11
12#include "qwindowsscreen.h"
13#include "qwindowstheme.h"
14#include "qwindowsservices.h"
15#include <QtGui/private/qtgui-config_p.h>
16#if QT_CONFIG(directwrite3)
17#include <QtGui/private/qwindowsdirectwritefontdatabase_p.h>
18#endif
19#ifndef QT_NO_FREETYPE
20# include <QtGui/private/qwindowsfontdatabase_ft_p.h>
21#endif
22#include <QtGui/private/qwindowsfontdatabase_p.h>
23#if QT_CONFIG(clipboard)
24# include "qwindowsclipboard.h"
25# if QT_CONFIG(draganddrop)
26# include "qwindowsdrag.h"
27# endif
28#endif
30#include "qwindowskeymapper.h"
31#if QT_CONFIG(accessibility)
33#endif
34
35#include <qpa/qplatformnativeinterface.h>
36#include <qpa/qwindowsysteminterface.h>
37#if QT_CONFIG(sessionmanager)
39#endif
40#include <QtGui/qpointingdevice.h>
41#include <QtGui/private/qguiapplication_p.h>
42#include <QtGui/private/qhighdpiscaling_p.h>
43#include <QtGui/qpa/qplatforminputcontextfactory_p.h>
44#include <QtGui/qpa/qplatformcursor.h>
45
46#include <QtGui/private/qwindowsguieventdispatcher_p.h>
47
48#include <QtCore/qdebug.h>
49#include <QtCore/qvariant.h>
50
51#include <QtCore/qoperatingsystemversion.h>
52#include <QtCore/private/qfunctions_win_p.h>
53
54#include <wrl.h>
55
56#include <limits.h>
57
58#if !defined(QT_NO_OPENGL)
59# include "qwindowsglcontext.h"
60#endif
61
63
64#if QT_CONFIG(cpp_winrt)
65# include <QtCore/private/qt_winrtbase_p.h>
66# include <winrt/Windows.UI.Notifications.h>
67# include <winrt/Windows.Data.Xml.Dom.h>
68# include <winrt/Windows.Foundation.h>
69# include <winrt/Windows.UI.ViewManagement.h>
70#endif
71
72#include <memory>
73
74static inline void initOpenGlBlacklistResources()
75{
76 Q_INIT_RESOURCE(openglblacklists);
77}
78
80
81using namespace Qt::StringLiterals;
82
84{
85 Q_DISABLE_COPY_MOVE(QWindowsIntegrationPrivate)
88
89 void parseOptions(QWindowsIntegration *q, const QStringList &paramList);
90
91 unsigned m_options = 0;
94#if QT_CONFIG(clipboard)
95 QWindowsClipboard m_clipboard;
96# if QT_CONFIG(draganddrop)
97 QWindowsDrag m_drag;
98# endif
99#endif
100#ifndef QT_NO_OPENGL
102 QScopedPointer<QWindowsStaticOpenGLContext> m_staticOpenGLContext;
103#endif // QT_NO_OPENGL
104 QScopedPointer<QPlatformInputContext> m_inputContext;
105#if QT_CONFIG(accessibility)
106 QWindowsUiaAccessibility m_accessibility;
107#endif
109};
110
111template <typename IntType>
112bool parseIntOption(const QString &parameter,const QLatin1StringView &option,
113 IntType minimumValue, IntType maximumValue, IntType *target)
114{
115 const int valueLength = parameter.size() - option.size() - 1;
116 if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != u'=')
117 return false;
118 bool ok;
119 const auto valueRef = QStringView{parameter}.right(valueLength);
120 const int value = valueRef.toInt(&ok);
121 if (ok) {
122 if (value >= int(minimumValue) && value <= int(maximumValue))
123 *target = static_cast<IntType>(value);
124 else {
125 qWarning() << "Value" << value << "for option" << option << "out of range"
126 << minimumValue << ".." << maximumValue;
127 }
128 } else {
129 qWarning() << "Invalid value" << valueRef << "for option" << option;
130 }
131 return true;
132}
133
134using DarkModeHandlingFlag = QNativeInterface::Private::QWindowsApplication::DarkModeHandlingFlag;
135using DarkModeHandling = QNativeInterface::Private::QWindowsApplication::DarkModeHandling;
136
137static inline unsigned parseOptions(const QStringList &paramList,
138 int *tabletAbsoluteRange,
139 QtWindows::DpiAwareness *dpiAwareness,
140 DarkModeHandling *darkModeHandling)
141{
142 unsigned options = 0;
143 for (const QString &param : paramList) {
144 if (param.startsWith(u"fontengine=")) {
145 if (param.endsWith(u"gdi")) {
147 } else if (param.endsWith(u"freetype")) {
149 } else if (param.endsWith(u"native")) {
151 }
152 } else if (param.startsWith(u"dialogs=")) {
153 if (param.endsWith(u"xp")) {
155 } else if (param.endsWith(u"none")) {
157 }
158 } else if (param == u"altgr") {
160 } else if (param == u"gl=gdi") {
162 } else if (param == u"nodirectwrite") {
164 } else if (param == u"nocolorfonts") {
166 } else if (param == u"nomousefromtouch") {
168 } else if (parseIntOption(param, "verbose"_L1, 0, INT_MAX, &QWindowsContext::verbose)
169 || parseIntOption(param, "tabletabsoluterange"_L1, 0, INT_MAX, tabletAbsoluteRange)
172 } else if (param == u"menus=native") {
174 } else if (param == u"menus=none") {
176 } else if (param == u"nowmpointer") {
178 } else if (param == u"reverse") {
180 } else if (param == u"darkmode=0") {
181 *darkModeHandling = {};
182 } else if (param == u"darkmode=1") {
183 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeWindowFrames);
184 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeStyle, false);
185 } else if (param == u"darkmode=2") {
186 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeWindowFrames);
187 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeStyle);
188 } else {
189 qWarning() << "Unknown option" << param;
190 }
191 }
192 return options;
193}
194
196{
198
199 static bool dpiAwarenessSet = false;
200 // Default to per-monitor-v2 awareness (if available)
202
203 int tabletAbsoluteRange = -1;
204 DarkModeHandling darkModeHandling = DarkModeHandlingFlag::DarkModeWindowFrames
205 | DarkModeHandlingFlag::DarkModeStyle;
206 m_options = ::parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness, &darkModeHandling);
207 q->setDarkModeHandling(darkModeHandling);
209 if (tabletAbsoluteRange >= 0)
210 QWindowsContext::setTabletAbsoluteRange(tabletAbsoluteRange);
211
214 else
217
218 if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication.
220 m_context.setProcessDpiAwareness(dpiAwareness);
221 qCDebug(lcQpaWindow) << "DpiAwareness=" << dpiAwareness
222 << "effective process DPI awareness=" << QWindowsContext::processDpiAwareness();
223 }
224 dpiAwarenessSet = true;
225 }
226
229
231}
232
237
238QWindowsIntegration *QWindowsIntegration::m_instance = nullptr;
239
242{
243 m_instance = this;
244 d->parseOptions(this, paramList);
245#if QT_CONFIG(clipboard)
246 d->m_clipboard.registerViewer();
247#endif
250}
251
253{
254 m_instance = nullptr;
255}
256
263
265{
266 switch (cap) {
267 case ThreadedPixmaps:
268 return true;
269#ifndef QT_NO_OPENGL
270 case OpenGL:
271 return true;
272 case ThreadedOpenGL:
274 return glContext->supportsThreadedOpenGL();
275 return false;
276#endif // !QT_NO_OPENGL
277 case WindowMasks:
278 return true;
279 case MultipleWindows:
280 return true;
281 case ForeignWindows:
282 return true;
283 case RasterGLSurface:
284 return true;
286 return true;
288 return false; // QTBUG-68329 QTBUG-53515 QTBUG-54734
290 return true;
291 default:
293 }
294 return false;
295}
296
298{
299 if (window->type() == Qt::Desktop) {
301 qCDebug(lcQpaWindow) << "Desktop window:" << window
302 << Qt::showbase << Qt::hex << result->winId() << Qt::noshowbase << Qt::dec << result->geometry();
303 return result;
304 }
305
306 QWindowsWindowData requested;
307 requested.flags = window->flags();
308 requested.geometry = window->isTopLevel()
311 if (!(requested.flags & Qt::FramelessWindowHint)) {
312 // Apply custom margins (see QWindowsWindow::setCustomMargins())).
313 const QVariant customMarginsV = window->property("_q_windowsCustomMargins");
314 if (customMarginsV.isValid())
315 requested.customMargins = qvariant_cast<QMargins>(customMarginsV);
316 }
317
318 QWindowsWindowData obtained =
321 qCDebug(lcQpaWindow).nospace()
322 << __FUNCTION__ << ' ' << window
323 << "\n Requested: " << requested.geometry << " frame incl.="
325 << ' ' << requested.flags
326 << "\n Obtained : " << obtained.geometry << " margins=" << obtained.fullFrameMargins
327 << " handle=" << obtained.hwnd << ' ' << obtained.flags << '\n';
328
329 if (Q_UNLIKELY(!obtained.hwnd))
330 return nullptr;
331
334
337
338 if (QWindowsMenuBar *menuBarToBeInstalled = QWindowsMenuBar::menuBarOf(window))
339 menuBarToBeInstalled->install(result);
340
341 return result;
342}
343
345{
346 const HWND hwnd = reinterpret_cast<HWND>(nativeHandle);
347 if (!IsWindow(hwnd)) {
348 qWarning("Windows QPA: Invalid foreign window ID %p.", hwnd);
349 return nullptr;
350 }
351 auto *result = new QWindowsForeignWindow(window, hwnd);
352 const QRect obtainedGeometry = result->geometry();
353 QScreen *screen = nullptr;
354 if (const QPlatformScreen *pScreen = result->screenForGeometry(obtainedGeometry))
355 screen = pScreen->screen();
356 if (screen && screen != window->screen())
357 window->setScreen(screen);
358 qCDebug(lcQpaWindow) << "Foreign window:" << window << Qt::showbase << Qt::hex
359 << result->winId() << Qt::noshowbase << Qt::dec << obtainedGeometry << screen;
360 return result;
361}
362
363// Overridden to return a QWindowsDirect2DWindow in Direct2D plugin.
368
369#ifndef QT_NO_OPENGL
370
371QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate()
372{
373#if defined(QT_OPENGL_DYNAMIC)
375 switch (requestedRenderer) {
380 qCWarning(lcQpaGl, "Unable to disable rotation.");
381 }
382 return glCtx;
383 }
384 qCWarning(lcQpaGl, "System OpenGL failed. Falling back to Software OpenGL.");
385 return QOpenGLStaticContext::create(true);
388 return swCtx;
389 qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
392 return nullptr;
393 default:
394 break;
395 }
396
397 const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(requestedRenderer);
398 if (supportedRenderers.testFlag(QWindowsOpenGLTester::DisableProgramCacheFlag)
401 }
402 if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) {
404 if ((supportedRenderers & QWindowsOpenGLTester::DisableRotationFlag)
406 qCWarning(lcQpaGl, "Unable to disable rotation.");
407 }
408 return glCtx;
409 }
410 }
411 return QOpenGLStaticContext::create(true);
412#else
414#endif
415}
416
418{
419 return QWindowsStaticOpenGLContext::doCreate();
420}
421
423{
424 qCDebug(lcQpaGl) << __FUNCTION__ << context->format();
426 std::unique_ptr<QWindowsOpenGLContext> result(staticOpenGLContext->createContext(context));
427 if (result->isValid())
428 return result.release();
429 }
430 return nullptr;
431}
432
443
451
453{
454 if (!ctx || !window)
455 return nullptr;
456
458 std::unique_ptr<QWindowsOpenGLContext> result(staticOpenGLContext->createContext(ctx, window));
459 if (result->isValid()) {
460 auto *context = new QOpenGLContext;
461 context->setShareContext(shareContext);
462 auto *contextPrivate = QOpenGLContextPrivate::get(context);
463 contextPrivate->adopt(result.release());
464 return context;
465 }
466 }
467
468 return nullptr;
469}
470
472{
474 if (!integration)
475 return nullptr;
476 QWindowsIntegrationPrivate *d = integration->d.data();
477 QMutexLocker lock(&d->m_staticContextLock);
478 if (d->m_staticOpenGLContext.isNull())
479 d->m_staticOpenGLContext.reset(QWindowsStaticOpenGLContext::create());
480 return d->m_staticOpenGLContext.data();
481}
482#endif // !QT_NO_OPENGL
483
485{
486 if (!d->m_fontDatabase) {
487#ifndef QT_NO_FREETYPE
490 else
491#endif // QT_NO_FREETYPE
492#if QT_CONFIG(directwrite3)
495 else
496#endif
498 }
499 return d->m_fontDatabase;
500}
501
502#ifdef SPI_GETKEYBOARDSPEED
503static inline int keyBoardAutoRepeatRateMS()
504{
505 DWORD time = 0;
506 if (SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &time, 0))
507 return time ? 1000 / static_cast<int>(time) : 500;
508 return 30;
509}
510#endif
511
513{
514 switch (hint) {
516 if (const unsigned timeMS = GetCaretBlinkTime())
517 return QVariant(timeMS != INFINITE ? int(timeMS) * 2 : 0);
518 break;
519#ifdef SPI_GETKEYBOARDSPEED
521 return QVariant(keyBoardAutoRepeatRateMS());
522#endif
530 break; // Not implemented
534 if (const UINT ms = GetDoubleClickTime())
535 return QVariant(int(ms));
536 break;
539 default:
540 break;
541 }
543}
544
549
550#if QT_CONFIG(clipboard)
552{
553 return &d->m_clipboard;
554}
555# if QT_CONFIG(draganddrop)
556QPlatformDrag *QWindowsIntegration::drag() const
557{
558 return &d->m_drag;
559}
560# endif // QT_CONFIG(draganddrop)
561#endif // !QT_NO_CLIPBOARD
562
567
568#if QT_CONFIG(accessibility)
569QPlatformAccessibility *QWindowsIntegration::accessibility() const
570{
571 return &d->m_accessibility;
572}
573#endif
574
576{
577 return d->m_options;
578}
579
580#if QT_CONFIG(sessionmanager)
582{
583 return new QWindowsSessionManager(id, key);
584}
585#endif
586
591
596
603
608
610{
611 MessageBeep(MB_OK); // For QApplication
612}
613
615{
616 // Clamp to positive numbers, as the Windows API doesn't support negative numbers
617 number = qMax(0, number);
618
619 // Persist, so we can re-apply it on setting changes and Explorer restart
620 m_applicationBadgeNumber = number;
621
622 static const bool isWindows11 = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11;
623
624#if QT_CONFIG(cpp_winrt)
625 // We prefer the native BadgeUpdater API, that allows us to set a number directly,
626 // but it requires that the application has a package identity, and also doesn't
627 // seem to work in all cases on < Windows 11.
628 QT_TRY {
629 if (isWindows11 && qt_win_hasPackageIdentity()) {
630 using namespace winrt::Windows::UI::Notifications;
631 auto badgeXml = BadgeUpdateManager::GetTemplateContent(BadgeTemplateType::BadgeNumber);
632 badgeXml.SelectSingleNode(L"//badge/@value").NodeValue(winrt::box_value(winrt::to_hstring(number)));
633 BadgeUpdateManager::CreateBadgeUpdaterForApplication().Update(BadgeNotification(badgeXml));
634 return;
635 }
636 } QT_CATCH(...) {
637 // fall back to win32 implementation
638 }
639#endif
640
641 // Fallback for non-packaged apps, Windows 10, or Qt builds without WinRT/C++ support
642
643 if (!number) {
644 // Clear badge
646 return;
647 }
648
649 const bool isDarkMode = QWindowsTheme::instance()->colorScheme()
651
652 QColor badgeColor;
653 QColor textColor;
654
655#if QT_CONFIG(cpp_winrt)
656 if (isWindows11) {
657 // Match colors used by BadgeUpdater
658 static const auto fromUIColor = [](winrt::Windows::UI::Color &&color) {
659 return QColor(color.R, color.G, color.B, color.A);
660 };
661 using namespace winrt::Windows::UI::ViewManagement;
662 const auto settings = UISettings();
663 badgeColor = fromUIColor(settings.GetColorValue(isDarkMode ?
664 UIColorType::AccentLight2 : UIColorType::Accent));
665 textColor = fromUIColor(settings.GetColorValue(UIColorType::Background));
666 }
667#endif
668
669 if (!badgeColor.isValid()) {
670 // Fall back to basic badge colors, based on Windows 10 look
671 badgeColor = isDarkMode ? Qt::black : QColor(220, 220, 220);
672 badgeColor.setAlphaF(0.5f);
673 textColor = isDarkMode ? Qt::white : Qt::black;
674 }
675
676 const auto devicePixelRatio = qApp->devicePixelRatio();
677
678 static const QSize iconBaseSize(16, 16);
679 QImage image(iconBaseSize * devicePixelRatio,
682
684
685 QRect badgeRect = image.rect();
686 QPen badgeBorderPen = Qt::NoPen;
687 if (!isWindows11) {
688 QColor badgeBorderColor = textColor;
689 badgeBorderColor.setAlphaF(0.5f);
690 badgeBorderPen = badgeBorderColor;
691 badgeRect.adjust(1, 1, -1, -1);
692 }
693 painter.setBrush(badgeColor);
694 painter.setPen(badgeBorderPen);
696 painter.drawEllipse(badgeRect);
697
698 auto pixelSize = qCeil(10.5 * devicePixelRatio);
699 // Unlike the BadgeUpdater API we're limited by a square
700 // badge, so adjust the font size when above two digits.
701 const bool textOverflow = number > 99;
702 if (textOverflow)
703 pixelSize *= 0.8;
704
706 font.setPixelSize(pixelSize);
709
710 painter.setRenderHint(QPainter::TextAntialiasing, devicePixelRatio > 1);
711 painter.setPen(textColor);
712
713 auto text = textOverflow ? u"99+"_s : QString::number(number);
714 painter.translate(textOverflow ? 1 : 0, textOverflow ? 0 : -1);
716
717 painter.end();
718
720}
721
723{
724 QComHelper comHelper;
725
727
728 ComPtr<ITaskbarList3> taskbarList;
729 CoCreateInstance(CLSID_TaskbarList, nullptr,
730 CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbarList));
731 if (!taskbarList) {
732 // There may not be any windows with a task bar button yet,
733 // in which case we'll apply the badge once a window with
734 // a button has been created.
735 return;
736 }
737
738 const auto hIcon = image.toHICON();
739
740 // Apply the icon to all top level windows, since the badge is
741 // set on an application level. If one of the windows go away
742 // the other windows will take over in showing the badge.
743 const auto topLevelWindows = QGuiApplication::topLevelWindows();
744 for (auto *topLevelWindow : topLevelWindows) {
745 if (!topLevelWindow->handle())
746 continue;
747 auto hwnd = reinterpret_cast<HWND>(topLevelWindow->winId());
748 taskbarList->SetOverlayIcon(hwnd, hIcon, L"");
749 }
750
751 DestroyIcon(hIcon);
752
753 // FIXME: Update icon when the application scale factor changes.
754 // Doing so in response to screen DPI changes is too soon, as the
755 // task bar is not yet ready for an updated icon, and will just
756 // result in a blurred icon even if our icon is high-DPI.
757}
758
760{
761 // The system color settings have changed, or we are reacting
762 // to a task bar button being created for the fist time or after
763 // Explorer had crashed and re-started. In any case, re-apply the
764 // badge so that everything is up to date.
765 if (m_applicationBadgeNumber)
766 setApplicationBadge(m_applicationBadgeNumber);
767}
768
769#if QT_CONFIG(vulkan)
770QPlatformVulkanInstance *QWindowsIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
771{
773}
774#endif
775
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
void setAlphaF(float alpha)
Sets the alpha of this color to alpha.
Definition qcolor.cpp:1511
static void setAttribute(Qt::ApplicationAttribute attribute, bool on=true)
Sets the attribute attribute if on is true; otherwise clears the attribute.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
\reentrant
Definition qfont.h:22
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
Definition qfont.cpp:1049
@ DemiBold
Definition qfont.h:69
@ Medium
Definition qfont.h:68
void setWeight(Weight weight)
Sets the weight of the font to weight, using the scale defined by \l QFont::Weight enumeration.
Definition qfont.cpp:1205
static QWindowList topLevelWindows()
Returns a list of the top-level windows in the application.
\inmodule QtGui
Definition qimage.h:37
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
\inmodule QtCore
Definition qmutex.h:313
\inmodule QtCore
Definition qmutex.h:281
Native interface to QPlatformWindow. \inmodule QtGui.
static QOpenGLContextPrivate * get(QOpenGLContext *context)
\inmodule QtGui
OpenGLModuleType
This enum defines the type of the underlying OpenGL implementation.
static Q_CORE_EXPORT QOperatingSystemVersionBase current()
static constexpr QOperatingSystemVersionBase Windows11
\variable QOperatingSystemVersion::Windows11
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const QFont & font() const
Returns the currently set font used for drawing text.
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
@ Antialiasing
Definition qpainter.h:52
@ TextAntialiasing
Definition qpainter.h:53
bool end()
Ends painting.
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint.
\inmodule QtGui
Definition qpen.h:28
The QPlatformClipboard class provides an abstraction for the system clipboard.
static void setCapability(Capability c)
The QPlatformDrag class provides an abstraction for drag.
The QPlatformFontDatabase class makes it possible to customize how fonts are discovered and how they ...
static QPlatformInputContext * create()
The QPlatformInputContext class abstracts the input method dependent data and composing state.
virtual QPlatformSessionManager * createPlatformSessionManager(const QString &id, const QString &key) const
virtual QVariant styleHint(StyleHint hint) const
virtual bool hasCapability(Capability cap) const
virtual QPlatformClipboard * clipboard() const
Accessor for the platform integration's clipboard.
virtual QPlatformTheme * createPlatformTheme(const QString &name) const
Capability
Capabilities are used to determine specific features of a platform integration.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
The QPlatformScreen class provides an abstraction for visual displays.
The QPlatformServices provides the backend for desktop-related functionality.
The QPlatformTheme class allows customizing the UI based on themes.
The QPlatformVulkanInstance class provides an abstraction for Vulkan instances.
The QPlatformWindow class provides an abstraction for top-level windows.
\inmodule QtCore\reentrant
Definition qrect.h:30
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
Definition qstring.h:731
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition qstring.cpp:5455
qsizetype size() const noexcept
Returns the number of characters in this string.
Definition qstring.h:186
QString right(qsizetype n) const &
Definition qstring.h:375
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8084
\inmodule QtCore
Definition qvariant.h:65
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
\inmodule QtGui
Definition qwindow.h:63
Clipboard implementation.
Singleton container for all relevant information.
QWindowsScreenManager & screenManager()
static bool setProcessDpiAwareness(QtWindows::DpiAwareness dpiAwareness)
static bool shouldHaveNonClientDpiScaling(const QWindow *window)
static void setTabletAbsoluteRange(int a)
static QtWindows::DpiAwareness processDpiAwareness()
QPlatformKeyMapper * keyMapper() const
bool useRTLExtensions() const
bool initPointer(unsigned integrationOptions)
bool initPowerNotificationHandler()
void setDetectAltGrModifier(bool a)
Window wrapping GetDesktopWindow not allowing any manipulation.
Windows drag implementation.
Font database for Windows.
static void setFontOptions(unsigned options)
Window wrapping a foreign native window.
Event dispatcher for Windows.
Windows Input context implementation.
QStringList themeNames() const override
QPlatformKeyMapper * keyMapper() const override
Accessor for the platform integration's key mapper.
QPlatformWindow * createPlatformWindow(QWindow *window) const override
Factory function for QPlatformWindow.
static QWindowsStaticOpenGLContext * staticOpenGLContext()
virtual QWindowsWindow * createPlatformWindowHelper(QWindow *window, const QWindowsWindowData &) const
QOpenGLContext * createOpenGLContext(HGLRC context, HWND window, QOpenGLContext *shareContext) const override
QWindowsIntegration(const QStringList &paramList)
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QPlatformTheme * createPlatformTheme(const QString &name) const override
bool hasCapability(QPlatformIntegration::Capability cap) const override
QOpenGLContext::OpenGLModuleType openGLModuleType() override
Platform integration function for querying the OpenGL implementation type.
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QPlatformWindow * createForeignWindow(QWindow *window, WId nativeHandle) const override
void initialize() override
Performs initialization steps that depend on having an event dispatcher available.
void setApplicationBadge(qint64 number) override
static QWindowsIntegration * instance()
HMODULE openGLModuleHandle() const override
void beep() const override
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
QPlatformServices * services() const override
QVariant styleHint(StyleHint hint) const override
QPlatformOpenGLContext * createPlatformOpenGLContext(QOpenGLContext *context) const override
Factory function for QPlatformOpenGLContext.
Windows native menu bar.
static QWindowsMenuBar * menuBarOf(const QWindow *notYetCreatedWindow)
static Renderer requestedRenderer()
static QWindowsOpenGLTester::Renderers supportedRenderers(Renderer requested)
static bool setOrientationPreference(Qt::ScreenOrientation o)
static QWindowsStaticOpenGLContext * create()
static const char * name
static QWindowsTheme * instance()
static QString formatWindowTitle(const QString &title)
EGLContext ctx
QString text
T toNativePixels(const T &value, const C *context)
T toNativeLocalPosition(const T &value, const C *context)
Combined button and popup list for selecting options.
@ AlignCenter
Definition qnamespace.h:163
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
@ LandscapeOrientation
Definition qnamespace.h:274
QTextStream & noshowbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) on stream and ...
@ white
Definition qnamespace.h:31
@ transparent
Definition qnamespace.h:47
@ black
Definition qnamespace.h:30
@ NoPen
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
@ AA_DisableShaderDiskCache
Definition qnamespace.h:462
@ AA_PluginApplication
Definition qnamespace.h:430
@ AA_CompressHighFrequencyEvents
Definition qnamespace.h:460
@ Desktop
Definition qnamespace.h:215
@ FramelessWindowHint
Definition qnamespace.h:225
Definition image.cpp:4
static void * context
#define Q_UNLIKELY(x)
QList< QString > QStringList
Constructs a string list that contains the given string, str.
#define qApp
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define QT_CATCH(A)
#define QT_TRY
bool qt_win_hasPackageIdentity()
#define qWarning
Definition qlogging.h:166
#define qCWarning(category,...)
#define qCDebug(category,...)
bool isDarkMode()
int qCeil(T v)
Definition qmath.h:36
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLuint64 key
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint color
[2]
GLenum target
GLenum const GLint * param
GLuint name
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLuint GLenum option
GLenum cap
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
static void initOpenGlBlacklistResources()
QNativeInterface::Private::QWindowsApplication::DarkModeHandlingFlag DarkModeHandlingFlag
QNativeInterface::Private::QWindowsApplication::DarkModeHandling DarkModeHandling
bool parseIntOption(const QString &parameter, const QLatin1StringView &option, IntType minimumValue, IntType maximumValue, IntType *target)
Options parseOptions()
Definition main.cpp:369
QScreen * screen
[1]
Definition main.cpp:29
#define Q_INIT_RESOURCE(name)
Definition qtresource.h:14
long long qint64
Definition qtypes.h:60
HINSTANCE HMODULE
#define explicit
QSettings settings("MySoft", "Star Runner")
[0]
QReadWriteLock lock
[0]
QPainter painter(this)
[7]
aWidget window() -> setWindowTitle("New Window Title")
[2]
static bool positionIncludesFrame(const QWindow *w)
QPlatformFontDatabase * m_fontDatabase
QScopedPointer< QWindowsStaticOpenGLContext > m_staticOpenGLContext
void parseOptions(QWindowsIntegration *q, const QStringList &paramList)
QScopedPointer< QPlatformInputContext > m_inputContext
Qt::WindowFlags flags
static QWindowsWindowData create(const QWindow *w, const QWindowsWindowData &parameters, const QString &title)