mirror of
https://github.com/hyprwm/hyprland-plugins.git
synced 2026-05-05 02:07:58 +02:00
hyprscrolling: respect focus_fit_method when moving windows and fix left column centering (#460)
* scrolling: add SWorkspaceData::centerOrFitCol and use it in CScrollingLayout::moveWindowTo. Remove clamp on leftOffset in SWorkspateData::recalculate to fix left column centering. * Omit this-> for member functions * rerun checks
This commit is contained in:
parent
2ced5d8ea7
commit
b8d6d36961
2 changed files with 18 additions and 7 deletions
|
|
@ -241,6 +241,18 @@ void SWorkspaceData::fitCol(SP<SColumnData> c) {
|
|||
}
|
||||
}
|
||||
|
||||
void SWorkspaceData::centerOrFitCol(SP<SColumnData> c) {
|
||||
if (!c)
|
||||
return;
|
||||
|
||||
static const auto PFITMETHOD = CConfigValue<Hyprlang::INT>("plugin:hyprscrolling:focus_fit_method");
|
||||
|
||||
if (*PFITMETHOD == 1)
|
||||
fitCol(c);
|
||||
else
|
||||
centerCol(c);
|
||||
}
|
||||
|
||||
SP<SColumnData> SWorkspaceData::atCenter() {
|
||||
static const auto PFSONONE = CConfigValue<Hyprlang::INT>("plugin:hyprscrolling:fullscreen_on_one_column");
|
||||
|
||||
|
|
@ -268,8 +280,6 @@ void SWorkspaceData::recalculate(bool forceInstant) {
|
|||
return;
|
||||
}
|
||||
|
||||
leftOffset = std::clamp((double)leftOffset, 0.0, maxWidth());
|
||||
|
||||
const auto MAX_WIDTH = maxWidth();
|
||||
|
||||
PHLMONITOR PMONITOR = workspace->m_monitor.lock();
|
||||
|
|
@ -1169,13 +1179,13 @@ void CScrollingLayout::moveWindowTo(PHLWINDOW w, const std::string& dir, bool si
|
|||
if (!COL) {
|
||||
const auto NEWCOL = WS->add(-1);
|
||||
NEWCOL->add(DATA);
|
||||
WS->centerCol(NEWCOL);
|
||||
WS->centerOrFitCol(NEWCOL);
|
||||
} else {
|
||||
if (COL->windowDatas.size() > 1 || DATA->column)
|
||||
COL->add(DATA, COL->idxForHeight(g_pInputManager->getMouseCoordsInternal().y) - 1);
|
||||
else
|
||||
COL->add(DATA);
|
||||
WS->centerCol(COL);
|
||||
WS->centerOrFitCol(COL);
|
||||
}
|
||||
} else if (dir == "r") {
|
||||
const auto COL = WS->next(DATA->column.lock());
|
||||
|
|
@ -1186,13 +1196,13 @@ void CScrollingLayout::moveWindowTo(PHLWINDOW w, const std::string& dir, bool si
|
|||
// make a new one
|
||||
const auto NEWCOL = WS->add();
|
||||
NEWCOL->add(DATA);
|
||||
WS->centerCol(NEWCOL);
|
||||
WS->centerOrFitCol(NEWCOL);
|
||||
} else {
|
||||
if (COL->windowDatas.size() > 1 || DATA->column)
|
||||
COL->add(DATA, COL->idxForHeight(g_pInputManager->getMouseCoordsInternal().y) - 1);
|
||||
else
|
||||
COL->add(DATA);
|
||||
WS->centerCol(COL);
|
||||
WS->centerOrFitCol(COL);
|
||||
}
|
||||
|
||||
} else if (dir == "t" || dir == "u")
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ struct SWorkspaceData {
|
|||
bool visible(SP<SColumnData> c);
|
||||
void centerCol(SP<SColumnData> c);
|
||||
void fitCol(SP<SColumnData> c);
|
||||
void centerOrFitCol(SP<SColumnData> c);
|
||||
|
||||
void recalculate(bool forceInstant = false);
|
||||
|
||||
|
|
@ -120,4 +121,4 @@ class CScrollingLayout : public IHyprLayout {
|
|||
void applyNodeDataToWindow(SP<SScrollingWindowData> node, bool instant, bool hasWindowsRight, bool hasWindowsLeft);
|
||||
|
||||
friend struct SWorkspaceData;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue