if (m_connection)
qDebug("Successfully connected to display %s", m_displayName.constData());
- m_reader = new QXcbEventReader(m_connection);
+ m_reader = new QXcbEventReader(this);
#ifdef XCB_POLL_FOR_QUEUED_EVENT
connect(m_reader, SIGNAL(eventPending()), this, SLOT(processXcbEvents()), Qt::QueuedConnection);
m_reader->start();
void QXcbEventReader::run()
{
xcb_generic_event_t *event;
- while (m_connection && (event = xcb_wait_for_event(m_connection))) {
+ while (m_connection && (event = xcb_wait_for_event(m_connection->xcb_connection()))) {
m_mutex.lock();
addEvent(event);
- while (m_connection && (event = xcb_poll_for_queued_event(m_connection)))
+ while (m_connection && (event = xcb_poll_for_queued_event(m_connection->xcb_connection())))
addEvent(event);
m_mutex.unlock();
emit eventPending();
void QXcbEventReader::addEvent(xcb_generic_event_t *event)
{
if ((event->response_type & ~0x80) == XCB_CLIENT_MESSAGE
- && ((xcb_client_message_event_t *)event)->type == QXcbAtom::_QT_CLOSE_CONNECTION)
+ && ((xcb_client_message_event_t *)event)->type == m_connection->atom(QXcbAtom::_QT_CLOSE_CONNECTION))
m_connection = 0;
m_events << event;
}
{
m_mutex.lock();
#ifndef XCB_POLL_FOR_QUEUED_EVENT
- while (xcb_generic_event_t *event = xcb_poll_for_event(m_connection))
+ while (xcb_generic_event_t *event = xcb_poll_for_event(m_connection->xcb_connection()))
m_events << event;
#endif
return &m_events;
m_mutex.unlock();
}
-void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom atom, uint id)
+void QXcbConnection::sendConnectionEvent(QXcbAtom::Atom a, uint id)
{
xcb_client_message_event_t event;
memset(&event, 0, sizeof(event));
event.format = 32;
event.sequence = 0;
event.window = m_connectionEventListener;
- event.type = atom;
+ event.type = atom(a);
event.data.data32[0] = id;
Q_XCB_CALL(xcb_send_event(xcb_connection(), false, m_connectionEventListener, XCB_EVENT_MASK_NO_EVENT, (const char *)&event));
};
}
+class QXcbConnection;
class QXcbEventReader : public QThread
{
Q_OBJECT
public:
- QXcbEventReader(xcb_connection_t *connection)
+ QXcbEventReader(QXcbConnection *connection)
: m_connection(connection)
{
}
QMutex m_mutex;
QList<xcb_generic_event_t *> m_events;
- xcb_connection_t *m_connection;
+ QXcbConnection *m_connection;
};
class QAbstractEventDispatcher;