summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbconnection.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2011-05-22 22:23:48 +0200
committerLars Knoll <lars.knoll@nokia.com>2011-05-30 14:44:12 +0200
commit1b1142b305c9664dd9d3d9544a9db5b5e4b6bd08 (patch)
treee92c63636371a79730a0ea78ab3df361ec3b222f /src/plugins/platforms/xcb/qxcbconnection.cpp
parent1d3864488cb2ae4b105948d6569d08c477f77d80 (diff)
Add xcb based mime type handling
Reworked the code from the xlib lighthouse plugin to remove most of the Xlib dependencies. The code originally comdes from qdnd_x11.cpp
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbconnection.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index da6e69eb36..bdd18500a3 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -583,9 +583,12 @@ static const char * xcb_atomnames = {
"_NET_ACTIVE_WINDOW\0"
// Property formats
+ "XA_STRING\0"
"COMPOUND_TEXT\0"
"TEXT\0"
"UTF8_STRING\0"
+ "XA_PIXMAP\0"
+ "XA_BITMAP\0"
// xdnd
"XdndEnter\0"
@@ -663,8 +666,32 @@ void QXcbConnection::initializeAllAtoms() {
for (i = 0; i < QXcbAtom::NAtoms; ++i)
cookies[i] = xcb_intern_atom(xcb_connection(), false, strlen(names[i]), names[i]);
- for (i = 0; i < QXcbAtom::NAtoms; ++i)
- m_allAtoms[i] = xcb_intern_atom_reply(xcb_connection(), cookies[i], 0)->atom;
+ for (i = 0; i < QXcbAtom::NAtoms; ++i) {
+ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(xcb_connection(), cookies[i], 0);
+ m_allAtoms[i] = reply->atom;
+ free(reply);
+ }
+}
+
+xcb_atom_t QXcbConnection::internAtom(const char *name)
+{
+ if (!name || *name == 0)
+ return XCB_NONE;
+
+ xcb_intern_atom_cookie_t cookie = xcb_intern_atom(xcb_connection(), false, strlen(name), name);
+ xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(xcb_connection(), cookie, 0);
+ int atom = reply->atom;
+ free(reply);
+ return atom;
+}
+
+QByteArray QXcbConnection::atomName(xcb_atom_t atom)
+{
+ xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name_unchecked(xcb_connection(), atom);
+ xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(xcb_connection(), cookie, 0);
+ QByteArray result(xcb_get_atom_name_name(reply));
+ free(reply);
+ return result;
}
void QXcbConnection::sync()