Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the plugins of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QWINDOWSCONTEXT_H
41#define QWINDOWSCONTEXT_H
42
43#include "qtwindowsglobal.h"
44#include <QtCore/qt_windows.h>
45
46#include <QtCore/qscopedpointer.h>
47#include <QtCore/qsharedpointer.h>
48#include <QtCore/qloggingcategory.h>
49
50#define STRICT_TYPED_ITEMIDS
51#include <shlobj.h>
52#include <shlwapi.h>
53
54struct IBindCtx;
55struct _SHSTOCKICONINFO;
56
57QT_BEGIN_NAMESPACE
58
59Q_DECLARE_LOGGING_CATEGORY(lcQpaWindows)
60Q_DECLARE_LOGGING_CATEGORY(lcQpaEvents)
61Q_DECLARE_LOGGING_CATEGORY(lcQpaGl)
62Q_DECLARE_LOGGING_CATEGORY(lcQpaMime)
63Q_DECLARE_LOGGING_CATEGORY(lcQpaInputMethods)
64Q_DECLARE_LOGGING_CATEGORY(lcQpaDialogs)
65Q_DECLARE_LOGGING_CATEGORY(lcQpaMenus)
66Q_DECLARE_LOGGING_CATEGORY(lcQpaTablet)
67Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility)
68Q_DECLARE_LOGGING_CATEGORY(lcQpaUiAutomation)
69Q_DECLARE_LOGGING_CATEGORY(lcQpaTrayIcon)
70
71class QWindow;
72class QPlatformScreen;
73class QPlatformWindow;
74class QWindowsMenuBar;
75class QWindowsScreenManager;
76class QWindowsTabletSupport;
77class QWindowsWindow;
78class QWindowsMimeConverter;
79struct QWindowCreationContext;
80struct QWindowsContextPrivate;
81class QPoint;
82class QKeyEvent;
83class QTouchDevice;
84
85struct QWindowsUser32DLL
86{
87 inline void init();
88 inline bool supportsPointerApi();
89
90 typedef BOOL (WINAPI *EnableMouseInPointer)(BOOL);
91 typedef BOOL (WINAPI *GetPointerType)(UINT32, PVOID);
92 typedef BOOL (WINAPI *GetPointerInfo)(UINT32, PVOID);
93 typedef BOOL (WINAPI *GetPointerDeviceRects)(HANDLE, RECT *, RECT *);
94 typedef BOOL (WINAPI *GetPointerTouchInfo)(UINT32, PVOID);
95 typedef BOOL (WINAPI *GetPointerFrameTouchInfo)(UINT32, UINT32 *, PVOID);
96 typedef BOOL (WINAPI *GetPointerFrameTouchInfoHistory)(UINT32, UINT32 *, UINT32 *, PVOID);
97 typedef BOOL (WINAPI *GetPointerPenInfo)(UINT32, PVOID);
98 typedef BOOL (WINAPI *GetPointerPenInfoHistory)(UINT32, UINT32 *, PVOID);
99 typedef BOOL (WINAPI *SkipPointerFrameMessages)(UINT32);
100 typedef BOOL (WINAPI *SetProcessDPIAware)();
101 typedef BOOL (WINAPI *AddClipboardFormatListener)(HWND);
102 typedef BOOL (WINAPI *RemoveClipboardFormatListener)(HWND);
103 typedef BOOL (WINAPI *GetDisplayAutoRotationPreferences)(DWORD *);
104 typedef BOOL (WINAPI *SetDisplayAutoRotationPreferences)(DWORD);
105 typedef BOOL (WINAPI *AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
106 typedef BOOL (WINAPI *EnableNonClientDpiScaling)(HWND);
107 typedef int (WINAPI *GetWindowDpiAwarenessContext)(HWND);
108 typedef int (WINAPI *GetAwarenessFromDpiAwarenessContext)(int);
109 typedef BOOL (WINAPI *SystemParametersInfoForDpi)(UINT, UINT, PVOID, UINT, UINT);
110
111 // Windows pointer functions (Windows 8 or later).
112 EnableMouseInPointer enableMouseInPointer = nullptr;
113 GetPointerType getPointerType = nullptr;
114 GetPointerInfo getPointerInfo = nullptr;
115 GetPointerDeviceRects getPointerDeviceRects = nullptr;
116 GetPointerTouchInfo getPointerTouchInfo = nullptr;
117 GetPointerFrameTouchInfo getPointerFrameTouchInfo = nullptr;
118 GetPointerFrameTouchInfoHistory getPointerFrameTouchInfoHistory = nullptr;
119 GetPointerPenInfo getPointerPenInfo = nullptr;
120 GetPointerPenInfoHistory getPointerPenInfoHistory = nullptr;
121 SkipPointerFrameMessages skipPointerFrameMessages = nullptr;
122
123 // Windows Vista onwards
124 SetProcessDPIAware setProcessDPIAware = nullptr;
125
126 // Clipboard listeners are present on Windows Vista onwards
127 // but missing in MinGW 4.9 stub libs. Can be removed in MinGW 5.
128 AddClipboardFormatListener addClipboardFormatListener = nullptr;
129 RemoveClipboardFormatListener removeClipboardFormatListener = nullptr;
130
131 // Rotation API
132 GetDisplayAutoRotationPreferences getDisplayAutoRotationPreferences = nullptr;
133 SetDisplayAutoRotationPreferences setDisplayAutoRotationPreferences = nullptr;
134
135 AdjustWindowRectExForDpi adjustWindowRectExForDpi = nullptr;
136 EnableNonClientDpiScaling enableNonClientDpiScaling = nullptr;
137 GetWindowDpiAwarenessContext getWindowDpiAwarenessContext = nullptr;
138 GetAwarenessFromDpiAwarenessContext getAwarenessFromDpiAwarenessContext = nullptr;
139 SystemParametersInfoForDpi systemParametersInfoForDpi = nullptr;
140};
141
142// Shell scaling library (Windows 8.1 onwards)
143struct QWindowsShcoreDLL {
144 void init();
145 inline bool isValid() const { return getProcessDpiAwareness && setProcessDpiAwareness && getDpiForMonitor; }
146
147 typedef HRESULT (WINAPI *GetProcessDpiAwareness)(HANDLE,int *);
148 typedef HRESULT (WINAPI *SetProcessDpiAwareness)(int);
149 typedef HRESULT (WINAPI *GetDpiForMonitor)(HMONITOR,int,UINT *,UINT *);
150
151 GetProcessDpiAwareness getProcessDpiAwareness = nullptr;
152 SetProcessDpiAwareness setProcessDpiAwareness = nullptr;
153 GetDpiForMonitor getDpiForMonitor = nullptr;
154};
155
156class QWindowsContext
157{
158 Q_DISABLE_COPY_MOVE(QWindowsContext)
159public:
160
161 enum SystemInfoFlags
162 {
163 SI_RTL_Extensions = 0x1,
164 SI_SupportsTouch = 0x2,
165 SI_SupportsPointer = 0x4,
166 };
167
168 // Verbose flag set by environment variable QT_QPA_VERBOSE
169 static int verbose;
170
171 explicit QWindowsContext();
172 ~QWindowsContext();
173
174 bool initTouch();
175 bool initTouch(unsigned integrationOptions); // For calls from QWindowsIntegration::QWindowsIntegration() only.
176 bool initTablet(unsigned integrationOptions);
177 bool initPointer(unsigned integrationOptions);
178
179 int defaultDPI() const;
180
181 QString registerWindowClass(const QWindow *w);
182 QString registerWindowClass(QString cname, WNDPROC proc,
183 unsigned style = 0, HBRUSH brush = nullptr,
184 bool icon = false);
185 HWND createDummyWindow(const QString &classNameIn,
186 const wchar_t *windowName,
187 WNDPROC wndProc = nullptr, DWORD style = WS_OVERLAPPED);
188
189 HDC displayContext() const;
190 int screenDepth() const;
191
192 static QWindowsContext *instance();
193
194 static QString windowsErrorMessage(unsigned long errorCode);
195
196 void addWindow(HWND, QWindowsWindow *w);
197 void removeWindow(HWND);
198
199 QWindowsWindow *findClosestPlatformWindow(HWND) const;
200 QWindowsWindow *findPlatformWindow(HWND) const;
201 QWindowsWindow *findPlatformWindow(const QWindowsMenuBar *mb) const;
202 QWindow *findWindow(HWND) const;
203 QWindowsWindow *findPlatformWindowAt(HWND parent, const QPoint &screenPoint,
204 unsigned cwex_flags) const;
205
206 static bool shouldHaveNonClientDpiScaling(const QWindow *window);
207
208 QWindow *windowUnderMouse() const;
209 void clearWindowUnderMouse();
210
211 inline bool windowsProc(HWND hwnd, UINT message,
212 QtWindows::WindowsEventType et,
213 WPARAM wParam, LPARAM lParam, LRESULT *result,
214 QWindowsWindow **platformWindowPtr);
215
216 QWindow *keyGrabber() const;
217 void setKeyGrabber(QWindow *hwnd);
218
219 QSharedPointer<QWindowCreationContext> setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx);
220 QSharedPointer<QWindowCreationContext> windowCreationContext() const;
221
222 void setTabletAbsoluteRange(int a);
223 void setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness);
224 static int processDpiAwareness();
225
226 void setDetectAltGrModifier(bool a);
227
228 // Returns a combination of SystemInfoFlags
229 unsigned systemInfo() const;
230
231 bool useRTLExtensions() const;
232 QList<int> possibleKeys(const QKeyEvent *e) const;
233
234 static bool isSessionLocked();
235
236 QWindowsMimeConverter &mimeConverter() const;
237 QWindowsScreenManager &screenManager();
238 QWindowsTabletSupport *tabletSupport() const;
239
240 static QWindowsUser32DLL user32dll;
241 static QWindowsShcoreDLL shcoredll;
242
243 static QByteArray comErrorString(HRESULT hr);
244 bool asyncExpose() const;
245 void setAsyncExpose(bool value);
246
247 static bool systemParametersInfo(unsigned action, unsigned param, void *out, unsigned dpi = 0);
248 static bool systemParametersInfoForScreen(unsigned action, unsigned param, void *out,
249 const QPlatformScreen *screen = nullptr);
250 static bool systemParametersInfoForWindow(unsigned action, unsigned param, void *out,
251 const QPlatformWindow *win = nullptr);
252 static bool nonClientMetrics(NONCLIENTMETRICS *ncm, unsigned dpi = 0);
253 static bool nonClientMetricsForScreen(NONCLIENTMETRICS *ncm,
254 const QPlatformScreen *screen = nullptr);
255 static bool nonClientMetricsForWindow(NONCLIENTMETRICS *ncm,
256 const QPlatformWindow *win = nullptr);
257
258 static DWORD readAdvancedExplorerSettings(const wchar_t *subKey, DWORD defaultValue);
259
260 QTouchDevice *touchDevice() const;
261
262 static bool filterNativeEvent(MSG *msg, LRESULT *result);
263 static bool filterNativeEvent(QWindow *window, MSG *msg, LRESULT *result);
264
265private:
266 void handleFocusEvent(QtWindows::WindowsEventType et, QWindowsWindow *w);
267#ifndef QT_NO_CONTEXTMENU
268 bool handleContextMenuEvent(QWindow *window, const MSG &msg);
269#endif
270 void handleExitSizeMove(QWindow *window);
271 void unregisterWindowClasses();
272
273 QScopedPointer<QWindowsContextPrivate> d;
274 static QWindowsContext *m_instance;
275};
276
277extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND, UINT, WPARAM, LPARAM);
278
279QT_END_NAMESPACE
280
281#endif // QWINDOWSCONTEXT_H
282

Warning: That file was not part of the compilation database. It may have many parsing errors.