mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-06 15:11:57 -07:00
feat: Add css style gaps (#4723)
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include "../managers/KeybindManager.hpp"
|
||||
|
||||
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
|
||||
#include "config/ConfigDataValues.hpp"
|
||||
#include "helpers/VarList.hpp"
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
@@ -76,6 +78,31 @@ static void configHandleGradientDestroy(void** data) {
|
||||
delete reinterpret_cast<CGradientValueData*>(*data);
|
||||
}
|
||||
|
||||
static Hyprlang::CParseResult configHandleGapSet(const char* VALUE, void** data) {
|
||||
std::string V = VALUE;
|
||||
|
||||
if (!*data)
|
||||
*data = new CCssGapData();
|
||||
|
||||
const auto DATA = reinterpret_cast<CCssGapData*>(*data);
|
||||
CVarList varlist(V);
|
||||
Hyprlang::CParseResult result;
|
||||
|
||||
try {
|
||||
DATA->parseGapData(varlist);
|
||||
} catch (...) {
|
||||
std::string parseError = "Error parsing gaps " + V;
|
||||
result.setError(parseError.c_str());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void configHandleGapDestroy(void** data) {
|
||||
if (*data)
|
||||
delete reinterpret_cast<CCssGapData*>(*data);
|
||||
}
|
||||
|
||||
static Hyprlang::CParseResult handleRawExec(const char* c, const char* v) {
|
||||
const std::string VALUE = v;
|
||||
const std::string COMMAND = c;
|
||||
@@ -279,8 +306,8 @@ CConfigManager::CConfigManager() {
|
||||
m_pConfig->addConfigValue("general:border_size", {1L});
|
||||
m_pConfig->addConfigValue("general:no_border_on_floating", {0L});
|
||||
m_pConfig->addConfigValue("general:border_part_of_window", {1L});
|
||||
m_pConfig->addConfigValue("general:gaps_in", {5L});
|
||||
m_pConfig->addConfigValue("general:gaps_out", {20L});
|
||||
m_pConfig->addConfigValue("general:gaps_in", Hyprlang::CConfigCustomValueType{configHandleGapSet, configHandleGapDestroy, "5"});
|
||||
m_pConfig->addConfigValue("general:gaps_out", Hyprlang::CConfigCustomValueType{configHandleGapSet, configHandleGapDestroy, "20"});
|
||||
m_pConfig->addConfigValue("general:gaps_workspaces", {0L});
|
||||
m_pConfig->addConfigValue("general:cursor_inactive_timeout", {0L});
|
||||
m_pConfig->addConfigValue("general:no_cursor_warps", {0L});
|
||||
@@ -2116,12 +2143,22 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin
|
||||
|
||||
auto assignRule = [&](std::string rule) -> std::optional<std::string> {
|
||||
size_t delim = std::string::npos;
|
||||
if ((delim = rule.find("gapsin:")) != std::string::npos)
|
||||
wsRule.gapsIn = std::stoi(rule.substr(delim + 7));
|
||||
else if ((delim = rule.find("gapsout:")) != std::string::npos)
|
||||
wsRule.gapsOut = std::stoi(rule.substr(delim + 8));
|
||||
else if ((delim = rule.find("bordersize:")) != std::string::npos)
|
||||
wsRule.borderSize = std::stoi(rule.substr(delim + 11));
|
||||
if ((delim = rule.find("gapsin:")) != std::string::npos) {
|
||||
CVarList varlist = CVarList(rule.substr(delim + 7), 0, ' ');
|
||||
wsRule.gapsIn = CCssGapData();
|
||||
try {
|
||||
wsRule.gapsIn->parseGapData(varlist);
|
||||
} catch (...) { return "Error parsing workspace rule gaps: {}", rule.substr(delim + 7); }
|
||||
} else if ((delim = rule.find("gapsout:")) != std::string::npos) {
|
||||
CVarList varlist = CVarList(rule.substr(delim + 8), 0, ' ');
|
||||
wsRule.gapsOut = CCssGapData();
|
||||
try {
|
||||
wsRule.gapsOut->parseGapData(varlist);
|
||||
} catch (...) { return "Error parsing workspace rule gaps: {}", rule.substr(delim + 8); }
|
||||
} else if ((delim = rule.find("bordersize:")) != std::string::npos)
|
||||
try {
|
||||
wsRule.borderSize = std::stoi(rule.substr(delim + 11));
|
||||
} catch (...) { return "Error parsing workspace rule bordersize: {}", rule.substr(delim + 11); }
|
||||
else if ((delim = rule.find("border:")) != std::string::npos)
|
||||
wsRule.border = configStringToInt(rule.substr(delim + 7));
|
||||
else if ((delim = rule.find("shadow:")) != std::string::npos)
|
||||
@@ -2264,4 +2301,4 @@ std::optional<std::string> CConfigManager::handlePlugin(const std::string& comma
|
||||
m_vDeclaredPlugins.push_back(path);
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user