decorations: recalc layout and positioner on add/remove

This commit is contained in:
Vaxry 2023-11-13 16:42:45 +00:00
parent 4d6fa6ed0c
commit 5edb4e4a30
3 changed files with 15 additions and 0 deletions

View file

@ -202,12 +202,16 @@ void CWindow::updateWindowDecos() {
void CWindow::addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco) { void CWindow::addWindowDeco(std::unique_ptr<IHyprWindowDecoration> deco) {
m_dWindowDecorations.emplace_back(std::move(deco)); m_dWindowDecorations.emplace_back(std::move(deco));
g_pDecorationPositioner->forceRecalcFor(this);
updateWindowDecos(); updateWindowDecos();
g_pLayoutManager->getCurrentLayout()->recalculateWindow(this);
} }
void CWindow::removeWindowDeco(IHyprWindowDecoration* deco) { void CWindow::removeWindowDeco(IHyprWindowDecoration* deco) {
m_vDecosToRemove.push_back(deco); m_vDecosToRemove.push_back(deco);
g_pDecorationPositioner->forceRecalcFor(this);
updateWindowDecos(); updateWindowDecos();
g_pLayoutManager->getCurrentLayout()->recalculateWindow(this);
} }
pid_t CWindow::getPID() { pid_t CWindow::getPID() {

View file

@ -95,6 +95,16 @@ void CDecorationPositioner::sanitizeDatas() {
}); });
} }
void CDecorationPositioner::forceRecalcFor(CWindow* pWindow) {
const auto WIT = std::find_if(m_mWindowDatas.begin(), m_mWindowDatas.end(), [&](const auto& other) { return other.first == pWindow; });
if (WIT == m_mWindowDatas.end())
return;
const auto WINDOWDATA = &WIT->second;
WINDOWDATA->needsRecalc = true;
}
void CDecorationPositioner::onWindowUpdate(CWindow* pWindow) { void CDecorationPositioner::onWindowUpdate(CWindow* pWindow) {
if (!g_pCompositor->windowExists(pWindow) || !pWindow->m_bIsMapped) if (!g_pCompositor->windowExists(pWindow) || !pWindow->m_bIsMapped)
return; return;

View file

@ -71,6 +71,7 @@ class CDecorationPositioner {
CBox getBoxWithIncludedDecos(CWindow* pWindow); CBox getBoxWithIncludedDecos(CWindow* pWindow);
void repositionDeco(IHyprWindowDecoration* deco); void repositionDeco(IHyprWindowDecoration* deco);
CBox getWindowDecorationBox(IHyprWindowDecoration* deco); CBox getWindowDecorationBox(IHyprWindowDecoration* deco);
void forceRecalcFor(CWindow* pWindow);
private: private:
struct SWindowPositioningData { struct SWindowPositioningData {