From 82c0b181e87a1f6aca2431669435461f39dfd696 Mon Sep 17 00:00:00 2001 From: Rui Guo Date: Mon, 1 Jun 2009 16:21:42 +0800 Subject: [PATCH] Update the window object interface a bit. 1. Make the title property read/write. 2. Add the get_monitor_status interface. 3. Get rid of a compiler warning. --- src/lua.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/lua.c b/src/lua.c index 083d042..5fd9e18 100644 --- a/src/lua.c +++ b/src/lua.c @@ -230,12 +230,27 @@ window_change_title(lua_State *L) struct win *w = check_window(L, 1); unsigned int len; const char *title = luaL_checklstring(L, 2, &len); - ChangeAKA(w, title, len); + ChangeAKA(w, (char *)title, len); return 0; } +static int +window_get_monitor_status(lua_State *L) +{ + struct win *w = check_window(L, 1); + int activity = luaL_checkint(L, 2); + if (activity) + //monitor + lua_pushinteger(L, w->w_monitor != MON_OFF); + else + //silence + lua_pushinteger(L, w->w_silence == SILENCE_ON ? w->w_silencewait: 0); + + return 1; +} + static const luaL_reg window_methods[] = { - {"change_title", window_change_title}, + {"get_monitor_status", window_get_monitor_status}, {0, 0} }; @@ -264,6 +279,7 @@ static const luaL_reg window_metamethods[] = { }; static const struct Xet_reg window_setters[] = { + {"title", 0, 0, window_change_title/*absolute setter*/}, {0, 0} }; @@ -275,7 +291,6 @@ static const struct Xet_reg window_getters[] = { {"pid", get_int, offsetof(struct win, w_pid)}, {"group", get_window, offsetof(struct win, w_group)}, {"bell", get_int, offsetof(struct win, w_bell)}, - {"monitor", get_int, offsetof(struct win, w_monitor)}, {0, 0} }; -- 2.11.4.GIT