aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/config
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-12-03 18:58:24 +0000
committerGitHub <[email protected]>2024-12-03 18:58:24 +0000
commit320144ae7288fe23686935ebb235d9fe0c900862 (patch)
tree351b04e228926f98c12c340284c25450bb1fed4f /src/config
parent92186898c0ca1b3f72922b72c4af1723f0d9b888 (diff)
downloadHyprland-320144ae7288fe23686935ebb235d9fe0c900862.tar.gz
Hyprland-320144ae7288fe23686935ebb235d9fe0c900862.zip
core: move colorspace handling to oklab (#8635)
* Meson: add hyprgraphics * Nix: add hyprgraphics * CI/setup_base: get hyprgraphics-git --------- Co-authored-by: Mihai Fufezan <[email protected]>
Diffstat (limited to 'src/config')
-rw-r--r--src/config/ConfigDataValues.hpp22
-rw-r--r--src/config/ConfigManager.cpp23
-rw-r--r--src/config/ConfigManager.hpp2
3 files changed, 33 insertions, 14 deletions
diff --git a/src/config/ConfigDataValues.hpp b/src/config/ConfigDataValues.hpp
index 37c9fc92..212f26fa 100644
--- a/src/config/ConfigDataValues.hpp
+++ b/src/config/ConfigDataValues.hpp
@@ -21,8 +21,9 @@ class ICustomConfigValueData {
class CGradientValueData : public ICustomConfigValueData {
public:
CGradientValueData() {};
- CGradientValueData(CColor col) {
+ CGradientValueData(CHyprColor col) {
m_vColors.push_back(col);
+ updateColorsOk();
};
virtual ~CGradientValueData() {};
@@ -30,14 +31,29 @@ class CGradientValueData : public ICustomConfigValueData {
return CVD_TYPE_GRADIENT;
}
- void reset(CColor col) {
+ void reset(CHyprColor col) {
m_vColors.clear();
m_vColors.emplace_back(col);
m_fAngle = 0;
+ updateColorsOk();
+ }
+
+ void updateColorsOk() {
+ m_vColorsOkLabA.clear();
+ for (auto& c : m_vColors) {
+ const auto OKLAB = c.asOkLab();
+ m_vColorsOkLabA.emplace_back(OKLAB.l);
+ m_vColorsOkLabA.emplace_back(OKLAB.a);
+ m_vColorsOkLabA.emplace_back(OKLAB.b);
+ m_vColorsOkLabA.emplace_back(c.a);
+ }
}
/* Vector containing the colors */
- std::vector<CColor> m_vColors;
+ std::vector<CHyprColor> m_vColors;
+
+ /* Vector containing pure colors for shoving into opengl */
+ std::vector<float> m_vColorsOkLabA;
/* Float corresponding to the angle (rad) */
float m_fAngle = 0;
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 07de8c24..820844eb 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -70,7 +70,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
const auto COL = configStringToInt(var);
if (!COL)
throw std::runtime_error(std::format("failed to parse {} as a color", var));
- DATA->m_vColors.push_back(CColor(COL.value()));
+ DATA->m_vColors.push_back(CHyprColor(COL.value()));
} catch (std::exception& e) {
Debug::log(WARN, "Error parsing gradient {}", V);
parseError = "Error parsing gradient " + V + ": " + e.what();
@@ -85,6 +85,8 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void**
DATA->m_vColors.push_back(0); // transparent
}
+ DATA->updateColorsOk();
+
Hyprlang::CParseResult result;
if (!parseError.empty())
result.setError(parseError.c_str());
@@ -676,7 +678,7 @@ CConfigManager::CConfigManager() {
Debug::disableTime = reinterpret_cast<int64_t* const*>(m_pConfig->getConfigValuePtr("debug:disable_time")->getDataStaticPtr());
if (ERR.has_value())
- g_pHyprError->queueCreate(ERR.value(), CColor{1.0, 0.1, 0.1, 1.0});
+ g_pHyprError->queueCreate(ERR.value(), CHyprColor{1.0, 0.1, 0.1, 1.0});
}
std::optional<std::string> CConfigManager::generateConfig(std::string configPath) {
@@ -883,14 +885,14 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
m_szConfigErrors = "";
if (result.error && !std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:suppress_errors")))
- g_pHyprError->queueCreate(result.getError(), CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
+ g_pHyprError->queueCreate(result.getError(), CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
else if (std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("autogenerated")) == 1)
g_pHyprError->queueCreate(
"Warning: You're using an autogenerated config! (config file: " + getMainConfigPath() +
" )\nSUPER+Q -> kitty (if it doesn't launch, make sure it's installed or choose a different terminal in the config)\nSUPER+M -> exit Hyprland",
- CColor(1.0, 1.0, 70.0 / 255.0, 1.0));
+ CHyprColor(1.0, 1.0, 70.0 / 255.0, 1.0));
else if (*PENABLEEXPLICIT != prevEnabledExplicit)
- g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CColor(0.9, 0.76, 0.221, 1.0));
+ g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CHyprColor(0.9, 0.76, 0.221, 1.0));
else
g_pHyprError->destroy();
@@ -948,7 +950,8 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
// manual crash
if (std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash")) && !m_bManualCrashInitiated) {
m_bManualCrashInitiated = true;
- g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CColor(0), 5000, ICON_INFO);
+ g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CHyprColor(0), 5000,
+ ICON_INFO);
} else if (m_bManualCrashInitiated && !std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash"))) {
// cowabunga it is
g_pHyprRenderer->initiateManualCrash();
@@ -1015,7 +1018,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
if (COMMAND.contains("explicit")) {
if (*PENABLEEXPLICIT != prevEnabledExplicit)
- g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CColor(0.9, 0.76, 0.221, 1.0));
+ g_pHyprError->queueCreate("Warning: You changed the render:explicit_sync option, this requires you to restart Hyprland.", CHyprColor(0.9, 0.76, 0.221, 1.0));
else
g_pHyprError->destroy();
}
@@ -1027,7 +1030,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
if (std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash")) && !m_bManualCrashInitiated) {
m_bManualCrashInitiated = true;
if (g_pHyprNotificationOverlay) {
- g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CColor(0), 5000,
+ g_pHyprNotificationOverlay->addNotification("Manual crash has been set up. Set debug:manual_crash back to 0 in order to crash the compositor.", CHyprColor(0), 5000,
ICON_INFO);
}
} else if (m_bManualCrashInitiated && !std::any_cast<Hyprlang::INT>(m_pConfig->getConfigValue("debug:manual_crash"))) {
@@ -1671,7 +1674,7 @@ SAnimationPropertyConfig* CConfigManager::getAnimationPropertyConfig(const std::
}
void CConfigManager::addParseError(const std::string& err) {
- g_pHyprError->queueCreate(err + "\nHyprland may not work correctly.", CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
+ g_pHyprError->queueCreate(err + "\nHyprland may not work correctly.", CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
}
PHLMONITOR CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
@@ -1716,7 +1719,7 @@ void CConfigManager::handlePluginLoads() {
error << "\n" << path;
}
- g_pHyprError->queueCreate(error.str(), CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
+ g_pHyprError->queueCreate(error.str(), CHyprColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
}
if (pluginsChanged) {
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index 88b74b6e..a3b86e69 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -119,7 +119,7 @@ struct SConfigOptionDescription {
};
struct SColorData {
- CColor color;
+ CHyprColor color;
};
struct SChoiceData {