Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwindowsguieventdispatcher.cpp
Go to the documentation of this file.
1// Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
2// Copyright (C) 2016 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
6
7#include <qpa/qwindowsysteminterface.h>
8
9#include <QtCore/QCoreApplication>
10#include <QtCore/QDebug>
11
13
14/*!
15 \class QWindowsGuiEventDispatcher
16 \brief Event dispatcher for Windows
17
18 Maintains a global stack storing the current event dispatcher and
19 its processing flags for access from the Windows procedure
20 qWindowsWndProc. Handling the QPA gui events should be done
21 from within the qWindowsWndProc to ensure correct processing of messages.
22
23 \internal
24*/
25
26QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) :
27 QEventDispatcherWin32(parent)
28{
29 setObjectName(QStringLiteral("QWindowsGuiEventDispatcher"));
30}
31
32bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
33{
34 const QEventLoop::ProcessEventsFlags oldFlags = m_flags;
35 m_flags = flags;
36 const bool rc = QEventDispatcherWin32::processEvents(flags);
37 m_flags = oldFlags;
38 return rc;
39}
40
41void QWindowsGuiEventDispatcher::sendPostedEvents()
42{
43 QEventDispatcherWin32::sendPostedEvents();
44 QWindowSystemInterface::sendWindowSystemEvents(m_flags);
45}
46
47// Helpers for printing debug output for WM_* messages.
54
55static const MessageDebugEntry
57 {WM_CREATE, "WM_CREATE", true},
58 {WM_PAINT, "WM_PAINT", true},
59 {WM_CLOSE, "WM_CLOSE", true},
60 {WM_DESTROY, "WM_DESTROY", true},
61 {WM_MOVE, "WM_MOVE", true},
62 {WM_SIZE, "WM_SIZE", true},
63 {WM_GETICON, "WM_GETICON", false},
64 {WM_KEYDOWN, "WM_KEYDOWN", true},
65 {WM_SYSKEYDOWN, "WM_SYSKEYDOWN", true},
66 {WM_SYSCOMMAND, "WM_SYSCOMMAND", true},
67 {WM_KEYUP, "WM_KEYUP", true},
68 {WM_SYSKEYUP, "WM_SYSKEYUP", true},
69#if defined(WM_APPCOMMAND)
70 {WM_APPCOMMAND, "WM_APPCOMMAND", true},
71#endif
72 {WM_IME_CHAR, "WM_IMECHAR", true},
73 {WM_IME_KEYDOWN, "WM_IMECHAR", true},
74 {WM_CANCELMODE, "WM_CANCELMODE", true},
75 {WM_CHAR, "WM_CHAR", true},
76 {WM_DEADCHAR, "WM_DEADCHAR", true},
77 {WM_ACTIVATE, "WM_ACTIVATE", true},
78 {WM_SETFOCUS, "WM_SETFOCUS", true},
79 {WM_KILLFOCUS, "WM_KILLFOCUS", true},
80 {WM_ENABLE, "WM_ENABLE", true},
81 {WM_SHOWWINDOW, "WM_SHOWWINDOW", true},
82 {WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED", true},
83 {WM_SETCURSOR, "WM_SETCURSOR", false},
84 {WM_GETFONT, "WM_GETFONT", true},
85 {WM_LBUTTONDOWN, "WM_LBUTTONDOWN", true},
86 {WM_LBUTTONUP, "WM_LBUTTONUP", true},
87 {WM_LBUTTONDBLCLK, "WM_LBUTTONDBLCLK", true},
88 {WM_RBUTTONDOWN, "WM_RBUTTONDOWN", true},
89 {WM_RBUTTONUP, "WM_RBUTTONUP", true},
90 {WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK", true},
91 {WM_MBUTTONDOWN, "WM_MBUTTONDOWN", true},
92 {WM_MBUTTONUP, "WM_MBUTTONUP", true},
93 {WM_MBUTTONDBLCLK, "WM_MBUTTONDBLCLK", true},
94 {WM_MOUSEWHEEL, "WM_MOUSEWHEEL", true},
95 {WM_XBUTTONDOWN, "WM_XBUTTONDOWN", true},
96 {WM_XBUTTONUP, "WM_XBUTTONUP", true},
97 {WM_XBUTTONDBLCLK, "WM_XBUTTONDBLCLK", true},
98 {WM_MOUSEHWHEEL, "WM_MOUSEHWHEEL", true},
99 {WM_GETOBJECT, "WM_GETOBJECT", true},
100 {WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true},
101 {WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE", true},
102 {WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
103#if defined(WM_DWMNCRENDERINGCHANGED)
104 {WM_DWMNCRENDERINGCHANGED, "WM_DWMNCRENDERINGCHANGED", true},
105#endif
106 {WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true},
107 {WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
108 {WM_RENDERFORMAT, "WM_RENDERFORMAT", true},
109 {WM_RENDERALLFORMATS, "WM_RENDERALLFORMATS", true},
110 {WM_DESTROYCLIPBOARD, "WM_DESTROYCLIPBOARD", true},
111 {WM_CAPTURECHANGED, "WM_CAPTURECHANGED", true},
112 {WM_IME_STARTCOMPOSITION, "WM_IME_STARTCOMPOSITION", true},
113 {WM_IME_COMPOSITION, "WM_IME_COMPOSITION", true},
114 {WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION", true},
115 {WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
116 {WM_IME_REQUEST, "WM_IME_REQUEST", true},
117#if !defined(QT_NO_SESSIONMANAGER)
118 {WM_QUERYENDSESSION, "WM_QUERYENDSESSION", true},
119 {WM_ENDSESSION, "WM_ENDSESSION", true},
120#endif
121 {WM_MOUSEACTIVATE,"WM_MOUSEACTIVATE", true},
122 {WM_CHILDACTIVATE, "WM_CHILDACTIVATE", true},
123 {WM_PARENTNOTIFY, "WM_PARENTNOTIFY", true},
124 {WM_ENTERIDLE, "WM_ENTERIDLE", false},
125 {WM_GETMINMAXINFO, "WM_GETMINMAXINFO", true},
126 {WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING", true},
127 {WM_NCCREATE, "WM_NCCREATE", true},
128 {WM_NCDESTROY, "WM_NCDESTROY", true},
129 {WM_NCCALCSIZE, "WM_NCCALCSIZE", true},
130 {WM_NCACTIVATE, "WM_NCACTIVATE", true},
131 {WM_NCMOUSEMOVE, "WM_NCMOUSEMOVE", true},
132 {WM_NCMOUSELEAVE, "WM_NCMOUSELEAVE", true},
133 {WM_NCLBUTTONDOWN, "WM_NCLBUTTONDOWN", true},
134 {WM_NCLBUTTONUP, "WM_NCLBUTTONUP", true},
135 {WM_ACTIVATEAPP, "WM_ACTIVATEAPP", true},
136 {WM_NCPAINT, "WM_NCPAINT", true},
137 {WM_ERASEBKGND, "WM_ERASEBKGND", true},
138 {WM_MOUSEMOVE, "WM_MOUSEMOVE", true},
139 {WM_MOUSELEAVE, "WM_MOUSELEAVE", true},
140 {WM_NCHITTEST, "WM_NCHITTEST", false},
141#ifdef WM_TOUCH
142 {WM_TOUCH, "WM_TOUCH", true},
143#endif
144 {WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN", true},
145 {WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE", true},
146 {WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD", true},
147 {WM_THEMECHANGED, "WM_THEMECHANGED", true},
148 {0x90, "WM_UAHDESTROYWINDOW", true},
149 {0x272, "WM_UNREGISTER_WINDOW_SERVICES", true},
150#ifdef WM_POINTERUPDATE
151 {WM_POINTERDEVICECHANGE, "WM_POINTERDEVICECHANGE", true},
152 {WM_POINTERDEVICEINRANGE, "WM_POINTERDEVICEINRANGE", true},
153 {WM_POINTERDEVICEOUTOFRANGE, "WM_POINTERDEVICEOUTOFRANGE", true},
154 {WM_NCPOINTERUPDATE, "WM_NCPOINTERUPDATE", true},
155 {WM_NCPOINTERDOWN, "WM_NCPOINTERDOWN", true},
156 {WM_NCPOINTERUP, "WM_NCPOINTERUP", true},
157 {WM_POINTERUPDATE, "WM_POINTERUPDATE", true},
158 {WM_POINTERDOWN, "WM_POINTERDOWN", true},
159 {WM_POINTERUP, "WM_POINTERUP", true},
160 {WM_POINTERENTER, "WM_POINTERENTER", true},
161 {WM_POINTERLEAVE, "WM_POINTERLEAVE", true},
162 {WM_POINTERACTIVATE, "WM_POINTERACTIVATE", true},
163 {WM_POINTERCAPTURECHANGED, "WM_POINTERCAPTURECHANGED", true},
164 {WM_TOUCHHITTESTING, "WM_TOUCHHITTESTING", true},
165 {WM_POINTERWHEEL, "WM_POINTERWHEEL", true},
166 {WM_POINTERHWHEEL, "WM_POINTERHWHEEL", true},
167#endif // WM_POINTERUPDATE
168#ifdef DM_POINTERHITTEST
169 {DM_POINTERHITTEST, "DM_POINTERHITTEST", true},
170#endif // DM_POINTERHITTEST
171#ifdef WM_POINTERROUTEDTO
172 {WM_POINTERROUTEDTO, "WM_POINTERROUTEDTO", true},
173 {WM_POINTERROUTEDAWAY, "WM_POINTERROUTEDAWAY", true},
174 {WM_POINTERROUTEDRELEASED, "WM_POINTERROUTEDRELEASED", true},
175#endif // WM_POINTERROUTEDTO
176#ifdef WM_GETDPISCALEDSIZE
177 {WM_GETDPISCALEDSIZE, "WM_GETDPISCALEDSIZE", true},
178#endif
179#ifdef WM_DPICHANGED
180 {WM_DPICHANGED, "WM_DPICHANGED", true},
181#endif
182};
183
184static inline const MessageDebugEntry *messageDebugEntry(UINT msg)
185{
186 for (size_t i = 0; i < sizeof(messageDebugEntries)/sizeof(MessageDebugEntry); i++)
187 if (messageDebugEntries[i].message == msg)
188 return messageDebugEntries + i;
189 return 0;
190}
191
192const char *QWindowsGuiEventDispatcher::windowsMessageName(UINT msg)
193{
194 if (const MessageDebugEntry *e = messageDebugEntry(msg))
195 return e->description;
196 return "Unknown";
197}
198
199QT_END_NAMESPACE
200
201#include "moc_qwindowsguieventdispatcher_p.cpp"
static const MessageDebugEntry messageDebugEntries[]
static const MessageDebugEntry * messageDebugEntry(UINT msg)