diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-07-25 20:27:44 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-07-25 20:28:05 +0530 |
| commit | 81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7 (patch) | |
| tree | aa24bcea93d19ce6298ad6aed499d324fac2ceae /src/LuaRuntimeApi.hpp | |
| parent | 2c7d36b4aa53ffa638a7aa7046767f10e7a152bf (diff) | |
| download | null-browser-81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7.tar.gz null-browser-81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7.zip | |
Add decoration is_enabled api + allowed specifying win_id for enabled
Diffstat (limited to 'src/LuaRuntimeApi.hpp')
| -rw-r--r-- | src/LuaRuntimeApi.hpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/LuaRuntimeApi.hpp b/src/LuaRuntimeApi.hpp index d8e6073..b308f56 100644 --- a/src/LuaRuntimeApi.hpp +++ b/src/LuaRuntimeApi.hpp @@ -1,10 +1,13 @@ #pragma once #include <lua.hpp> +#include <optional> #include "LuaRuntime.hpp" #include "WindowActionRouter.hpp" #include "events/Event.hpp" +#include "lua.h" +#include "widgets/BrowserWindow.hpp" #include "widgets/Decorations.hpp" int lua_api_view_set_url(lua_State *state) { @@ -269,13 +272,23 @@ int lua_api_view_scroll_bottom(lua_State *state) { int lua_api_decorations_set_enabled(lua_State *state) { auto type = (DecorationType)lua_tointeger(state, 1); bool enabled = lua_toboolean(state, 2); - qDebug() << type << enabled; + std::optional<WindowId> win_id = + lua_isnoneornil(state, 3) ? std::nullopt : std::make_optional(lua_tointeger(state, 3)); auto &runtime = LuaRuntime::instance(); - emit runtime.decoration_set_enabled(type, enabled); + emit runtime.decoration_set_enabled(type, enabled, win_id); lua_pushnil(state); return 1; } +int lua_api_decorations_get_enabled(lua_State *state) { + auto type = (DecorationType)lua_tointeger(state, 1); + WindowId win_id = lua_isnoneornil(state, 2) ? lua_tointeger(state, 2) : 0; + auto &router = WindowActionRouter::instance(); + auto value = router.fetch_is_decoration_enabled(type, win_id); + lua_pushboolean(state, value); + return 1; +} + // NOLINTNEXTLINE static luaL_Reg internals_api[] = { luaL_Reg{"event_add_listener", &lua_event_register}, @@ -301,5 +314,6 @@ static luaL_Reg internals_api[] = { luaL_Reg{"search_previous", &lua_api_search_previous}, luaL_Reg{"search_next", &lua_api_search_next}, luaL_Reg{"decorations_set_enabled", &lua_api_decorations_set_enabled}, + luaL_Reg{"decorations_get_enabled", &lua_api_decorations_get_enabled}, luaL_Reg{nullptr, nullptr}, }; |
