| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qabstractnativeeventfilter.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||
| 7 | ** | - | ||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||
| 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 http://www.qt.io/terms-conditions. For further | - | ||||||
| 15 | ** information use the contact form at http://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 2.1 or version 3 as published by the Free | - | ||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||
| 25 | ** | - | ||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||
| 29 | ** | - | ||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||
| 31 | ** | - | ||||||
| 32 | ****************************************************************************/ | - | ||||||
| 33 | - | |||||||
| 34 | #include "qabstractnativeeventfilter.h" | - | ||||||
| 35 | #include "qabstracteventdispatcher.h" | - | ||||||
| 36 | - | |||||||
| 37 | QT_BEGIN_NAMESPACE | - | ||||||
| 38 | - | |||||||
| 39 | /*! | - | ||||||
| 40 | \class QAbstractNativeEventFilter | - | ||||||
| 41 | \inmodule QtCore | - | ||||||
| 42 | \since 5.0 | - | ||||||
| 43 | - | |||||||
| 44 | \brief The QAbstractNativeEventFilter class provides an interface for receiving native | - | ||||||
| 45 | events, such as MSG or XCB event structs. | - | ||||||
| 46 | */ | - | ||||||
| 47 | - | |||||||
| 48 | /*! | - | ||||||
| 49 | Creates a native event filter. | - | ||||||
| 50 | - | |||||||
| 51 | By default this doesn't do anything. Remember to install it on the application | - | ||||||
| 52 | object. | - | ||||||
| 53 | */ | - | ||||||
| 54 | QAbstractNativeEventFilter::QAbstractNativeEventFilter() | - | ||||||
| 55 | { | - | ||||||
| 56 | Q_UNUSED(d); | - | ||||||
| 57 | } executed 70 times by 2 tests: end of blockExecuted by:
| 70 | ||||||
| 58 | - | |||||||
| 59 | /*! | - | ||||||
| 60 | Destroys the native event filter. | - | ||||||
| 61 | - | |||||||
| 62 | This automatically removes it from the application. | - | ||||||
| 63 | */ | - | ||||||
| 64 | QAbstractNativeEventFilter::~QAbstractNativeEventFilter() | - | ||||||
| 65 | { | - | ||||||
| 66 | QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance(); | - | ||||||
| 67 | if (eventDispatcher)
| 0-70 | ||||||
| 68 | eventDispatcher->removeNativeEventFilter(this); executed 70 times by 2 tests: eventDispatcher->removeNativeEventFilter(this);Executed by:
| 70 | ||||||
| 69 | } executed 70 times by 2 tests: end of blockExecuted by:
| 70 | ||||||
| 70 | - | |||||||
| 71 | /*! | - | ||||||
| 72 | \fn bool QAbstractNativeEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) | - | ||||||
| 73 | - | |||||||
| 74 | This method is called for every native event. | - | ||||||
| 75 | - | |||||||
| 76 | \note The filter function here receives native messages, | - | ||||||
| 77 | for example, MSG or XCB event structs. | - | ||||||
| 78 | - | |||||||
| 79 | It is called by the QPA platform plugin. On Windows, it is called by | - | ||||||
| 80 | the event dispatcher. | - | ||||||
| 81 | - | |||||||
| 82 | The type of event \a eventType is specific to the platform plugin chosen at run-time, | - | ||||||
| 83 | and can be used to cast \a message to the right type. | - | ||||||
| 84 | - | |||||||
| 85 | On X11, \a eventType is set to "xcb_generic_event_t", and the \a message can be casted | - | ||||||
| 86 | to a xcb_generic_event_t pointer. | - | ||||||
| 87 | - | |||||||
| 88 | On Windows, \a eventType is set to "windows_generic_MSG" for messages sent to toplevel windows, | - | ||||||
| 89 | and "windows_dispatcher_MSG" for system-wide messages such as messages from a registered hot key. | - | ||||||
| 90 | In both cases, the \a message can be casted to a MSG pointer. | - | ||||||
| 91 | The \a result pointer is only used on Windows, and corresponds to the LRESULT pointer. | - | ||||||
| 92 | - | |||||||
| 93 | On macOS, \a eventType is set to "mac_generic_NSEvent", and the \a message can be casted to an NSEvent pointer. | - | ||||||
| 94 | - | |||||||
| 95 | On Blackberry (not plain QNX) \a eventType is set to "bps_event_t", and the \a message can be casted | - | ||||||
| 96 | to a bps_event_t pointer. | - | ||||||
| 97 | - | |||||||
| 98 | In your reimplementation of this function, if you want to filter | - | ||||||
| 99 | the \a message out, i.e. stop it being handled further, return | - | ||||||
| 100 | true; otherwise return false. | - | ||||||
| 101 | - | |||||||
| 102 | \b {Linux example} | - | ||||||
| 103 | \snippet code/src_corelib_kernel_qabstractnativeeventfilter.cpp 0 | - | ||||||
| 104 | - | |||||||
| 105 | \b {macOS example} | - | ||||||
| 106 | - | |||||||
| 107 | mycocoaeventfilter.h: | - | ||||||
| 108 | \snippet code/src_corelib_kernel_qabstractnativeeventfilter.h 0 | - | ||||||
| 109 | - | |||||||
| 110 | mycocoaeventfilter.mm: | - | ||||||
| 111 | \snippet code/src_corelib_kernel_qabstractnativeeventfilter.mm 0 | - | ||||||
| 112 | - | |||||||
| 113 | myapp.pro: | - | ||||||
| 114 | \snippet code/src_corelib_kernel_qabstractnativeeventfilter.pro 0 | - | ||||||
| 115 | */ | - | ||||||
| 116 | - | |||||||
| 117 | QT_END_NAMESPACE | - | ||||||
| Source code | Switch to Preprocessed file |