summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-05-26 01:35:29 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-05-30 14:44:12 +0200
commitbbb2da4a1b49f37e3b009ea81ffcd0cc03e07ef4 (patch)
tree21b6ee174252639f64d84be05fea8c1699211d67 /src/plugins/platforms/xcb/qxcbconnection.h
parentb03ed7b15107accbb74b10c5c1d77d46244df9fa (diff)
add an xcb based clipboard implementation
Copying from the app to somewhere else works fine, but pasting into the app is still broken.
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.h')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 07c3f75b9d..6782d70d56 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -59,6 +59,7 @@ typedef QHash<xcb_window_t, QXcbWindow *> WindowMapper;
namespace QXcbAtom {
static const xcb_atom_t XA_PRIMARY = 1;
static const xcb_atom_t XA_SECONDARY = 2;
+ static const xcb_atom_t XA_ATOM = 4;
static const xcb_atom_t XA_PIXMAP = 20;
static const xcb_atom_t XA_BITMAP = 5;
static const xcb_atom_t XA_STRING = 32;
@@ -226,6 +227,7 @@ namespace QXcbAtom {
}
class QXcbKeyboard;
+class QXcbClipboard;
class QXcbConnection : public QObject
{
@@ -249,6 +251,8 @@ public:
QXcbKeyboard *keyboard() const { return m_keyboard; }
+ QXcbClipboard *clipboard() const { return m_clipboard; }
+
#ifdef XCB_USE_XLIB
void *xlib_display() const { return m_xlib_display; }
#endif
@@ -265,11 +269,18 @@ 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);
+ xcb_generic_event_t *checkEvent(int type);
+ template<typename T>
+ inline xcb_generic_event_t *checkEvent(const T &checker);
+
private slots:
void processXcbEvents();
@@ -292,6 +303,7 @@ private:
QByteArray m_displayName;
QXcbKeyboard *m_keyboard;
+ QXcbClipboard *m_clipboard;
#if defined(XCB_USE_XLIB)
void *m_xlib_display;
@@ -319,12 +331,30 @@ 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;
};
#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)