summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorColin Guthrie <cguthrie@mandriva.org>2010-05-29 19:33:54 +0100
committerColin Guthrie <cguthrie@mandriva.org>2010-08-15 21:41:52 +0100
commit2b88634671d1b745b1364e9cf4827e30a5ff2a6e (patch)
treeeb453f9e6c9eb70fb34a8483aca9ab8e72b7cb26 /src/utils
parent4a1072e0bcce9165a262dc76a12baa2680caa0e3 (diff)
x11: Partially convert to XCB.
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
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/pax11publish.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/utils/pax11publish.c b/src/utils/pax11publish.c
index a9eb329f..111bee23 100644
--- a/src/utils/pax11publish.c
+++ b/src/utils/pax11publish.c
@@ -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;