[seed] Add an xorg extension (experimental) - at present only has one function to get the screen idle time.
- From: Alan Knowles <alank src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seed] Add an xorg extension (experimental) - at present only has one function to get the screen idle time.
- Date: Wed, 30 Nov 2011 14:18:12 +0000 (UTC)
commit 67484737433bcf5263194d84ae3f0c2526cccc3d
Author: Alan Knowles <alan akbkhome com>
Date: Wed Nov 30 22:17:57 2011 +0800
Add an xorg extension (experimental) - at present only has one function to get the screen idle time...
configure.ac | 31 ++++++++++++++++++
modules/Makefile.am | 2 +-
modules/xorg/Makefile.am | 29 +++++++++++++++++
modules/xorg/seed-xorg.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 140 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1f9bd74..dfd9d93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -188,6 +188,35 @@ fi
AM_CONDITIONAL(BUILD_SQLITE_MODULE, test "x$want_sqlite_module" = "xyes")
AC_SUBST(BUILD_SQLITE_MODULE)
+
+dnl ==== xorg ====
+AC_ARG_ENABLE(xorg-module,
+ AC_HELP_STRING([--enable-xorg-module],
+ [enable the xorg Seed module. [default=no]]),
+ [want_xorg_module=$enableval],[want_xorg_module="no"])
+
+if test x"$want_xorg_module" = x"yes" ; then
+
+ PKG_CHECK_MODULES(LIBXSS, [xscrnsaver], [
+ AC_DEFINE(USE_LIBXSS, 1, [Use XScreenSaver for idleness])
+ AC_SUBST(LIBXSS_CFLAGS)
+ AC_SUBST(LIBXSS_LIBS)
+ ] , [
+ echo ""
+ echo "configure: error: "
+ echo "XScreenSaver development headers not found."
+ echo "Use --disable-screensaver if you do not need it."
+ echo "If you're using debian or ubuntu,install it by"
+ echo "\"sudo apt-get install libxss-dev\""
+ echo ""
+ exit -1
+ ])
+fi
+
+AM_CONDITIONAL(BUILD_XORG_MODULE, test "x$want_xorg_module" = "xyes")
+AC_SUBST(BUILD_XORG_MODULE)
+
+
dnl ==== Example ====
AC_ARG_ENABLE(example-module,
AC_HELP_STRING([--enable-example-module],
@@ -447,6 +476,7 @@ doc/mapping/Makefile
modules/Makefile
modules/example/Makefile
modules/sqlite/Makefile
+modules/xorg/Makefile
modules/canvas/Makefile
modules/readline/Makefile
modules/multiprocessing/Makefile
@@ -482,6 +512,7 @@ Modules:
multiprocessing............$want_multiprocessing_module
readline...................$want_readline_module
SQLite.....................$want_sqlite_module
+ XOrg.......................$want_xorg_module
DBus.......................$want_dbus_module
libxml.....................$want_libxml_module
cairo......................$want_cairo_module
diff --git a/modules/Makefile.am b/modules/Makefile.am
index ebaaad9..7a99ba2 100644
--- a/modules/Makefile.am
+++ b/modules/Makefile.am
@@ -1 +1 @@
-SUBDIRS = example sqlite canvas multiprocessing readline os sandbox dbus libxml cairo gtkbuilder gettext mpfr ffi DynamicObject
+SUBDIRS = example sqlite canvas multiprocessing readline os sandbox dbus libxml cairo gtkbuilder gettext mpfr ffi DynamicObject xorg
diff --git a/modules/xorg/Makefile.am b/modules/xorg/Makefile.am
new file mode 100644
index 0000000..08cb871
--- /dev/null
+++ b/modules/xorg/Makefile.am
@@ -0,0 +1,29 @@
+if BUILD_XORG_MODULE
+
+seedlibdir = ${libdir}/seed SEED_GTK_VERSION@
+
+seedlib_LTLIBRARIES = \
+ libseed_xorg.la
+
+libseed_xorg_la_SOURCES = \
+ seed-xorg.c
+
+libseed_xorg_la_CFLAGS = \
+ -I top_srcdir@/libseed/ \
+ $(GOBJECT_INTROSPECTION_CFLAGS) \
+ $(LIBXSS_CFLAGS) \
+ $(SEED_DEBUG_CFLAGS) \
+ $(SEED_PROFILE_CFLAGS)
+
+libseed_xorg_la_LDFLAGS = \
+ -module -avoid-version \
+ $(GOBJECT_INTROSPECTION_LDFLAGS) \
+ $(LIBXSS_LDLAGS) \
+ $(SEED_DEBUG_LDFLAGS)
+
+libseed_xorg_la_LIBADD = \
+ $(top_builddir)/libseed/libseed SEED_GTK_VERSION@.la \
+ $(LIBXSS_LIBS) \
+ $(SEED_PROFILE_LIBS)
+
+endif
diff --git a/modules/xorg/seed-xorg.c b/modules/xorg/seed-xorg.c
new file mode 100644
index 0000000..af42fc5
--- /dev/null
+++ b/modules/xorg/seed-xorg.c
@@ -0,0 +1,79 @@
+/* -*- mode: C; indent-tabs-mode: t; tab-width: 8; c-basic-offset: 2; -*- */
+
+/*
+ * This file is part of Seed, the GObject Introspection<->Javascript bindings.
+ *
+ * Seed is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 2 of
+ * the License, or (at your option) any later version.
+ * Seed is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Seed. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) Alan Knowles 2011 <alan akbkhome com>
+ *
+ * This started of as a way to get Xorg information not easily available elsewhere
+ *
+ * It currently is only used with libxss (screensaver extension) to
+ * get the idle time.
+ *
+ */
+
+#include "../../libseed/seed.h"
+#include <X11/extensions/scrnsaver.h>
+
+
+/**
+ * screensaverinfo_get_idletime()
+ * @returns screen idle time.
+ */
+
+SeedValue seed_xorg_screensaverinfo_get_idletime(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ int rc = -1;
+
+ XScreenSaverInfo *info = XScreenSaverAllocInfo();
+ Display *display = XOpenDisplay(NULL);
+
+ if (display != NULL) {
+ XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
+ rc = info->idle;
+ }
+
+ XFree(info);
+ return seed_value_from_int(ctx, rc, exception);
+
+
+}
+
+
+seed_static_function xorg_funcs[] = {
+ {"screensaverinfo_get_idletime", seed_xorg_screensaverinfo_get_idletime, 0},
+
+ {NULL, NULL, 0}
+};
+
+SeedObject
+seed_module_init(SeedEngine * eng)
+{
+ SeedObject seed_xorg;
+ SeedClass seed_xorg_class;
+ seed_class_definition seed_xorg_class_definition = seed_empty_class;
+
+ seed_xorg_class_definition.static_functions = xorg_funcs;
+ seed_xorg_class = seed_create_class (&seed_xorg_class_definition);
+
+ seed_xorg = seed_make_object (eng->context, seed_xorg_class, NULL);
+
+
+ return seed_xorg;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]