From f73e9c19f7fd4f7aaecd06a283b125078d8ad884 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Sat, 18 Sep 2010 11:12:56 +0100 Subject: x11: Use the default screen for X11 properties. This commit restores the functionality originally included in 65e807 by Leszek Koltunski. --- src/modules/x11/module-x11-publish.c | 37 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src/modules') diff --git a/src/modules/x11/module-x11-publish.c b/src/modules/x11/module-x11-publish.c index e811bdf0..6544e07d 100644 --- a/src/modules/x11/module-x11-publish.c +++ b/src/modules/x11/module-x11-publish.c @@ -84,6 +84,8 @@ struct userdata { static void publish_servers(struct userdata *u, pa_strlist *l) { + int screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper)); + if (l) { char *s; @@ -91,20 +93,22 @@ 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_xcb_connection(u->x11_wrapper), "PULSE_SERVER", s); + pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SERVER", s); pa_xfree(s); } else - 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), screen, "PULSE_SERVER"); } static pa_hook_result_t servers_changed_cb(void *hook_data, void *call_data, void *slot_data) { pa_strlist *servers = call_data; struct userdata *u = slot_data; char t[256]; + int screen; pa_assert(u); - if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) { + screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper)); + if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", t, sizeof(t)) || strcmp(t, u->id)) { pa_log_warn("PulseAudio information vanished from X11!"); return PA_HOOK_OK; } @@ -138,6 +142,7 @@ int pa__init(pa_module*m) { char *mid, *sid; char hx[PA_NATIVE_COOKIE_LENGTH*2+1]; const char *t; + int screen; pa_assert(m); @@ -163,26 +168,27 @@ int pa__init(pa_module*m) { if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL)))) goto fail; + screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper)); mid = pa_machine_id(); 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_xcb_connection(u->x11_wrapper), "PULSE_ID", u->id); + pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID", u->id); if ((sid = pa_session_id())) { - pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SESSION_ID", sid); + pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "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_xcb_connection(u->x11_wrapper), "PULSE_SOURCE", t); + pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SOURCE", t); if ((t = pa_modargs_get_value(ma, "sink", NULL))) - pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_SINK", t); + pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SINK", t); - pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), "PULSE_COOKIE", + pa_x11_set_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "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); @@ -213,17 +219,18 @@ void pa__done(pa_module*m) { if (u->x11_wrapper) { char t[256]; + int screen = DefaultScreen(pa_x11_wrapper_get_display(u->x11_wrapper)); /* Yes, here is a race condition */ - if (!pa_x11_get_prop(pa_x11_wrapper_get_xcb_connection(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), screen, "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_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"); + pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_ID"); + pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SERVER"); + pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SINK"); + pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SOURCE"); + pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_COOKIE"); + pa_x11_del_prop(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper), screen, "PULSE_SESSION_ID"); xcb_flush(pa_x11_wrapper_get_xcb_connection(u->x11_wrapper)); } -- cgit