Add kiwmi:active_output()

This commit is contained in:
buffet 2021-08-01 22:04:32 +00:00
parent 1cc4f52a77
commit 0492605d1b
2 changed files with 28 additions and 0 deletions

View file

@ -29,6 +29,27 @@
#include "luak/lua_compat.h" #include "luak/lua_compat.h"
#include "server.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 static int
l_kiwmi_server_cursor(lua_State *L) 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[] = { static const luaL_Reg kiwmi_server_methods[] = {
{"active_output", l_kiwmi_server_active_output},
{"cursor", l_kiwmi_server_cursor}, {"cursor", l_kiwmi_server_cursor},
{"focused_view", l_kiwmi_server_focused_view}, {"focused_view", l_kiwmi_server_focused_view},
{"on", luaK_callback_register_dispatch}, {"on", luaK_callback_register_dispatch},

View file

@ -13,6 +13,12 @@ This is the entry point to the API.
### Methods ### Methods
#### kiwmi:active_output()
Returns the active `kiwmi_output`.
See `request_active_output`.
#### kiwmi:cursor() #### kiwmi:cursor()
Returns a reference to the cursor object. Returns a reference to the cursor object.