summaryrefslogtreecommitdiffstats
path: root/src/pulsecore
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/pulsecore
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/pulsecore')
-rw-r--r--src/pulsecore/x11prop.c55
-rw-r--r--src/pulsecore/x11prop.h9
-rw-r--r--src/pulsecore/x11wrap.c4
-rw-r--r--src/pulsecore/x11wrap.h4
4 files changed, 47 insertions, 25 deletions
diff --git a/src/pulsecore/x11prop.c b/src/pulsecore/x11prop.c
index 873a76e7..cc5987a8 100644
--- a/src/pulsecore/x11prop.c
+++ b/src/pulsecore/x11prop.c
@@ -25,45 +25,58 @@
#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, RootWindow(d, 0), 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, RootWindow(d, 0), 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 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;
+
+ req = xcb_get_property(xcb, 0, screen->root, a, STRING, 0, (uint32_t)(l-1));
+ prop = xcb_get_property_reply(xcb, req, NULL);
+
+ if (!prop)
+ goto finish;
- Atom a = XInternAtom(d, name, False);
- if (XGetWindowProperty(d, RootWindow(d, 0), a, 0, (long) ((l+2)/4), False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop) != Success)
+ if (PA_XCB_FORMAT != prop->format)
goto finish;
- if (actual_type != XA_STRING)
+ 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;
}
diff --git a/src/pulsecore/x11prop.h b/src/pulsecore/x11prop.h
index dc675263..74922615 100644
--- a/src/pulsecore/x11prop.h
+++ b/src/pulsecore/x11prop.h
@@ -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
@@ -24,10 +25,10 @@
#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
diff --git a/src/pulsecore/x11wrap.c b/src/pulsecore/x11wrap.c
index 1960a12f..454507ae 100644
--- a/src/pulsecore/x11wrap.c
+++ b/src/pulsecore/x11wrap.c
@@ -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;
diff --git a/src/pulsecore/x11wrap.h b/src/pulsecore/x11wrap.h
index b57541f2..fc2e01fe 100644
--- a/src/pulsecore/x11wrap.h
+++ b/src/pulsecore/x11wrap.h
@@ -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);