summaryrefslogtreecommitdiff
path: root/src/config/lua/ConfigManager.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/config/lua/ConfigManager.hpp')
-rw-r--r--src/config/lua/ConfigManager.hpp65
1 files changed, 37 insertions, 28 deletions
diff --git a/src/config/lua/ConfigManager.hpp b/src/config/lua/ConfigManager.hpp
index 77387758..4e670b23 100644
--- a/src/config/lua/ConfigManager.hpp
+++ b/src/config/lua/ConfigManager.hpp
@@ -8,6 +8,7 @@
#include <chrono>
#include <string_view>
#include <unordered_map>
+#include <expected>
#include "../../helpers/memory/Memory.hpp"
#include "../ConfigManager.hpp"
@@ -38,6 +39,10 @@ namespace Config::Lua {
class CConfigManagerPluginLuaTestAccessor;
}
+namespace Config::Lua::Layouts {
+ struct SLuaLayoutProvider;
+}
+
namespace Config::Lua::Bindings {
void registerBindings(lua_State* L, CConfigManager* mgr);
}
@@ -87,6 +92,7 @@ namespace Config::Lua {
void registerLuaRef(int ref);
void callLuaFn(int ref);
+ std::expected<void, std::string> registerLuaLayoutProvider(std::string name, lua_State* L, int providerTableIdx);
// execute an arbitrary lua string on the current state.
std::optional<std::string> eval(const std::string& code);
@@ -100,6 +106,7 @@ namespace Config::Lua {
static constexpr int LUA_TIMEOUT_EVENT_CALLBACK_MS = 50;
static constexpr int LUA_TIMEOUT_KEYBIND_CALLBACK_MS = 100;
static constexpr int LUA_TIMEOUT_TIMER_CALLBACK_MS = 50;
+ static constexpr int LUA_TIMEOUT_LAYOUT_CALLBACK_MS = 50;
static constexpr int LUA_TIMEOUT_EVAL_MS = 250;
static constexpr int LUA_TIMEOUT_DISPATCH_MS = 100;
@@ -136,34 +143,36 @@ namespace Config::Lua {
std::unordered_map<std::string, SP<Desktop::Rule::CLayerRule>> m_luaLayerRules;
private:
- void reinitLuaState();
- void postConfigReload();
- void registerValue(const char* name, ILuaConfigValue* val);
- void cleanTimers();
- void clearHeldLuaRefs();
- std::string luaConfigValueName(const std::string& s);
- std::expected<void, std::string> registerPluginLuaFunctionInState(uint64_t id, const std::string& namespace_, const std::string& name);
- std::expected<void, std::string> unregisterPluginLuaFunctionInState(const std::string& namespace_, const std::string& name);
- void erasePluginLuaFunction(uint64_t id);
- void reregisterLuaPluginFns();
-
- static void watchdogHook(lua_State* L, lua_Debug* ar);
-
- lua_State* m_lua = nullptr;
-
- bool m_lastConfigVerificationWasSuccessful = true;
- bool m_isFirstLaunch = true;
- bool m_manualCrashInitiated = false;
- bool m_watchdogActive = false;
- bool m_isParsingConfig = false;
- bool m_isEvaluating = false;
-
- std::chrono::steady_clock::time_point m_watchdogDeadline;
- std::string m_watchdogContext;
-
- std::string m_mainConfigPath;
-
- std::vector<int> m_heldLuaRefs;
+ void reinitLuaState();
+ void postConfigReload();
+ void registerValue(const char* name, ILuaConfigValue* val);
+ void cleanTimers();
+ void clearLuaLayoutProviders();
+ void clearHeldLuaRefs();
+ std::string luaConfigValueName(const std::string& s);
+ std::expected<void, std::string> registerPluginLuaFunctionInState(uint64_t id, const std::string& namespace_, const std::string& name);
+ std::expected<void, std::string> unregisterPluginLuaFunctionInState(const std::string& namespace_, const std::string& name);
+ void erasePluginLuaFunction(uint64_t id);
+ void reregisterLuaPluginFns();
+
+ static void watchdogHook(lua_State* L, lua_Debug* ar);
+
+ lua_State* m_lua = nullptr;
+
+ bool m_lastConfigVerificationWasSuccessful = true;
+ bool m_isFirstLaunch = true;
+ bool m_manualCrashInitiated = false;
+ bool m_watchdogActive = false;
+ bool m_isParsingConfig = false;
+ bool m_isEvaluating = false;
+
+ std::chrono::steady_clock::time_point m_watchdogDeadline;
+ std::string m_watchdogContext;
+
+ std::string m_mainConfigPath;
+
+ std::vector<int> m_heldLuaRefs;
+ std::vector<SP<Layouts::SLuaLayoutProvider>> m_luaLayoutProviders;
// this is here for legacy reasons.
std::unordered_map<std::string, const void*> m_configPtrMap;