layout/scroll: fix configuredWidths not setting properly on new workspaces (#13476)
This commit is contained in:
parent
5c370c3333
commit
743dffd638
1 changed files with 18 additions and 11 deletions
|
|
@ -466,6 +466,21 @@ CScrollingAlgorithm::CScrollingAlgorithm() {
|
||||||
m_scrollingData = makeShared<SScrollingData>(this);
|
m_scrollingData = makeShared<SScrollingData>(this);
|
||||||
m_scrollingData->self = m_scrollingData;
|
m_scrollingData->self = m_scrollingData;
|
||||||
|
|
||||||
|
// Helper to parse explicit_column_widths string
|
||||||
|
auto parseColumnWidths = [](const std::string& dir) -> std::vector<float> {
|
||||||
|
auto widthVec = std::vector<float>();
|
||||||
|
|
||||||
|
CConstVarList widths(dir, 0, ',');
|
||||||
|
for (auto& w : widths) {
|
||||||
|
try {
|
||||||
|
widthVec.emplace_back(std::clamp(std::stof(std::string{w}), MIN_COLUMN_WIDTH, MAX_COLUMN_WIDTH));
|
||||||
|
} catch (...) { Log::logger->log(Log::ERR, "scrolling: Failed to parse width {} as float", w); }
|
||||||
|
}
|
||||||
|
if (widthVec.empty())
|
||||||
|
widthVec = {0.333, 0.5, 0.667, 1.0}; // default
|
||||||
|
return widthVec;
|
||||||
|
};
|
||||||
|
|
||||||
// Helper to parse direction string
|
// Helper to parse direction string
|
||||||
auto parseDirection = [](const std::string& dir) -> eScrollDirection {
|
auto parseDirection = [](const std::string& dir) -> eScrollDirection {
|
||||||
if (dir == "left")
|
if (dir == "left")
|
||||||
|
|
@ -478,19 +493,11 @@ CScrollingAlgorithm::CScrollingAlgorithm() {
|
||||||
return SCROLL_DIR_RIGHT; // default
|
return SCROLL_DIR_RIGHT; // default
|
||||||
};
|
};
|
||||||
|
|
||||||
m_configCallback = Event::bus()->m_events.config.reloaded.listen([this, parseDirection] {
|
m_configCallback = Event::bus()->m_events.config.reloaded.listen([this, parseColumnWidths, parseDirection] {
|
||||||
static const auto PCONFDIRECTION = CConfigValue<Hyprlang::STRING>("scrolling:direction");
|
static const auto PCONFDIRECTION = CConfigValue<Hyprlang::STRING>("scrolling:direction");
|
||||||
|
|
||||||
m_config.configuredWidths.clear();
|
m_config.configuredWidths.clear();
|
||||||
|
m_config.configuredWidths = parseColumnWidths(*PCONFWIDTHS);
|
||||||
CConstVarList widths(*PCONFWIDTHS, 0, ',');
|
|
||||||
for (auto& w : widths) {
|
|
||||||
try {
|
|
||||||
m_config.configuredWidths.emplace_back(std::clamp(std::stof(std::string{w}), MIN_COLUMN_WIDTH, MAX_COLUMN_WIDTH));
|
|
||||||
} catch (...) { Log::logger->log(Log::ERR, "scrolling: Failed to parse width {} as float", w); }
|
|
||||||
}
|
|
||||||
if (m_config.configuredWidths.empty())
|
|
||||||
m_config.configuredWidths = {0.333, 0.5, 0.667, 1.0};
|
|
||||||
|
|
||||||
// Update scroll direction
|
// Update scroll direction
|
||||||
m_scrollingData->controller->setDirection(parseDirection(*PCONFDIRECTION));
|
m_scrollingData->controller->setDirection(parseDirection(*PCONFDIRECTION));
|
||||||
|
|
@ -523,7 +530,7 @@ CScrollingAlgorithm::CScrollingAlgorithm() {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initialize default widths and direction
|
// Initialize default widths and direction
|
||||||
m_config.configuredWidths = {0.333, 0.5, 0.667, 1.0};
|
m_config.configuredWidths = parseColumnWidths(*PCONFWIDTHS);
|
||||||
m_scrollingData->controller->setDirection(parseDirection(*PCONFDIRECTION));
|
m_scrollingData->controller->setDirection(parseDirection(*PCONFDIRECTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue