From 0b525cdc63b6dbed55d3a618664e059055c3938d Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 20:09:42 +0200 Subject: default to multisample on --- src/config/ConfigManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index fb3aae1f..b9e6f48a 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -47,7 +47,7 @@ void CConfigManager::setDefaultVars() { configValues["decoration:active_opacity"].floatValue = 1; configValues["decoration:inactive_opacity"].floatValue = 1; configValues["decoration:fullscreen_opacity"].floatValue = 1; - configValues["decoration:multisample_edges"].intValue = 0; + configValues["decoration:multisample_edges"].intValue = 1; configValues["decoration:no_blur_on_oversized"].intValue = 1; configValues["decoration:drop_shadow"].intValue = 1; configValues["decoration:shadow_range"].intValue = 4; -- cgit v1.2.3 From 44aeb1fc909ec9cb3e6b82a5397e9eec8839192b Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 22:15:06 +0200 Subject: added decoration:shadow_offset --- src/config/ConfigManager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index b9e6f48a..35cf64e0 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -53,6 +53,7 @@ void CConfigManager::setDefaultVars() { configValues["decoration:shadow_range"].intValue = 4; configValues["decoration:shadow_render_power"].intValue = 3; configValues["decoration:shadow_ignore_window"].intValue = 1; + configValues["decoration:shadow_offset"].strValue = "0 0"; configValues["decoration:col.shadow"].intValue = 0xee1a1a1a; configValues["dwindle:pseudotile"].intValue = 0; -- cgit v1.2.3 From 3263e48675107632b1a6547163153633a9cbfbf7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sun, 26 Jun 2022 22:47:13 +0200 Subject: rerender monitors on config reload --- src/config/ConfigManager.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 35cf64e0..f8f49ed6 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -807,6 +807,10 @@ void CConfigManager::loadConfigLoadVars() { // Update window border colors g_pCompositor->updateAllWindowsBorders(); + + // Force the compositor to fully re-render all monitors + for (auto& m : g_pCompositor->m_lMonitors) + m.forceFullFrames = 2; } void CConfigManager::tick() { -- cgit v1.2.3 From 37abe0aedc7373fadc638d87f4700bae606cd998 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 29 Jun 2022 11:44:00 +0200 Subject: added debug:damage_blink --- src/config/ConfigManager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index f8f49ed6..c52a04bf 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -38,6 +38,7 @@ void CConfigManager::setDefaultVars() { configValues["debug:int"].intValue = 0; configValues["debug:log_damage"].intValue = 0; configValues["debug:overlay"].intValue = 0; + configValues["debug:damage_blink"].intValue = 0; configValues["decoration:rounding"].intValue = 1; configValues["decoration:blur"].intValue = 1; -- cgit v1.2.3 From 328b3fa4bc4f3776f2128f84709556569c4824d9 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:44:26 +0200 Subject: mordernize pointers --- src/config/ConfigManager.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index c52a04bf..75546a63 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -613,8 +613,8 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: parseError = ""; // invalidate layouts jic - for (auto& m : g_pCompositor->m_lMonitors) - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); + for (auto& m : g_pCompositor->m_vMonitors) + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); // Update window border colors g_pCompositor->updateAllWindowsBorders(); @@ -774,8 +774,8 @@ void CConfigManager::loadConfigLoadVars() { ifs.close(); } - for (auto& m : g_pCompositor->m_lMonitors) - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m.ID); + for (auto& m : g_pCompositor->m_vMonitors) + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); // Update the keyboard layout to the cfg'd one if this is not the first launch if (!isFirstLaunch) @@ -810,8 +810,8 @@ void CConfigManager::loadConfigLoadVars() { g_pCompositor->updateAllWindowsBorders(); // Force the compositor to fully re-render all monitors - for (auto& m : g_pCompositor->m_lMonitors) - m.forceFullFrames = 2; + for (auto& m : g_pCompositor->m_vMonitors) + m->forceFullFrames = 2; } void CConfigManager::tick() { @@ -970,9 +970,9 @@ void CConfigManager::dispatchExecOnce() { } void CConfigManager::performMonitorReload() { - for (auto& m : g_pCompositor->m_lMonitors) { - auto rule = getMonitorRuleFor(m.szName); - g_pHyprRenderer->applyMonitorRule(&m, &rule); + for (auto& m : g_pCompositor->m_vMonitors) { + auto rule = getMonitorRuleFor(m->szName); + g_pHyprRenderer->applyMonitorRule(m.get(), &rule); } m_bWantsMonitorReload = false; -- cgit v1.2.3 From d010ca20492c7638d15690e888d80c6020685df1 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:26:00 +0200 Subject: added per-device config options --- src/config/ConfigManager.cpp | 106 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 13 deletions(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 75546a63..d76a1800 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -105,6 +105,24 @@ void CConfigManager::setDefaultVars() { configValues["autogenerated"].intValue = 0; } +void CConfigManager::setDeviceDefaultVars(const std::string& dev) { + auto& cfgValues = deviceConfigs[dev]; + + cfgValues["kb_layout"].strValue = "us"; + cfgValues["kb_variant"].strValue = STRVAL_EMPTY; + cfgValues["kb_options"].strValue = STRVAL_EMPTY; + cfgValues["kb_rules"].strValue = STRVAL_EMPTY; + cfgValues["kb_model"].strValue = STRVAL_EMPTY; + cfgValues["repeat_rate"].intValue = 25; + cfgValues["repeat_delay"].intValue = 600; + cfgValues["natural_scroll"].intValue = 0; + cfgValues["numlock_by_default"].intValue = 0; + cfgValues["disable_while_typing"].intValue = 1; + cfgValues["clickfinger_behavior"].intValue = 0; + cfgValues["middle_button_emulation"].intValue = 0; + cfgValues["tap-to-click"].intValue = 1; +} + void CConfigManager::init() { loadConfigLoadVars(); @@ -134,33 +152,56 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field."; } - return; + if (COMMAND.find("device:") == 0 /* devices parsed later */) { + parseError = ""; + } else { + return; + } } + SConfigValue* CONFIGENTRY = nullptr; + + if (COMMAND.find("device:") == 0) { + const auto DEVICE = COMMAND.substr(7).substr(0, COMMAND.find_last_of(':') - 7); + const auto CONFIGVAR = COMMAND.substr(COMMAND.find_last_of(':') + 1); + + if (!deviceConfigExists(DEVICE)) + setDeviceDefaultVars(DEVICE); + + auto it = deviceConfigs.find(DEVICE); + + if (it->second.find(CONFIGVAR) == it->second.end()) { + parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">: No such field."; + return; + } + + CONFIGENTRY = &it->second.at(CONFIGVAR); + } else { + CONFIGENTRY = &configValues.at(COMMAND); + } - auto& CONFIGENTRY = configValues.at(COMMAND); - if (CONFIGENTRY.intValue != -1) { + if (CONFIGENTRY->intValue != -1) { try { if (VALUE.find("0x") == 0) { // Values with 0x are hex const auto VALUEWITHOUTHEX = VALUE.substr(2); - CONFIGENTRY.intValue = stol(VALUEWITHOUTHEX, nullptr, 16); + CONFIGENTRY->intValue = stol(VALUEWITHOUTHEX, nullptr, 16); } else - CONFIGENTRY.intValue = stol(VALUE); + CONFIGENTRY->intValue = stol(VALUE); } catch (...) { Debug::log(WARN, "Error reading value of %s", COMMAND.c_str()); parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">."; } - } else if (CONFIGENTRY.floatValue != -1) { + } else if (CONFIGENTRY->floatValue != -1) { try { - CONFIGENTRY.floatValue = stof(VALUE); + CONFIGENTRY->floatValue = stof(VALUE); } catch (...) { Debug::log(WARN, "Error reading value of %s", COMMAND.c_str()); parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">."; } - } else if (CONFIGENTRY.strValue != "") { + } else if (CONFIGENTRY->strValue != "") { try { - CONFIGENTRY.strValue = VALUE; + CONFIGENTRY->strValue = VALUE; } catch (...) { Debug::log(WARN, "Error reading value of %s", COMMAND.c_str()); parseError = "Error setting value <" + VALUE + "> for field <" + COMMAND + ">."; @@ -706,6 +747,7 @@ void CConfigManager::loadConfigLoadVars() { g_pAnimationManager->removeAllBeziers(); m_mAdditionalReservedAreas.clear(); configDynamicVars.clear(); + deviceConfigs.clear(); // paths configPaths.clear(); @@ -849,7 +891,7 @@ void CConfigManager::tick() { } std::mutex configmtx; -SConfigValue CConfigManager::getConfigValueSafe(std::string val) { +SConfigValue CConfigManager::getConfigValueSafe(const std::string& val) { std::lock_guard lg(configmtx); SConfigValue copy = configValues[val]; @@ -857,15 +899,29 @@ SConfigValue CConfigManager::getConfigValueSafe(std::string val) { return copy; } -int CConfigManager::getInt(std::string v) { +SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, const std::string& val) { + std::lock_guard lg(configmtx); + + const auto it = deviceConfigs.find(dev); + + if (it == deviceConfigs.end()) { + return SConfigValue(); + } + + SConfigValue copy = it->second[val]; + + return copy; +} + +int CConfigManager::getInt(const std::string& v) { return getConfigValueSafe(v).intValue; } -float CConfigManager::getFloat(std::string v) { +float CConfigManager::getFloat(const std::string& v) { return getConfigValueSafe(v).floatValue; } -std::string CConfigManager::getString(std::string v) { +std::string CConfigManager::getString(const std::string& v) { const auto VAL = getConfigValueSafe(v).strValue; if (VAL == STRVAL_EMPTY) @@ -874,6 +930,23 @@ std::string CConfigManager::getString(std::string v) { return VAL; } +int CConfigManager::getDeviceInt(const std::string& dev, const std::string& v) { + return getConfigValueSafeDevice(dev, v).intValue; +} + +float CConfigManager::getDeviceFloat(const std::string& dev, const std::string& v) { + return getConfigValueSafeDevice(dev, v).floatValue; +} + +std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v) { + const auto VAL = getConfigValueSafeDevice(dev, v).strValue; + + if (VAL == STRVAL_EMPTY) + return ""; + + return VAL; +} + void CConfigManager::setInt(std::string v, int val) { configValues[v].intValue = val; } @@ -981,3 +1054,10 @@ void CConfigManager::performMonitorReload() { SConfigValue* CConfigManager::getConfigValuePtr(std::string val) { return &configValues[val]; } + +bool CConfigManager::deviceConfigExists(const std::string& dev) { + const auto it = deviceConfigs.find(dev); + + return it != deviceConfigs.end(); +} + -- cgit v1.2.3 From 92890d492a2dea43837591de79ffec828b50d6e2 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:38:06 +0200 Subject: fallback on unset device config var --- src/config/ConfigManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index d76a1800..215d71c0 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -180,6 +180,8 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s CONFIGENTRY = &configValues.at(COMMAND); } + CONFIGENTRY->set = true; + if (CONFIGENTRY->intValue != -1) { try { if (VALUE.find("0x") == 0) { @@ -910,6 +912,15 @@ SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, co SConfigValue copy = it->second[val]; + // fallback if not set explicitly + if (!copy.set) { + for (auto& cv : configValues) { + if (cv.first.find(val) == cv.first.length() - val.length()) { + copy = cv.second; + } + } + } + return copy; } -- cgit v1.2.3 From 91d68513de5b182103393ee4abd3eb37db905bee Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 30 Jun 2022 23:55:28 +0200 Subject: fix possible segfault by realloc --- src/config/ConfigManager.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 215d71c0..26503f7e 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1054,11 +1054,20 @@ void CConfigManager::dispatchExecOnce() { } void CConfigManager::performMonitorReload() { + + bool overAgain = false; + for (auto& m : g_pCompositor->m_vMonitors) { auto rule = getMonitorRuleFor(m->szName); - g_pHyprRenderer->applyMonitorRule(m.get(), &rule); + if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule)) { + overAgain = true; + break; + } } + if (overAgain) + performMonitorReload(); + m_bWantsMonitorReload = false; } -- cgit v1.2.3 From 868e0f48d023714a205acf071594983d22d1478c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 1 Jul 2022 15:57:56 +0200 Subject: added debug:disable_logs --- src/config/ConfigManager.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/config/ConfigManager.cpp') diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 26503f7e..f313b155 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -15,6 +15,8 @@ CConfigManager::CConfigManager() { static const char* const ENVHOME = getenv("HOME"); const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf"); configPaths.emplace_back(CONFIGPATH); + + Debug::disableLogs = &configValues["debug:disable_logs"].intValue; } void CConfigManager::setDefaultVars() { @@ -39,6 +41,7 @@ void CConfigManager::setDefaultVars() { configValues["debug:log_damage"].intValue = 0; configValues["debug:overlay"].intValue = 0; configValues["debug:damage_blink"].intValue = 0; + configValues["debug:disable_logs"].intValue = 0; configValues["decoration:rounding"].intValue = 1; configValues["decoration:blur"].intValue = 1; -- cgit v1.2.3