diff --git a/kiwmi/luak/kiwmi_server.c b/kiwmi/luak/kiwmi_server.c index 17bab2e..431b582 100644 --- a/kiwmi/luak/kiwmi_server.c +++ b/kiwmi/luak/kiwmi_server.c @@ -29,6 +29,27 @@ #include "luak/lua_compat.h" #include "server.h" +static int +l_kiwmi_server_active_output(lua_State *L) +{ + struct kiwmi_object *obj = + *(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_server"); + + struct kiwmi_server *server = obj->object; + + struct kiwmi_output *output = desktop_active_output(server); + + lua_pushcfunction(L, luaK_kiwmi_output_new); + lua_pushlightuserdata(L, server->lua); + lua_pushlightuserdata(L, output); + if (lua_pcall(L, 2, 1, 0)) { + wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); + return 0; + } + + return 1; +} + static int l_kiwmi_server_cursor(lua_State *L) { @@ -243,6 +264,7 @@ l_kiwmi_server_view_at(lua_State *L) } static const luaL_Reg kiwmi_server_methods[] = { + {"active_output", l_kiwmi_server_active_output}, {"cursor", l_kiwmi_server_cursor}, {"focused_view", l_kiwmi_server_focused_view}, {"on", luaK_callback_register_dispatch}, diff --git a/lua_docs.md b/lua_docs.md index 1ec953b..96e28fd 100644 --- a/lua_docs.md +++ b/lua_docs.md @@ -13,6 +13,12 @@ This is the entry point to the API. ### Methods +#### kiwmi:active_output() + +Returns the active `kiwmi_output`. + +See `request_active_output`. + #### kiwmi:cursor() Returns a reference to the cursor object.