mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-08-17 01:00:27 +03:00
plugins: fix config value usage in init
This commit is contained in:
parent
da7ea2b33d
commit
0c61a1530f
@ -77,8 +77,12 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
|||||||
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "processMouseDownNormal");
|
static const auto METHODS = HyprlandAPI::findFunctionsByName(PHANDLE, "processMouseDownNormal");
|
||||||
g_pMouseDownHook = HyprlandAPI::createFunctionHook(PHANDLE, METHODS[0].address, (void*)&hkProcessMouseDownNormal);
|
g_pMouseDownHook = HyprlandAPI::createFunctionHook(PHANDLE, METHODS[0].address, (void*)&hkProcessMouseDownNormal);
|
||||||
|
|
||||||
|
static auto* const PBORDERCOLOR = HyprlandAPI::getConfigValue(PHANDLE, "plugin:example:border_color");
|
||||||
|
|
||||||
// fancy notifications
|
// fancy notifications
|
||||||
HyprlandAPI::addNotificationV2(PHANDLE, {{"text", "Example hint"}, {"time", (uint64_t)10000}, {"color", CColor(0.2, 0.2, 0.9, 1.0)}, {"icon", ICON_HINT}});
|
HyprlandAPI::addNotificationV2(
|
||||||
|
PHANDLE,
|
||||||
|
{{"text", "Example hint, color " + std::to_string(PBORDERCOLOR->intValue)}, {"time", (uint64_t)10000}, {"color", CColor{PBORDERCOLOR->intValue}}, {"icon", ICON_HINT}});
|
||||||
|
|
||||||
// Enable our hooks
|
// Enable our hooks
|
||||||
g_pFocusHook->hook();
|
g_pFocusHook->hook();
|
||||||
|
@ -371,8 +371,10 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
|
|||||||
CONFIGENTRY = &it->second;
|
CONFIGENTRY = &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CONFIGENTRY)
|
if (!CONFIGENTRY) {
|
||||||
|
m_vFailedPluginConfigValues.emplace_back(std::make_pair<>(COMMAND, VALUE));
|
||||||
return; // silent ignore
|
return; // silent ignore
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
CONFIGENTRY = &configValues.at(COMMAND);
|
CONFIGENTRY = &configValues.at(COMMAND);
|
||||||
}
|
}
|
||||||
@ -1458,6 +1460,7 @@ void CConfigManager::loadConfigLoadVars() {
|
|||||||
setDefaultAnimationVars(); // reset anims
|
setDefaultAnimationVars(); // reset anims
|
||||||
m_vDeclaredPlugins.clear();
|
m_vDeclaredPlugins.clear();
|
||||||
m_dLayerRules.clear();
|
m_dLayerRules.clear();
|
||||||
|
m_vFailedPluginConfigValues.clear();
|
||||||
|
|
||||||
// paths
|
// paths
|
||||||
configPaths.clear();
|
configPaths.clear();
|
||||||
@ -2179,6 +2182,11 @@ void CConfigManager::addPluginConfigVar(HANDLE handle, const std::string& name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
(*CONFIGMAPIT->second)[name] = value;
|
(*CONFIGMAPIT->second)[name] = value;
|
||||||
|
|
||||||
|
if (const auto IT = std::find_if(m_vFailedPluginConfigValues.begin(), m_vFailedPluginConfigValues.end(), [&](const auto& other) { return other.first == name; });
|
||||||
|
IT != m_vFailedPluginConfigValues.end()) {
|
||||||
|
configSetValueSafe(IT->first, IT->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::removePluginConfig(HANDLE handle) {
|
void CConfigManager::removePluginConfig(HANDLE handle) {
|
||||||
|
@ -252,6 +252,8 @@ class CConfigManager {
|
|||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> environmentVariables;
|
std::vector<std::pair<std::string, std::string>> environmentVariables;
|
||||||
|
|
||||||
|
std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins
|
||||||
|
|
||||||
// internal methods
|
// internal methods
|
||||||
void setDefaultVars();
|
void setDefaultVars();
|
||||||
void setDefaultAnimationVars();
|
void setDefaultAnimationVars();
|
||||||
|
@ -112,6 +112,9 @@ void CPluginSystem::unloadPlugin(const CPlugin* plugin, bool eject) {
|
|||||||
Debug::log(LOG, " [PluginSystem] Plugin %s unloaded.", plugin->name.c_str());
|
Debug::log(LOG, " [PluginSystem] Plugin %s unloaded.", plugin->name.c_str());
|
||||||
|
|
||||||
std::erase_if(m_vLoadedPlugins, [&](const auto& other) { return other->m_pHandle == plugin->m_pHandle; });
|
std::erase_if(m_vLoadedPlugins, [&](const auto& other) { return other->m_pHandle == plugin->m_pHandle; });
|
||||||
|
|
||||||
|
// reload config to fix some stuf like e.g. unloadedPluginVars
|
||||||
|
g_pConfigManager->m_bForceReload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginSystem::unloadAllPlugins() {
|
void CPluginSystem::unloadAllPlugins() {
|
||||||
|
Loading…
Reference in New Issue
Block a user