Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowscontext.h
Go to the documentation of this file.
1// Copyright (C) 2016 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#ifndef QWINDOWSCONTEXT_H
5#define QWINDOWSCONTEXT_H
6
7#include "qtwindowsglobal.h"
8#include <QtCore/qt_windows.h>
9
10#include <QtCore/qscopedpointer.h>
11#include <QtCore/qsharedpointer.h>
12#include <QtCore/qloggingcategory.h>
13
14#define STRICT_TYPED_ITEMIDS
15#include <shlobj.h>
16#include <shlwapi.h>
17
19
24Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods)
28Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility)
29Q_DECLARE_LOGGING_CATEGORY(lcQpaUiAutomation)
30Q_DECLARE_LOGGING_CATEGORY(lcQpaTrayIcon)
32
33class QWindow;
34class QPlatformScreen;
35class QPlatformWindow;
36class QWindowsMenuBar;
39class QWindowsWindow;
43class QPoint;
44class QKeyEvent;
45class QPointingDevice;
46
48{
49 Q_DISABLE_COPY_MOVE(QWindowsContext)
50public:
52
54 {
58 };
59
60 // Verbose flag set by environment variable QT_QPA_VERBOSE
61 static int verbose;
62
63 explicit QWindowsContext();
65
66 bool initTouch();
67 bool initTouch(unsigned integrationOptions); // For calls from QWindowsIntegration::QWindowsIntegration() only.
69 bool initTablet();
70 bool initPointer(unsigned integrationOptions);
71 bool disposeTablet();
72
74
75 int defaultDPI() const;
76
77 static QString classNamePrefix();
79 QString registerWindowClass(QString cname, WNDPROC proc,
80 unsigned style = 0, HBRUSH brush = nullptr,
81 bool icon = false);
82 HWND createDummyWindow(const QString &classNameIn,
83 const wchar_t *windowName,
84 WNDPROC wndProc = nullptr, DWORD style = WS_OVERLAPPED);
85
86 HDC displayContext() const;
87 int screenDepth() const;
88
89 static QWindowsContext *instance();
90
91 void addWindow(HWND, QWindowsWindow *w);
92 void removeWindow(HWND);
93
97 QWindow *findWindow(HWND) const;
98 QWindowsWindow *findPlatformWindowAt(HWND parent, const QPoint &screenPoint,
99 unsigned cwex_flags) const;
100
101 static bool shouldHaveNonClientDpiScaling(const QWindow *window);
102
103 QWindow *windowUnderMouse() const;
105
106 inline bool windowsProc(HWND hwnd, UINT message,
108 WPARAM wParam, LPARAM lParam, LRESULT *result,
109 QWindowsWindow **platformWindowPtr);
110
111 QWindow *keyGrabber() const;
112 void setKeyGrabber(QWindow *hwnd);
113
116
117 static void setTabletAbsoluteRange(int a);
118
119 static bool setProcessDpiAwareness(QtWindows::DpiAwareness dpiAwareness);
122
123 static bool isDarkMode();
124
125 void setDetectAltGrModifier(bool a);
126
127 // Returns a combination of SystemInfoFlags
128 unsigned systemInfo() const;
129
130 bool useRTLExtensions() const;
131 QList<int> possibleKeys(const QKeyEvent *e) const;
132
134
135 static bool isSessionLocked();
136
140
141 bool asyncExpose() const;
142 void setAsyncExpose(bool value);
143
144 static void forceNcCalcSize(HWND hwnd);
145
146 static bool systemParametersInfo(unsigned action, unsigned param, void *out, unsigned dpi = 0);
147 static bool systemParametersInfoForScreen(unsigned action, unsigned param, void *out,
148 const QPlatformScreen *screen = nullptr);
149 static bool systemParametersInfoForWindow(unsigned action, unsigned param, void *out,
150 const QPlatformWindow *win = nullptr);
151 static bool nonClientMetrics(NONCLIENTMETRICS *ncm, unsigned dpi = 0);
152 static bool nonClientMetricsForScreen(NONCLIENTMETRICS *ncm,
153 const QPlatformScreen *screen = nullptr);
154 static bool nonClientMetricsForWindow(NONCLIENTMETRICS *ncm,
155 const QPlatformWindow *win = nullptr);
156
157 static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue);
158
159 static bool filterNativeEvent(MSG *msg, LRESULT *result);
160 static bool filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result);
161
162private:
163 void handleFocusEvent(QtWindows::WindowsEventType et, QWindowsWindow *w);
164#ifndef QT_NO_CONTEXTMENU
165 bool handleContextMenuEvent(QWindow *window, const MSG &msg);
166#endif
167 void handleExitSizeMove(QWindow *window);
168 void unregisterWindowClasses();
169
171 static QWindowsContext *m_instance;
172};
173
174extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND, UINT, WPARAM, LPARAM);
175
177
178#endif // QWINDOWSCONTEXT_H
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
The QPlatformScreen class provides an abstraction for visual displays.
The QPlatformWindow class provides an abstraction for top-level windows.
\inmodule QtCore\reentrant
Definition qpoint.h:23
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtGui
Definition qwindow.h:63
Singleton container for all relevant information.
static bool isDarkMode()
QSharedPointer< QWindowCreationContext > windowCreationContext() const
QWindowsScreenManager & screenManager()
static QString classNamePrefix()
QWindowsWindow * findClosestPlatformWindow(HWND) const
QWindow * findWindow(HWND) const
static bool filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result)
bool asyncExpose() const
void addWindow(HWND, QWindowsWindow *w)
static bool systemParametersInfoForScreen(unsigned action, unsigned param, void *out, const QPlatformScreen *screen=nullptr)
static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue)
static bool setProcessDpiAwareness(QtWindows::DpiAwareness dpiAwareness)
HDC displayContext() const
static bool shouldHaveNonClientDpiScaling(const QWindow *window)
QWindowsTabletSupport * tabletSupport() const
static bool systemParametersInfoForWindow(unsigned action, unsigned param, void *out, const QPlatformWindow *win=nullptr)
QString registerWindowClass(const QWindow *w)
static void setTabletAbsoluteRange(int a)
static void forceNcCalcSize(HWND hwnd)
QWindowsWindow * findPlatformWindowAt(HWND parent, const QPoint &screenPoint, unsigned cwex_flags) const
void setKeyGrabber(QWindow *hwnd)
static bool nonClientMetrics(NONCLIENTMETRICS *ncm, unsigned dpi=0)
QList< int > possibleKeys(const QKeyEvent *e) const
HWND createDummyWindow(const QString &classNameIn, const wchar_t *windowName, WNDPROC wndProc=nullptr, DWORD style=WS_OVERLAPPED)
Convenience to create a non-visible, message-only dummy window for example used as clipboard watcher ...
void setAsyncExpose(bool value)
QSharedPointer< QWindowCreationContext > setWindowCreationContext(const QSharedPointer< QWindowCreationContext > &ctx)
static QtWindows::DpiAwareness windowDpiAwareness(HWND hwnd)
bool windowsProc(HWND hwnd, UINT message, QtWindows::WindowsEventType et, WPARAM wParam, LPARAM lParam, LRESULT *result, QWindowsWindow **platformWindowPtr)
Main windows procedure registered for windows.
unsigned systemInfo() const
static QtWindows::DpiAwareness processDpiAwareness()
QWindowsWindow * findPlatformWindow(HWND) const
QWindow * keyGrabber() const
QWindow * windowUnderMouse() const
bool useRTLExtensions() const
bool initPointer(unsigned integrationOptions)
static bool systemParametersInfo(unsigned action, unsigned param, void *out, unsigned dpi=0)
QWindowsMimeRegistry & mimeConverter() const
static bool nonClientMetricsForWindow(NONCLIENTMETRICS *ncm, const QPlatformWindow *win=nullptr)
static bool isSessionLocked()
int screenDepth() const
bool initPowerNotificationHandler()
HandleBaseWindowHash & windows()
static QWindowsContext * instance()
static bool nonClientMetricsForScreen(NONCLIENTMETRICS *ncm, const QPlatformScreen *screen=nullptr)
static bool filterNativeEvent(MSG *msg, LRESULT *result)
void setDetectAltGrModifier(bool a)
Windows native menu bar.
Manages the list of QWindowsMimeConverter instances.
Manages a list of QWindowsScreen.
Tablet support for Windows.
Raster or OpenGL Window.
EGLContext ctx
double e
Combined button and popup list for selecting options.
WindowsEventType
Enumerations for WM_XX events.
Definition brush.cpp:5
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_LOGGING_CATEGORY(name)
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLuint GLsizei const GLchar * message
GLenum const GLint * param
GLuint64EXT * result
[6]
QScreen * screen
[1]
Definition main.cpp:29
struct tagMSG MSG
LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND, UINT, WPARAM, LPARAM)
QWidget * win
Definition settings.cpp:6
QTextStream out(stdout)
[7]
aWidget window() -> setWindowTitle("New Window Title")
[2]
Active Context for creating windows.
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent