diff options
| author | sam <haminoooin@gmail.com> | 2025-06-03 02:22:51 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-02 19:22:51 +0100 |
| commit | b1d0a727cc594e5329c5971d73391c7529e1c80e (patch) | |
| tree | ad03a8b8b6445cde6214365828d48447c2e64878 /src/layout/IHyprLayout.cpp | |
| parent | ef2c73af80d37265babc3287b3e5502a40c39374 (diff) | |
internal: Center window on parent if available (#10582)
Fixes #10537
Diffstat (limited to 'src/layout/IHyprLayout.cpp')
| -rw-r--r-- | src/layout/IHyprLayout.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index fbde7344..40794b3e 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -158,6 +158,7 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) { } // TODO: detect a popup in a more consistent way. + bool centeredOnParent = false; if ((desiredGeometry.x == 0 && desiredGeometry.y == 0) || !visible || !pWindow->m_isX11) { // if the pos isn't set, fall back to the center placement if it's not a child auto pos = PMONITOR->m_position + PMONITOR->m_size / 2.F - desiredGeometry.size() / 2.F; @@ -168,10 +169,11 @@ void IHyprLayout::onWindowCreatedFloating(PHLWINDOW pWindow) { *pWindow->m_realPosition = PARENT->m_realPosition->goal() + PARENT->m_realSize->goal() / 2.F - desiredGeometry.size() / 2.F; pWindow->m_workspace = PARENT->m_workspace; pWindow->m_monitor = PARENT->m_monitor; + centeredOnParent = true; } } - - *pWindow->m_realPosition = pos; + if (!centeredOnParent) + *pWindow->m_realPosition = pos; } else { // if it is, we respect where it wants to put itself, but apply monitor offset if outside // most of these are popups |
