1
/****************************************************************************
3
** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
4
** Copyright (C) 2016 The Qt Company Ltd.
5
** Contact: https://www.qt.io/licensing/
7
** This file is part of the plugins of the Qt Toolkit.
9
** $QT_BEGIN_LICENSE:LGPL$
10
** Commercial License Usage
11
** Licensees holding valid commercial Qt licenses may use this file in
12
** accordance with the commercial license agreement provided with the
13
** Software or, alternatively, in accordance with the terms contained in
14
** a written agreement between you and The Qt Company. For licensing terms
15
** and conditions see https://www.qt.io/terms-conditions. For further
16
** information use the contact form at https://www.qt.io/contact-us.
18
** GNU Lesser General Public License Usage
19
** Alternatively, this file may be used under the terms of the GNU Lesser
20
** General Public License version 3 as published by the Free Software
21
** Foundation and appearing in the file LICENSE.LGPL3 included in the
22
** packaging of this file. Please review the following information to
23
** ensure the GNU Lesser General Public License version 3 requirements
24
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
26
** GNU General Public License Usage
27
** Alternatively, this file may be used under the terms of the GNU
28
** General Public License version 2.0 or (at your option) the GNU General
29
** Public license version 3 or any later version approved by the KDE Free
30
** Qt Foundation. The licenses are as published by the Free Software
31
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32
** included in the packaging of this file. Please review the following
33
** information to ensure the GNU General Public License requirements will
34
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35
** https://www.gnu.org/licenses/gpl-3.0.html.
39
****************************************************************************/
41
#include "qwindowsguieventdispatcher_p.h"
43
#include <qpa/qwindowsysteminterface.h>
45
#include <QtCore/QCoreApplication>
46
#include <QtCore/QDebug>
51
\class QWindowsGuiEventDispatcher
52
\brief Event dispatcher for Windows
54
Maintains a global stack storing the current event dispatcher and
55
its processing flags for access from the Windows procedure
56
qWindowsWndProc. Handling the Lighthouse gui events should be done
57
from within the qWindowsWndProc to ensure correct processing of messages.
60
\ingroup qt-lighthouse-win
63
QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) :
64
QEventDispatcherWin32(parent), m_flags(0)
66
setObjectName(QStringLiteral("QWindowsGuiEventDispatcher"));
67
createInternalHwnd(); // QTBUG-40881: Do not delay registering timers, etc. for QtMfc.
70
bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
72
const QEventLoop::ProcessEventsFlags oldFlags = m_flags;
74
const bool rc = QEventDispatcherWin32::processEvents(flags);
79
void QWindowsGuiEventDispatcher::sendPostedEvents()
81
QEventDispatcherWin32::sendPostedEvents();
82
QWindowSystemInterface::sendWindowSystemEvents(m_flags);
85
// Helpers for printing debug output for WM_* messages.
86
struct MessageDebugEntry
89
const char *description;
93
static const MessageDebugEntry
94
messageDebugEntries[] = {
95
{WM_CREATE, "WM_CREATE", true},
96
{WM_PAINT, "WM_PAINT", true},
97
{WM_CLOSE, "WM_CLOSE", true},
98
{WM_DESTROY, "WM_DESTROY", true},
99
{WM_MOVE, "WM_MOVE", true},
100
{WM_SIZE, "WM_SIZE", true},
101
{WM_GETICON, "WM_GETICON", false},
102
{WM_KEYDOWN, "WM_KEYDOWN", true},
103
{WM_SYSKEYDOWN, "WM_SYSKEYDOWN", true},
104
{WM_SYSCOMMAND, "WM_SYSCOMMAND", true},
105
{WM_KEYUP, "WM_KEYUP", true},
106
{WM_SYSKEYUP, "WM_SYSKEYUP", true},
107
#if defined(WM_APPCOMMAND)
108
{WM_APPCOMMAND, "WM_APPCOMMAND", true},
110
{WM_IME_CHAR, "WM_IMECHAR", true},
111
{WM_IME_KEYDOWN, "WM_IMECHAR", true},
112
{WM_CANCELMODE, "WM_CANCELMODE", true},
113
{WM_CHAR, "WM_CHAR", true},
114
{WM_DEADCHAR, "WM_DEADCHAR", true},
115
{WM_ACTIVATE, "WM_ACTIVATE", true},
116
{WM_SETFOCUS, "WM_SETFOCUS", true},
117
{WM_KILLFOCUS, "WM_KILLFOCUS", true},
118
{WM_ENABLE, "WM_ENABLE", true},
119
{WM_SHOWWINDOW, "WM_SHOWWINDOW", true},
120
{WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED", true},
121
{WM_SETCURSOR, "WM_SETCURSOR", false},
122
{WM_GETFONT, "WM_GETFONT", true},
123
{WM_LBUTTONDOWN, "WM_LBUTTONDOWN", true},
124
{WM_LBUTTONUP, "WM_LBUTTONUP", true},
125
{WM_LBUTTONDBLCLK, "WM_LBUTTONDBLCLK", true},
126
{WM_RBUTTONDOWN, "WM_RBUTTONDOWN", true},
127
{WM_RBUTTONUP, "WM_RBUTTONUP", true},
128
{WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK", true},
129
{WM_MBUTTONDOWN, "WM_MBUTTONDOWN", true},
130
{WM_MBUTTONUP, "WM_MBUTTONUP", true},
131
{WM_MBUTTONDBLCLK, "WM_MBUTTONDBLCLK", true},
132
{WM_MOUSEWHEEL, "WM_MOUSEWHEEL", true},
133
{WM_XBUTTONDOWN, "WM_XBUTTONDOWN", true},
134
{WM_XBUTTONUP, "WM_XBUTTONUP", true},
135
{WM_XBUTTONDBLCLK, "WM_XBUTTONDBLCLK", true},
136
{WM_MOUSEHWHEEL, "WM_MOUSEHWHEEL", true},
137
{WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true},
138
{WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE", true},
139
{WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
140
#if defined(WM_DWMNCRENDERINGCHANGED)
141
{WM_DWMNCRENDERINGCHANGED, "WM_DWMNCRENDERINGCHANGED", true},
143
{WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true},
144
{WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
145
{WM_RENDERFORMAT, "WM_RENDERFORMAT", true},
146
{WM_RENDERALLFORMATS, "WM_RENDERALLFORMATS", true},
147
{WM_DESTROYCLIPBOARD, "WM_DESTROYCLIPBOARD", true},
148
{WM_CAPTURECHANGED, "WM_CAPTURECHANGED", true},
149
{WM_IME_STARTCOMPOSITION, "WM_IME_STARTCOMPOSITION", true},
150
{WM_IME_COMPOSITION, "WM_IME_COMPOSITION", true},
151
{WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION", true},
152
{WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
153
{WM_IME_REQUEST, "WM_IME_REQUEST", true},
154
#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
155
{WM_QUERYENDSESSION, "WM_QUERYENDSESSION", true},
156
{WM_ENDSESSION, "WM_ENDSESSION", true},
159
{WM_MOUSEACTIVATE,"WM_MOUSEACTIVATE", true},
160
{WM_CHILDACTIVATE, "WM_CHILDACTIVATE", true},
161
{WM_PARENTNOTIFY, "WM_PARENTNOTIFY", true},
162
{WM_ENTERIDLE, "WM_ENTERIDLE", false},
163
{WM_GETMINMAXINFO, "WM_GETMINMAXINFO", true},
164
{WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING", true},
165
{WM_NCCREATE, "WM_NCCREATE", true},
166
{WM_NCCALCSIZE, "WM_NCCALCSIZE", true},
167
{WM_NCACTIVATE, "WM_NCACTIVATE", true},
168
{WM_NCMOUSEMOVE, "WM_NCMOUSEMOVE", true},
169
{WM_NCMOUSELEAVE, "WM_NCMOUSELEAVE", true},
170
{WM_NCLBUTTONDOWN, "WM_NCLBUTTONDOWN", true},
171
{WM_NCLBUTTONUP, "WM_NCLBUTTONUP", true},
172
{WM_ACTIVATEAPP, "WM_ACTIVATEAPP", true},
173
{WM_NCPAINT, "WM_NCPAINT", true},
174
{WM_ERASEBKGND, "WM_ERASEBKGND", true},
175
{WM_MOUSEMOVE, "WM_MOUSEMOVE", true},
176
{WM_MOUSELEAVE, "WM_MOUSELEAVE", true},
177
{WM_NCHITTEST, "WM_NCHITTEST", false},
179
{WM_TOUCH, "WM_TOUCH", true},
181
{WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN", true},
182
{WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE", true},
183
{WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD", true},
184
#endif // !Q_OS_WINCE
185
{WM_THEMECHANGED, "WM_THEMECHANGED", true}
188
static inline const MessageDebugEntry *messageDebugEntry(UINT msg)
190
for (size_t i = 0; i < sizeof(messageDebugEntries)/sizeof(MessageDebugEntry); i++)
191
if (messageDebugEntries[i].message == msg)
192
return messageDebugEntries + i;
196
const char *QWindowsGuiEventDispatcher::windowsMessageName(UINT msg)
198
if (const MessageDebugEntry *e = messageDebugEntry(msg))
199
return e->description;