7#include <QtCore/QThread>
9#include <QtCore/QEventLoop>
10#include <QtCore/QList>
11#include <QtCore/QMutex>
12#include <QtCore/QWaitCondition>
22 QXcbEventNode(xcb_generic_event_t *e =
nullptr)
25 xcb_generic_event_t *event;
26 QXcbEventNode *next =
nullptr;
27 bool fromHeap =
false;
31class QAbstractEventDispatcher;
66 bool isEmpty()
const {
return m_head == m_flushedTail && !m_head->event; }
67 xcb_generic_event_t *
takeFirst(QEventLoop::ProcessEventsFlags flags);
75 template<
typename Peeker>
76 xcb_generic_event_t *
peek(Peeker &&peeker) {
79 template<
typename Peeker>
80 inline xcb_generic_event_t *
peek(
PeekOption config, Peeker &&peeker);
85 using PeekerCallback =
bool (*)(xcb_generic_event_t *event,
void *peekerData);
87 PeekOptions option =
PeekDefault, qint32 peekerId = -1);
89 const QXcbEventNode *
flushedTail()
const {
return m_flushedTail; }
91 unsigned long time = (
std::numeric_limits<
unsigned long>::max)());
94 QXcbEventNode *qXcbEventNodeFactory(xcb_generic_event_t *event);
97 void sendCloseConnectionEvent()
const;
98 bool isCloseConnectionEvent(
const xcb_generic_event_t *event);
100 QXcbEventNode *m_head =
nullptr;
101 QXcbEventNode *m_flushedTail =
nullptr;
102 std::atomic<QXcbEventNode *> m_tail {
nullptr };
103 std::atomic_uint m_nodesRestored { 0 };
105 QXcbConnection *m_connection =
nullptr;
106 bool m_closeConnectionDetected =
false;
109 uint m_poolIndex = 0;
111 qint32 m_peekerIdSource = 0;
112 bool m_queueModified =
false;
113 bool m_peekerIndexCacheDirty =
false;
114 QHash<qint32, QXcbEventNode *> m_peekerToNode;
116 QList<xcb_generic_event_t *> m_inputEvents;
119 quint64 m_nodesOnHeap = 0;
121 QMutex m_newEventsMutex;
122 QWaitCondition m_newEventsCondition;
125template<
typename Peeker>
132 QXcbEventNode *node = m_head;
134 xcb_generic_event_t *event = node->event;
135 if (event && peeker(event, event->response_type & ~0x80)) {
137 node->event =
nullptr;
142 if (node == m_flushedTail)
bool(*)(xcb_generic_event_t *event, void *peekerData) PeekerCallback
bool removePeekerId(qint32 peekerId)
qint32 generatePeekerId()
const QXcbEventNode * flushedTail() const
xcb_generic_event_t * peek(PeekOption config, Peeker &&peeker)
@ PeekConsumeMatchAndContinue
xcb_generic_event_t * takeFirst(QEventLoop::ProcessEventsFlags flags)
xcb_generic_event_t * peek(Peeker &&peeker)
xcb_generic_event_t * takeFirst()
void flushBufferedEvents()
void waitForNewEvents(const QXcbEventNode *sinceFlushedTail, unsigned long time=(std::numeric_limits< unsigned long >::max)())
bool peekEventQueue(PeekerCallback peeker, void *peekerData=nullptr, PeekOptions option=PeekDefault, qint32 peekerId=-1)
bool isForeignWindow() const override
QXcbForeignWindow(QWindow *window, WId nativeHandle)
QXcbConnection * connection() const
xcb_connection_t * xcb_connection() const
xcb_atom_t atom(QXcbAtom::Atom atom) const
void setConnection(QXcbConnection *connection)
QXcbObject(QXcbConnection *connection=nullptr)
QXcbWindow * window() const
QXcbSyncWindowRequest(QXcbWindow *w)
virtual ~QXcbWindowEventListener()
virtual void handleConfigureNotifyEvent(const xcb_configure_notify_event_t *)
virtual void handleUnmapNotifyEvent(const xcb_unmap_notify_event_t *)
virtual void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource=Qt::MouseEventNotSynthesized)
virtual void handleButtonPressEvent(const xcb_button_press_event_t *)
virtual void handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
virtual void handleMapNotifyEvent(const xcb_map_notify_event_t *)
virtual void handleClientMessageEvent(const xcb_client_message_event_t *)
virtual void handleDestroyNotifyEvent(const xcb_destroy_notify_event_t *)
virtual void handleXIEnterLeave(xcb_ge_event_t *)
virtual void handleMotionNotifyEvent(const xcb_motion_notify_event_t *)
virtual void handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
virtual void handleButtonReleaseEvent(const xcb_button_release_event_t *)
virtual void handleExposeEvent(const xcb_expose_event_t *)
virtual void handleFocusOutEvent(const xcb_focus_out_event_t *)
virtual void handleFocusInEvent(const xcb_focus_in_event_t *)
virtual void handlePropertyNotifyEvent(const xcb_property_notify_event_t *)
virtual bool handleNativeEvent(xcb_generic_event_t *)
virtual QXcbWindow * toWindow()
QHash< xcb_window_t, QXcbWindowEventListener * > WindowMapper
QList< xcb_rectangle_t > qRegionToXcbRectangleList(const QRegion ®ion)