Add the window.viewing_canvases method
authorRui Guo <firemeteor.guo@gmail.com>
Mon, 10 Aug 2009 13:08:49 +0000 (10 21:08 +0800)
committerRui Guo <firemeteor.guo@gmail.com>
Mon, 10 Aug 2009 13:08:49 +0000 (10 21:08 +0800)
src/lua.c

index 441a26d..3539cda 100644 (file)
--- a/src/lua.c
+++ b/src/lua.c
@@ -483,8 +483,30 @@ window_activate(lua_State *L)
   return 0;
 }
 
+static int
+window_get_showing_canvases(lua_State *L)
+{
+  struct win *w = check_window(L, 1);
+  int count = 0;
+  struct canvas *cv = w->w_layer.l_cvlist;
+  if (!cv) {
+      lua_pushnil(L);
+      return 1;
+  }
+  lua_newtable(L);
+  while (cv) {
+    lua_pushinteger(L, count++);
+    push_canvas(L, &cv);
+    lua_settable(L, -3);
+    cv = cv->c_lnext;
+  }
+
+  return 1;
+}
+
 static const luaL_reg window_methods[] = {
   {"get_monitor_status", window_get_monitor_status},
+  {"showing_canvases", window_get_showing_canvases},
   {"stuff", window_stuff},
   {"activate", window_activate},
   {"hook", LuaRegEvent},