Qt 6.x
The Qt SDK
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
109{
110 Q_DISABLE_COPY_MOVE(QWindowsIntegrationPrivate)
113
114 void parseOptions(QWindowsIntegration *q, const QStringList &paramList);
115
116 unsigned m_options = 0;
119#if QT_CONFIG(clipboard)
120 QWindowsClipboard m_clipboard;
121# if QT_CONFIG(draganddrop)
122 QWindowsDrag m_drag;
123# endif
124#endif
125#ifndef QT_NO_OPENGL
128#endif // QT_NO_OPENGL
130#if QT_CONFIG(accessibility)
131 QWindowsUiaAccessibility m_accessibility;
132#endif
134};
135
136template <typename IntType>
137bool parseIntOption(const QString &parameter,const QLatin1StringView &option,
138 IntType minimumValue, IntType maximumValue, IntType *target)
139{
140 const int valueLength = parameter.size() - option.size() - 1;
141 if (valueLength < 1 || !parameter.startsWith(option) || parameter.at(option.size()) != u'=')
142 return false;
143 bool ok;
144 const auto valueRef = QStringView{parameter}.right(valueLength);
145 const int value = valueRef.toInt(&ok);
146 if (ok) {
147 if (value >= int(minimumValue) && value <= int(maximumValue))
148 *target = static_cast<IntType>(value);
149 else {
150 qWarning() << "Value" << value << "for option" << option << "out of range"
151 << minimumValue << ".." << maximumValue;
152 }
153 } else {
154 qWarning() << "Invalid value" << valueRef << "for option" << option;
155 }
156 return true;
157}
158
159using DarkModeHandlingFlag = QNativeInterface::Private::QWindowsApplication::DarkModeHandlingFlag;
160using DarkModeHandling = QNativeInterface::Private::QWindowsApplication::DarkModeHandling;
161
162static inline unsigned parseOptions(const QStringList &paramList,
163 int *tabletAbsoluteRange,
164 QtWindows::DpiAwareness *dpiAwareness,
165 DarkModeHandling *darkModeHandling)
166{
167 unsigned options = 0;
168 for (const QString &param : paramList) {
169 if (param.startsWith(u"fontengine=")) {
170 if (param.endsWith(u"directwrite")) {
172 } else if (param.endsWith(u"freetype")) {
174 } else if (param.endsWith(u"native")) {
176 }
177 } else if (param.startsWith(u"dialogs=")) {
178 if (param.endsWith(u"xp")) {
180 } else if (param.endsWith(u"none")) {
182 }
183 } else if (param == u"altgr") {
185 } else if (param == u"gl=gdi") {
187 } else if (param == u"nodirectwrite") {
189 } else if (param == u"nocolorfonts") {
191 } else if (param == u"nomousefromtouch") {
193 } else if (parseIntOption(param, "verbose"_L1, 0, INT_MAX, &QWindowsContext::verbose)
194 || parseIntOption(param, "tabletabsoluterange"_L1, 0, INT_MAX, tabletAbsoluteRange)
197 } else if (param == u"menus=native") {
199 } else if (param == u"menus=none") {
201 } else if (param == u"nowmpointer") {
203 } else if (param == u"reverse") {
205 } else if (param == u"darkmode=0") {
206 *darkModeHandling = {};
207 } else if (param == u"darkmode=1") {
208 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeWindowFrames);
209 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeStyle, false);
210 } else if (param == u"darkmode=2") {
211 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeWindowFrames);
212 darkModeHandling->setFlag(DarkModeHandlingFlag::DarkModeStyle);
213 } else {
214 qWarning() << "Unknown option" << param;
215 }
216 }
217 return options;
218}
219
221{
223
224 static bool dpiAwarenessSet = false;
225 // Default to per-monitor-v2 awareness (if available)
227
228 int tabletAbsoluteRange = -1;
229 DarkModeHandling darkModeHandling = DarkModeHandlingFlag::DarkModeWindowFrames
230 | DarkModeHandlingFlag::DarkModeStyle;
231 m_options = ::parseOptions(paramList, &tabletAbsoluteRange, &dpiAwareness, &darkModeHandling);
232 q->setDarkModeHandling(darkModeHandling);
234 if (tabletAbsoluteRange >= 0)
235 QWindowsContext::setTabletAbsoluteRange(tabletAbsoluteRange);
236
239 else
242
243 if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication.
245 m_context.setProcessDpiAwareness(dpiAwareness);
246 qCDebug(lcQpaWindow) << "DpiAwareness=" << dpiAwareness
247 << "effective process DPI awareness=" << QWindowsContext::processDpiAwareness();
248 }
249 dpiAwarenessSet = true;
250 }
251
254
256}
257
259{
260 delete m_fontDatabase;
261}
262
263QWindowsIntegration *QWindowsIntegration::m_instance = nullptr;
264
267{
268 m_instance = this;
269 d->parseOptions(this, paramList);
270#if QT_CONFIG(clipboard)
271 d->m_clipboard.registerViewer();
272#endif
275}
276
278{
279 m_instance = nullptr;
280}
281
283{
287}
288
290{
291 switch (cap) {
292 case ThreadedPixmaps:
293 return true;
294#ifndef QT_NO_OPENGL
295 case OpenGL:
296 return true;
297 case ThreadedOpenGL:
299 return glContext->supportsThreadedOpenGL();
300 return false;
301#endif // !QT_NO_OPENGL
302 case WindowMasks:
303 return true;
304 case MultipleWindows:
305 return true;
306 case ForeignWindows:
307 return true;
308 case RasterGLSurface:
309 return true;
311 return true;
313 return false; // QTBUG-68329 QTBUG-53515 QTBUG-54734
314 default:
316 }
317 return false;
318}
319
321{
322 if (window->type() == Qt::Desktop) {
324 qCDebug(lcQpaWindow) << "Desktop window:" << window
325 << Qt::showbase << Qt::hex << result->winId() << Qt::noshowbase << Qt::dec << result->geometry();
326 return result;
327 }
328
329 QWindowsWindowData requested;
330 requested.flags = window->flags();
331 requested.geometry = window->isTopLevel()
334 if (!(requested.flags & Qt::FramelessWindowHint)) {
335 // Apply custom margins (see QWindowsWindow::setCustomMargins())).
336 const QVariant customMarginsV = window->property("_q_windowsCustomMargins");
337 if (customMarginsV.isValid())
338 requested.customMargins = qvariant_cast<QMargins>(customMarginsV);
339 }
340
341 QWindowsWindowData obtained =
344 qCDebug(lcQpaWindow).nospace()
345 << __FUNCTION__ << ' ' << window
346 << "\n Requested: " << requested.geometry << " frame incl.="
348 << ' ' << requested.flags
349 << "\n Obtained : " << obtained.geometry << " margins=" << obtained.fullFrameMargins
350 << " handle=" << obtained.hwnd << ' ' << obtained.flags << '\n';
351
352 if (Q_UNLIKELY(!obtained.hwnd))
353 return nullptr;
354
357
360
361 if (QWindowsMenuBar *menuBarToBeInstalled = QWindowsMenuBar::menuBarOf(window))
362 menuBarToBeInstalled->install(result);
363
364 return result;
365}
366
368{
369 const HWND hwnd = reinterpret_cast<HWND>(nativeHandle);
370 if (!IsWindow(hwnd)) {
371 qWarning("Windows QPA: Invalid foreign window ID %p.", hwnd);
372 return nullptr;
373 }
374 auto *result = new QWindowsForeignWindow(window, hwnd);
375 const QRect obtainedGeometry = result->geometry();
376 QScreen *screen = nullptr;
377 if (const QPlatformScreen *pScreen = result->screenForGeometry(obtainedGeometry))
378 screen = pScreen->screen();
379 if (screen && screen != window->screen())
380 window->setScreen(screen);
381 qCDebug(lcQpaWindow) << "Foreign window:" << window << Qt::showbase << Qt::hex
382 << result->winId() << Qt::noshowbase << Qt::dec << obtainedGeometry << screen;
383 return result;
384}
385
386// Overridden to return a QWindowsDirect2DWindow in Direct2D plugin.
388{
389 return new QWindowsWindow(window, data);
390}
391
392#ifndef QT_NO_OPENGL
393
394QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate()
395{
396#if defined(QT_OPENGL_DYNAMIC)
398 switch (requestedRenderer) {
403 qCWarning(lcQpaGl, "Unable to disable rotation.");
404 }
405 return glCtx;
406 }
407 qCWarning(lcQpaGl, "System OpenGL failed. Falling back to Software OpenGL.");
408 return QOpenGLStaticContext::create(true);
411 return swCtx;
412 qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL.");
415 return nullptr;
416 default:
417 break;
418 }
419
420 const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(requestedRenderer);
421 if (supportedRenderers.testFlag(QWindowsOpenGLTester::DisableProgramCacheFlag)
424 }
425 if (supportedRenderers & QWindowsOpenGLTester::DesktopGl) {
427 if ((supportedRenderers & QWindowsOpenGLTester::DisableRotationFlag)
429 qCWarning(lcQpaGl, "Unable to disable rotation.");
430 }
431 return glCtx;
432 }
433 }
434 return QOpenGLStaticContext::create(true);
435#else
437#endif
438}
439
441{
442 return QWindowsStaticOpenGLContext::doCreate();
443}
444
446{
447 qCDebug(lcQpaGl) << __FUNCTION__ << context->format();
449 std::unique_ptr<QWindowsOpenGLContext> result(staticOpenGLContext->createContext(context));
450 if (result->isValid())
451 return result.release();
452 }
453 return nullptr;
454}
455
457{
458#if !defined(QT_OPENGL_DYNAMIC)
460#else
464#endif
465}
466
468{
470 return static_cast<HMODULE>(staticOpenGLContext->moduleHandle());
471
472 return nullptr;
473}
474
476{
477 if (!ctx || !window)
478 return nullptr;
479
481 std::unique_ptr<QWindowsOpenGLContext> result(staticOpenGLContext->createContext(ctx, window));
482 if (result->isValid()) {
483 auto *context = new QOpenGLContext;
484 context->setShareContext(shareContext);
485 auto *contextPrivate = QOpenGLContextPrivate::get(context);
486 contextPrivate->adopt(result.release());
487 return context;
488 }
489 }
490
491 return nullptr;
492}
493
495{
497 if (!integration)
498 return nullptr;
499 QWindowsIntegrationPrivate *d = integration->d.data();
500 QMutexLocker lock(&d->m_staticContextLock);
501 if (d->m_staticOpenGLContext.isNull())
502 d->m_staticOpenGLContext.reset(QWindowsStaticOpenGLContext::create());
503 return d->m_staticOpenGLContext.data();
504}
505#endif // !QT_NO_OPENGL
506
508{
509 if (!d->m_fontDatabase) {
510#if QT_CONFIG(directwrite3)
513 else
514#endif
515#ifndef QT_NO_FREETYPE
518 else
519#endif // QT_NO_FREETYPE
521 }
522 return d->m_fontDatabase;
523}
524
525#ifdef SPI_GETKEYBOARDSPEED
526static inline int keyBoardAutoRepeatRateMS()
527{
528 DWORD time = 0;
529 if (SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &time, 0))
530 return time ? 1000 / static_cast<int>(time) : 500;
531 return 30;
532}
533#endif
534
536{
537 switch (hint) {
539 if (const unsigned timeMS = GetCaretBlinkTime())
540 return QVariant(timeMS != INFINITE ? int(timeMS) * 2 : 0);
541 break;
542#ifdef SPI_GETKEYBOARDSPEED
544 return QVariant(keyBoardAutoRepeatRateMS());
545#endif
553 break; // Not implemented
557 if (const UINT ms = GetDoubleClickTime())
558 return QVariant(int(ms));
559 break;
562 default:
563 break;
564 }
566}
567
569{
571}
572
574{
575 return d->m_context.possibleKeys(e);
576}
577
578#if QT_CONFIG(clipboard)
580{
581 return &d->m_clipboard;
582}
583# if QT_CONFIG(draganddrop)
584QPlatformDrag *QWindowsIntegration::drag() const
585{
586 return &d->m_drag;
587}
588# endif // QT_CONFIG(draganddrop)
589#endif // !QT_NO_CLIPBOARD
590
592{
593 return d->m_inputContext.data();
594}
595
596#if QT_CONFIG(accessibility)
597QPlatformAccessibility *QWindowsIntegration::accessibility() const
598{
599 return &d->m_accessibility;
600}
601#endif
602
604{
605 return d->m_options;
606}
607
608#if QT_CONFIG(sessionmanager)
610{
611 return new QWindowsSessionManager(id, key);
612}
613#endif
614
616{
618}
619
621{
623}
624
626{
628 return new QWindowsTheme;
630}
631
633{
634 return &d->m_services;
635}
636
638{
639 MessageBeep(MB_OK); // For QApplication
640}
641
643{
644 // Clamp to positive numbers, as the Windows API doesn't support negative numbers
645 number = qMax(0, number);
646
647 // Persist, so we can re-apply it on setting changes and Explorer restart
648 m_applicationBadgeNumber = number;
649
650 static const bool isWindows11 = QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11;
651
652#if QT_CONFIG(cpp_winrt)
653 // We prefer the native BadgeUpdater API, that allows us to set a number directly,
654 // but it requires that the application has a package identity, and also doesn't
655 // seem to work in all cases on < Windows 11.
656 if (isWindows11 && qt_win_hasPackageIdentity()) {
657 using namespace winrt::Windows::UI::Notifications;
658 auto badgeXml = BadgeUpdateManager::GetTemplateContent(BadgeTemplateType::BadgeNumber);
659 badgeXml.SelectSingleNode(L"//badge/@value").NodeValue(winrt::box_value(winrt::to_hstring(number)));
660 BadgeUpdateManager::CreateBadgeUpdaterForApplication().Update(BadgeNotification(badgeXml));
661 return;
662 }
663#endif
664
665 // Fallback for non-packaged apps, Windows 10, or Qt builds without WinRT/C++ support
666
667 if (!number) {
668 // Clear badge
670 return;
671 }
672
674
675 QColor badgeColor;
676 QColor textColor;
677
678#if QT_CONFIG(cpp_winrt)
679 if (isWindows11) {
680 // Match colors used by BadgeUpdater
681 static const auto fromUIColor = [](winrt::Windows::UI::Color &&color) {
682 return QColor(color.R, color.G, color.B, color.A);
683 };
684 using namespace winrt::Windows::UI::ViewManagement;
685 const auto settings = UISettings();
686 badgeColor = fromUIColor(settings.GetColorValue(isDarkMode ?
687 UIColorType::AccentLight2 : UIColorType::Accent));
688 textColor = fromUIColor(settings.GetColorValue(UIColorType::Background));
689 }
690#endif
691
692 if (!badgeColor.isValid()) {
693 // Fall back to basic badge colors, based on Windows 10 look
694 badgeColor = isDarkMode ? Qt::black : QColor(220, 220, 220);
695 badgeColor.setAlphaF(0.5f);
696 textColor = isDarkMode ? Qt::white : Qt::black;
697 }
698
699 const auto devicePixelRatio = qApp->devicePixelRatio();
700
701 static const QSize iconBaseSize(16, 16);
702 QImage image(iconBaseSize * devicePixelRatio,
705
707
708 QRect badgeRect = image.rect();
709 QPen badgeBorderPen = Qt::NoPen;
710 if (!isWindows11) {
711 QColor badgeBorderColor = textColor;
712 badgeBorderColor.setAlphaF(0.5f);
713 badgeBorderPen = badgeBorderColor;
714 badgeRect.adjust(1, 1, -1, -1);
715 }
716 painter.setBrush(badgeColor);
717 painter.setPen(badgeBorderPen);
719 painter.drawEllipse(badgeRect);
720
721 auto pixelSize = qCeil(10.5 * devicePixelRatio);
722 // Unlike the BadgeUpdater API we're limited by a square
723 // badge, so adjust the font size when above two digits.
724 const bool textOverflow = number > 99;
725 if (textOverflow)
726 pixelSize *= 0.8;
727
729 font.setPixelSize(pixelSize);
732
733 painter.setRenderHint(QPainter::TextAntialiasing, devicePixelRatio > 1);
734 painter.setPen(textColor);
735
736 auto text = textOverflow ? u"99+"_s : QString::number(number);
737 painter.translate(textOverflow ? 1 : 0, textOverflow ? 0 : -1);
739
740 painter.end();
741
743}
744
746{
747 QComHelper comHelper;
748
750
751 ComPtr<ITaskbarList3> taskbarList;
752 CoCreateInstance(CLSID_TaskbarList, nullptr,
753 CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbarList));
754 if (!taskbarList) {
755 // There may not be any windows with a task bar button yet,
756 // in which case we'll apply the badge once a window with
757 // a button has been created.
758 return;
759 }
760
761 const auto hIcon = image.toHICON();
762
763 // Apply the icon to all top level windows, since the badge is
764 // set on an application level. If one of the windows go away
765 // the other windows will take over in showing the badge.
766 const auto topLevelWindows = QGuiApplication::topLevelWindows();
767 for (auto *topLevelWindow : topLevelWindows) {
768 if (!topLevelWindow->handle())
769 continue;
770 auto hwnd = reinterpret_cast<HWND>(topLevelWindow->winId());
771 taskbarList->SetOverlayIcon(hwnd, hIcon, L"");
772 }
773
774 DestroyIcon(hIcon);
775
776 // FIXME: Update icon when the application scale factor changes.
777 // Doing so in response to screen DPI changes is too soon, as the
778 // task bar is not yet ready for an updated icon, and will just
779 // result in a blurred icon even if our icon is high-DPI.
780}
781
783{
784 // The system color settings have changed, or we are reacting
785 // to a task bar button being created for the fist time or after
786 // Explorer had crashed and re-started. In any case, re-apply the
787 // badge so that everything is up to date.
788 setApplicationBadge(m_applicationBadgeNumber);
789}
790
791#if QT_CONFIG(vulkan)
792QPlatformVulkanInstance *QWindowsIntegration::createPlatformVulkanInstance(QVulkanInstance *instance) const
793{
795}
796#endif
797
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
bool isValid() const noexcept
Returns true if the color is valid; otherwise returns false.
Definition qcolor.h:285
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:20
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
Definition qfont.cpp:1034
@ DemiBold
Definition qfont.h:66
@ Medium
Definition qfont.h:65
void setWeight(Weight weight)
Sets the weight of the font to weight, using the scale defined by \l QFont::Weight enumeration.
Definition qfont.cpp:1190
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
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
\inmodule QtCore
Definition qmutex.h:317
\inmodule QtCore
Definition qmutex.h:285
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 QOperatingSystemVersion current()
[0]
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:25
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
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition qrect.h:372
\inmodule QtCore
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:76
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString right(qsizetype n) const
Returns a substring that contains the n rightmost characters of the string.
Definition qstring.cpp:5180
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:660
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:5299
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition qstring.h:898
qsizetype size() const
Returns the number of characters in this string.
Definition qstring.h:182
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1079
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:7822
\inmodule QtCore
Definition qvariant.h:64
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:707
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
\inmodule QtGui
Definition qwindow.h:63
bool isDarkMode() const override
Clipboard implementation.
Singleton container for all relevant information.
static bool isDarkMode()
QWindowsScreenManager & screenManager()
static bool setProcessDpiAwareness(QtWindows::DpiAwareness dpiAwareness)
static bool shouldHaveNonClientDpiScaling(const QWindow *window)
static void setTabletAbsoluteRange(int a)
QList< int > possibleKeys(const QKeyEvent *e) const
static QtWindows::DpiAwareness processDpiAwareness()
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.
QPlatformIntegration implementation for Windows.
QStringList themeNames() const override
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
Qt::KeyboardModifiers queryKeyboardModifiers() 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
QList< int > possibleKeys(const QKeyEvent *e) const override
Should be used to obtain a list of possible shortcuts for the given key event.
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.
static Qt::KeyboardModifiers queryKeyboardModifiers()
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)
virtual QOpenGLContext::OpenGLModuleType moduleType() const =0
virtual void * moduleHandle() const =0
static QWindowsStaticOpenGLContext * create()
virtual QWindowsOpenGLContext * createContext(QOpenGLContext *context)=0
static const char * name
static QString formatWindowTitle(const QString &title)
EGLContext ctx
QString text
double e
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:162
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:273
QTextStream & noshowbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) on stream and ...
@ white
Definition qnamespace.h:30
@ transparent
Definition qnamespace.h:46
@ black
Definition qnamespace.h:29
@ NoPen
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
@ AA_DisableShaderDiskCache
Definition qnamespace.h:461
@ AA_PluginApplication
Definition qnamespace.h:429
@ AA_CompressHighFrequencyEvents
Definition qnamespace.h:459
@ Desktop
Definition qnamespace.h:214
@ FramelessWindowHint
Definition qnamespace.h:224
Definition image.cpp:4
static void * context
#define Q_UNLIKELY(x)
#define qApp
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qt_win_hasPackageIdentity()
#define qWarning
Definition qlogging.h:162
#define qCWarning(category,...)
#define qCDebug(category,...)
int qCeil(T v)
Definition qmath.h:36
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLuint64 key
GLenum target
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
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:367
QScreen * screen
[1]
Definition main.cpp:29
#define Q_INIT_RESOURCE(name)
Definition qtresource.h:14
long long qint64
Definition qtypes.h:55
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)