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>
119#if QT_CONFIG(clipboard)
121# if QT_CONFIG(draganddrop)
130#if QT_CONFIG(accessibility)
131 QWindowsUiaAccessibility m_accessibility;
136template <
typename IntType>
138 IntType minimumValue, IntType maximumValue, IntType *
target)
140 const int valueLength = parameter.
size() -
option.size() - 1;
147 if (
value >=
int(minimumValue) &&
value <=
int(maximumValue))
151 << minimumValue <<
".." << maximumValue;
154 qWarning() <<
"Invalid value" << valueRef <<
"for option" <<
option;
163 int *tabletAbsoluteRange,
167 unsigned options = 0;
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")) {
177 }
else if (
param.startsWith(u
"dialogs=")) {
178 if (
param.endsWith(u
"xp")) {
180 }
else if (
param.endsWith(u
"none")) {
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") {
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);
224 static bool dpiAwarenessSet =
false;
228 int tabletAbsoluteRange = -1;
229 DarkModeHandling darkModeHandling = DarkModeHandlingFlag::DarkModeWindowFrames
230 | DarkModeHandlingFlag::DarkModeStyle;
232 q->setDarkModeHandling(darkModeHandling);
234 if (tabletAbsoluteRange >= 0)
243 if (!dpiAwarenessSet) {
246 qCDebug(lcQpaWindow) <<
"DpiAwareness=" << dpiAwareness
249 dpiAwarenessSet =
true;
270#if QT_CONFIG(clipboard)
271 d->m_clipboard.registerViewer();
279 m_instance =
nullptr;
299 return glContext->supportsThreadedOpenGL();
336 const QVariant customMarginsV =
window->property(
"_q_windowsCustomMargins");
338 requested.
customMargins = qvariant_cast<QMargins>(customMarginsV);
345 << __FUNCTION__ <<
' ' <<
window
346 <<
"\n Requested: " << requested.
geometry <<
" frame incl.="
348 <<
' ' << requested.
flags
350 <<
" handle=" << obtained.
hwnd <<
' ' << obtained.
flags <<
'\n';
362 menuBarToBeInstalled->install(
result);
369 const HWND hwnd =
reinterpret_cast<HWND
>(nativeHandle);
370 if (!IsWindow(hwnd)) {
371 qWarning(
"Windows QPA: Invalid foreign window ID %p.", hwnd);
378 screen = pScreen->screen();
396#if defined(QT_OPENGL_DYNAMIC)
398 switch (requestedRenderer) {
403 qCWarning(lcQpaGl,
"Unable to disable rotation.");
407 qCWarning(lcQpaGl,
"System OpenGL failed. Falling back to Software OpenGL.");
412 qCWarning(lcQpaGl,
"Software OpenGL failed. Falling back to system OpenGL.");
429 qCWarning(lcQpaGl,
"Unable to disable rotation.");
442 return QWindowsStaticOpenGLContext::doCreate();
458#if !defined(QT_OPENGL_DYNAMIC)
484 context->setShareContext(shareContext);
486 contextPrivate->adopt(
result.release());
501 if (
d->m_staticOpenGLContext.isNull())
503 return d->m_staticOpenGLContext.data();
510#if QT_CONFIG(directwrite3)
515#ifndef QT_NO_FREETYPE
525#ifdef SPI_GETKEYBOARDSPEED
526static inline int keyBoardAutoRepeatRateMS()
529 if (SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &
time, 0))
530 return time ? 1000 /
static_cast<int>(
time) : 500;
539 if (
const unsigned timeMS = GetCaretBlinkTime())
540 return QVariant(timeMS != INFINITE ?
int(timeMS) * 2 : 0);
542#ifdef SPI_GETKEYBOARDSPEED
544 return QVariant(keyBoardAutoRepeatRateMS());
557 if (
const UINT ms = GetDoubleClickTime())
578#if QT_CONFIG(clipboard)
581 return &d->m_clipboard;
583# if QT_CONFIG(draganddrop)
596#if QT_CONFIG(accessibility)
597QPlatformAccessibility *QWindowsIntegration::accessibility()
const
599 return &d->m_accessibility;
608#if QT_CONFIG(sessionmanager)
648 m_applicationBadgeNumber =
number;
652#if QT_CONFIG(cpp_winrt)
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));
678#if QT_CONFIG(cpp_winrt)
681 static const auto fromUIColor = [](winrt::Windows::UI::Color &&
color) {
684 using namespace winrt::Windows::UI::ViewManagement;
687 UIColorType::AccentLight2 : UIColorType::Accent));
688 textColor = fromUIColor(
settings.GetColorValue(UIColorType::Background));
699 const auto devicePixelRatio =
qApp->devicePixelRatio();
701 static const QSize iconBaseSize(16, 16);
711 QColor badgeBorderColor = textColor;
713 badgeBorderPen = badgeBorderColor;
714 badgeRect.
adjust(1, 1, -1, -1);
721 auto pixelSize =
qCeil(10.5 * devicePixelRatio);
724 const bool textOverflow =
number > 99;
747 QComHelper comHelper;
751 ComPtr<ITaskbarList3> taskbarList;
752 CoCreateInstance(CLSID_TaskbarList,
nullptr,
753 CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&taskbarList));
761 const auto hIcon =
image.toHICON();
767 for (
auto *topLevelWindow : topLevelWindows) {
768 if (!topLevelWindow->handle())
770 auto hwnd =
reinterpret_cast<HWND
>(topLevelWindow->winId());
771 taskbarList->SetOverlayIcon(hwnd, hIcon, L
"");
The QColor class provides colors based on RGB, HSV or CMYK values.
void setAlphaF(float alpha)
Sets the alpha of this color to alpha.
bool isValid() const noexcept
Returns true if the color is valid; otherwise returns false.
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
The QKeyEvent class describes a key event.
Native interface to QPlatformWindow. \inmodule QtGui.
static QOpenGLContextPrivate * get(QOpenGLContext *context)
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.
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 QString requested()
static QPlatformInputContext * create()
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
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.
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
QString right(qsizetype n) const
Returns a substring that contains the n rightmost characters of the string.
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.
bool isNull() const
Returns true if this string is null; otherwise returns false.
qsizetype size() const
Returns the number of characters in this string.
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...
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
static void setPlatformSynthesizesMouse(bool v)
bool isDarkMode() const override
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)
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 qreal fontSmoothingGamma()
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
~QWindowsIntegration() override
@ FontDatabaseDirectWrite
@ 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
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()
@ DisableProgramCacheFlag
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 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
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
QMargins fullFrameMargins
static QWindowsWindowData create(const QWindow *w, const QWindowsWindowData ¶meters, const QString &title)