Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:21

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QCOREEVENT_H
0005 #define QCOREEVENT_H
0006 
0007 #include <QtCore/qnamespace.h>
0008 #include <QtCore/qbytearray.h>
0009 #include <QtCore/qobjectdefs.h>
0010 
0011 QT_BEGIN_NAMESPACE
0012 
0013 #define Q_EVENT_DISABLE_COPY(Class) \
0014 protected: \
0015     Class(const Class &) = default; \
0016     Class(Class &&) = delete; \
0017     Class &operator=(const Class &other) = default; \
0018     Class &operator=(Class &&) = delete
0019 
0020 #define Q_DECL_EVENT_COMMON(Class) \
0021     protected: \
0022         Class(const Class &); \
0023         Class(Class &&) = delete; \
0024         Class &operator=(const Class &other) = default; \
0025         Class &operator=(Class &&) = delete; \
0026     public: \
0027         Class* clone() const override; \
0028         ~Class() override; \
0029     private:
0030 
0031 #define Q_IMPL_EVENT_COMMON(Class) \
0032     Class::Class(const Class &) = default; \
0033     Class::~Class() = default; \
0034     Class* Class::clone() const \
0035     { \
0036         auto c = new Class(*this); \
0037         [[maybe_unused]] QEvent *e = c; \
0038         /* check that covariant return is safe to add */ \
0039         Q_ASSERT(reinterpret_cast<quintptr>(c) == reinterpret_cast<quintptr>(e)); \
0040         return c; \
0041     }
0042 
0043 class QEventPrivate;
0044 class Q_CORE_EXPORT QEvent           // event base class
0045 {
0046     Q_GADGET
0047     QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
0048 
0049     Q_EVENT_DISABLE_COPY(QEvent);
0050 public:
0051     enum Type {
0052         /*
0053           If you get a strange compiler error on the line with None,
0054           it's probably because you're also including X11 headers,
0055           which #define the symbol None. Put the X11 includes after
0056           the Qt includes to solve this problem.
0057         */
0058         None = 0,                               // invalid event
0059         Timer = 1,                              // timer event
0060         MouseButtonPress = 2,                   // mouse button pressed
0061         MouseButtonRelease = 3,                 // mouse button released
0062         MouseButtonDblClick = 4,                // mouse button double click
0063         MouseMove = 5,                          // mouse move
0064         KeyPress = 6,                           // key pressed
0065         KeyRelease = 7,                         // key released
0066         FocusIn = 8,                            // keyboard focus received
0067         FocusOut = 9,                           // keyboard focus lost
0068         FocusAboutToChange = 23,                // keyboard focus is about to be lost
0069         Enter = 10,                             // mouse enters widget
0070         Leave = 11,                             // mouse leaves widget
0071         Paint = 12,                             // paint widget
0072         Move = 13,                              // move widget
0073         Resize = 14,                            // resize widget
0074         Create = 15,                            // after widget creation
0075         Destroy = 16,                           // during widget destruction
0076         Show = 17,                              // widget is shown
0077         Hide = 18,                              // widget is hidden
0078         Close = 19,                             // request to close widget
0079         Quit = 20,                              // request to quit application
0080         ParentChange = 21,                      // object has been reparented
0081         ParentAboutToChange = 131,              // sent just before the parent change is done
0082         ThreadChange = 22,                      // object has changed threads
0083         WindowActivate = 24,                    // window was activated
0084         WindowDeactivate = 25,                  // window was deactivated
0085         ShowToParent = 26,                      // widget is shown to parent
0086         HideToParent = 27,                      // widget is hidden to parent
0087         Wheel = 31,                             // wheel event
0088         WindowTitleChange = 33,                 // window title changed
0089         WindowIconChange = 34,                  // icon changed
0090         ApplicationWindowIconChange = 35,       // application icon changed
0091         ApplicationFontChange = 36,             // application font changed
0092         ApplicationLayoutDirectionChange = 37,  // application layout direction changed
0093         ApplicationPaletteChange = 38,          // application palette changed
0094         PaletteChange = 39,                     // widget palette changed
0095         Clipboard = 40,                         // internal clipboard event
0096         Speech = 42,                            // reserved for speech input
0097         MetaCall =  43,                         // meta call event
0098         SockAct = 50,                           // socket activation
0099         WinEventAct = 132,                      // win event activation
0100         DeferredDelete = 52,                    // deferred delete event
0101         DragEnter = 60,                         // drag moves into widget
0102         DragMove = 61,                          // drag moves in widget
0103         DragLeave = 62,                         // drag leaves or is cancelled
0104         Drop = 63,                              // actual drop
0105         DragResponse = 64,                      // drag accepted/rejected
0106         ChildAdded = 68,                        // new child widget
0107         ChildPolished = 69,                     // polished child widget
0108         ChildRemoved = 71,                      // deleted child widget
0109         ShowWindowRequest = 73,                 // widget's window should be mapped
0110         PolishRequest = 74,                     // widget should be polished
0111         Polish = 75,                            // widget is polished
0112         LayoutRequest = 76,                     // widget should be relayouted
0113         UpdateRequest = 77,                     // widget should be repainted
0114         UpdateLater = 78,                       // request update() later
0115 
0116         EmbeddingControl = 79,                  // ActiveX embedding
0117         ActivateControl = 80,                   // ActiveX activation
0118         DeactivateControl = 81,                 // ActiveX deactivation
0119         ContextMenu = 82,                       // context popup menu
0120         InputMethod = 83,                       // input method
0121         TabletMove = 87,                        // Wacom tablet event
0122         LocaleChange = 88,                      // the system locale changed
0123         LanguageChange = 89,                    // the application language changed
0124         LayoutDirectionChange = 90,             // the layout direction changed
0125         Style = 91,                             // internal style event
0126         TabletPress = 92,                       // tablet press
0127         TabletRelease = 93,                     // tablet release
0128         OkRequest = 94,                         // CE (Ok) button pressed
0129         HelpRequest = 95,                       // CE (?)  button pressed
0130 
0131         IconDrag = 96,                          // proxy icon dragged
0132 
0133         FontChange = 97,                        // font has changed
0134         EnabledChange = 98,                     // enabled state has changed
0135         ActivationChange = 99,                  // window activation has changed
0136         StyleChange = 100,                      // style has changed
0137         IconTextChange = 101,                   // icon text has changed.  Deprecated.
0138         ModifiedChange = 102,                   // modified state has changed
0139         MouseTrackingChange = 109,              // mouse tracking state has changed
0140 
0141         WindowBlocked = 103,                    // window is about to be blocked modally
0142         WindowUnblocked = 104,                  // windows modal blocking has ended
0143         WindowStateChange = 105,
0144 
0145         ReadOnlyChange = 106,                   // readonly state has changed
0146 
0147         ToolTip = 110,
0148         WhatsThis = 111,
0149         StatusTip = 112,
0150 
0151         ActionChanged = 113,
0152         ActionAdded = 114,
0153         ActionRemoved = 115,
0154 
0155         FileOpen = 116,                         // file open request
0156 
0157         Shortcut = 117,                         // shortcut triggered
0158         ShortcutOverride = 51,                  // shortcut override request
0159 
0160         WhatsThisClicked = 118,
0161 
0162         ToolBarChange = 120,                    // toolbar visibility toggled
0163 
0164         ApplicationActivate = 121,              // deprecated. Use ApplicationStateChange instead.
0165         ApplicationActivated = ApplicationActivate, // deprecated
0166         ApplicationDeactivate = 122,            // deprecated. Use ApplicationStateChange instead.
0167         ApplicationDeactivated = ApplicationDeactivate, // deprecated
0168 
0169         QueryWhatsThis = 123,                   // query what's this widget help
0170         EnterWhatsThisMode = 124,
0171         LeaveWhatsThisMode = 125,
0172 
0173         ZOrderChange = 126,                     // child widget has had its z-order changed
0174 
0175         HoverEnter = 127,                       // mouse cursor enters a hover widget
0176         HoverLeave = 128,                       // mouse cursor leaves a hover widget
0177         HoverMove = 129,                        // mouse cursor move inside a hover widget
0178 
0179         // last event id used = 132
0180 
0181 #ifdef QT_KEYPAD_NAVIGATION
0182         EnterEditFocus = 150,                   // enter edit mode in keypad navigation
0183         LeaveEditFocus = 151,                   // enter edit mode in keypad navigation
0184 #endif
0185         AcceptDropsChange = 152,
0186 
0187         ZeroTimerEvent = 154,                   // Used for Windows Zero timer events
0188 
0189         GraphicsSceneMouseMove = 155,           // GraphicsView
0190         GraphicsSceneMousePress = 156,
0191         GraphicsSceneMouseRelease = 157,
0192         GraphicsSceneMouseDoubleClick = 158,
0193         GraphicsSceneContextMenu = 159,
0194         GraphicsSceneHoverEnter = 160,
0195         GraphicsSceneHoverMove = 161,
0196         GraphicsSceneHoverLeave = 162,
0197         GraphicsSceneHelp = 163,
0198         GraphicsSceneDragEnter = 164,
0199         GraphicsSceneDragMove = 165,
0200         GraphicsSceneDragLeave = 166,
0201         GraphicsSceneDrop = 167,
0202         GraphicsSceneWheel = 168,
0203         GraphicsSceneLeave = 220,
0204 
0205         KeyboardLayoutChange = 169,             // keyboard layout changed
0206 
0207         DynamicPropertyChange = 170,            // A dynamic property was changed through setProperty/property
0208 
0209         TabletEnterProximity = 171,
0210         TabletLeaveProximity = 172,
0211 
0212         NonClientAreaMouseMove = 173,
0213         NonClientAreaMouseButtonPress = 174,
0214         NonClientAreaMouseButtonRelease = 175,
0215         NonClientAreaMouseButtonDblClick = 176,
0216 
0217         MacSizeChange = 177,                    // when the Qt::WA_Mac{Normal,Small,Mini}Size changes
0218 
0219         ContentsRectChange = 178,               // sent by QWidget::setContentsMargins (internal)
0220 
0221         MacGLWindowChange = 179,                // Internal! the window of the GLWidget has changed
0222 
0223         FutureCallOut = 180,
0224 
0225         GraphicsSceneResize  = 181,
0226         GraphicsSceneMove  = 182,
0227 
0228         CursorChange = 183,
0229         ToolTipChange = 184,
0230 
0231         NetworkReplyUpdated = 185,              // Internal for QNetworkReply
0232 
0233         GrabMouse = 186,
0234         UngrabMouse = 187,
0235         GrabKeyboard = 188,
0236         UngrabKeyboard = 189,
0237 
0238         StateMachineSignal = 192,
0239         StateMachineWrapped = 193,
0240 
0241         TouchBegin = 194,
0242         TouchUpdate = 195,
0243         TouchEnd = 196,
0244 
0245 #ifndef QT_NO_GESTURES
0246         NativeGesture = 197,                    // QtGui native gesture
0247 #endif
0248         RequestSoftwareInputPanel = 199,
0249         CloseSoftwareInputPanel = 200,
0250 
0251         WinIdChange = 203,
0252 #ifndef QT_NO_GESTURES
0253         Gesture = 198,
0254         GestureOverride = 202,
0255 #endif
0256         ScrollPrepare = 204,
0257         Scroll = 205,
0258 
0259         Expose = 206,
0260 
0261         InputMethodQuery = 207,
0262         OrientationChange = 208,                // Screen orientation has changed
0263 
0264         TouchCancel = 209,
0265 
0266         ThemeChange = 210,
0267 
0268         SockClose = 211,                        // socket closed
0269 
0270         PlatformPanel = 212,
0271 
0272         StyleAnimationUpdate = 213,             // style animation target should be updated
0273         ApplicationStateChange = 214,
0274 
0275         WindowChangeInternal = 215,             // internal for QQuickWidget and texture-based widgets
0276         ScreenChangeInternal = 216,
0277 
0278         PlatformSurface = 217,                  // Platform surface created or about to be destroyed
0279 
0280         Pointer = 218,                          // Qt 5: QQuickPointerEvent; Qt 6: unused so far
0281 
0282         TabletTrackingChange = 219,             // tablet tracking state has changed
0283 
0284         // GraphicsSceneLeave = 220,
0285         WindowAboutToChangeInternal = 221,      // internal for QQuickWidget and texture-based widgets
0286 
0287         DevicePixelRatioChange = 222,
0288 
0289         ChildWindowAdded = 223,
0290         ChildWindowRemoved = 224,
0291         ParentWindowAboutToChange = 225,
0292         ParentWindowChange = 226,
0293 
0294         // 512 reserved for Qt Jambi's MetaCall event
0295         // 513 reserved for Qt Jambi's DeleteOnMainThread event
0296 
0297         User = 1000,                            // first user event id
0298         MaxUser = 65535                         // last user event id
0299     };
0300     Q_ENUM(Type)
0301 
0302     explicit QEvent(Type type);
0303     virtual ~QEvent();
0304     inline Type type() const { return static_cast<Type>(t); }
0305     inline bool spontaneous() const { return m_spont; }
0306 
0307     inline virtual void setAccepted(bool accepted) { m_accept = accepted; }
0308     inline bool isAccepted() const { return m_accept; }
0309 
0310     inline void accept() { m_accept = true; }
0311     inline void ignore() { m_accept = false; }
0312 
0313     inline bool isInputEvent() const noexcept { return m_inputEvent; }
0314     inline bool isPointerEvent() const noexcept { return m_pointerEvent; }
0315     inline bool isSinglePointEvent() const noexcept { return m_singlePointEvent; }
0316 
0317     static int registerEventType(int hint = -1) noexcept;
0318 
0319     virtual QEvent *clone() const;
0320 
0321 protected:
0322     struct InputEventTag { explicit InputEventTag() = default; };
0323     QEvent(Type type, InputEventTag) : QEvent(type) { m_inputEvent = true; }
0324     struct PointerEventTag { explicit PointerEventTag() = default; };
0325     QEvent(Type type, PointerEventTag) : QEvent(type, InputEventTag{}) { m_pointerEvent = true; }
0326     struct SinglePointEventTag { explicit SinglePointEventTag() = default; };
0327     QEvent(Type type, SinglePointEventTag) : QEvent(type, PointerEventTag{}) { m_singlePointEvent = true; }
0328     quint16 t;
0329 
0330 private:
0331     /*
0332         We can assume that C++ types are 8-byte aligned, and we can't assume that compilers
0333         coalesce data members from subclasses. Use bitfields to fill up to next 8-byte
0334         aligned size, which is 16 bytes. That way we don't waste memory, and have plenty of room
0335         for future flags.
0336         Don't use bitfields for the most important flags, as that would generate more code, and
0337         access is always inline. Bytes used are:
0338         8 vptr + 2 type + 3 bool flags => 3 bytes left, so 24 bits. However, compilers will word-
0339         align the quint16s after the bools, so add another unused bool to fill that gap, which
0340         leaves us with 16 bits.
0341     */
0342     bool m_posted = false;
0343     bool m_spont = false;
0344     bool m_accept = true;
0345     bool m_unused = false;
0346     quint16 m_reserved : 13;
0347     quint16 m_inputEvent : 1;
0348     quint16 m_pointerEvent : 1;
0349     quint16 m_singlePointEvent : 1;
0350 
0351     friend class QCoreApplication;
0352     friend class QCoreApplicationPrivate;
0353     friend class QThreadData;
0354     friend class QApplication;
0355     friend class QGraphicsScenePrivate;
0356     // from QtTest:
0357     friend class QSpontaneKeyEvent;
0358     // needs this:
0359     Q_ALWAYS_INLINE
0360     void setSpontaneous() { m_spont = true; }
0361 };
0362 
0363 class Q_CORE_EXPORT QTimerEvent : public QEvent
0364 {
0365     Q_DECL_EVENT_COMMON(QTimerEvent)
0366 public:
0367     explicit QTimerEvent(int timerId);
0368     int timerId() const { return id; }
0369 
0370 protected:
0371     int id;
0372 };
0373 
0374 class QObject;
0375 
0376 class Q_CORE_EXPORT QChildEvent : public QEvent
0377 {
0378     Q_DECL_EVENT_COMMON(QChildEvent)
0379 public:
0380     QChildEvent(Type type, QObject *child);
0381 
0382     QObject *child() const { return c; }
0383     bool added() const { return type() == ChildAdded; }
0384     bool polished() const { return type() == ChildPolished; }
0385     bool removed() const { return type() == ChildRemoved; }
0386 
0387 protected:
0388     QObject *c;
0389 };
0390 
0391 class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent
0392 {
0393     Q_DECL_EVENT_COMMON(QDynamicPropertyChangeEvent)
0394 public:
0395     explicit QDynamicPropertyChangeEvent(const QByteArray &name);
0396 
0397     inline QByteArray propertyName() const { return n; }
0398 
0399 private:
0400     QByteArray n;
0401 };
0402 
0403 QT_END_NAMESPACE
0404 
0405 #endif // QCOREEVENT_H