2023-02-27 12:32:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
2025-04-29 18:59:43 +02:00
|
|
|
#include "../helpers/defer/Promise.hpp"
|
2023-02-27 12:32:38 +00:00
|
|
|
#include "PluginAPI.hpp"
|
|
|
|
|
#include <csetjmp>
|
2025-04-29 18:59:43 +02:00
|
|
|
#include <expected>
|
2023-02-27 12:32:38 +00:00
|
|
|
|
|
|
|
|
class IHyprWindowDecoration;
|
|
|
|
|
|
|
|
|
|
class CPlugin {
|
|
|
|
|
public:
|
2024-05-05 17:16:00 +01:00
|
|
|
std::string name = "";
|
|
|
|
|
std::string description = "";
|
|
|
|
|
std::string author = "";
|
|
|
|
|
std::string version = "";
|
2023-02-27 12:32:38 +00:00
|
|
|
|
2024-05-05 17:16:00 +01:00
|
|
|
std::string path = "";
|
2023-02-27 12:32:38 +00:00
|
|
|
|
2024-05-05 17:16:00 +01:00
|
|
|
bool m_bLoadedWithConfig = false;
|
2023-05-01 07:10:53 -07:00
|
|
|
|
2024-05-05 17:16:00 +01:00
|
|
|
HANDLE m_pHandle = nullptr;
|
2023-02-27 12:32:38 +00:00
|
|
|
|
2024-05-05 17:16:00 +01:00
|
|
|
std::vector<IHyprLayout*> registeredLayouts;
|
|
|
|
|
std::vector<IHyprWindowDecoration*> registeredDecorations;
|
|
|
|
|
std::vector<std::pair<std::string, WP<HOOK_CALLBACK_FN>>> registeredCallbacks;
|
|
|
|
|
std::vector<std::string> registeredDispatchers;
|
|
|
|
|
std::vector<SP<SHyprCtlCommand>> registeredHyprctlCommands;
|
2023-02-27 12:32:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CPluginSystem {
|
|
|
|
|
public:
|
|
|
|
|
CPluginSystem();
|
|
|
|
|
|
2025-04-29 18:59:43 +02:00
|
|
|
SP<CPromise<CPlugin*>> loadPlugin(const std::string& path);
|
|
|
|
|
void unloadPlugin(const CPlugin* plugin, bool eject = false);
|
|
|
|
|
void unloadAllPlugins();
|
|
|
|
|
void updateConfigPlugins(const std::vector<std::string>& plugins, bool& changed);
|
|
|
|
|
CPlugin* getPluginByPath(const std::string& path);
|
|
|
|
|
CPlugin* getPluginByHandle(HANDLE handle);
|
|
|
|
|
std::vector<CPlugin*> getAllPlugins();
|
|
|
|
|
size_t pluginCount();
|
|
|
|
|
void sigGetPlugins(CPlugin** data, size_t len);
|
2023-02-27 12:32:38 +00:00
|
|
|
|
2025-04-29 18:59:43 +02:00
|
|
|
bool m_bAllowConfigVars = false;
|
2023-02-27 12:32:38 +00:00
|
|
|
|
|
|
|
|
private:
|
2025-04-29 18:59:43 +02:00
|
|
|
std::vector<UP<CPlugin>> m_vLoadedPlugins;
|
2023-02-27 12:32:38 +00:00
|
|
|
|
2025-04-29 18:59:43 +02:00
|
|
|
jmp_buf m_jbPluginFaultJumpBuf;
|
|
|
|
|
|
|
|
|
|
std::expected<CPlugin*, std::string> loadPluginInternal(const std::string& path);
|
2023-02-27 12:32:38 +00:00
|
|
|
};
|
|
|
|
|
|
2025-01-23 21:55:41 +01:00
|
|
|
inline UP<CPluginSystem> g_pPluginSystem;
|