15#include <QtGui/private/qtgui-config_p.h>
16#if QT_CONFIG(directwrite3)
17#include <QtGui/private/qwindowsdirectwritefontdatabase_p.h>
20# include <QtGui/private/qwindowsfontdatabase_ft_p.h>
22#include <QtGui/private/qwindowsfontdatabase_p.h>
23#if QT_CONFIG(clipboard)
25# if QT_CONFIG(draganddrop)
31#if QT_CONFIG(accessibility)
35#include <qpa/qplatformnativeinterface.h>
36#include <qpa/qwindowsysteminterface.h>
37#if QT_CONFIG(sessionmanager)
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>
46#include <QtGui/private/qwindowsguieventdispatcher_p.h>
48#include <QtCore/qdebug.h>
49#include <QtCore/qvariant.h>
51#include <QtCore/qoperatingsystemversion.h>
52#include <QtCore/private/qfunctions_win_p.h>
58#if !defined(QT_NO_OPENGL)
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>
94#if QT_CONFIG(clipboard)
96# if QT_CONFIG(draganddrop)
105#if QT_CONFIG(accessibility)
106 QWindowsUiaAccessibility m_accessibility;
111template <
typename IntType>
113 IntType minimumValue, IntType maximumValue, IntType *
target)
115 const int valueLength = parameter.
size() -
option.size() - 1;
122 if (
value >=
int(minimumValue) &&
value <=
int(maximumValue))
126 << minimumValue <<
".." << maximumValue;
129 qWarning() <<
"Invalid value" << valueRef <<
"for option" <<
option;
138 int *tabletAbsoluteRange,
142 unsigned options = 0;
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")) {
152 }
else if (
param.startsWith(u
"dialogs=")) {
153 if (
param.endsWith(u
"xp")) {
155 }
else if (
param.endsWith(u
"none")) {
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") {
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);
199 static bool dpiAwarenessSet =
false;
203 int tabletAbsoluteRange = -1;
204 DarkModeHandling darkModeHandling = DarkModeHandlingFlag::DarkModeWindowFrames
205 | DarkModeHandlingFlag::DarkModeStyle;
207 q->setDarkModeHandling(darkModeHandling);
209 if (tabletAbsoluteRange >= 0)
218 if (!dpiAwarenessSet) {
221 qCDebug(lcQpaWindow) <<
"DpiAwareness=" << dpiAwareness
224 dpiAwarenessSet =
true;
245#if QT_CONFIG(clipboard)
246 d->m_clipboard.registerViewer();
254 m_instance =
nullptr;
274 return glContext->supportsThreadedOpenGL();
313 const QVariant customMarginsV =
window->property(
"_q_windowsCustomMargins");
314 if (customMarginsV.isValid())
315 requested.
customMargins = qvariant_cast<QMargins>(customMarginsV);
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';
339 menuBarToBeInstalled->install(
result);
346 const HWND hwnd =
reinterpret_cast<HWND
>(nativeHandle);
347 if (!IsWindow(hwnd)) {
348 qWarning(
"Windows QPA: Invalid foreign window ID %p.", hwnd);
355 screen = pScreen->screen();
373#if defined(QT_OPENGL_DYNAMIC)
375 switch (requestedRenderer) {
380 qCWarning(lcQpaGl,
"Unable to disable rotation.");
384 qCWarning(lcQpaGl,
"System OpenGL failed. Falling back to Software OpenGL.");
389 qCWarning(lcQpaGl,
"Software OpenGL failed. Falling back to system OpenGL.");
406 qCWarning(lcQpaGl,
"Unable to disable rotation.");
419 return QWindowsStaticOpenGLContext::doCreate();
435#if !defined(QT_OPENGL_DYNAMIC)
461 context->setShareContext(shareContext);
463 contextPrivate->adopt(
result.release());
478 if (
d->m_staticOpenGLContext.isNull())
480 return d->m_staticOpenGLContext.data();
487#ifndef QT_NO_FREETYPE
492#if QT_CONFIG(directwrite3)
502#ifdef SPI_GETKEYBOARDSPEED
503static inline int keyBoardAutoRepeatRateMS()
506 if (SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &
time, 0))
507 return time ? 1000 /
static_cast<int>(
time) : 500;
516 if (
const unsigned timeMS = GetCaretBlinkTime())
517 return QVariant(timeMS != INFINITE ?
int(timeMS) * 2 : 0);
519#ifdef SPI_GETKEYBOARDSPEED
521 return QVariant(keyBoardAutoRepeatRateMS());
534 if (
const UINT ms = GetDoubleClickTime())
550#if QT_CONFIG(clipboard)
553 return &d->m_clipboard;
555# if QT_CONFIG(draganddrop)
568#if QT_CONFIG(accessibility)
569QPlatformAccessibility *QWindowsIntegration::accessibility()
const
571 return &d->m_accessibility;
580#if QT_CONFIG(sessionmanager)
620 m_applicationBadgeNumber =
number;
624#if QT_CONFIG(cpp_winrt)
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));
655#if QT_CONFIG(cpp_winrt)
658 static const auto fromUIColor = [](winrt::Windows::UI::Color &&
color) {
661 using namespace winrt::Windows::UI::ViewManagement;
664 UIColorType::AccentLight2 : UIColorType::Accent));
665 textColor = fromUIColor(
settings.GetColorValue(UIColorType::Background));
669 if (!badgeColor.isValid()) {
672 badgeColor.setAlphaF(0.5f);
676 const auto devicePixelRatio =
qApp->devicePixelRatio();
678 static const QSize iconBaseSize(16, 16);
688 QColor badgeBorderColor = textColor;
690 badgeBorderPen = badgeBorderColor;
691 badgeRect.adjust(1, 1, -1, -1);
698 auto pixelSize =
qCeil(10.5 * devicePixelRatio);
701 const bool textOverflow =
number > 99;
724 QComHelper comHelper;
728 ComPtr<ITaskbarList3> taskbarList;
729 CoCreateInstance(CLSID_TaskbarList,
nullptr,
730 CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbarList));
738 const auto hIcon =
image.toHICON();
744 for (
auto *topLevelWindow : topLevelWindows) {
745 if (!topLevelWindow->handle())
747 auto hwnd =
reinterpret_cast<HWND
>(topLevelWindow->winId());
748 taskbarList->SetOverlayIcon(hwnd, hIcon, L
"");
765 if (m_applicationBadgeNumber)
The QColor class provides colors based on RGB, HSV or CMYK values.
void setAlphaF(float alpha)
Sets the alpha of this color to alpha.
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.
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
void setWeight(Weight weight)
Sets the weight of the font to weight, using the scale defined by \l QFont::Weight enumeration.
static QWindowList topLevelWindows()
Returns a list of the top-level windows in the application.
@ Format_ARGB32_Premultiplied
Native interface to QPlatformWindow. \inmodule QtGui.
static QOpenGLContextPrivate * get(QOpenGLContext *context)
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.
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.
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.
static QPlatformInputContext * create()
static QStringList requested()
The QPlatformInputContext class abstracts the input method dependent data and composing state.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
\inmodule QtCore\reentrant
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.
\macro QT_RESTRICTED_CAST_FROM_ASCII
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 ...
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
qsizetype size() const noexcept
Returns the number of characters in this string.
QString right(qsizetype n) const &
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
static void setPlatformSynthesizesMouse(bool v)
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 qreal fontSmoothingGamma()
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
~QWindowsIntegration() override
@ DontPassOsMouseEventsSynthesizedFromTouch
@ DontUseDirectWriteFonts
QOpenGLContext * createOpenGLContext(HGLRC context, HWND window, QOpenGLContext *shareContext) const override
QWindowsIntegration(const QStringList ¶mList)
void updateApplicationBadge()
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.
@ DisableProgramCacheFlag
static Renderer requestedRenderer()
static QWindowsOpenGLTester::Renderers supportedRenderers(Renderer requested)
static bool setOrientationPreference(Qt::ScreenOrientation o)
static QWindowsStaticOpenGLContext * create()
static QWindowsTheme * instance()
static QString formatWindowTitle(const QString &title)
@ DisableNonClientScaling
T toNativePixels(const T &value, const C *context)
T toNativeLocalPosition(const T &value, const C *context)
Combined button and popup list for selecting options.
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...
QTextStream & noshowbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() & ~QTextStream::ShowBase) on stream and ...
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
@ AA_DisableShaderDiskCache
@ AA_CompressHighFrequencyEvents
QList< QString > QStringList
Constructs a string list that contains the given string, str.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qt_win_hasPackageIdentity()
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMax(const T &a, const T &b)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const GLint * param
GLdouble GLdouble GLdouble GLdouble q
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define Q_INIT_RESOURCE(name)
QSettings settings("MySoft", "Star Runner")
[0]
static bool positionIncludesFrame(const QWindow *w)
QWindowsContext m_context
QWindowsServices m_services
QPlatformFontDatabase * m_fontDatabase
QScopedPointer< QWindowsStaticOpenGLContext > m_staticOpenGLContext
void parseOptions(QWindowsIntegration *q, const QStringList ¶mList)
~QWindowsIntegrationPrivate()
QMutex m_staticContextLock
QScopedPointer< QPlatformInputContext > m_inputContext
static QWindowsWindowData create(const QWindow *w, const QWindowsWindowData ¶meters, const QString &title)