scroll: clamp column widths properly
ref https://github.com/hyprwm/Hyprland/discussions/13458
This commit is contained in:
parent
f0a80ce5e0
commit
f41e3c2203
2 changed files with 14 additions and 9 deletions
|
|
@ -296,23 +296,21 @@ SScrollingData::SScrollingData(CScrollingAlgorithm* algo) : algorithm(algo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SP<SColumnData> SScrollingData::add() {
|
SP<SColumnData> SScrollingData::add() {
|
||||||
static const auto PCOLWIDTH = CConfigValue<Hyprlang::FLOAT>("scrolling:column_width");
|
auto col = columns.emplace_back(makeShared<SColumnData>(self.lock()));
|
||||||
auto col = columns.emplace_back(makeShared<SColumnData>(self.lock()));
|
col->self = col;
|
||||||
col->self = col;
|
|
||||||
|
|
||||||
size_t stripIdx = controller->addStrip(*PCOLWIDTH);
|
size_t stripIdx = controller->addStrip(algorithm->defaultColumnWidth());
|
||||||
controller->getStrip(stripIdx).userData = col;
|
controller->getStrip(stripIdx).userData = col;
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
|
|
||||||
SP<SColumnData> SScrollingData::add(int after) {
|
SP<SColumnData> SScrollingData::add(int after) {
|
||||||
static const auto PCOLWIDTH = CConfigValue<Hyprlang::FLOAT>("scrolling:column_width");
|
auto col = makeShared<SColumnData>(self.lock());
|
||||||
auto col = makeShared<SColumnData>(self.lock());
|
col->self = col;
|
||||||
col->self = col;
|
|
||||||
columns.insert(columns.begin() + after + 1, col);
|
columns.insert(columns.begin() + after + 1, col);
|
||||||
|
|
||||||
controller->insertStrip(after, *PCOLWIDTH);
|
controller->insertStrip(after, algorithm->defaultColumnWidth());
|
||||||
controller->getStrip(after + 1).userData = col;
|
controller->getStrip(after + 1).userData = col;
|
||||||
|
|
||||||
return col;
|
return col;
|
||||||
|
|
@ -486,7 +484,7 @@ CScrollingAlgorithm::CScrollingAlgorithm() {
|
||||||
CConstVarList widths(*PCONFWIDTHS, 0, ',');
|
CConstVarList widths(*PCONFWIDTHS, 0, ',');
|
||||||
for (auto& w : widths) {
|
for (auto& w : widths) {
|
||||||
try {
|
try {
|
||||||
m_config.configuredWidths.emplace_back(std::stof(std::string{w}));
|
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); }
|
} catch (...) { Log::logger->log(Log::ERR, "scrolling: Failed to parse width {} as float", w); }
|
||||||
}
|
}
|
||||||
if (m_config.configuredWidths.empty())
|
if (m_config.configuredWidths.empty())
|
||||||
|
|
@ -1424,3 +1422,8 @@ CBox CScrollingAlgorithm::usableArea() {
|
||||||
box.translate(-m_parent->space()->workspace()->m_monitor->m_position);
|
box.translate(-m_parent->space()->workspace()->m_monitor->m_position);
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CScrollingAlgorithm::defaultColumnWidth() {
|
||||||
|
static const auto PCOLWIDTH = CConfigValue<Hyprlang::FLOAT>("scrolling:column_width");
|
||||||
|
return std::clamp(*PCOLWIDTH, MIN_COLUMN_WIDTH, MAX_COLUMN_WIDTH);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,8 @@ namespace Layout::Tiled {
|
||||||
void moveTargetTo(SP<ITarget> t, Math::eDirection dir, bool silent);
|
void moveTargetTo(SP<ITarget> t, Math::eDirection dir, bool silent);
|
||||||
void focusOnInput(SP<ITarget> target, eInputMode input);
|
void focusOnInput(SP<ITarget> target, eInputMode input);
|
||||||
|
|
||||||
|
float defaultColumnWidth();
|
||||||
|
|
||||||
friend struct SScrollingData;
|
friend struct SScrollingData;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue