Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qabstracteventdispatcher.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
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 QtCore module 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 | #include "qabstracteventdispatcher.h" | - | ||||||
41 | #include "qabstracteventdispatcher_p.h" | - | ||||||
42 | #include "qabstractnativeeventfilter.h" | - | ||||||
43 | - | |||||||
44 | #include "qthread.h" | - | ||||||
45 | #include <private/qthread_p.h> | - | ||||||
46 | #include <private/qcoreapplication_p.h> | - | ||||||
47 | #include <private/qfreelist_p.h> | - | ||||||
48 | - | |||||||
49 | QT_BEGIN_NAMESPACE | - | ||||||
50 | - | |||||||
51 | // we allow for 2^24 = 8^8 = 16777216 simultaneously running timers | - | ||||||
52 | struct QtTimerIdFreeListConstants : public QFreeListDefaultConstants | - | ||||||
53 | { | - | ||||||
54 | enum | - | ||||||
55 | { | - | ||||||
56 | InitialNextValue = 1, | - | ||||||
57 | BlockCount = 6 | - | ||||||
58 | }; | - | ||||||
59 | - | |||||||
60 | static const int Sizes[BlockCount]; | - | ||||||
61 | }; | - | ||||||
62 | - | |||||||
63 | enum { | - | ||||||
64 | Offset0 = 0x00000000, | - | ||||||
65 | Offset1 = 0x00000040, | - | ||||||
66 | Offset2 = 0x00000100, | - | ||||||
67 | Offset3 = 0x00001000, | - | ||||||
68 | Offset4 = 0x00010000, | - | ||||||
69 | Offset5 = 0x00100000, | - | ||||||
70 | - | |||||||
71 | Size0 = Offset1 - Offset0, | - | ||||||
72 | Size1 = Offset2 - Offset1, | - | ||||||
73 | Size2 = Offset3 - Offset2, | - | ||||||
74 | Size3 = Offset4 - Offset3, | - | ||||||
75 | Size4 = Offset5 - Offset4, | - | ||||||
76 | Size5 = QtTimerIdFreeListConstants::MaxIndex - Offset5 | - | ||||||
77 | }; | - | ||||||
78 | - | |||||||
79 | const int QtTimerIdFreeListConstants::Sizes[QtTimerIdFreeListConstants::BlockCount] = { | - | ||||||
80 | Size0, | - | ||||||
81 | Size1, | - | ||||||
82 | Size2, | - | ||||||
83 | Size3, | - | ||||||
84 | Size4, | - | ||||||
85 | Size5 | - | ||||||
86 | }; | - | ||||||
87 | - | |||||||
88 | typedef QFreeList<void, QtTimerIdFreeListConstants> QtTimerIdFreeList; | - | ||||||
89 | Q_GLOBAL_STATIC(QtTimerIdFreeList, timerIdFreeList) executed 209 times by 201 tests: end of block Executed by:
executed 209 times by 201 tests: guard.store(QtGlobalStatic::Destroyed); Executed by:
executed 331776 times by 299 tests: return &holder.value; Executed by:
| 0-331776 | ||||||
90 | - | |||||||
91 | int QAbstractEventDispatcherPrivate::allocateTimerId() | - | ||||||
92 | { | - | ||||||
93 | return timerIdFreeList()->next(); executed 166642 times by 206 tests: return timerIdFreeList()->next(); Executed by:
| 166642 | ||||||
94 | } | - | ||||||
95 | - | |||||||
96 | void QAbstractEventDispatcherPrivate::releaseTimerId(int timerId) | - | ||||||
97 | { | - | ||||||
98 | // this function may be called by a global destructor after | - | ||||||
99 | // timerIdFreeList() has been destructed | - | ||||||
100 | if (QtTimerIdFreeList *fl = timerIdFreeList())
| 12-165134 | ||||||
101 | fl->release(timerId); executed 165134 times by 290 tests: fl->release(timerId); Executed by:
| 165134 | ||||||
102 | } executed 165146 times by 302 tests: end of block Executed by:
| 165146 | ||||||
103 | - | |||||||
104 | /*! | - | ||||||
105 | \class QAbstractEventDispatcher | - | ||||||
106 | \inmodule QtCore | - | ||||||
107 | \brief The QAbstractEventDispatcher class provides an interface to manage Qt's event queue. | - | ||||||
108 | - | |||||||
109 | \ingroup events | - | ||||||
110 | - | |||||||
111 | An event dispatcher receives events from the window system and other | - | ||||||
112 | sources. It then sends them to the QCoreApplication or QApplication | - | ||||||
113 | instance for processing and delivery. QAbstractEventDispatcher provides | - | ||||||
114 | fine-grained control over event delivery. | - | ||||||
115 | - | |||||||
116 | For simple control of event processing use | - | ||||||
117 | QCoreApplication::processEvents(). | - | ||||||
118 | - | |||||||
119 | For finer control of the application's event loop, call | - | ||||||
120 | instance() and call functions on the QAbstractEventDispatcher | - | ||||||
121 | object that is returned. If you want to use your own instance of | - | ||||||
122 | QAbstractEventDispatcher or of a QAbstractEventDispatcher | - | ||||||
123 | subclass, you must install it with QCoreApplication::setEventDispatcher() | - | ||||||
124 | or QThread::setEventDispatcher() \e before a default event dispatcher has | - | ||||||
125 | been installed. | - | ||||||
126 | - | |||||||
127 | The main event loop is started by calling | - | ||||||
128 | QCoreApplication::exec(), and stopped by calling | - | ||||||
129 | QCoreApplication::exit(). Local event loops can be created using | - | ||||||
130 | QEventLoop. | - | ||||||
131 | - | |||||||
132 | Programs that perform long operations can call processEvents() | - | ||||||
133 | with a bitwise OR combination of various QEventLoop::ProcessEventsFlag | - | ||||||
134 | values to control which events should be delivered. | - | ||||||
135 | - | |||||||
136 | QAbstractEventDispatcher also allows the integration of an | - | ||||||
137 | external event loop with the Qt event loop. | - | ||||||
138 | - | |||||||
139 | \sa QEventLoop, QCoreApplication, QThread | - | ||||||
140 | */ | - | ||||||
141 | - | |||||||
142 | /*! | - | ||||||
143 | Constructs a new event dispatcher with the given \a parent. | - | ||||||
144 | */ | - | ||||||
145 | QAbstractEventDispatcher::QAbstractEventDispatcher(QObject *parent) | - | ||||||
146 | : QObject(*new QAbstractEventDispatcherPrivate, parent) {} executed 30 times by 4 tests: end of block Executed by:
| 30 | ||||||
147 | - | |||||||
148 | /*! | - | ||||||
149 | \internal | - | ||||||
150 | */ | - | ||||||
151 | QAbstractEventDispatcher::QAbstractEventDispatcher(QAbstractEventDispatcherPrivate &dd, | - | ||||||
152 | QObject *parent) | - | ||||||
153 | : QObject(dd, parent) {} executed 621759 times by 517 tests: end of block Executed by:
| 621759 | ||||||
154 | - | |||||||
155 | /*! | - | ||||||
156 | Destroys the event dispatcher. | - | ||||||
157 | */ | - | ||||||
158 | QAbstractEventDispatcher::~QAbstractEventDispatcher() | - | ||||||
159 | { } | - | ||||||
160 | - | |||||||
161 | /*! | - | ||||||
162 | Returns a pointer to the event dispatcher object for the specified | - | ||||||
163 | \a thread. If \a thread is zero, the current thread is used. If no | - | ||||||
164 | event dispatcher exists for the specified thread, this function | - | ||||||
165 | returns 0. | - | ||||||
166 | - | |||||||
167 | \b{Note:} If Qt is built without thread support, the \a thread | - | ||||||
168 | argument is ignored. | - | ||||||
169 | */ | - | ||||||
170 | QAbstractEventDispatcher *QAbstractEventDispatcher::instance(QThread *thread) | - | ||||||
171 | { | - | ||||||
172 | QThreadData *data = thread ? QThreadData::get2(thread) : QThreadData::current();
| 3646-659856 | ||||||
173 | return data->eventDispatcher.load(); executed 663502 times by 174 tests: return data->eventDispatcher.load(); Executed by:
| 663502 | ||||||
174 | } | - | ||||||
175 | - | |||||||
176 | /*! | - | ||||||
177 | \fn bool QAbstractEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) | - | ||||||
178 | - | |||||||
179 | Processes pending events that match \a flags until there are no | - | ||||||
180 | more events to process. Returns \c true if an event was processed; | - | ||||||
181 | otherwise returns \c false. | - | ||||||
182 | - | |||||||
183 | This function is especially useful if you have a long running | - | ||||||
184 | operation, and want to show its progress without allowing user | - | ||||||
185 | input by using the QEventLoop::ExcludeUserInputEvents flag. | - | ||||||
186 | - | |||||||
187 | If the QEventLoop::WaitForMoreEvents flag is set in \a flags, the | - | ||||||
188 | behavior of this function is as follows: | - | ||||||
189 | - | |||||||
190 | \list | - | ||||||
191 | - | |||||||
192 | \li If events are available, this function returns after processing | - | ||||||
193 | them. | - | ||||||
194 | - | |||||||
195 | \li If no events are available, this function will wait until more | - | ||||||
196 | are available and return after processing newly available events. | - | ||||||
197 | - | |||||||
198 | \endlist | - | ||||||
199 | - | |||||||
200 | If the QEventLoop::WaitForMoreEvents flag is not set in \a flags, | - | ||||||
201 | and no events are available, this function will return | - | ||||||
202 | immediately. | - | ||||||
203 | - | |||||||
204 | \b{Note:} This function does not process events continuously; it | - | ||||||
205 | returns after all available events are processed. | - | ||||||
206 | - | |||||||
207 | \sa hasPendingEvents() | - | ||||||
208 | */ | - | ||||||
209 | - | |||||||
210 | /*! \fn bool QAbstractEventDispatcher::hasPendingEvents() | - | ||||||
211 | \deprecated | - | ||||||
212 | - | |||||||
213 | Returns \c true if there is an event waiting; otherwise returns false. This | - | ||||||
214 | function is an implementation detail for | - | ||||||
215 | QCoreApplication::hasPendingEvents() and must not be called directly. | - | ||||||
216 | */ | - | ||||||
217 | - | |||||||
218 | /*! | - | ||||||
219 | \fn void QAbstractEventDispatcher::registerSocketNotifier(QSocketNotifier *notifier) | - | ||||||
220 | - | |||||||
221 | Registers \a notifier with the event loop. Subclasses must | - | ||||||
222 | implement this method to tie a socket notifier into another | - | ||||||
223 | event loop. | - | ||||||
224 | */ | - | ||||||
225 | - | |||||||
226 | /*! \fn void QAbstractEventDispatcher::unregisterSocketNotifier(QSocketNotifier *notifier) | - | ||||||
227 | - | |||||||
228 | Unregisters \a notifier from the event dispatcher. Subclasses must | - | ||||||
229 | reimplement this method to tie a socket notifier into another | - | ||||||
230 | event loop. Reimplementations must call the base | - | ||||||
231 | implementation. | - | ||||||
232 | */ | - | ||||||
233 | - | |||||||
234 | /*! | - | ||||||
235 | \obsolete | - | ||||||
236 | - | |||||||
237 | \fn int QAbstractEventDispatcher::registerTimer(int interval, QObject *object) | - | ||||||
238 | - | |||||||
239 | Registers a timer with the specified \a interval for the given \a object | - | ||||||
240 | and returns the timer id. | - | ||||||
241 | */ | - | ||||||
242 | - | |||||||
243 | /*! | - | ||||||
244 | \obsolete | - | ||||||
245 | - | |||||||
246 | \fn void QAbstractEventDispatcher::registerTimer(int timerId, int interval, QObject *object) | - | ||||||
247 | - | |||||||
248 | Register a timer with the specified \a timerId and \a interval for the | - | ||||||
249 | given \a object. | - | ||||||
250 | */ | - | ||||||
251 | - | |||||||
252 | /*! | - | ||||||
253 | Registers a timer with the specified \a interval and \a timerType for the | - | ||||||
254 | given \a object and returns the timer id. | - | ||||||
255 | */ | - | ||||||
256 | int QAbstractEventDispatcher::registerTimer(int interval, Qt::TimerType timerType, QObject *object) | - | ||||||
257 | { | - | ||||||
258 | int id = QAbstractEventDispatcherPrivate::allocateTimerId(); | - | ||||||
259 | registerTimer(id, interval, timerType, object); | - | ||||||
260 | return id; executed 166642 times by 206 tests: return id; Executed by:
| 166642 | ||||||
261 | } | - | ||||||
262 | - | |||||||
263 | /*! | - | ||||||
264 | \fn void QAbstractEventDispatcher::registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object) | - | ||||||
265 | - | |||||||
266 | Register a timer with the specified \a timerId, \a interval, and \a | - | ||||||
267 | timerType for the given \a object. | - | ||||||
268 | */ | - | ||||||
269 | - | |||||||
270 | /*! | - | ||||||
271 | \fn bool QAbstractEventDispatcher::unregisterTimer(int timerId) | - | ||||||
272 | - | |||||||
273 | Unregisters the timer with the given \a timerId. | - | ||||||
274 | Returns \c true if successful; otherwise returns \c false. | - | ||||||
275 | - | |||||||
276 | \sa registerTimer(), unregisterTimers() | - | ||||||
277 | */ | - | ||||||
278 | - | |||||||
279 | /*! | - | ||||||
280 | \fn bool QAbstractEventDispatcher::unregisterTimers(QObject *object) | - | ||||||
281 | - | |||||||
282 | Unregisters all the timers associated with the given \a object. | - | ||||||
283 | Returns \c true if all timers were successful removed; otherwise returns \c false. | - | ||||||
284 | - | |||||||
285 | \sa unregisterTimer(), registeredTimers() | - | ||||||
286 | */ | - | ||||||
287 | - | |||||||
288 | /*! | - | ||||||
289 | \fn QList<TimerInfo> QAbstractEventDispatcher::registeredTimers(QObject *object) const | - | ||||||
290 | - | |||||||
291 | Returns a list of registered timers for \a object. The TimerInfo struct has | - | ||||||
292 | \c timerId, \c interval, and \c timerType members. | - | ||||||
293 | - | |||||||
294 | \sa Qt::TimerType | - | ||||||
295 | */ | - | ||||||
296 | - | |||||||
297 | /*! | - | ||||||
298 | \fn int QAbstractEventDispatcher::remainingTime(int timerId) | - | ||||||
299 | - | |||||||
300 | Returns the remaining time in milliseconds with the given \a timerId. | - | ||||||
301 | If the timer is inactive, the returned value will be -1. If the timer is | - | ||||||
302 | overdue, the returned value will be 0. | - | ||||||
303 | - | |||||||
304 | \sa Qt::TimerType | - | ||||||
305 | */ | - | ||||||
306 | - | |||||||
307 | /*! \fn void QAbstractEventDispatcher::wakeUp() | - | ||||||
308 | \threadsafe | - | ||||||
309 | - | |||||||
310 | Wakes up the event loop. | - | ||||||
311 | - | |||||||
312 | \sa awake() | - | ||||||
313 | */ | - | ||||||
314 | - | |||||||
315 | /*! | - | ||||||
316 | \fn void QAbstractEventDispatcher::interrupt() | - | ||||||
317 | - | |||||||
318 | Interrupts event dispatching. The event dispatcher will | - | ||||||
319 | return from processEvents() as soon as possible. | - | ||||||
320 | */ | - | ||||||
321 | - | |||||||
322 | /*! \fn void QAbstractEventDispatcher::flush() | - | ||||||
323 | - | |||||||
324 | Flushes the event queue. This normally returns almost | - | ||||||
325 | immediately. Does nothing on platforms other than X11. | - | ||||||
326 | */ | - | ||||||
327 | - | |||||||
328 | // ### DOC: Are these called when the _application_ starts/stops or just | - | ||||||
329 | // when the current _event loop_ starts/stops? | - | ||||||
330 | /*! | - | ||||||
331 | \internal | - | ||||||
332 | */ | - | ||||||
333 | void QAbstractEventDispatcher::startingUp() | - | ||||||
334 | { } | - | ||||||
335 | - | |||||||
336 | /*! | - | ||||||
337 | \internal | - | ||||||
338 | */ | - | ||||||
339 | void QAbstractEventDispatcher::closingDown() | - | ||||||
340 | { } | - | ||||||
341 | - | |||||||
342 | /*! | - | ||||||
343 | \class QAbstractEventDispatcher::TimerInfo | - | ||||||
344 | \inmodule QtCore | - | ||||||
345 | - | |||||||
346 | This struct represents information about a timer: | - | ||||||
347 | \l{QAbstractEventDispatcher::TimerInfo::timerId}{timerId}, | - | ||||||
348 | \l{QAbstractEventDispatcher::TimerInfo::interval}{interval}, and | - | ||||||
349 | \l{QAbstractEventDispatcher::TimerInfo::timerType}{timerType}. | - | ||||||
350 | - | |||||||
351 | \sa registeredTimers() | - | ||||||
352 | */ | - | ||||||
353 | /*! \fn QAbstractEventDispatcher::TimerInfo::TimerInfo(int timerId, int interval, Qt::TimerType timerType) | - | ||||||
354 | - | |||||||
355 | Constructs a TimerInfo struct with the given \a timerId, \a interval, and | - | ||||||
356 | \a timerType. | - | ||||||
357 | */ | - | ||||||
358 | /*! | - | ||||||
359 | \variable QAbstractEventDispatcher::TimerInfo::timerId | - | ||||||
360 | - | |||||||
361 | The timer's unique id. | - | ||||||
362 | */ | - | ||||||
363 | /*! | - | ||||||
364 | \variable QAbstractEventDispatcher::TimerInfo::interval | - | ||||||
365 | - | |||||||
366 | The timer's interval. | - | ||||||
367 | */ | - | ||||||
368 | /*! | - | ||||||
369 | \variable QAbstractEventDispatcher::TimerInfo::timerType | - | ||||||
370 | - | |||||||
371 | The timer's type | - | ||||||
372 | - | |||||||
373 | \sa Qt::TimerType | - | ||||||
374 | */ | - | ||||||
375 | - | |||||||
376 | /*! | - | ||||||
377 | Installs an event filter \a filterObj for all native event filters | - | ||||||
378 | received by the application. | - | ||||||
379 | - | |||||||
380 | The event filter \a filterObj receives events via its \l {QAbstractNativeEventFilter::}{nativeEventFilter()} | - | ||||||
381 | function, which is called for all events received by all threads. | - | ||||||
382 | - | |||||||
383 | The \l {QAbstractNativeEventFilter::}{nativeEventFilter()} function should return true | - | ||||||
384 | if the event should be filtered, (in this case, stopped). It should return false to allow | - | ||||||
385 | normal Qt processing to continue: the native event can then be translated | - | ||||||
386 | into a QEvent and handled by the standard Qt \l{QEvent} {event} filtering, | - | ||||||
387 | e.g. QObject::installEventFilter(). | - | ||||||
388 | - | |||||||
389 | If multiple event filters are installed, the filter that was installed last | - | ||||||
390 | is activated first. | - | ||||||
391 | - | |||||||
392 | \note The filter function set here receives native messages, | - | ||||||
393 | that is, MSG or XEvent structs. | - | ||||||
394 | - | |||||||
395 | For maximum portability, you should always try to use QEvent objects | - | ||||||
396 | and QObject::installEventFilter() whenever possible. | - | ||||||
397 | - | |||||||
398 | \sa QObject::installEventFilter() | - | ||||||
399 | - | |||||||
400 | \since 5.0 | - | ||||||
401 | */ | - | ||||||
402 | void QAbstractEventDispatcher::installNativeEventFilter(QAbstractNativeEventFilter *filterObj) | - | ||||||
403 | { | - | ||||||
404 | Q_D(QAbstractEventDispatcher); | - | ||||||
405 | - | |||||||
406 | // clean up unused items in the list | - | ||||||
407 | d->eventFilters.removeAll(0); | - | ||||||
408 | d->eventFilters.removeAll(filterObj); | - | ||||||
409 | d->eventFilters.prepend(filterObj); | - | ||||||
410 | } executed 405 times by 2 tests: end of block Executed by:
| 405 | ||||||
411 | - | |||||||
412 | /*! | - | ||||||
413 | Removes the event filter \a filter from this object. The | - | ||||||
414 | request is ignored if such an event filter has not been installed. | - | ||||||
415 | - | |||||||
416 | All event filters for this object are automatically removed when | - | ||||||
417 | this object is destroyed. | - | ||||||
418 | - | |||||||
419 | It is always safe to remove an event filter, even during event filter | - | ||||||
420 | filter activation (that is, even from within the \l {QAbstractNativeEventFilter::}{nativeEventFilter()} function). | - | ||||||
421 | - | |||||||
422 | \sa installNativeEventFilter(), QAbstractNativeEventFilter | - | ||||||
423 | \since 5.0 | - | ||||||
424 | */ | - | ||||||
425 | void QAbstractEventDispatcher::removeNativeEventFilter(QAbstractNativeEventFilter *filter) | - | ||||||
426 | { | - | ||||||
427 | Q_D(QAbstractEventDispatcher); | - | ||||||
428 | for (int i = 0; i < d->eventFilters.count(); ++i) {
| 73-478 | ||||||
429 | if (d->eventFilters.at(i) == filter) {
| 73-405 | ||||||
430 | d->eventFilters[i] = 0; | - | ||||||
431 | break; executed 405 times by 2 tests: break; Executed by:
| 405 | ||||||
432 | } | - | ||||||
433 | } executed 73 times by 1 test: end of block Executed by:
| 73 | ||||||
434 | } executed 478 times by 2 tests: end of block Executed by:
| 478 | ||||||
435 | - | |||||||
436 | /*! | - | ||||||
437 | Sends \a message through the event filters that were set by | - | ||||||
438 | installNativeEventFilter(). This function returns \c true as soon as an | - | ||||||
439 | event filter returns \c true, and false otherwise to indicate that | - | ||||||
440 | the processing of the event should continue. | - | ||||||
441 | - | |||||||
442 | Subclasses of QAbstractEventDispatcher \e must call this function | - | ||||||
443 | for \e all messages received from the system to ensure | - | ||||||
444 | compatibility with any extensions that may be used in the | - | ||||||
445 | application. The type of event \a eventType is specific to the platform | - | ||||||
446 | plugin chosen at run-time, and can be used to cast message to the right type. | - | ||||||
447 | The \a result pointer is only used on Windows, and corresponds to the LRESULT pointer. | - | ||||||
448 | - | |||||||
449 | Note that the type of \a message is platform dependent. See | - | ||||||
450 | QAbstractNativeEventFilter for details. | - | ||||||
451 | - | |||||||
452 | \sa installNativeEventFilter(), QAbstractNativeEventFilter::nativeEventFilter() | - | ||||||
453 | \since 5.0 | - | ||||||
454 | */ | - | ||||||
455 | bool QAbstractEventDispatcher::filterNativeEvent(const QByteArray &eventType, void *message, long *result) | - | ||||||
456 | { | - | ||||||
457 | Q_D(QAbstractEventDispatcher); | - | ||||||
458 | if (!d->eventFilters.isEmpty()) {
| 242174-2647856 | ||||||
459 | // Raise the loopLevel so that deleteLater() calls in or triggered | - | ||||||
460 | // by event_filter() will be processed from the main event loop. | - | ||||||
461 | QScopedScopeLevelCounter scopeLevelCounter(d->threadData); | - | ||||||
462 | for (int i = 0; i < d->eventFilters.size(); ++i) {
| 2647856 | ||||||
463 | QAbstractNativeEventFilter *filter = d->eventFilters.at(i); | - | ||||||
464 | if (!filter)
| 6612-2641244 | ||||||
465 | continue; executed 6612 times by 1 test: continue; Executed by:
| 6612 | ||||||
466 | if (filter->nativeEventFilter(eventType, message, result))
| 0-2641244 | ||||||
467 | return true; never executed: return true; | 0 | ||||||
468 | } executed 2641244 times by 2 tests: end of block Executed by:
| 2641244 | ||||||
469 | } executed 2647856 times by 2 tests: end of block Executed by:
| 2647856 | ||||||
470 | return false; executed 2890030 times by 114 tests: return false; Executed by:
| 2890030 | ||||||
471 | } | - | ||||||
472 | - | |||||||
473 | /*! \fn bool QAbstractEventDispatcher::filterEvent(void *message) | - | ||||||
474 | \deprecated | - | ||||||
475 | - | |||||||
476 | Calls filterNativeEvent() with an empty eventType and \a message. | - | ||||||
477 | This function returns \c true as soon as an | - | ||||||
478 | event filter returns \c true, and false otherwise to indicate that | - | ||||||
479 | the processing of the event should continue. | - | ||||||
480 | */ | - | ||||||
481 | - | |||||||
482 | /*! \fn bool QAbstractEventDispatcher::registerEventNotifier(QWinEventNotifier *notifier); | - | ||||||
483 | - | |||||||
484 | This pure virtual method exists on windows only and has to be reimplemented by a Windows specific | - | ||||||
485 | event dispatcher implementation. \a notifier is the QWinEventNotifier instance to be registered. | - | ||||||
486 | - | |||||||
487 | The method should return true if the registration of \a notifier was sucessful, otherwise false. | - | ||||||
488 | - | |||||||
489 | QWinEventNotifier calls this method in it's constructor and there should never be a need to call this | - | ||||||
490 | method directly. | - | ||||||
491 | - | |||||||
492 | \sa QWinEventNotifier, unregisterEventNotifier() | - | ||||||
493 | */ | - | ||||||
494 | - | |||||||
495 | /*! \fn bool QAbstractEventDispatcher::unregisterEventNotifier(QWinEventNotifier *notifier); | - | ||||||
496 | - | |||||||
497 | This pure virtual method exists on windows only and has to be reimplemented by a Windows specific | - | ||||||
498 | event dispatcher implementation. \a notifier is the QWinEventNotifier instance to be unregistered. | - | ||||||
499 | - | |||||||
500 | QWinEventNotifier calls this method in it's destructor and there should never be a need to call this | - | ||||||
501 | method directly. | - | ||||||
502 | - | |||||||
503 | \sa QWinEventNotifier, registerEventNotifier() | - | ||||||
504 | */ | - | ||||||
505 | - | |||||||
506 | /*! \fn void QAbstractEventDispatcher::awake() | - | ||||||
507 | - | |||||||
508 | This signal is emitted after the event loop returns from a | - | ||||||
509 | function that could block. | - | ||||||
510 | - | |||||||
511 | \sa wakeUp(), aboutToBlock() | - | ||||||
512 | */ | - | ||||||
513 | - | |||||||
514 | /*! \fn void QAbstractEventDispatcher::aboutToBlock() | - | ||||||
515 | - | |||||||
516 | This signal is emitted before the event loop calls a function that | - | ||||||
517 | could block. | - | ||||||
518 | - | |||||||
519 | \sa awake() | - | ||||||
520 | */ | - | ||||||
521 | - | |||||||
522 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |