From 0a9840507a4c1980f17b7cd0f99482a67282c9ed Mon Sep 17 00:00:00 2001 From: Rob Taylor Date: Mon, 24 Sep 2007 18:59:53 +0100 Subject: dpms plugin: fix multiple opening of display XOpenDisplay was being called multiple times, overriting previous Display. Changed to listen to xorg.has_xauthority and only open the diplay once availiable. --- plugins/glue/dpms/ohm-plugin-dpms.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/glue/dpms/ohm-plugin-dpms.c b/plugins/glue/dpms/ohm-plugin-dpms.c index 9826918..d23f311 100644 --- a/plugins/glue/dpms/ohm-plugin-dpms.c +++ b/plugins/glue/dpms/ohm-plugin-dpms.c @@ -37,6 +37,7 @@ static Display *dpy; enum { CONF_BACKLIGHT_STATE_CHANGED, + CONF_XORG_HASXAUTH_CHANGED, CONF_LAST }; @@ -109,11 +110,8 @@ ohm_dpms_set_mode (OhmDpmsMode mode) CARD16 state; OhmDpmsMode current_mode; - /* FIXME: why is dpy NULL if we don't do this? */ - dpy = XOpenDisplay (":0"); /* fixme: don't assume :0 */ - if (dpy == NULL) { - g_debug ("cannot open display"); + g_debug ("display not open"); return FALSE; } @@ -146,7 +144,6 @@ ohm_dpms_set_mode (OhmDpmsMode mode) } XSync (dpy, FALSE); - XCloseDisplay(dpy); return TRUE; } @@ -163,8 +160,6 @@ plugin_initalize (OhmPlugin *plugin) /* we can assume DPMS is on */ ohm_plugin_conf_set_key (plugin, "backlight.state", 1); - /* open display, need to free using XCloseDisplay */ - dpy = XOpenDisplay (":0"); /* fixme: don't assume :0 */ } /** @@ -197,6 +192,9 @@ plugin_notify (OhmPlugin *plugin, gint id, gint value) } else { ohm_dpms_set_mode (OHM_DPMS_MODE_ON); } + } else if (id == CONF_XORG_HASXAUTH_CHANGED && value == 1) { + /* open display, need to free using XCloseDisplay */ + dpy = XOpenDisplay (":0"); /* fixme: don't assume :0 */ } } @@ -210,6 +208,8 @@ OHM_PLUGIN_DESCRIPTION ( plugin_notify /* notify */ ); -OHM_PLUGIN_INTERESTED ({"backlight.state", CONF_BACKLIGHT_STATE_CHANGED}); +OHM_PLUGIN_INTERESTED ( + {"backlight.state", CONF_BACKLIGHT_STATE_CHANGED}, + {"xorg.has_xauthority", CONF_XORG_HASXAUTH_CHANGED}); OHM_PLUGIN_REQUIRES ("backlight"); -- cgit v1.2.3