1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qwindowsguieventdispatcher.h"
43 #include "qwindowscontext.h"
45 #include <QtGui/qwindowsysteminterface.h>
47 #include <QtCore/QStack>
48 #include <QtCore/QDebug>
55 \class QWindowsGuiEventDispatcher
56 \brief Event dispatcher for Windows
58 Maintains a global stack storing the current event dispatcher and
59 its processing flags for access from the Windows procedure
60 qWindowsWndProc. Handling the Lighthouse gui events should be done
61 from within the qWindowsWndProc to ensure correct processing of messages.
64 \ingroup qt-lighthouse-win
67 QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) :
68 QEventDispatcherWin32(parent), m_flags(0)
70 setObjectName(QStringLiteral("QWindowsGuiEventDispatcher"));
73 bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
76 if (QWindowsContext::verboseEvents > 2)
77 qDebug(">%s %s %d", __FUNCTION__, qPrintable(objectName()), int(flags));
78 const bool rc = QEventDispatcherWin32::processEvents(flags);
79 if (QWindowsContext::verboseEvents > 2)
80 qDebug("<%s %s returns %d", __FUNCTION__, qPrintable(objectName()), rc);
84 void QWindowsGuiEventDispatcher::sendPostedEvents()
86 QWindowSystemInterface::sendWindowSystemEvents(m_flags);
89 // Helpers for printing debug output for WM_* messages.
90 struct MessageDebugEntry
93 const char *description;
97 static const MessageDebugEntry
98 messageDebugEntries[] = {
99 {WM_CREATE, "WM_CREATE", true},
100 {WM_PAINT, "WM_PAINT", true},
101 {WM_CLOSE, "WM_CLOSE", true},
102 {WM_DESTROY, "WM_DESTROY", true},
103 {WM_MOVE, "WM_MOVE", true},
104 {WM_SIZE, "WM_SIZE", true},
105 {WM_MOUSEACTIVATE,"WM_MOUSEACTIVATE", true},
106 {WM_CHILDACTIVATE, "WM_CHILDACTIVATE", true},
107 {WM_PARENTNOTIFY, "WM_PARENTNOTIFY", true},
108 {WM_ENTERIDLE, "WM_ENTERIDLE", false},
109 {WM_GETICON, "WM_GETICON", false},
110 {WM_KEYDOWN, "WM_KEYDOWN", true},
111 {WM_SYSKEYDOWN, "WM_SYSKEYDOWN", true},
112 {WM_SYSCOMMAND, "WM_SYSCOMMAND", true},
113 {WM_KEYUP, "WM_KEYUP", true},
114 {WM_SYSKEYUP, "WM_SYSKEYUP", true},
115 {WM_IME_CHAR, "WM_IMECHAR", true},
116 {WM_IME_KEYDOWN, "WM_IMECHAR", true},
117 {WM_CANCELMODE, "WM_CANCELMODE", true},
118 {WM_CHAR, "WM_CHAR", true},
119 {WM_DEADCHAR, "WM_DEADCHAR", true},
120 {WM_ACTIVATE, "WM_ACTIVATE", true},
121 {WM_GETMINMAXINFO, "WM_GETMINMAXINFO", true},
122 {WM_SETFOCUS, "WM_SETFOCUS", true},
123 {WM_KILLFOCUS, "WM_KILLFOCUS", true},
124 {WM_ENABLE, "WM_ENABLE", true},
125 {WM_SHOWWINDOW, "WM_SHOWWINDOW", true},
126 {WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING", true},
127 {WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED", true},
128 {WM_SETCURSOR, "WM_SETCURSOR", false},
129 {WM_GETFONT, "WM_GETFONT", true},
130 {WM_NCMOUSEMOVE, "WM_NCMOUSEMOVE", true},
131 {WM_LBUTTONDOWN, "WM_LBUTTONDOWN", true},
132 {WM_LBUTTONUP, "WM_LBUTTONUP", true},
133 {WM_LBUTTONDBLCLK, "WM_LBUTTONDBLCLK", true},
134 {WM_RBUTTONDOWN, "WM_RBUTTONDOWN", true},
135 {WM_RBUTTONUP, "WM_RBUTTONUP", true},
136 {WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK", true},
137 {WM_MBUTTONDOWN, "WM_MBUTTONDOWN", true},
138 {WM_MBUTTONUP, "WM_MBUTTONUP", true},
139 {WM_MBUTTONDBLCLK, "WM_MBUTTONDBLCLK", true},
140 {WM_MOUSEWHEEL, "WM_MOUSEWHEEL", true},
141 {WM_XBUTTONDOWN, "WM_XBUTTONDOWN", true},
142 {WM_XBUTTONUP, "WM_XBUTTONUP", true},
143 {WM_XBUTTONDBLCLK, "WM_XBUTTONDBLCLK", true},
144 {WM_MOUSEHWHEEL, "WM_MOUSEHWHEEL", true},
145 {WM_NCCREATE, "WM_NCCREATE", true},
146 {WM_NCCALCSIZE, "WM_NCCALCSIZE", true},
147 {WM_NCACTIVATE, "WM_NCACTIVATE", true},
148 {WM_NCMOUSELEAVE, "WM_NCMOUSELEAVE", true},
149 {WM_NCLBUTTONDOWN, "WM_NCLBUTTONDOWN", true},
150 {WM_NCLBUTTONUP, "WM_NCLBUTTONUP", true},
151 {WM_ACTIVATEAPP, "WM_ACTIVATEAPP", true},
152 {WM_NCPAINT, "WM_NCPAINT", true},
153 {WM_ERASEBKGND, "WM_ERASEBKGND", true},
154 {WM_MOUSEMOVE, "WM_MOUSEMOVE", true},
155 {WM_MOUSELEAVE, "WM_MOUSELEAVE", true},
156 {WM_NCHITTEST, "WM_NCHITTEST", false},
157 {WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true},
158 {WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE", true},
159 {WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
160 #if defined(WM_DWMNCRENDERINGCHANGED)
161 {WM_DWMNCRENDERINGCHANGED, "WM_DWMNCRENDERINGCHANGED", true},
163 {WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true},
164 {WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
165 {WM_TOUCH, "WM_TOUCH", true},
166 {WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN", true},
167 {WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD", true},
168 {WM_RENDERFORMAT, "WM_RENDERFORMAT", true},
169 {WM_RENDERALLFORMATS, "WM_RENDERALLFORMATS", true},
170 {WM_DESTROYCLIPBOARD, "WM_DESTROYCLIPBOARD", true},
171 {WM_CAPTURECHANGED, "WM_CAPTURECHANGED", true},
172 {WM_IME_STARTCOMPOSITION, "WM_IME_STARTCOMPOSITION", true},
173 {WM_IME_COMPOSITION, "WM_IME_COMPOSITION", true},
174 {WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION", true},
175 {WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
176 {WM_IME_REQUEST, "WM_IME_REQUEST", true},
177 {WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE", true},
178 {WM_THEMECHANGED, "WM_THEMECHANGED", true}
181 static inline const MessageDebugEntry *messageDebugEntry(UINT msg)
183 for (size_t i = 0; i < sizeof(messageDebugEntries)/sizeof(MessageDebugEntry); i++)
184 if (messageDebugEntries[i].message == msg)
185 return messageDebugEntries + i;
189 const char *QWindowsGuiEventDispatcher::windowsMessageName(UINT msg)
191 if (const MessageDebugEntry *e = messageDebugEntry(msg))
192 return e->description;