]> code.delx.au - pulseaudio/commitdiff
x11: Partially convert to XCB.
authorColin Guthrie <cguthrie@mandriva.org>
Sat, 29 May 2010 18:33:54 +0000 (19:33 +0100)
committerColin Guthrie <cguthrie@mandriva.org>
Sat, 18 Sep 2010 11:04:09 +0000 (12:04 +0100)
This commit mostly converts the X11 handling to XCB. There are still
some uses of XLib to deal with the X11 session handling modules, however all
client-side code should now be free of XLib and thus this should fix Bug #799

Note that this removes the screen-based changes by Leszek Koltunski
in 65e80, however this will be restored in due course.

configure.ac
src/modules/x11/module-x11-publish.c
src/pulse/client-conf-x11.c
src/pulsecore/x11prop.c
src/pulsecore/x11prop.h
src/pulsecore/x11wrap.c
src/pulsecore/x11wrap.h
src/utils/pax11publish.c

index a3551f0690c2aa086afca8b0640d1ea041a5850d..5d69c924cdb0598ad7b71d7709a72b2ab34be1b1 100644 (file)
@@ -531,7 +531,7 @@ AC_ARG_ENABLE([x11],
         [x11=auto])
 
 if test "x${x11}" != xno ; then
-    PKG_CHECK_MODULES(X11, [ x11 ice sm xtst ],
+    PKG_CHECK_MODULES(X11, [ x11-xcb ice sm xtst xcb-atom ],
         HAVE_X11=1,
         [
             HAVE_X11=0
index 7ee1b6daf91afa09adeb20762cb9811562baa483..e811bdf0d581dda8ea29621d8e130cb170cf50b4 100644 (file)
@@ -28,8 +28,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
+#include <xcb/xcb.h>
 
 #include <pulse/util.h>
 #include <pulse/xmalloc.h>
@@ -92,10 +91,10 @@ static void publish_servers(struct userdata *u, pa_strlist *l) {
         s = pa_strlist_tostring(l);
         pa_strlist_reverse(l);
 
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER", s);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER", s);
         pa_xfree(s);
     } else
-        pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER");
+        pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER");
 }
 
 static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, void *slot_data) {
@@ -105,7 +104,7 @@ static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, voi
 
     pa_assert(u);
 
-    if (!pa_x11_get_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) {
+    if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) {
         pa_log_warn("PulseAudio information vanished from X11!");
         return PA_HOOK_OK;
     }
@@ -168,22 +167,22 @@ int pa__init(pa_module*m) {
     u->id = pa_sprintf_malloc("%lu@%s/%lu", (unsigned long) getuid(), mid, (unsigned long) getpid());
     pa_xfree(mid);
 
-    pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", u->id);
+    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", u->id);
 
     if ((sid = pa_session_id())) {
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SESSION_ID", sid);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SESSION_ID", sid);
         pa_xfree(sid);
     }
 
     publish_servers(u, pa_native_protocol_servers(u->protocol));
 
     if ((t = pa_modargs_get_value(ma, "source", NULL)))
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SOURCE", t);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SOURCE", t);
 
     if ((t = pa_modargs_get_value(ma, "sink", NULL)))
-        pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SINK", t);
+        pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SINK", t);
 
-    pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_COOKIE",
+    pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_COOKIE",
                     pa_hexstr(pa_auth_cookie_read(u->auth_cookie, PA_NATIVE_COOKIE_LENGTH), PA_NATIVE_COOKIE_LENGTH, hx, sizeof(hx)));
 
     u->x11_client = pa_x11_client_new(u->x11_wrapper, NULL, x11_kill_cb, u);
@@ -216,16 +215,16 @@ void pa__done(pa_module*m) {
         char t[256];
 
         /* Yes, here is a race condition */
-        if (!pa_x11_get_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id))
+        if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id))
             pa_log_warn("PulseAudio information vanished from X11!");
         else {
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SINK");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SOURCE");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_COOKIE");
-            pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SESSION_ID");
-            XSync(pa_x11_wrapper_get_display(u->x11_wrapper), False);
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SERVER");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SINK");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SOURCE");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_COOKIE");
+            pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SESSION_ID");
+            xcb_flush(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper));
         }
 
         pa_x11_wrapper_unref(u->x11_wrapper);
index 4970363b1fb786b34a3e96c7fd1b1dc68f0c0652..565f997d99f7c99239e2a6d864ae4081657522c7 100644 (file)
@@ -25,8 +25,7 @@
 
 #include <string.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
+#include <xcb/xcb.h>
 
 #include <pulse/xmalloc.h>
 #include <pulse/i18n.h>
@@ -39,7 +38,7 @@
 #include "client-conf-x11.h"
 
 int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
-    Display *d = NULL;
+    xcb_connection_t *xcb = NULL;
     int ret = -1;
     char t[1024];
 
@@ -51,18 +50,18 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
     if (*dname == 0)
         goto finish;
 
-    if (!(d = XOpenDisplay(dname))) {
-        pa_log(_("XOpenDisplay() failed"));
+    if (!(xcb = xcb_connect(dname, NULL))) {
+        pa_log(_("xcb_connect() failed"));
         goto finish;
     }
 
-    if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t))) {
         pa_bool_t disable_autospawn = TRUE;
 
         pa_xfree(c->default_server);
         c->default_server = pa_xstrdup(t);
 
-        if (pa_x11_get_prop(d, "PULSE_SESSION_ID", t, sizeof(t))) {
+        if (pa_x11_get_prop(xcb, "PULSE_SESSION_ID", t, sizeof(t))) {
             char *id;
 
             if ((id = pa_session_id())) {
@@ -76,17 +75,17 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
             c->autospawn = FALSE;
     }
 
-    if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t))) {
         pa_xfree(c->default_sink);
         c->default_sink = pa_xstrdup(t);
     }
 
-    if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t))) {
         pa_xfree(c->default_source);
         c->default_source = pa_xstrdup(t);
     }
 
-    if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t))) {
+    if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t))) {
         uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
 
         if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) {
@@ -106,8 +105,8 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
     ret = 0;
 
 finish:
-    if (d)
-        XCloseDisplay(d);
+    if (xcb)
+        xcb_disconnect(xcb);
 
     return ret;
 
index dc8ec2947650e35f6906e6c790e12daccf84da13..cc5987a849e9e2947186f1220b8f43d7bc4c81c9 100644 (file)
 
 #include <string.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-
 #include "x11prop.h"
 
-void pa_x11_set_prop(Display *d, const char *name, const char *data) {
-    Atom a = XInternAtom(d, name, False);
-    XChangeProperty(d, DefaultRootWindow(d), a, XA_STRING, 8, PropModeReplace, (const unsigned char*) data, (int) (strlen(data)+1));
+#include <xcb/xproto.h>
+#include <xcb/xcb_atom.h>
+
+#define PA_XCB_FORMAT 8
+
+void pa_x11_set_prop(xcb_connection_t *xcb, const char *name, const char *data) {
+    xcb_screen_t *screen;
+    xcb_atom_t a = xcb_atom_get(xcb, name);
+    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
+    xcb_change_property(xcb, XCB_PROP_MODE_REPLACE, screen->root, a, STRING, PA_XCB_FORMAT, (int) strlen(data), (const void*) data);
 }
 
-void pa_x11_del_prop(Display *d, const char *name) {
-    Atom a = XInternAtom(d, name, False);
-    XDeleteProperty(d, DefaultRootWindow(d), a);
+void pa_x11_del_prop(xcb_connection_t *xcb, const char *name) {
+    xcb_screen_t *screen;
+    xcb_atom_t a = xcb_atom_get(xcb, name);
+    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
+    xcb_delete_property(xcb, screen->root, a);
 }
 
-char* pa_x11_get_prop(Display *d, const char *name, char *p, size_t l) {
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long nbytes_after;
-    unsigned char *prop = NULL;
+char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l) {
     char *ret = NULL;
-    int window_ret;
+    int len;
+    xcb_get_property_cookie_t req;
+    xcb_get_property_reply_t* prop = NULL;
+    xcb_screen_t *screen;
+    xcb_atom_t a = xcb_atom_get(xcb, name);
+    screen = xcb_setup_roots_iterator(xcb_get_setup(xcb)).data;
 
-    Atom a = XInternAtom(d, name, False);
+    req = xcb_get_property(xcb, 0, screen->root, a, STRING, 0, (uint32_t)(l-1));
+    prop = xcb_get_property_reply(xcb, req, NULL);
 
-    window_ret = XGetWindowProperty(d, DefaultRootWindow(d), a, 0, (long) ((l+2)/4), False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop);
+    if (!prop)
+        goto finish;
 
-    if (window_ret != Success || actual_type != XA_STRING) {
-        if (DefaultScreen(d) != 0) {
-            window_ret = XGetWindowProperty(d, RootWindow(d, 0), a, 0, (long) ((l+2)/4), False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop);
+    if (PA_XCB_FORMAT != prop->format)
+        goto finish;
 
-            if (window_ret != Success || actual_type != XA_STRING)
-                goto finish;
-        } else
-            goto finish;
-    }
+    len = xcb_get_property_value_length(prop);
+    if (len < 1 || len >= (int)l)
+        goto finish;
 
-    memcpy(p, prop, nitems);
-    p[nitems] = 0;
+    memcpy(p, xcb_get_property_value(prop), len);
+    p[len] = 0;
 
     ret = p;
 
 finish:
 
     if (prop)
-        XFree(prop);
+        free(prop);
 
     return ret;
 }
index dc675263137f5b64b1f86f2f2c74052dbe28a335..74922615bbfd60e41531916002f3c15c70909630 100644 (file)
@@ -5,6 +5,7 @@
   This file is part of PulseAudio.
 
   Copyright 2004-2006 Lennart Poettering
+  Copyright 2010 Colin Guthrie
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
 
 #include <sys/types.h>
 
-#include <X11/Xlib.h>
+#include <xcb/xcb.h>
 
-void pa_x11_set_prop(Display *d, const char *name, const char *data);
-void pa_x11_del_prop(Display *d, const char *name);
-char* pa_x11_get_prop(Display *d, const char *name, char *p, size_t l);
+void pa_x11_set_prop(xcb_connection_t *xcb, const char *name, const char *data);
+void pa_x11_del_prop(xcb_connection_t *xcb, const char *name);
+char* pa_x11_get_prop(xcb_connection_t *xcb, const char *name, char *p, size_t l);
 
 #endif
index 1960a12fe16519af95899a9a017eb270cb1cd59e..454507ae50b9e0aed1cb24277d7461f2ffb09cc4 100644 (file)
@@ -259,6 +259,10 @@ Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w) {
     return w->display;
 }
 
+xcb_connection_t *pa_x11_wrapper_get_xcb_connection(pa_x11_wrapper *w) {
+    return XGetXCBConnection(pa_x11_wrapper_get_display(w));
+}
+
 void pa_x11_wrapper_kill(pa_x11_wrapper *w) {
     pa_x11_client *c, *n;
 
index b57541f2941f357064503a69031412c26bd32f65..fc2e01fecb7edeec6e7d4251deffd9ebc4bf64e5 100644 (file)
@@ -23,6 +23,7 @@
 ***/
 
 #include <X11/Xlib.h>
+#include <X11/Xlib-xcb.h>
 
 #include <pulsecore/core.h>
 
@@ -46,6 +47,9 @@ void pa_x11_wrapper_unref(pa_x11_wrapper* w);
 /* Return the X11 display object for this connection */
 Display *pa_x11_wrapper_get_display(pa_x11_wrapper *w);
 
+/* Return the XCB connection object for this connection */
+xcb_connection_t *pa_x11_wrapper_get_xcb_connection(pa_x11_wrapper *w);
+
 /* Kill the connection to the X11 display */
 void pa_x11_wrapper_kill(pa_x11_wrapper *w);
 
index a9eb329f0ff77638c199c7b9e66f9fae94c9afe7..111bee2392e23b0da625f3a7fd4f76c79659e124 100644 (file)
@@ -29,8 +29,7 @@
 #include <assert.h>
 #include <locale.h>
 
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
+#include <xcb/xcb.h>
 
 #include <pulse/util.h>
 #include <pulse/i18n.h>
@@ -46,7 +45,7 @@
 int main(int argc, char *argv[]) {
     const char *dname = NULL, *sink = NULL, *source = NULL, *server = NULL, *cookie_file = PA_NATIVE_COOKIE_FILE;
     int c, ret = 1;
-    Display *d = NULL;
+    xcb_connection_t *xcb = NULL;
     enum { DUMP, EXPORT, IMPORT, REMOVE } mode = DUMP;
 
     setlocale(LC_ALL, "");
@@ -96,21 +95,21 @@ int main(int argc, char *argv[]) {
         }
     }
 
-    if (!(d = XOpenDisplay(dname))) {
-        pa_log(_("XOpenDisplay() failed"));
+    if (!(xcb = xcb_connect(dname, NULL))) {
+        pa_log(_("xcb_connect() failed"));
         goto finish;
     }
 
     switch (mode) {
         case DUMP: {
             char t[1024];
-            if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t)))
                 printf(_("Server: %s\n"), t);
-            if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t)))
                 printf(_("Source: %s\n"), t);
-            if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t)))
                 printf(_("Sink: %s\n"), t);
-            if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t)))
                 printf(_("Cookie: %s\n"), t);
 
             break;
@@ -118,14 +117,14 @@ int main(int argc, char *argv[]) {
 
         case IMPORT: {
             char t[1024];
-            if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SERVER", t, sizeof(t)))
                 printf("PULSE_SERVER='%s'\nexport PULSE_SERVER\n", t);
-            if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SOURCE", t, sizeof(t)))
                 printf("PULSE_SOURCE='%s'\nexport PULSE_SOURCE\n", t);
-            if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t)))
+            if (pa_x11_get_prop(xcb, "PULSE_SINK", t, sizeof(t)))
                 printf("PULSE_SINK='%s'\nexport PULSE_SINK\n", t);
 
-            if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t))) {
+            if (pa_x11_get_prop(xcb, "PULSE_COOKIE", t, sizeof(t))) {
                 uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
                 size_t l;
                 if ((l = pa_parsehex(t, cookie, sizeof(cookie))) != sizeof(cookie)) {
@@ -158,16 +157,16 @@ int main(int argc, char *argv[]) {
                 goto finish;
             }
 
-            pa_x11_del_prop(d, "PULSE_SERVER");
-            pa_x11_del_prop(d, "PULSE_SINK");
-            pa_x11_del_prop(d, "PULSE_SOURCE");
-            pa_x11_del_prop(d, "PULSE_ID");
-            pa_x11_del_prop(d, "PULSE_COOKIE");
+            pa_x11_del_prop(xcb, "PULSE_SERVER");
+            pa_x11_del_prop(xcb, "PULSE_SINK");
+            pa_x11_del_prop(xcb, "PULSE_SOURCE");
+            pa_x11_del_prop(xcb, "PULSE_ID");
+            pa_x11_del_prop(xcb, "PULSE_COOKIE");
 
             if (server)
-                pa_x11_set_prop(d, "PULSE_SERVER", server);
+                pa_x11_set_prop(xcb, "PULSE_SERVER", server);
             else if (conf->default_server)
-                pa_x11_set_prop(d, "PULSE_SERVER", conf->default_server);
+                pa_x11_set_prop(xcb, "PULSE_SERVER", conf->default_server);
             else {
                 char hn[256];
                 if (!pa_get_fqdn(hn, sizeof(hn))) {
@@ -175,18 +174,18 @@ int main(int argc, char *argv[]) {
                     goto finish;
                 }
 
-                pa_x11_set_prop(d, "PULSE_SERVER", hn);
+                pa_x11_set_prop(xcb, "PULSE_SERVER", hn);
             }
 
             if (sink)
-                pa_x11_set_prop(d, "PULSE_SINK", sink);
+                pa_x11_set_prop(xcb, "PULSE_SINK", sink);
             else if (conf->default_sink)
-                pa_x11_set_prop(d, "PULSE_SINK", conf->default_sink);
+                pa_x11_set_prop(xcb, "PULSE_SINK", conf->default_sink);
 
             if (source)
-                pa_x11_set_prop(d, "PULSE_SOURCE", source);
+                pa_x11_set_prop(xcb, "PULSE_SOURCE", source);
             if (conf->default_source)
-                pa_x11_set_prop(d, "PULSE_SOURCE", conf->default_source);
+                pa_x11_set_prop(xcb, "PULSE_SOURCE", conf->default_source);
 
             pa_client_conf_free(conf);
 
@@ -195,16 +194,16 @@ int main(int argc, char *argv[]) {
                 goto finish;
             }
 
-            pa_x11_set_prop(d, "PULSE_COOKIE", pa_hexstr(cookie, sizeof(cookie), hx, sizeof(hx)));
+            pa_x11_set_prop(xcb, "PULSE_COOKIE", pa_hexstr(cookie, sizeof(cookie), hx, sizeof(hx)));
             break;
         }
 
         case REMOVE:
-            pa_x11_del_prop(d, "PULSE_SERVER");
-            pa_x11_del_prop(d, "PULSE_SINK");
-            pa_x11_del_prop(d, "PULSE_SOURCE");
-            pa_x11_del_prop(d, "PULSE_ID");
-            pa_x11_del_prop(d, "PULSE_COOKIE");
+            pa_x11_del_prop(xcb, "PULSE_SERVER");
+            pa_x11_del_prop(xcb, "PULSE_SINK");
+            pa_x11_del_prop(xcb, "PULSE_SOURCE");
+            pa_x11_del_prop(xcb, "PULSE_ID");
+            pa_x11_del_prop(xcb, "PULSE_COOKIE");
             break;
 
         default:
@@ -216,9 +215,9 @@ int main(int argc, char *argv[]) {
 
 finish:
 
-    if (d) {
-        XSync(d, False);
-        XCloseDisplay(d);
+    if (xcb) {
+        xcb_flush(xcb);
+        xcb_disconnect(xcb);
     }
 
     return ret;