summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Taylor <rob.taylor@codethink.co.uk>2007-09-13 13:34:08 +0100
committerRob Taylor <rob.taylor@codethink.co.uk>2007-09-13 13:34:08 +0100
commit691eb0eee82027611ba761548390c4649a230aeb (patch)
tree97cde622444c8d7f72d742d37d65fc38ee867ebc
parente3c5f2f25d390878f77cb03b978e3d3c5dcc7c3b (diff)
parentf3e2735d7d2a1dcc9a6cff9cdadba79446c5dd7d (diff)
Merge branch 'master' of git+ssh://git.freedesktop.org/git/ohm into debian-origin
-rw-r--r--configure.in16
-rw-r--r--docs/Makefile.am24
-rw-r--r--libidletime/libidletime.c35
-rw-r--r--libidletime/libidletime.h4
-rw-r--r--ohmd/ohm-plugin.c1
-rw-r--r--plugins/glue/idle/ohm-plugin-idle.c30
-rw-r--r--plugins/glue/xorg/ohm-plugin-xorg.c18
7 files changed, 98 insertions, 30 deletions
diff --git a/configure.in b/configure.in
index 9eda015..1a4ecdd 100644
--- a/configure.in
+++ b/configure.in
@@ -118,16 +118,26 @@ single_user_device="yes"
if test "$single_user_device" = yes; then
AC_DEFINE(OHM_SINGLE_USER_DEVICE, 1, [Whether OHM is built for a single-user device with a known .Xauthority location])
+ AC_ARG_WITH(xauth,
+ [AC_HELP_STRING([--without-xauth],
+ [Whether xauth is needed to access the Xserver.]
+ )],
+ [with_xauth="$withval"], [with_xauth="yes"]
+ )
+
+
AC_ARG_WITH(xauth-dir,
[AC_HELP_STRING([--with-xauth-dir=<dir>],
[directory where we can find .Xauthority (for single-user device)]
)]
)
- if test -z "$with_xauth_dir"; then
- AC_MSG_ERROR([Must use --with-xauth-dir for a single-user device])
+ if test "x$with_xauth" = "xno"; then
+ AC_DEFINE(OHM_DEVICE_NO_XAUTH, 1, [No Xauth needed for Xserver access])
+ elif test -z "$with_xauth_dir"; then
+ AC_MSG_ERROR([Must use --without-xauth or --with-xauth-dir for a single-user device])
else
- AC_DEFINE(OHM_DEVICE_XAUTH_DIR, "$xauth_dir", [Where to find .Xauthority])
+ AC_DEFINE_UNQUOTED(OHM_DEVICE_XAUTH_DIR, "$with_xauth_dir", [Where to find .Xauthority])
fi
fi
diff --git a/docs/Makefile.am b/docs/Makefile.am
index c3d3800..0b6cca2 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -21,15 +21,6 @@ SPEC_XML_FILES = \
SPEC_HTML_FILES = \
index.html
-htmldocdir = $(docdir)
-htmldoc_DATA = index.html
-
-if DOCBOOK_DOCS_ENABLED
-
-index.html : introduction.xml
- $(XMLTO) html-nochunks -m config.xsl index.xml
-endif # DOCBOOK_DOCS_ENABLED
-
clean-local:
rm -f *~
rm -f *.html
@@ -39,5 +30,16 @@ EXTRA_DIST = \
config.xsl \
docbook.css \
$(SPEC_XML_FILES) \
- $(IMAGE_FILES) \
- $(SPEC_HTML_FILES)
+ $(IMAGE_FILES)
+
+if DOCBOOK_DOCS_ENABLED
+
+htmldocdir = $(docdir)
+htmldoc_DATA = index.html
+
+index.html : introduction.xml
+ $(XMLTO) html-nochunks -m config.xsl index.xml
+
+EXTRA_DIST += $(SPEC_HTML_FILES)
+
+endif #DOCBOOK_DOCS_ENABLED
diff --git a/libidletime/libidletime.c b/libidletime/libidletime.c
index 0d75b50..feecef1 100644
--- a/libidletime/libidletime.c
+++ b/libidletime/libidletime.c
@@ -41,6 +41,21 @@ static void idletime_finalize (GObject *object);
#define LIBIDLETIME_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LIBIDLETIME_TYPE, LibIdletimePrivate))
+inline gint64
+xsyncvalue_to_int64 (XSyncValue *value)
+{
+ return ((guint64) XSyncValueHigh32 (*value)) << 32
+ | (guint64) XSyncValueLow32 (*value);
+}
+
+inline XSyncValue
+int64_to_xsyncvalue (gint64 value)
+{
+ XSyncValue ret;
+ XSyncIntsToValue (&ret, value, ((guint64)value) >> 32);
+ return ret;
+}
+
struct LibIdletimePrivate
{
int sync_event;
@@ -268,7 +283,7 @@ idletime_alarm_get (LibIdletime *idletime)
* idletime_alarm_set:
*/
gboolean
-idletime_alarm_set (LibIdletime *idletime, guint id, guint timeout)
+idletime_alarm_set (LibIdletime *idletime, guint id, gint64 timeout)
{
LibIdletimeAlarm *alarm;
if (id == 0) {
@@ -294,7 +309,7 @@ idletime_alarm_set (LibIdletime *idletime, guint id, guint timeout)
}
/* set the timeout */
- XSyncIntToValue (&alarm->timeout, timeout);
+ alarm->timeout = int64_to_xsyncvalue(timeout);
/* set, and start the timer */
idletime_xsync_alarm_set (idletime, alarm, TRUE);
@@ -332,6 +347,22 @@ idletime_alarm_remove (LibIdletime *idletime, guint id)
}
/**
+ * idletime_get_current_idle:
+ * @idletime: An #LibIdletime instantiation
+ *
+ * Returns the current number of milliseconds idle
+ */
+gint64
+idletime_get_current_idle (LibIdletime *idletime)
+{
+ XSyncValue value;
+ if (XSyncQueryCounter (idletime->priv->dpy, idletime->priv->idle_counter, &value))
+ return xsyncvalue_to_int64 (&value);
+ else
+ return 0LL;
+}
+
+/**
* idletime_class_init:
* @klass: This class instance
**/
diff --git a/libidletime/libidletime.h b/libidletime/libidletime.h
index cfd7a81..dfaee7e 100644
--- a/libidletime/libidletime.h
+++ b/libidletime/libidletime.h
@@ -55,10 +55,12 @@ void idletime_alarm_reset_all (LibIdletime *idletime);
guint idletime_alarm_get (LibIdletime *idletime);
gboolean idletime_alarm_set (LibIdletime *idletime,
guint id,
- guint timeout);
+ gint64 timeout);
gboolean idletime_alarm_remove (LibIdletime *idletime,
guint id);
+gint64 idletime_get_current_idle (LibIdletime *idletime);
+
G_END_DECLS
#endif /* __LIBIDLETIME_H */
diff --git a/ohmd/ohm-plugin.c b/ohmd/ohm-plugin.c
index 1480ebd..dcce2a6 100644
--- a/ohmd/ohm-plugin.c
+++ b/ohmd/ohm-plugin.c
@@ -159,6 +159,7 @@ ohm_plugin_conf_set_key (OhmPlugin *plugin,
* itself if it's interest in that key
*/
plugin->priv->key_being_set = key;
+ ohm_debug ("plugin %s setting key %s to %d", plugin->priv->name, key, value);
ret = ohm_conf_set_key_internal (plugin->priv->conf, key, value, TRUE, &error);
plugin->priv->key_being_set = NULL;
diff --git a/plugins/glue/idle/ohm-plugin-idle.c b/plugins/glue/idle/ohm-plugin-idle.c
index 5c6bff4..3b55202 100644
--- a/plugins/glue/idle/ohm-plugin-idle.c
+++ b/plugins/glue/idle/ohm-plugin-idle.c
@@ -26,11 +26,12 @@
#include <stdlib.h>
static LibIdletime *idletime = NULL;
+static gint64 timeout_offset = 0;
enum {
CONF_XORG_HASXAUTH_CHANGED,
CONF_IDLE_TIMEOUT_CHANGED,
- CONF_IDLE_STATE_CHANGED,
+ CONF_IDLE_RESET,
CONF_LAST
};
@@ -43,6 +44,7 @@ ohm_alarm_expired_cb (LibIdletime *idletime, guint alarm, gpointer data)
if (alarm == 0 ) {
/* activity, reset state to 0 */
ohm_plugin_conf_set_key (plugin, "idle.state", 0);
+ timeout_offset = 0;
} else {
ohm_plugin_conf_get_key (plugin, "idle.state", &state);
ohm_plugin_conf_set_key (plugin, "idle.state", state+1);
@@ -68,6 +70,7 @@ plugin_connect_idletime (OhmPlugin *plugin)
G_CALLBACK (ohm_alarm_expired_cb), plugin);
ohm_plugin_conf_set_key (plugin, "idle.state", 0);
+ ohm_plugin_conf_set_key (plugin, "idle.reset", 0);
ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
@@ -111,6 +114,7 @@ plugin_initalize (OhmPlugin *plugin)
static void
plugin_notify (OhmPlugin *plugin, gint id, gint value)
{
+ g_debug ("idle got notify, id = %d, value = %d", id, value);
gint timeout;
if (id == CONF_XORG_HASXAUTH_CHANGED) {
if (value == 1) {
@@ -120,12 +124,20 @@ plugin_notify (OhmPlugin *plugin, gint id, gint value)
if (idletime) {
if (id == CONF_IDLE_TIMEOUT_CHANGED ) {
g_debug("setting new timeout %d", value);
- idletime_alarm_set (idletime, 1, value);
- } else if (id == CONF_IDLE_STATE_CHANGED ) {
- if (value == 0) {
- ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
- idletime_alarm_set (idletime, 1, timeout);
- }
+ idletime_alarm_set (idletime, 1, timeout_offset+value);
+ } else if (id == CONF_IDLE_RESET && value == 1) {
+ timeout_offset = idletime_get_current_idle (idletime);
+ ohm_plugin_conf_get_key (plugin, "idle.timeout", &timeout);
+ g_debug ("idle plugin reset. current timeout = %d, timeout-offset = %lld", timeout, timeout_offset);
+
+ /* most of the time this isn't needed as the below set
+ * of idle.state will result in a timout change,
+ * but just incase it doesn't happen. or the
+ * new timeout is the same as the old..
+ */
+ idletime_alarm_set (idletime, 1, timeout_offset+timeout);
+ ohm_plugin_conf_set_key (plugin, "idle.reset", 0);
+ ohm_plugin_conf_set_key (plugin, "idle.state", 0);
}
}
}
@@ -148,9 +160,9 @@ OHM_PLUGIN_DESCRIPTION (
OHM_PLUGIN_REQUIRES ("xorg");
-OHM_PLUGIN_PROVIDES ("idle.state", "idle.timeout");
+OHM_PLUGIN_PROVIDES ("idle.state", "idle.timeout", "idle.reset");
OHM_PLUGIN_INTERESTED (
{"xorg.has_xauthority", CONF_XORG_HASXAUTH_CHANGED},
{"idle.timeout", CONF_IDLE_TIMEOUT_CHANGED},
- {"idle.state", CONF_IDLE_STATE_CHANGED});
+ {"idle.reset", CONF_IDLE_RESET});
diff --git a/plugins/glue/xorg/ohm-plugin-xorg.c b/plugins/glue/xorg/ohm-plugin-xorg.c
index f91c8af..3bca47b 100644
--- a/plugins/glue/xorg/ohm-plugin-xorg.c
+++ b/plugins/glue/xorg/ohm-plugin-xorg.c
@@ -32,10 +32,13 @@ static gboolean
plugin_poll_startup (gpointer data)
{
OhmPlugin *plugin = (OhmPlugin *) data;
+
+#ifdef OHM_SINGLE_USER_DEVICE
+#ifndef OHM_DEVICE_NO_XAUTH
+
gboolean ret;
const gchar *xauth;
-#ifdef OHM_SINGLE_USER_DEVICE
xauth = OHM_DEVICE_XAUTH_DIR "/.Xauthority";
g_debug ("xorg: testing %s", xauth);
ret = g_file_test (xauth, G_FILE_TEST_EXISTS);
@@ -53,14 +56,21 @@ plugin_poll_startup (gpointer data)
g_debug ("xorg: no .Xauthority found");
return TRUE;
}
+ setenv ("XAUTHORITY", xauth, 1);
+ g_debug ("Using XAUTHORITY %s", xauth);
+#else
+ g_debug ("Not using XAuth");
+#endif
+
#else
#error ConsoleKit support not yet implemented
#endif
+
+ setenv ("DISPLAY", ":0", 1);
+
/* woot! X is alive */
g_debug ("Got X!");
ohm_plugin_conf_set_key (plugin, "xorg.has_xauthority", 1);
- setenv ("XAUTHORITY", xauth, 1);
- setenv ("DISPLAY", ":0", 1);
/* we don't need to poll anymore */
return FALSE;
}
@@ -82,7 +92,7 @@ plugin_initialize (OhmPlugin *plugin)
/* naive try... we might be running under X */
ret = plugin_poll_startup (plugin);
- if (ret == FALSE) {
+ if (ret == TRUE) {
/* we failed to connect to X - maybe X is not alive yet? */
g_debug ("Could not connect to X, polling until we can");
g_timeout_add (2000, plugin_poll_startup, plugin);