[ohm] ohm: Branch 'master' - 9 commits
Rob Taylor
robtaylor at kemper.freedesktop.org
Mon Sep 24 11:04:54 PDT 2007
configure.in | 4 ++
libidletime/libidletime.c | 17 +--------
ohmd/ohm-conf.c | 48 ++++++++++++++++++++++++--
ohmd/ohm-conf.h | 3 +
ohmd/ohm-module.c | 2 +
plugins/glue/backlight/ohm-plugin-backlight.c | 16 ++++++++
plugins/glue/dpms/ohm-plugin-dpms.c | 16 ++++----
plugins/glue/idle/ohm-plugin-idle.c | 25 +------------
plugins/policy/display/ohm-plugin-display.c | 10 ++++-
9 files changed, 90 insertions(+), 51 deletions(-)
New commits:
diff-tree 0a9840507a4c1980f17b7cd0f99482a67282c9ed (from cfa3c5ee97c159742685c1c0c8012ae7c078aa41)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Mon Sep 24 18:59:53 2007 +0100
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.
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 i
} 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");
diff-tree cfa3c5ee97c159742685c1c0c8012ae7c078aa41 (from 7920baf543a25504697bb711ef59d150bcd8ed10)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Mon Sep 24 18:07:44 2007 +0100
Support pre hal 0.5.10 org.freedesktop.Hal.Device.LaptopPanel.SetBrightness
Pre 0.5.10, SetBrightness returned an int32, in newer hal it returns uint32 for
consistency. This patch will build the backlight plugin supporting pre 0.5.10
if the libhal installed at buildtime is pre 0.5.10
# Please enter the commit message for your changes.
# (Comment lines starting with '#' will not be included)
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: configure.in
# modified: plugins/glue/backlight/ohm-plugin-backlight.c
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# docs/index.html
# docs/reference/libohm/html/
# docs/reference/libohm/libohm-decl-list.txt
# docs/reference/libohm/libohm-decl.txt
# docs/reference/libohm/libohm-overrides.txt
# docs/reference/libohm/libohm-sections.txt
# docs/reference/libohm/libohm-undocumented.txt
# docs/reference/libohm/libohm.types
# docs/reference/libohm/tmpl/
# docs/reference/libohm/xml/
# docs/reference/ohm-plugin/html/
# docs/reference/ohm-plugin/ohm-plugin-decl.txt
# docs/reference/ohm-plugin/ohm-plugin-undocumented.txt
# docs/reference/ohm-plugin/tmpl/
# docs/reference/ohm-plugin/xml/
# gtk-doc.make
# local-ohm.patch
diff --git a/configure.in b/configure.in
index 1a4ecdd..6adc831 100644
--- a/configure.in
+++ b/configure.in
@@ -101,6 +101,10 @@ PKG_CHECK_MODULES(HAL, hal >= 0.5.7)
AC_SUBST(HAL_CFLAGS)
AC_SUBST(HAL_LIBS)
+if pkg-config --atleast-version=0.5.10 hal; then
+ AC_DEFINE(HAL_SET_BRIGHTNESS_UNSIGNED, 1, [org.freedesktop.Hal.Device.LaptopPanel.SetBrightness returns UINT32])
+fi
+
PKG_CHECK_MODULES(GDK, gdk-2.0 >= 2.10.0 gdk-x11-2.0 >= 2.10.0)
AC_SUBST(GDK_CFLAGS)
AC_SUBST(GDK_LIBS)
diff --git a/plugins/glue/backlight/ohm-plugin-backlight.c b/plugins/glue/backlight/ohm-plugin-backlight.c
index ee64036..e5c0388 100644
--- a/plugins/glue/backlight/ohm-plugin-backlight.c
+++ b/plugins/glue/backlight/ohm-plugin-backlight.c
@@ -66,11 +66,20 @@ backlight_set_brightness (OhmPlugin *plu
/* get the brightness from HAL */
error = NULL;
+#ifdef HAL_SET_BRIGHTNESS_UNSIGNED
ret = dbus_g_proxy_call (proxy, "SetBrightness", &error,
G_TYPE_INT, (int)brightness,
G_TYPE_INVALID,
G_TYPE_UINT, &retval,
G_TYPE_INVALID);
+#else
+ ret = dbus_g_proxy_call (proxy, "SetBrightness", &error,
+ G_TYPE_INT, (int)brightness,
+ G_TYPE_INVALID,
+ G_TYPE_INT, &retval,
+ G_TYPE_INVALID);
+#endif
+
if (error != NULL) {
g_printerr ("Error: %s\n", error->message);
g_error_free (error);
diff-tree 7920baf543a25504697bb711ef59d150bcd8ed10 (from ae876ad4f754f45a85b06a7ec1060d3c71f899c2)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Mon Sep 24 18:03:54 2007 +0100
add initializing stage to ohm-conf
Adds an initializing state to OhmConf in which no key-changed signals are
emitted. Any keys changed in this state are flagged as touched. When switched
out of initialising state, key-changed signals are emitted for all touched
keys.
Modifies OhmModule to switch the OhmConf into initalising state when calling
the init method of the loaded modules, swithing back to normal when all modules
have been initialised.
diff --git a/ohmd/ohm-conf.c b/ohmd/ohm-conf.c
index b36259b..84314bf 100644
--- a/ohmd/ohm-conf.c
+++ b/ohmd/ohm-conf.c
@@ -45,6 +45,7 @@
struct OhmConfPrivate
{
GHashTable *keys;
+ gboolean initializing;
};
enum {
@@ -60,7 +61,8 @@ G_DEFINE_TYPE (OhmConf, ohm_conf, G_TYPE
typedef struct ConfValue ConfValue;
struct ConfValue
{
- gboolean public;
+ gboolean public:1;
+ gboolean touched:1;
gint value;
};
@@ -89,6 +91,40 @@ ohm_conf_error_quark (void)
}
return quark;
}
+static void
+emit_touched (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ OhmConf *conf = (OhmConf*) user_data;
+ ConfValue *cv = (ConfValue *)value;
+ cv->touched = 0;
+ g_signal_emit (conf, signals [KEY_CHANGED], 0, key, cv->value);
+}
+
+/**
+ * ohm_conf_set_initializing
+ * @conf: an #OhmConf
+ * @state: OhmConf initialistion state
+ *
+ * Set or clear the conf object's initialisation state.
+ * When in initialisation state, no 'key-changed' signals are emitted and
+ * touched keys are just flagged. On switching from initialisation to normal,
+ * signals are emitted for all touched keys and the touched flags are cleared.
+ */
+
+void
+ohm_conf_set_initializing (OhmConf *conf,
+ gboolean state)
+{
+ if (state) {
+ conf->priv->initializing = TRUE;
+ } else {
+ conf->priv->initializing = FALSE;
+ g_hash_table_foreach (conf->priv->keys, emit_touched, conf);
+ }
+
+}
/**
* ohm_conf_get_key:
@@ -175,6 +211,7 @@ ohm_conf_add_key (OhmConf *conf,
cv = new_conf_value();
cv->public = public;
+ cv->touched = 0;
cv->value = value;
/* we need to create new objects in the store for each added user */
@@ -272,8 +309,13 @@ ohm_conf_set_key_internal (OhmConf *
/* Only force signal if different */
if (cv->value != value) {
cv->value = value;
- ohm_debug ("emit key-changed : %s", key);
- g_signal_emit (conf, signals [KEY_CHANGED], 0, key, value);
+ if (conf->priv->initializing){
+ ohm_debug ("initializing, setting %s to touched", key);
+ cv->touched = 1;
+ } else{
+ ohm_debug ("emit key-changed : %s", key);
+ g_signal_emit (conf, signals [KEY_CHANGED], 0, key, value);
+ }
}
return TRUE;
diff --git a/ohmd/ohm-conf.h b/ohmd/ohm-conf.h
index 33cd06f..09e2ae5 100644
--- a/ohmd/ohm-conf.h
+++ b/ohmd/ohm-conf.h
@@ -62,8 +62,9 @@ typedef void (*OhmConfForeachFunc) (co
GType ohm_conf_get_type (void);
GQuark ohm_conf_error_quark (void);
-OhmConf *ohm_conf_new (void);
+OhmConf *ohm_conf_new (void);
+void ohm_conf_set_initializing (OhmConf *conf, gboolean state);
gboolean ohm_conf_get_key (OhmConf *conf,
const gchar *key,
gint *value,
diff --git a/ohmd/ohm-module.c b/ohmd/ohm-module.c
index f306aff..16d40b1 100644
--- a/ohmd/ohm-module.c
+++ b/ohmd/ohm-module.c
@@ -453,6 +453,7 @@ ohm_module_init (OhmModule *module)
}
}
+ ohm_conf_set_initializing (module->priv->conf, TRUE);
/* initialize each plugin */
ohm_debug ("starting plugin initialization");
for (l=module->priv->plugins; l != NULL; l=l->next) {
@@ -461,6 +462,7 @@ ohm_module_init (OhmModule *module)
ohm_debug ("initialize %s", name);
ohm_plugin_initialize (plugin);
}
+ ohm_conf_set_initializing (module->priv->conf, FALSE);
}
/**
diff-tree ae876ad4f754f45a85b06a7ec1060d3c71f899c2 (from dbd1446caf5dececfa3066bcb5fa2c12326ff73a)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Mon Sep 24 17:59:10 2007 +0100
display policy: add some debug output for state.
diff --git a/plugins/policy/display/ohm-plugin-display.c b/plugins/policy/display/ohm-plugin-display.c
index 034474b..e8ba21a 100644
--- a/plugins/policy/display/ohm-plugin-display.c
+++ b/plugins/policy/display/ohm-plugin-display.c
@@ -44,12 +44,15 @@ reset_brightness (OhmPlugin *plugin)
/* FIXME: turn on dcon -- why was this here? */
/* ohm_plugin_conf_set_key (plugin, "backlight.state", 1); */
+ g_debug("%s", G_STRFUNC);
+
ohm_plugin_conf_get_key (plugin, "acadapter.state", &onac);
if (onac == TRUE) {
ohm_plugin_conf_get_key (plugin, "display.value_ac", &value);
} else {
ohm_plugin_conf_get_key (plugin, "display.value_battery", &value);
}
+ g_debug("%s: acadapter.state = %d, setting brightness %d", G_STRFUNC, onac, value);
/* dim screen to idle brightness */
ohm_plugin_conf_set_key (plugin, "backlight.percent_brightness", value);
@@ -63,6 +66,8 @@ brightness_momentary (OhmPlugin *plugin,
gint value;
gint state;
+ g_debug("%s", G_STRFUNC);
+
ohm_plugin_conf_get_key (plugin, "backlight.state", &state);
if (state == 0) {
/* work round a idletime bugs */
@@ -78,12 +83,14 @@ brightness_momentary (OhmPlugin *plugin,
/* if not idle any more */
if (is_idle == FALSE) {
+ g_debug("%s: is_idle=FALSE< restting brighness", G_STRFUNC);
reset_brightness (plugin);
return;
}
/* dim screen to idle brightness */
ohm_plugin_conf_get_key (plugin, "display.value_idle", &value);
+ g_debug ("%s: Setting brightness to %d", G_STRFUNC, value);
ohm_plugin_conf_set_key (plugin, "backlight.percent_brightness", value);
}
diff-tree dbd1446caf5dececfa3066bcb5fa2c12326ff73a (from 55ba3a7c3bb62cb7ea2161a03207cee6be59d6c0)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Mon Sep 24 12:10:25 2007 +0100
add some debug to backlight plugin
diff --git a/plugins/glue/backlight/ohm-plugin-backlight.c b/plugins/glue/backlight/ohm-plugin-backlight.c
index 19c0272..ee64036 100644
--- a/plugins/glue/backlight/ohm-plugin-backlight.c
+++ b/plugins/glue/backlight/ohm-plugin-backlight.c
@@ -62,6 +62,8 @@ backlight_set_brightness (OhmPlugin *plu
HAL_DBUS_SERVICE, udi,
HAL_DBUS_INTERFACE_LAPTOP_PANEL);
+ g_debug ("%s: Calling " HAL_DBUS_INTERFACE_LAPTOP_PANEL ".SetBrightness %d", G_STRFUNC, brightness);
+
/* get the brightness from HAL */
error = NULL;
ret = dbus_g_proxy_call (proxy, "SetBrightness", &error,
@@ -148,6 +150,9 @@ plugin_initalize (OhmPlugin *plugin)
/* get the only device with capability and watch it */
num = ohm_plugin_hal_add_device_capability (plugin, "laptop_panel");
+
+ g_debug ("%s: Got %d devices with laptop_panel capability", G_STRFUNC, num);
+
if (num > 1) {
g_warning ("not tested with not one laptop_panel");
}
@@ -155,6 +160,8 @@ plugin_initalize (OhmPlugin *plugin)
if (num != 0) {
/* get levels that the adapter supports -- this does not change ever */
ohm_plugin_hal_get_int (plugin, 0, "laptop_panel.num_levels", &data.levels);
+ g_debug ("%s: data.levels = %d", G_STRFUNC, data.levels);
+
if (data.levels == 0) {
g_error ("levels zero!");
return;
diff-tree 55ba3a7c3bb62cb7ea2161a03207cee6be59d6c0 (from 44e720303af9454d74e50e69c962451fd97b07b1)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Sun Sep 23 18:45:15 2007 +0100
idle glue: remove unnecessary init
No need to check xorg.has_xauthority as we'll get a notify after intialisation.
diff --git a/plugins/glue/idle/ohm-plugin-idle.c b/plugins/glue/idle/ohm-plugin-idle.c
index 3b55202..f163d9a 100644
--- a/plugins/glue/idle/ohm-plugin-idle.c
+++ b/plugins/glue/idle/ohm-plugin-idle.c
@@ -83,27 +83,6 @@ plugin_connect_idletime (OhmPlugin *plug
}
/**
- * plugin_initalize:
- * @plugin: This class instance
- *
- * Coldplug, i.e. read and set the initial state of the plugin.
- * We can assume all the required modules have been loaded, although it's
- * dangerous to assume the key values are anything other than the defaults.
- */
-static void
-plugin_initalize (OhmPlugin *plugin)
-{
- gint value;
-
- /* check system inhibit - this is broken as any client can unref all */
- ohm_plugin_conf_get_key (plugin, "xorg.has_xauthority", &value);
- if (value == 1) {
- plugin_connect_idletime (plugin);
- }
-
-}
-
-/**
* plugin_notify:
* @plugin: This class instance
*
@@ -153,9 +132,9 @@ OHM_PLUGIN_DESCRIPTION (
"0.0.1", /* version */
"richard at hughsie.com", /* author */
OHM_LICENSE_LGPL, /* license */
- plugin_initalize, /* initalize */
+ NULL, /* initalize */
plugin_destroy, /* destroy */
- plugin_notify /* notify */
+ plugin_notify /* notify */
);
OHM_PLUGIN_REQUIRES ("xorg");
diff-tree 44e720303af9454d74e50e69c962451fd97b07b1 (from e71617dab0bbd728cc4e8c736fecef934f108041)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Sun Sep 23 18:42:08 2007 +0100
display policy: handle return from powersave correctly
When coming back from powersave, set backlight.state=1.
diff --git a/plugins/policy/display/ohm-plugin-display.c b/plugins/policy/display/ohm-plugin-display.c
index cfb032c..034474b 100644
--- a/plugins/policy/display/ohm-plugin-display.c
+++ b/plugins/policy/display/ohm-plugin-display.c
@@ -95,7 +95,7 @@ backlight_powersave (OhmPlugin *plugin,
gint state;
ohm_plugin_conf_get_key (plugin, "backlight.state", &state);
- if (state == 0) {
+ if (is_idle && state == 0) {
/* work round a idletime bugs */
return;
}
@@ -109,6 +109,7 @@ backlight_powersave (OhmPlugin *plugin,
/* if not idle any more */
if (is_idle == FALSE) {
+ ohm_plugin_conf_set_key (plugin, "backlight.state", 1);
reset_brightness (plugin);
return;
}
diff-tree e71617dab0bbd728cc4e8c736fecef934f108041 (from b95316f6a8a7e30d009851ff7babb65deea427f5)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Sun Sep 23 18:23:56 2007 +0100
libidletime: debug output for counter value on timeouts
diff --git a/libidletime/libidletime.c b/libidletime/libidletime.c
index 1c95508..2a0775b 100644
--- a/libidletime/libidletime.c
+++ b/libidletime/libidletime.c
@@ -240,6 +240,7 @@ idletime_x_event_filter (GdkXEvent *gdkx
/* save the last state we triggered */
idletime->priv->last_event = alarm->id;
+ g_debug ("%s: alarm %d fired, idle time = %lld", G_STRFUNC, alarm->id, xsyncvalue_to_int64(&alarm_event->counter_value));
/* do the signal */
if (alarm->id != 0) {
idletime_timeout (idletime, alarm);
diff-tree b95316f6a8a7e30d009851ff7babb65deea427f5 (from f3e2735d7d2a1dcc9a6cff9cdadba79446c5dd7d)
Author: Rob Taylor <rob.taylor at codethink.co.uk>
Date: Sun Sep 23 18:14:29 2007 +0200
use int64_to_xsyncvalue and xsyncvalue_to_int64 rather than XSyncValueAdd and friends.
Removes idletime_xsync_value_add_one, replaced with int64 manipulation.
diff --git a/libidletime/libidletime.c b/libidletime/libidletime.c
index feecef1..1c95508 100644
--- a/libidletime/libidletime.c
+++ b/libidletime/libidletime.c
@@ -159,20 +159,6 @@ idletime_timeout (LibIdletime *idletime,
}
/**
- * idletime_xsync_value_add_one:
- *
- * Just adds one to a XSyncValue. I love X.
- */
-static void
-idletime_xsync_value_add_one (XSyncValue *from, XSyncValue *to)
-{
- int overflow;
- XSyncValue add;
- XSyncIntToValue (&add, -1);
- XSyncValueAdd (to, *from, add, &overflow);
-}
-
-/**
* idletime_alarm_find_id:
*/
static LibIdletimeAlarm *
@@ -202,7 +188,7 @@ idletime_x_set_reset (LibIdletime *idlet
if (idletime->priv->reset_set == FALSE) {
/* don't match on the current value because
* XSyncNegativeComparison means less or equal. */
- idletime_xsync_value_add_one (&alarm_event->counter_value, &alarm->timeout);
+ alarm->timeout = int64_to_xsyncvalue (xsyncvalue_to_int64 (&alarm_event->counter_value) - 1LL);
/* set the reset alarm to fire the next time
* idletime->priv->idle_counter < the current counter value */
More information about the Ohm-devel
mailing list