Implement display.idle_timeout interface, currently write-only
authorGuo Rui <firemeteor@Adam.(none)>
Mon, 13 Jul 2009 16:08:07 +0000 (14 00:08 +0800)
committerGuo Rui <firemeteor@Adam.(none)>
Mon, 13 Jul 2009 16:08:07 +0000 (14 00:08 +0800)
src/lua.c

index 866c1df..3aa7d0b 100644 (file)
--- a/src/lua.c
+++ b/src/lua.c
@@ -788,7 +788,26 @@ static const luaL_reg display_metamethods[] = {
   {0, 0}
 };
 
+static int
+display_new_idle_timeout(lua_State *L)
+{
+  struct display *disp = check_display(L, 1);
+  int timeout = luaL_checkinteger(L, 3) * 1000;
+  struct event *ev = &disp->d_idleev;
+  if (timeout > 0)
+    {
+      SetTimeout(ev, timeout);
+      if (!ev->queued)
+       evenq(ev);
+    }
+  else
+    evdeq(ev);
+  
+  return 0;
+}
+
 static const struct Xet_reg display_setters[] = {
+  {"idle_timeout", 0, 0, display_new_idle_timeout/*absolute setter*/},
   {0, 0}
 };