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
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;
37class QWindowsMenuBar;
40class QWindowsWindow;
44class QPoint;
45class QKeyEvent;
46class QPointingDevice;
48{
49 Q_DISABLE_COPY_MOVE(QWindowsContext)
50public:
51 using HandleBaseWindowHash = QHash<HWND, QWindowsWindow *>;
52
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
114 QSharedPointer<QWindowCreationContext> setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx);
115 QSharedPointer<QWindowCreationContext> windowCreationContext() const;
116
117 static void setTabletAbsoluteRange(int a);
118
119 static bool setProcessDpiAwareness(QtWindows::DpiAwareness dpiAwareness);
122
123 void setDetectAltGrModifier(bool a);
124
125 // Returns a combination of SystemInfoFlags
126 unsigned systemInfo() const;
127
128 bool useRTLExtensions() const;
130
132
133 static bool isSessionLocked();
134
138
139 bool asyncExpose() const;
140 void setAsyncExpose(bool value);
141
142 static void forceNcCalcSize(HWND hwnd);
143
144 static bool systemParametersInfo(unsigned action, unsigned param, void *out, unsigned dpi = 0);
145 static bool systemParametersInfoForScreen(unsigned action, unsigned param, void *out,
146 const QPlatformScreen *screen = nullptr);
147 static bool systemParametersInfoForWindow(unsigned action, unsigned param, void *out,
148 const QPlatformWindow *win = nullptr);
149 static bool nonClientMetrics(NONCLIENTMETRICS *ncm, unsigned dpi = 0);
150 static bool nonClientMetricsForScreen(NONCLIENTMETRICS *ncm,
151 const QPlatformScreen *screen = nullptr);
152 static bool nonClientMetricsForWindow(NONCLIENTMETRICS *ncm,
153 const QPlatformWindow *win = nullptr);
154
155 static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue);
156
157 static bool filterNativeEvent(MSG *msg, LRESULT *result);
158 static bool filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result);
159
160private:
161 void handleFocusEvent(QtWindows::WindowsEventType et, QWindowsWindow *w);
162#ifndef QT_NO_CONTEXTMENU
163 bool handleContextMenuEvent(QWindow *window, const MSG &msg);
164#endif
165 void handleExitSizeMove(QWindow *window);
166 void unregisterWindowClasses();
167
168 QScopedPointer<QWindowsContextPrivate> d;
169 static QWindowsContext *m_instance;
170};
171
172extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND, UINT, WPARAM, LPARAM);
173
175
176#endif // QWINDOWSCONTEXT_H
The QKeyEvent class describes a key event.
Definition qevent.h:424
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:25
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtGui
Definition qwindow.h:63
Singleton container for all relevant information.
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)
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
QPlatformKeyMapper * keyMapper() 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
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.