diff options
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.h')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection.h | 74 |
1 files changed, 70 insertions, 4 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 01bc719546..6a80f57972 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -44,6 +44,7 @@ #include <xcb/xcb.h> +#include <QHash> #include <QList> #include <QObject> #include <QVector> @@ -51,6 +52,13 @@ #define Q_XCB_DEBUG class QXcbScreen; +class QXcbWindow; +class QXcbDrag; +class QXcbKeyboard; +class QXcbClipboard; +class QXcbWMSupport; + +typedef QHash<xcb_window_t, QXcbWindow *> WindowMapper; namespace QXcbAtom { enum Atom { @@ -160,7 +168,6 @@ namespace QXcbAtom { _NET_ACTIVE_WINDOW, // Property formats - COMPOUND_TEXT, TEXT, UTF8_STRING, @@ -215,8 +222,7 @@ namespace QXcbAtom { }; } -class QXcbKeyboard; - +class QAbstractEventDispatcher; class QXcbConnection : public QObject { Q_OBJECT @@ -226,17 +232,26 @@ public: QXcbConnection *connection() const { return const_cast<QXcbConnection *>(this); } - QList<QXcbScreen *> screens() const { return m_screens; } + const QList<QXcbScreen *> &screens() const { return m_screens; } int primaryScreen() const { return m_primaryScreen; } xcb_atom_t atom(QXcbAtom::Atom atom); + xcb_atom_t internAtom(const char *name); + QByteArray atomName(xcb_atom_t atom); const char *displayName() const { return m_displayName.constData(); } xcb_connection_t *xcb_connection() const { return m_connection; } + const xcb_setup_t *setup() const { return m_setup; } + const xcb_format_t *formatForDepth(uint8_t depth) const; QXcbKeyboard *keyboard() const { return m_keyboard; } + QXcbClipboard *clipboard() const { return m_clipboard; } + QXcbDrag *drag() const { return m_drag; } + + QXcbWMSupport *wmSupport() const { return m_wmSupport; } + #ifdef XCB_USE_XLIB void *xlib_display() const { return m_xlib_display; } #endif @@ -253,7 +268,26 @@ public: #endif void sync(); + void flush() { xcb_flush(m_connection); } + void handleXcbError(xcb_generic_error_t *error); + void handleXcbEvent(xcb_generic_event_t *event); + + void addWindow(xcb_window_t id, QXcbWindow *window); + void removeWindow(xcb_window_t id); + QXcbWindow *platformWindowFromId(xcb_window_t id); + + xcb_generic_event_t *checkEvent(int type); + template<typename T> + inline xcb_generic_event_t *checkEvent(const T &checker); + + typedef bool (*PeekFunc)(xcb_generic_event_t *); + void addPeekFunc(PeekFunc f); + + inline xcb_timestamp_t time() const { return m_time; } + inline void setTime(xcb_timestamp_t t) { if (t > m_time) m_time = t; } + + bool hasXFixes() const { return xfixes_first_event > 0; } private slots: void processXcbEvents(); @@ -261,9 +295,12 @@ private slots: private: void initializeAllAtoms(); void sendConnectionEvent(QXcbAtom::Atom atom, uint id = 0); + void initializeXFixes(); + void initializeXRender(); #ifdef XCB_USE_DRI2 void initializeDri2(); #endif + void handleClientMessageEvent(const xcb_client_message_event_t *event); xcb_connection_t *m_connection; const xcb_setup_t *m_setup; @@ -273,9 +310,14 @@ private: xcb_atom_t m_allAtoms[QXcbAtom::NAtoms]; + xcb_timestamp_t m_time; + QByteArray m_displayName; QXcbKeyboard *m_keyboard; + QXcbClipboard *m_clipboard; + QXcbDrag *m_drag; + QXcbWMSupport *m_wmSupport; #if defined(XCB_USE_XLIB) void *m_xlib_display; @@ -303,10 +345,34 @@ private: template <typename cookie_t> friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line); #endif + QVector<xcb_generic_event_t *> eventqueue; + + WindowMapper m_mapper; + + QVector<PeekFunc> m_peekFuncs; + + uint32_t xfixes_first_event; }; #define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display())) +template<typename T> +xcb_generic_event_t *QXcbConnection::checkEvent(const T &checker) +{ + while (xcb_generic_event_t *event = xcb_poll_for_event(xcb_connection())) + eventqueue.append(event); + + for (int i = 0; i < eventqueue.size(); ++i) { + xcb_generic_event_t *event = eventqueue.at(i); + if (checker.check(event)) { + eventqueue[i] = 0; + return event; + } + } + return 0; +} + + #ifdef Q_XCB_DEBUG template <typename cookie_t> cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line) |