Comments in configs folder and template handler function

This commit is contained in:
Jasson 2024-07-10 03:15:43 -04:00
parent b03f41efec
commit 0c68eaf99f
10 changed files with 400 additions and 206 deletions

View file

@ -1,4 +1,3 @@
#include <cctype>
#include <netdb.h> #include <netdb.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <cstdio> #include <cstdio>
@ -10,7 +9,6 @@
#include <sys/un.h> #include <sys/un.h>
#include <pwd.h> #include <pwd.h>
#include <unistd.h> #include <unistd.h>
#include <ranges>
#include <algorithm> #include <algorithm>
#include <csignal> #include <csignal>
#include <format> #include <format>
@ -22,7 +20,6 @@
#include <vector> #include <vector>
#include <deque> #include <deque>
#include <filesystem> #include <filesystem>
#include <cstdarg>
#include <regex> #include <regex>
#include <sys/socket.h> #include <sys/socket.h>
#include <hyprutils/string/String.hpp> #include <hyprutils/string/String.hpp>

View file

@ -1,48 +1,89 @@
#pragma once #pragma once
#include "../defines.hpp" #include "../defines.hpp"
#include "../helpers/varlist/VarList.hpp"
#include <vector> #include <vector>
#include <hyprutils/string/VarList.hpp>
/**
* @enum eConfigValueDataTypes
* @brief Enumerates the possible data types for configuration values.
*/
enum eConfigValueDataTypes { enum eConfigValueDataTypes {
CVD_TYPE_INVALID = -1, CVD_TYPE_INVALID = -1,
CVD_TYPE_GRADIENT = 0, CVD_TYPE_GRADIENT = 0,
CVD_TYPE_CSS_VALUE = 1 CVD_TYPE_CSS_VALUE = 1
}; };
/**
* @class ICustomConfigValueData
* @brief Abstract base class for custom configuration value data.
*/
class ICustomConfigValueData { class ICustomConfigValueData {
public: public:
/** @brief Virtual destructor. */
virtual ~ICustomConfigValueData() = 0; virtual ~ICustomConfigValueData() = 0;
/**
* @brief Get the data type of the custom configuration value.
* @return The data type.
*/
virtual eConfigValueDataTypes getDataType() = 0; virtual eConfigValueDataTypes getDataType() = 0;
/**
* @brief Convert the custom configuration value to a string.
* @return The string representation of the value.
*/
virtual std::string toString() = 0; virtual std::string toString() = 0;
}; };
/**
* @class CGradientValueData
* @brief Represents gradient configuration value data.
*/
class CGradientValueData : public ICustomConfigValueData { class CGradientValueData : public ICustomConfigValueData {
public: public:
/** @brief Default constructor. */
CGradientValueData() {}; CGradientValueData() {};
/**
* @brief Constructor with initial color.
* @param col Initial color.
*/
CGradientValueData(CColor col) { CGradientValueData(CColor col) {
m_vColors.push_back(col); m_vColors.push_back(col);
}; };
/** @brief Destructor. */
virtual ~CGradientValueData() {}; virtual ~CGradientValueData() {};
/**
* @brief Get the data type of the gradient value.
* @return The data type (CVD_TYPE_GRADIENT).
*/
virtual eConfigValueDataTypes getDataType() { virtual eConfigValueDataTypes getDataType() {
return CVD_TYPE_GRADIENT; return CVD_TYPE_GRADIENT;
} }
/**
* @brief Reset the gradient with a single color.
* @param col The color to reset the gradient to.
*/
void reset(CColor col) { void reset(CColor col) {
m_vColors.clear(); m_vColors.clear();
m_vColors.emplace_back(col); m_vColors.emplace_back(col);
m_fAngle = 0; m_fAngle = 0;
} }
/* Vector containing the colors */ /** @brief Vector containing the colors */
std::vector<CColor> m_vColors; std::vector<CColor> m_vColors;
/* Float corresponding to the angle (rad) */ /** @brief Float representing the angle (in radians). */
float m_fAngle = 0; float m_fAngle = 0;
// /**
* @brief Equality operator for comparing gradient values.
* @param other The other gradient value to compare with.
* @return True if equal, false otherwise.
*/
bool operator==(const CGradientValueData& other) const { bool operator==(const CGradientValueData& other) const {
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle) if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
return false; return false;
@ -54,6 +95,10 @@ class CGradientValueData : public ICustomConfigValueData {
return true; return true;
} }
/**
* @brief Convert the gradient value to a string.
* @return The string representation of the gradient value.
*/
virtual std::string toString() { virtual std::string toString() {
std::string result; std::string result;
for (auto& c : m_vColors) { for (auto& c : m_vColors) {
@ -65,12 +110,43 @@ class CGradientValueData : public ICustomConfigValueData {
} }
}; };
/**
* @class CCssGapData
* @brief Represents CSS gap configuration value data.
*/
class CCssGapData : public ICustomConfigValueData { class CCssGapData : public ICustomConfigValueData {
public: public:
/** @brief Default constructor. */
CCssGapData() : top(0), right(0), bottom(0), left(0) {}; CCssGapData() : top(0), right(0), bottom(0), left(0) {};
/**
* @brief Constructor with global gap size.
* @param global The global gap size.
*/
CCssGapData(int64_t global) : top(global), right(global), bottom(global), left(global) {}; CCssGapData(int64_t global) : top(global), right(global), bottom(global), left(global) {};
/**
* @brief Constructor with vertical and horizontal gap sizes.
* @param vertical The vertical gap size.
* @param horizontal The horizontal gap size.
*/
CCssGapData(int64_t vertical, int64_t horizontal) : top(vertical), right(horizontal), bottom(vertical), left(horizontal) {}; CCssGapData(int64_t vertical, int64_t horizontal) : top(vertical), right(horizontal), bottom(vertical), left(horizontal) {};
/**
* @brief Constructor with top, horizontal, and bottom gap sizes.
* @param top The top gap size.
* @param horizontal The horizontal gap size.
* @param bottom The bottom gap size.
*/
CCssGapData(int64_t top, int64_t horizontal, int64_t bottom) : top(top), right(horizontal), bottom(bottom), left(horizontal) {}; CCssGapData(int64_t top, int64_t horizontal, int64_t bottom) : top(top), right(horizontal), bottom(bottom), left(horizontal) {};
/**
* @brief Constructor with top, right, bottom, and left gap sizes.
* @param top The top gap size.
* @param right The right gap size.
* @param bottom The bottom gap size.
* @param left The left gap size.
*/
CCssGapData(int64_t top, int64_t right, int64_t bottom, int64_t left) : top(top), right(right), bottom(bottom), left(left) {}; CCssGapData(int64_t top, int64_t right, int64_t bottom, int64_t left) : top(top), right(right), bottom(bottom), left(left) {};
/* Css like directions */ /* Css like directions */
@ -79,7 +155,11 @@ class CCssGapData : public ICustomConfigValueData {
int64_t bottom; int64_t bottom;
int64_t left; int64_t left;
void parseGapData(CVarList varlist) { /**
* @brief Parses gap data from a variable list.
* @param varlist The variable list to parse.
*/
void parseGapData(Hyprutils::String::CVarList varlist) {
switch (varlist.size()) { switch (varlist.size()) {
case 1: { case 1: {
*this = CCssGapData(std::stoi(varlist[0])); *this = CCssGapData(std::stoi(varlist[0]));
@ -105,6 +185,10 @@ class CCssGapData : public ICustomConfigValueData {
} }
} }
/**
* @brief Reset the gaps to a global size.
* @param global The global gap size.
*/
void reset(int64_t global) { void reset(int64_t global) {
top = global; top = global;
right = global; right = global;
@ -112,10 +196,18 @@ class CCssGapData : public ICustomConfigValueData {
left = global; left = global;
} }
/**
* @brief Get the data type of the CSS gap value.
* @return The data type (CVD_TYPE_CSS_VALUE).
*/
virtual eConfigValueDataTypes getDataType() { virtual eConfigValueDataTypes getDataType() {
return CVD_TYPE_CSS_VALUE; return CVD_TYPE_CSS_VALUE;
} }
/**
* @brief Convert the CSS gap value to a string.
* @return The string representation of the CSS gap value.
*/
virtual std::string toString() { virtual std::string toString() {
return std::format("{} {} {} {}", top, right, bottom, left); return std::format("{} {} {} {}", top, right, bottom, left);
} }

View file

@ -3,11 +3,13 @@
#include "../render/decorations/CHyprGroupBarDecoration.hpp" #include "../render/decorations/CHyprGroupBarDecoration.hpp"
#include "config/ConfigDataValues.hpp" #include "config/ConfigDataValues.hpp"
#include "helpers/varlist/VarList.hpp"
#include "../protocols/LayerShell.hpp" #include "../protocols/LayerShell.hpp"
#include "config/defaultConfig.hpp"
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
#include <hyprlang.hpp>
#include <hyprutils/string/VarList.hpp>
#include <string.h> #include <string.h>
#include <string> #include <string>
#include <sys/stat.h> #include <sys/stat.h>
@ -27,6 +29,12 @@ using namespace Hyprutils::String;
extern "C" char** environ; extern "C" char** environ;
/**
* @brief Parses a gradient configuration value and sets it to the provided data.
* @param VALUE The string representation of the gradient value.
* @param data Pointer to the gradient data.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void** data) { static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void** data) {
std::string V = VALUE; std::string V = VALUE;
@ -81,11 +89,21 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
return result; return result;
} }
/**
* @brief Destroys the gradient configuration data.
* @param data Pointer to the gradient data.
*/
static void configHandleGradientDestroy(void** data) { static void configHandleGradientDestroy(void** data) {
if (*data) if (*data)
delete reinterpret_cast<CGradientValueData*>(*data); delete reinterpret_cast<CGradientValueData*>(*data);
} }
/**
* @brief Parses a gap configuration value and sets it to the provided data.
* @param VALUE The string representation of the gap value.
* @param data Pointer to the gap data.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data) { static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data) {
std::string V = VALUE; std::string V = VALUE;
@ -106,209 +124,204 @@ static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data)
return result; return result;
} }
/**
* @brief Destroys the gap configuration data.
* @param data Pointer to the gap data.
*/
static void configHandleGapDestroy(void** data) { static void configHandleGapDestroy(void** data) {
if (*data) if (*data)
delete reinterpret_cast<CCssGapData*>(*data); delete reinterpret_cast<CCssGapData*>(*data);
} }
/**
* @brief Template function to handle command parsing and execution.
* @param c The command.
* @param v The value.
* @param handler Function pointer to the specific handler in the ConfigManager.
* @return CParseResult object indicating the success or failure of the operation.
*/
template <typename Handler>
static Hyprlang::CParseResult handleCommand(const char* c, const char* v, Handler handler) {
const std::string VALUE = v;
const std::string COMMAND = c;
const auto RESULT = (g_pConfigManager.get()->*handler)(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
}
/**
* @brief Handles raw execution commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleRawExec(const char* c, const char* v) { static Hyprlang::CParseResult handleRawExec(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleRawExec);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleRawExec(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles exec-once commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleExecOnce(const char* c, const char* v) { static Hyprlang::CParseResult handleExecOnce(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleExecOnce);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleExecOnce(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles monitor commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleMonitor(const char* c, const char* v) { static Hyprlang::CParseResult handleMonitor(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleMonitor);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleMonitor(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles Bezier curve commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleBezier(const char* c, const char* v) { static Hyprlang::CParseResult handleBezier(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleBezier);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleBezier(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles animation commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleAnimation(const char* c, const char* v) { static Hyprlang::CParseResult handleAnimation(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleAnimation);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleAnimation(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles keybind commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleBind(const char* c, const char* v) { static Hyprlang::CParseResult handleBind(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleBind);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleBind(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles unbind commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleUnbind(const char* c, const char* v) { static Hyprlang::CParseResult handleUnbind(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleUnbind);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleUnbind(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles window rule commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleWindowRule(const char* c, const char* v) { static Hyprlang::CParseResult handleWindowRule(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleWindowRule);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleWindowRule(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles layer rule commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleLayerRule(const char* c, const char* v) { static Hyprlang::CParseResult handleLayerRule(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleLayerRule);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleLayerRule(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles window rule version 2 commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleWindowRuleV2(const char* c, const char* v) { static Hyprlang::CParseResult handleWindowRuleV2(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleWindowRuleV2);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleWindowRuleV2(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles blur layer shell commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleBlurLS(const char* c, const char* v) { static Hyprlang::CParseResult handleBlurLS(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleBlurLS);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleBlurLS(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles workspace rule commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleWorkspaceRules(const char* c, const char* v) { static Hyprlang::CParseResult handleWorkspaceRules(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleWorkspaceRules);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleWorkspaceRules(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles submap commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleSubmap(const char* c, const char* v) { static Hyprlang::CParseResult handleSubmap(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleSubmap);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleSubmap(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles source commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleSource(const char* c, const char* v) { static Hyprlang::CParseResult handleSource(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleSource);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleSource(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles environment variable commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handleEnv(const char* c, const char* v) { static Hyprlang::CParseResult handleEnv(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handleEnv);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handleEnv(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/**
* @brief Handles plugin commands from the configuration.
* @param c The command.
* @param v The value.
* @return CParseResult object indicating the success or failure of the operation.
*/
static Hyprlang::CParseResult handlePlugin(const char* c, const char* v) { static Hyprlang::CParseResult handlePlugin(const char* c, const char* v) {
const std::string VALUE = v; return handleCommand(c, v, &CConfigManager::handlePlugin);
const std::string COMMAND = c;
const auto RESULT = g_pConfigManager->handlePlugin(COMMAND, VALUE);
Hyprlang::CParseResult result;
if (RESULT.has_value())
result.setError(RESULT.value().c_str());
return result;
} }
/** @brief Constructs a CConfigManager object, initializes configuration settings, and sets default values. */
CConfigManager::CConfigManager() { CConfigManager::CConfigManager() {
const auto ERR = verifyConfigExists(); const auto ERR = verifyConfigExists();
configPaths.emplace_back(getMainConfigPath()); configPaths.emplace_back(getMainConfigPath()); // Add the main configuration path to configPaths
// Initialize the m_pConfig object with the main config path and configuration options
m_pConfig = std::make_unique<Hyprlang::CConfig>(configPaths.begin()->c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = true}); m_pConfig = std::make_unique<Hyprlang::CConfig>(configPaths.begin()->c_str(), Hyprlang::SConfigOptions{.throwAllErrors = true, .allowMissingConfig = true});
// Add general configuration values
m_pConfig->addConfigValue("general:sensitivity", {1.0f}); m_pConfig->addConfigValue("general:sensitivity", {1.0f});
m_pConfig->addConfigValue("general:apply_sens_to_raw", Hyprlang::INT{0}); m_pConfig->addConfigValue("general:apply_sens_to_raw", Hyprlang::INT{0});
m_pConfig->addConfigValue("general:border_size", Hyprlang::INT{1}); m_pConfig->addConfigValue("general:border_size", Hyprlang::INT{1});
@ -325,6 +338,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("general:allow_tearing", Hyprlang::INT{0}); m_pConfig->addConfigValue("general:allow_tearing", Hyprlang::INT{0});
m_pConfig->addConfigValue("general:resize_corner", Hyprlang::INT{0}); m_pConfig->addConfigValue("general:resize_corner", Hyprlang::INT{0});
// Add miscellaneous configuration values
m_pConfig->addConfigValue("misc:disable_hyprland_logo", Hyprlang::INT{0}); m_pConfig->addConfigValue("misc:disable_hyprland_logo", Hyprlang::INT{0});
m_pConfig->addConfigValue("misc:disable_splash_rendering", Hyprlang::INT{0}); m_pConfig->addConfigValue("misc:disable_splash_rendering", Hyprlang::INT{0});
m_pConfig->addConfigValue("misc:col.splash", Hyprlang::INT{0x55ffffff}); m_pConfig->addConfigValue("misc:col.splash", Hyprlang::INT{0x55ffffff});
@ -355,6 +369,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("misc:initial_workspace_tracking", Hyprlang::INT{1}); m_pConfig->addConfigValue("misc:initial_workspace_tracking", Hyprlang::INT{1});
m_pConfig->addConfigValue("misc:middle_click_paste", Hyprlang::INT{1}); m_pConfig->addConfigValue("misc:middle_click_paste", Hyprlang::INT{1});
// Add group-related configuration values
m_pConfig->addConfigValue("group:insert_after_current", Hyprlang::INT{1}); m_pConfig->addConfigValue("group:insert_after_current", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:focus_removed_window", Hyprlang::INT{1}); m_pConfig->addConfigValue("group:focus_removed_window", Hyprlang::INT{1});
m_pConfig->addConfigValue("group:groupbar:enabled", Hyprlang::INT{1}); m_pConfig->addConfigValue("group:groupbar:enabled", Hyprlang::INT{1});
@ -368,6 +383,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("group:groupbar:text_color", Hyprlang::INT{0xffffffff}); m_pConfig->addConfigValue("group:groupbar:text_color", Hyprlang::INT{0xffffffff});
m_pConfig->addConfigValue("group:groupbar:stacked", Hyprlang::INT{0}); m_pConfig->addConfigValue("group:groupbar:stacked", Hyprlang::INT{0});
// Add debug configuration values
m_pConfig->addConfigValue("debug:int", Hyprlang::INT{0}); m_pConfig->addConfigValue("debug:int", Hyprlang::INT{0});
m_pConfig->addConfigValue("debug:log_damage", Hyprlang::INT{0}); m_pConfig->addConfigValue("debug:log_damage", Hyprlang::INT{0});
m_pConfig->addConfigValue("debug:overlay", Hyprlang::INT{0}); m_pConfig->addConfigValue("debug:overlay", Hyprlang::INT{0});
@ -384,6 +400,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("debug:disable_scale_checks", Hyprlang::INT{0}); m_pConfig->addConfigValue("debug:disable_scale_checks", Hyprlang::INT{0});
m_pConfig->addConfigValue("debug:colored_stdout_logs", Hyprlang::INT{1}); m_pConfig->addConfigValue("debug:colored_stdout_logs", Hyprlang::INT{1});
// Add decoration-related configuration values
m_pConfig->addConfigValue("decoration:rounding", Hyprlang::INT{0}); m_pConfig->addConfigValue("decoration:rounding", Hyprlang::INT{0});
m_pConfig->addConfigValue("decoration:blur:enabled", Hyprlang::INT{1}); m_pConfig->addConfigValue("decoration:blur:enabled", Hyprlang::INT{1});
m_pConfig->addConfigValue("decoration:blur:size", Hyprlang::INT{8}); m_pConfig->addConfigValue("decoration:blur:size", Hyprlang::INT{8});
@ -554,7 +571,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addConfigValue("group:groupbar:col.locked_active", Hyprlang::CConfigCustomValueType{&configHandleGradientSet, configHandleGradientDestroy, "0x66ff5500"}); m_pConfig->addConfigValue("group:groupbar:col.locked_active", Hyprlang::CConfigCustomValueType{&configHandleGradientSet, configHandleGradientDestroy, "0x66ff5500"});
m_pConfig->addConfigValue("group:groupbar:col.locked_inactive", Hyprlang::CConfigCustomValueType{&configHandleGradientSet, configHandleGradientDestroy, "0x66775500"}); m_pConfig->addConfigValue("group:groupbar:col.locked_inactive", Hyprlang::CConfigCustomValueType{&configHandleGradientSet, configHandleGradientDestroy, "0x66775500"});
// devices // Devices
m_pConfig->addSpecialCategory("device", {"name"}); m_pConfig->addSpecialCategory("device", {"name"});
m_pConfig->addSpecialConfigValue("device", "sensitivity", {0.F}); m_pConfig->addSpecialConfigValue("device", "sensitivity", {0.F});
m_pConfig->addSpecialConfigValue("device", "accel_profile", {STRVAL_EMPTY}); m_pConfig->addSpecialConfigValue("device", "accel_profile", {STRVAL_EMPTY});
@ -590,7 +607,7 @@ CConfigManager::CConfigManager() {
m_pConfig->addSpecialConfigValue("device", "active_area_position", Hyprlang::VEC2{0, 0}); // only for tablets m_pConfig->addSpecialConfigValue("device", "active_area_position", Hyprlang::VEC2{0, 0}); // only for tablets
m_pConfig->addSpecialConfigValue("device", "active_area_size", Hyprlang::VEC2{0, 0}); // only for tablets m_pConfig->addSpecialConfigValue("device", "active_area_size", Hyprlang::VEC2{0, 0}); // only for tablets
// keywords // Keywords
m_pConfig->registerHandler(&::handleRawExec, "exec", {false}); m_pConfig->registerHandler(&::handleRawExec, "exec", {false});
m_pConfig->registerHandler(&::handleExecOnce, "exec-once", {false}); m_pConfig->registerHandler(&::handleExecOnce, "exec-once", {false});
m_pConfig->registerHandler(&::handleMonitor, "monitor", {false}); m_pConfig->registerHandler(&::handleMonitor, "monitor", {false});
@ -627,6 +644,11 @@ CConfigManager::CConfigManager() {
g_pHyprError->queueCreate(ERR.value(), CColor{1.0, 0.1, 0.1, 1.0}); g_pHyprError->queueCreate(ERR.value(), CColor{1.0, 0.1, 0.1, 1.0});
} }
/**
* @brief Retrieves the configuration directory path.
* @return The absolute path to the configuration directory.
* @throws std::runtime_error if neither HOME nor XDG_CONFIG_HOME is set.
*/
std::string CConfigManager::getConfigDir() { std::string CConfigManager::getConfigDir() {
static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME"); static const char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
@ -641,6 +663,10 @@ std::string CConfigManager::getConfigDir() {
return home + std::string("/.config"); return home + std::string("/.config");
} }
/**
* @brief Retrieves the main configuration file path.
* @return The absolute path to the main configuration file.
*/
std::string CConfigManager::getMainConfigPath() { std::string CConfigManager::getMainConfigPath() {
if (!g_pCompositor->explicitConfigPath.empty()) if (!g_pCompositor->explicitConfigPath.empty())
return g_pCompositor->explicitConfigPath; return g_pCompositor->explicitConfigPath;
@ -648,6 +674,10 @@ std::string CConfigManager::getMainConfigPath() {
return getConfigDir() + "/hypr/" + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf"); return getConfigDir() + "/hypr/" + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
} }
/**
* @brief Retrieves concatenated string contents of all configuration files specified in `configPaths`.
* @return A string containing concatenated contents of all configuration files.
*/
const std::string CConfigManager::getConfigString() { const std::string CConfigManager::getConfigString() {
std::string configString; std::string configString;
std::string currFileContent; std::string currFileContent;
@ -667,10 +697,15 @@ const std::string CConfigManager::getConfigString() {
return configString; return configString;
} }
/**
* @brief Retrieves the current configuration errors as a string.
* @return A string containing current configuration errors.
*/
std::string CConfigManager::getErrors() { std::string CConfigManager::getErrors() {
return m_szConfigErrors; return m_szConfigErrors;
} }
/** @brief Reloads the configuration. */
void CConfigManager::reload() { void CConfigManager::reload() {
EMIT_HOOK_EVENT("preConfigReload", nullptr); EMIT_HOOK_EVENT("preConfigReload", nullptr);
setDefaultAnimationVars(); setDefaultAnimationVars();
@ -680,6 +715,7 @@ void CConfigManager::reload() {
postConfigReload(ERR); postConfigReload(ERR);
} }
/** @brief Initializes default animation variables if it's the first launch. */
void CConfigManager::setDefaultAnimationVars() { void CConfigManager::setDefaultAnimationVars() {
if (isFirstLaunch) { if (isFirstLaunch) {
INITANIMCFG("global"); INITANIMCFG("global");
@ -1082,7 +1118,7 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(PHLWINDOW pWindow, boo
if (!valid(pWindow)) if (!valid(pWindow))
return std::vector<SWindowRule>(); return std::vector<SWindowRule>();
// if the window is unmapped, don't process exec rules yet. // Adjust shadowExec based on window mapping status
shadowExec = shadowExec || !pWindow->m_bIsMapped; shadowExec = shadowExec || !pWindow->m_bIsMapped;
std::vector<SWindowRule> returns; std::vector<SWindowRule> returns;
@ -1092,11 +1128,11 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(PHLWINDOW pWindow, boo
Debug::log(LOG, "Searching for matching rules for {} (title: {})", appidclass, title); Debug::log(LOG, "Searching for matching rules for {} (title: {})", appidclass, title);
// since some rules will be applied later, we need to store some flags // Since some rules will be applied later, we need to store some flags
bool hasFloating = pWindow->m_bIsFloating; bool hasFloating = pWindow->m_bIsFloating;
bool hasFullscreen = pWindow->m_bIsFullscreen; bool hasFullscreen = pWindow->m_bIsFullscreen;
// local tags for dynamic tag rule match // Local tags for dynamic tag rule match
auto tags = pWindow->m_tags; auto tags = pWindow->m_tags;
for (auto& rule : m_dWindowRules) { for (auto& rule : m_dWindowRules) {

View file

@ -3,32 +3,31 @@
#define CONFIG_MANAGER_H #define CONFIG_MANAGER_H
#include <map> #include <map>
#include "../debug/Log.hpp"
#include <unordered_map> #include <unordered_map>
#include "../defines.hpp" #include "../defines.hpp"
#include <vector> #include <vector>
#include <deque> #include <deque>
#include <algorithm>
#include <regex>
#include <optional> #include <optional>
#include <functional>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include "../helpers/WLClasses.hpp" #include "../helpers/WLClasses.hpp"
#include "../helpers/Monitor.hpp" #include "../helpers/Monitor.hpp"
#include "../helpers/varlist/VarList.hpp"
#include "../desktop/Window.hpp" #include "../desktop/Window.hpp"
#include "../desktop/LayerSurface.hpp" #include "../desktop/LayerSurface.hpp"
#include "defaultConfig.hpp"
#include "ConfigDataValues.hpp" #include "ConfigDataValues.hpp"
#include <hyprlang.hpp> #include <hyprlang.hpp>
// Macros for initializing and creating animation configurations
#define INITANIMCFG(name) animationConfig[name] = {} #define INITANIMCFG(name) animationConfig[name] = {}
#define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]} #define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
#define HANDLE void* #define HANDLE void*
/**
* @struct SWorkspaceRule
* @brief Configuration rules for workspaces.
*/
struct SWorkspaceRule { struct SWorkspaceRule {
std::string monitor = ""; std::string monitor = "";
std::string workspaceString = ""; std::string workspaceString = "";
@ -48,6 +47,10 @@ struct SWorkspaceRule {
std::map<std::string, std::string> layoutopts; std::map<std::string, std::string> layoutopts;
}; };
/**
* @struct SMonitorAdditionalReservedArea
* @brief Reserved areas for monitors.
*/
struct SMonitorAdditionalReservedArea { struct SMonitorAdditionalReservedArea {
int top = 0; int top = 0;
int bottom = 0; int bottom = 0;
@ -55,6 +58,10 @@ struct SMonitorAdditionalReservedArea {
int right = 0; int right = 0;
}; };
/**
* @struct SAnimationPropertyConfig
* @brief Configuration for animation properties.
*/
struct SAnimationPropertyConfig { struct SAnimationPropertyConfig {
bool overridden = true; bool overridden = true;
@ -67,22 +74,38 @@ struct SAnimationPropertyConfig {
SAnimationPropertyConfig* pParentAnimation = nullptr; SAnimationPropertyConfig* pParentAnimation = nullptr;
}; };
/**
* @struct SPluginKeyword
* @brief Stores plugin keyword information.
*/
struct SPluginKeyword { struct SPluginKeyword {
HANDLE handle = 0; HANDLE handle = 0;
std::string name = ""; std::string name = "";
Hyprlang::PCONFIGHANDLERFUNC fn = nullptr; Hyprlang::PCONFIGHANDLERFUNC fn = nullptr;
}; };
/**
* @struct SPluginVariable
* @brief Stores plugin variable information.
*/
struct SPluginVariable { struct SPluginVariable {
HANDLE handle = 0; HANDLE handle = 0;
std::string name = ""; std::string name = "";
}; };
/**
* @struct SExecRequestedRule
* @brief Stores rules requested with exec.
*/
struct SExecRequestedRule { struct SExecRequestedRule {
std::string szRule = ""; std::string szRule = "";
uint64_t iPid = 0; uint64_t iPid = 0;
}; };
/**
* @class CConfigManager
* @brief Manages configuration settings.
*/
class CConfigManager { class CConfigManager {
public: public:
CConfigManager(); CConfigManager();
@ -147,7 +170,7 @@ class CConfigManager {
void handlePluginLoads(); void handlePluginLoads();
std::string getErrors(); std::string getErrors();
// keywords // Keywords
std::optional<std::string> handleRawExec(const std::string&, const std::string&); std::optional<std::string> handleRawExec(const std::string&, const std::string&);
std::optional<std::string> handleExecOnce(const std::string&, const std::string&); std::optional<std::string> handleExecOnce(const std::string&, const std::string&);
std::optional<std::string> handleMonitor(const std::string&, const std::string&); std::optional<std::string> handleMonitor(const std::string&, const std::string&);
@ -171,14 +194,14 @@ class CConfigManager {
private: private:
std::unique_ptr<Hyprlang::CConfig> m_pConfig; std::unique_ptr<Hyprlang::CConfig> m_pConfig;
std::deque<std::string> configPaths; // stores all the config paths std::deque<std::string> configPaths; // Stores all the config paths
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times std::unordered_map<std::string, time_t> configModifyTimes; // Stores modify times
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // Stores all the animations with their set values
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
std::vector<SExecRequestedRule> execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty std::vector<SExecRequestedRule> execRequestedRules; // Rules requested with exec, e.g. [workspace 2] kitty
std::vector<std::string> m_vDeclaredPlugins; std::vector<std::string> m_vDeclaredPlugins;
std::vector<SPluginKeyword> pluginKeywords; std::vector<SPluginKeyword> pluginKeywords;
@ -196,10 +219,10 @@ class CConfigManager {
bool m_bManualCrashInitiated = false; bool m_bManualCrashInitiated = false;
std::deque<std::string> firstExecRequests; std::deque<std::string> firstExecRequests;
std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // For plugin values of unloaded plugins
std::string m_szConfigErrors = ""; std::string m_szConfigErrors = "";
// internal methods // Internal methods
void setAnimForChildren(SAnimationPropertyConfig* const); void setAnimForChildren(SAnimationPropertyConfig* const);
void updateBlurredLS(const std::string&, const bool); void updateBlurredLS(const std::string&, const bool);
void setDefaultAnimationVars(); void setDefaultAnimationVars();

View file

@ -3,24 +3,36 @@
#include <string> #include <string>
#include <typeindex> #include <typeindex>
#include <hyprlang.hpp> #include <hyprlang.hpp>
#include "../debug/Log.hpp"
#include "../macros.hpp" #include "../macros.hpp"
#include "ConfigManager.hpp" #include "ConfigManager.hpp"
/**
* @class CConfigValue
* @brief A template class to handle configuration values.
*
* This class provides a type-safe way to access configuration values.
* It supports custom types defined in Hyprlang.
*
* @tparam T Type of the configuration value.
*/
template <typename T> template <typename T>
class CConfigValue { class CConfigValue {
public: public:
/**
* @brief Constructor that initializes the configuration value.
* @param val The key to look up the configuration value.
*/
CConfigValue(const std::string& val) { CConfigValue(const std::string& val) {
const auto PVHYPRLANG = g_pConfigManager->getHyprlangConfigValuePtr(val); const auto PVHYPRLANG = g_pConfigManager->getHyprlangConfigValuePtr(val);
p_ = PVHYPRLANG->getDataStaticPtr(); p_ = PVHYPRLANG->getDataStaticPtr();
#ifdef HYPRLAND_DEBUG #ifdef HYPRLAND_DEBUG
// verify type // Verify type during debug mode
const auto ANY = PVHYPRLANG->getValue(); const auto ANY = PVHYPRLANG->getValue();
const auto TYPE = std::type_index(ANY.type()); const auto TYPE = std::type_index(ANY.type());
// exceptions // Handle specific type exceptions
const bool STRINGEX = (typeid(T) == typeid(std::string) && TYPE == typeid(Hyprlang::STRING)); const bool STRINGEX = (typeid(T) == typeid(std::string) && TYPE == typeid(Hyprlang::STRING));
const bool CUSTOMEX = (typeid(T) == typeid(Hyprlang::CUSTOMTYPE) && (TYPE == typeid(Hyprlang::CUSTOMTYPE*) || TYPE == typeid(void*) /* dunno why it does this? */)); const bool CUSTOMEX = (typeid(T) == typeid(Hyprlang::CUSTOMTYPE) && (TYPE == typeid(Hyprlang::CUSTOMTYPE*) || TYPE == typeid(void*) /* dunno why it does this? */));
@ -28,44 +40,82 @@ class CConfigValue {
#endif #endif
} }
/**
* @brief Returns a pointer to the configuration value.
* @return Pointer to the configuration value.
*/
T* ptr() const { T* ptr() const {
return *(T* const*)p_; return *(T* const*)p_;
} }
/**
* @brief Dereference operator to access the configuration value.
* @return The configuration value.
*/
T operator*() const { T operator*() const {
return *ptr(); return *ptr();
} }
private: private:
void* const* p_ = nullptr; void* const* p_ = nullptr; //< Pointer to the configuration value.
}; };
// Specializations for std::string
/**
* @brief Specialization of ptr() for std::string.
* @return nullptr since this implementation is not supported.
*/
template <> template <>
inline std::string* CConfigValue<std::string>::ptr() const { inline std::string* CConfigValue<std::string>::ptr() const {
RASSERT(false, "Impossible to implement ptr() of CConfigValue<std::string>"); RASSERT(false, "Impossible to implement ptr() of CConfigValue<std::string>");
return nullptr; return nullptr;
} }
/**
* @brief Specialization of operator* for std::string.
* @return The configuration value as std::string.
*/
template <> template <>
inline std::string CConfigValue<std::string>::operator*() const { inline std::string CConfigValue<std::string>::operator*() const {
return std::string{*(Hyprlang::STRING*)p_}; return std::string{*(Hyprlang::STRING*)p_};
} }
// Specializations for Hyprlang::STRING
/**
* @brief Specialization of ptr() for Hyprlang::STRING.
* @return Pointer to the Hyprlang::STRING configuration value.
*/
template <> template <>
inline Hyprlang::STRING* CConfigValue<Hyprlang::STRING>::ptr() const { inline Hyprlang::STRING* CConfigValue<Hyprlang::STRING>::ptr() const {
return (Hyprlang::STRING*)p_; return (Hyprlang::STRING*)p_;
} }
/**
* @brief Specialization of operator* for Hyprlang::STRING.
* @return The Hyprlang::STRING configuration value.
*/
template <> template <>
inline Hyprlang::STRING CConfigValue<Hyprlang::STRING>::operator*() const { inline Hyprlang::STRING CConfigValue<Hyprlang::STRING>::operator*() const {
return *(Hyprlang::STRING*)p_; return *(Hyprlang::STRING*)p_;
} }
// Specializations for Hyprlang::CUSTOMTYPE
/**
* @brief Specialization of ptr() for Hyprlang::CUSTOMTYPE.
* @return Pointer to the Hyprlang::CUSTOMTYPE configuration value.
*/
template <> template <>
inline Hyprlang::CUSTOMTYPE* CConfigValue<Hyprlang::CUSTOMTYPE>::ptr() const { inline Hyprlang::CUSTOMTYPE* CConfigValue<Hyprlang::CUSTOMTYPE>::ptr() const {
return *(Hyprlang::CUSTOMTYPE* const*)p_; return *(Hyprlang::CUSTOMTYPE* const*)p_;
} }
/**
* @brief Specialization of operator* for Hyprlang::CUSTOMTYPE.
* @return The Hyprlang::CUSTOMTYPE configuration value.
*/
template <> template <>
inline Hyprlang::CUSTOMTYPE CConfigValue<Hyprlang::CUSTOMTYPE>::operator*() const { inline Hyprlang::CUSTOMTYPE CConfigValue<Hyprlang::CUSTOMTYPE>::operator*() const {
RASSERT(false, "Impossible to implement operator* of CConfigValue<Hyprlang::CUSTOMTYPE>, use ptr()"); RASSERT(false, "Impossible to implement operator* of CConfigValue<Hyprlang::CUSTOMTYPE>, use ptr()");

View file

@ -1,6 +1,5 @@
#include "LayerSurface.hpp" #include "LayerSurface.hpp"
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "../events/Events.hpp"
#include "../protocols/LayerShell.hpp" #include "../protocols/LayerShell.hpp"
#include "../protocols/core/Compositor.hpp" #include "../protocols/core/Compositor.hpp"
#include "../managers/SeatManager.hpp" #include "../managers/SeatManager.hpp"
@ -367,12 +366,12 @@ void CLayerSurface::applyRules() {
} else if (rule.rule == "dimaround") { } else if (rule.rule == "dimaround") {
dimAround = true; dimAround = true;
} else if (rule.rule.starts_with("xray")) { } else if (rule.rule.starts_with("xray")) {
CVarList vars{rule.rule, 0, ' '}; Hyprutils::String::CVarList vars{rule.rule, 0, ' '};
try { try {
xray = configStringToInt(vars[1]); xray = configStringToInt(vars[1]);
} catch (...) {} } catch (...) {}
} else if (rule.rule.starts_with("animation")) { } else if (rule.rule.starts_with("animation")) {
CVarList vars{rule.rule, 2, 's'}; Hyprutils::String::CVarList vars{rule.rule, 2, 's'};
animationStyle = vars[1]; animationStyle = vars[1];
} }
} }
@ -398,7 +397,7 @@ void CLayerSurface::startAnimation(bool in, bool instant) {
int force = -1; int force = -1;
CVarList args(ANIMSTYLE, 0, 's'); Hyprutils::String::CVarList args(ANIMSTYLE, 0, 's');
if (args.size() > 1) { if (args.size() > 1) {
const auto ARG2 = args[1]; const auto ARG2 = args[1];
if (ARG2 == "top") if (ARG2 == "top")

View file

@ -1019,7 +1019,7 @@ void CHyprDwindleLayout::alterSplitRatio(PHLWINDOW pWindow, float ratio, bool ex
} }
std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::string message) { std::any CHyprDwindleLayout::layoutMessage(SLayoutMessageHeader header, std::string message) {
const auto ARGS = CVarList(message, 0, ' '); const auto ARGS = Hyprutils::String::CVarList(message, 0, ' ');
if (ARGS[0] == "togglesplit") { if (ARGS[0] == "togglesplit") {
toggleSplit(header.pWindow); toggleSplit(header.pWindow);
} else if (ARGS[0] == "swapsplit") { } else if (ARGS[0] == "swapsplit") {

View file

@ -1096,7 +1096,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
g_pInputManager->m_pForcedFocus.reset(); g_pInputManager->m_pForcedFocus.reset();
}; };
CVarList vars(message, 0, ' '); Hyprutils::String::CVarList vars(message, 0, ' ');
if (vars.size() < 1 || vars[0].empty()) { if (vars.size() < 1 || vars[0].empty()) {
Debug::log(ERR, "layoutmsg called without params"); Debug::log(ERR, "layoutmsg called without params");
@ -1376,7 +1376,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
} }
// If vars is null, we use the default list // If vars is null, we use the default list
void CHyprMasterLayout::runOrientationCycle(SLayoutMessageHeader& header, CVarList* vars, int direction) { void CHyprMasterLayout::runOrientationCycle(SLayoutMessageHeader& header, Hyprutils::String::CVarList* vars, int direction) {
std::vector<eOrientation> cycle; std::vector<eOrientation> cycle;
if (vars != nullptr) if (vars != nullptr)
buildOrientationCycleVectorFromVars(cycle, *vars); buildOrientationCycleVectorFromVars(cycle, *vars);
@ -1416,7 +1416,7 @@ void CHyprMasterLayout::buildOrientationCycleVectorFromEOperation(std::vector<eO
} }
} }
void CHyprMasterLayout::buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, CVarList& vars) { void CHyprMasterLayout::buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, Hyprutils::String::CVarList& vars) {
for (size_t i = 1; i < vars.size(); ++i) { for (size_t i = 1; i < vars.size(); ++i) {
if (vars[i] == "top") { if (vars[i] == "top") {
cycle.push_back(ORIENTATION_TOP); cycle.push_back(ORIENTATION_TOP);

View file

@ -2,10 +2,8 @@
#include "IHyprLayout.hpp" #include "IHyprLayout.hpp"
#include "../desktop/DesktopTypes.hpp" #include "../desktop/DesktopTypes.hpp"
#include "../config/ConfigManager.hpp"
#include <vector> #include <vector>
#include <list> #include <list>
#include <deque>
#include <any> #include <any>
enum eFullscreenMode : int8_t; enum eFullscreenMode : int8_t;
@ -77,9 +75,9 @@ class CHyprMasterLayout : public IHyprLayout {
bool m_bForceWarps = false; bool m_bForceWarps = false;
void buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, CVarList& vars); void buildOrientationCycleVectorFromVars(std::vector<eOrientation>& cycle, Hyprutils::String::CVarList& vars);
void buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle); void buildOrientationCycleVectorFromEOperation(std::vector<eOrientation>& cycle);
void runOrientationCycle(SLayoutMessageHeader& header, CVarList* vars, int next); void runOrientationCycle(SLayoutMessageHeader& header, Hyprutils::String::CVarList* vars, int next);
eOrientation getDynamicOrientation(PHLWORKSPACE); eOrientation getDynamicOrientation(PHLWORKSPACE);
int getNodesOnWorkspace(const int&); int getNodesOnWorkspace(const int&);
void applyNodeDataToWindow(SMasterNodeData*); void applyNodeDataToWindow(SMasterNodeData*);

View file

@ -861,7 +861,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
keeb.get()); keeb.get());
keeb->keyboardEvents.keymap.registerStaticListener( keeb->keyboardEvents.keymap.registerStaticListener(
[this](void* owner, std::any data) { [](void* owner, std::any data) {
auto PKEEB = ((IKeyboard*)owner)->self.lock(); auto PKEEB = ((IKeyboard*)owner)->self.lock();
const auto LAYOUT = PKEEB->getActiveLayout(); const auto LAYOUT = PKEEB->getActiveLayout();
@ -1173,7 +1173,7 @@ void CInputManager::setPointerConfigs() {
} else if (ACCELPROFILE == "flat") { } else if (ACCELPROFILE == "flat") {
libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT); libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT);
} else if (ACCELPROFILE.starts_with("custom")) { } else if (ACCELPROFILE.starts_with("custom")) {
CVarList accelValues = {ACCELPROFILE, 0, ' '}; Hyprutils::String::CVarList accelValues = {ACCELPROFILE, 0, ' '};
try { try {
double accelStep = std::stod(accelValues[1]); double accelStep = std::stod(accelValues[1]);
@ -1185,7 +1185,7 @@ void CInputManager::setPointerConfigs() {
const auto CONFIG = libinput_config_accel_create(LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM); const auto CONFIG = libinput_config_accel_create(LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM);
if (!SCROLLPOINTS.empty()) { if (!SCROLLPOINTS.empty()) {
CVarList scrollValues = {SCROLLPOINTS, 0, ' '}; Hyprutils::String::CVarList scrollValues = {SCROLLPOINTS, 0, ' '};
try { try {
double scrollStep = std::stod(scrollValues[0]); double scrollStep = std::stod(scrollValues[0]);
std::vector<double> scrollPoints; std::vector<double> scrollPoints;
@ -1624,8 +1624,7 @@ void CInputManager::newSwitch(wlr_input_device* pDevice) {
Debug::log(LOG, "New switch with name \"{}\" added", pDevice->name); Debug::log(LOG, "New switch with name \"{}\" added", pDevice->name);
PNEWDEV->hyprListener_destroy.initCallback( PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) { destroySwitch((SSwitchDevice*)owner); }, PNEWDEV, "SwitchDevice");
&pDevice->events.destroy, [&](void* owner, void* data) { destroySwitch((SSwitchDevice*)owner); }, PNEWDEV, "SwitchDevice");
const auto PSWITCH = wlr_switch_from_input_device(pDevice); const auto PSWITCH = wlr_switch_from_input_device(pDevice);