diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 9e254fa6..58995f00 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -288,12 +288,13 @@ bool CPopup::visible() { return false; } -void CPopup::bfHelper(std::vector nodes, std::function fn, void* data) { +void CPopup::bfHelper(std::vector const& nodes, std::function fn, void* data) { for (auto const& n : nodes) { fn(n, data); } std::vector nodes2; + nodes2.reserve(nodes.size() * 2); for (auto const& n : nodes) { for (auto const& c : n->m_vChildren) { diff --git a/src/desktop/Popup.hpp b/src/desktop/Popup.hpp index 04996612..f34b8a2c 100644 --- a/src/desktop/Popup.hpp +++ b/src/desktop/Popup.hpp @@ -81,5 +81,5 @@ class CPopup { Vector2D localToGlobal(const Vector2D& rel); Vector2D t1ParentCoords(); - static void bfHelper(std::vector nodes, std::function fn, void* data); + static void bfHelper(std::vector const& nodes, std::function fn, void* data); }; diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 9a2e00a9..d78d3d8b 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -252,9 +252,10 @@ void CWLSurfaceResource::resetRole() { role = makeShared(); } -void CWLSurfaceResource::bfHelper(std::vector> nodes, std::function, const Vector2D&, void*)> fn, void* data) { +void CWLSurfaceResource::bfHelper(std::vector> const& nodes, std::function, const Vector2D&, void*)> fn, void* data) { std::vector> nodes2; + nodes2.reserve(nodes.size() * 2); // first, gather all nodes below for (auto const& n : nodes) { diff --git a/src/protocols/core/Compositor.hpp b/src/protocols/core/Compositor.hpp index fbffd966..e5bdf082 100644 --- a/src/protocols/core/Compositor.hpp +++ b/src/protocols/core/Compositor.hpp @@ -147,7 +147,7 @@ class CWLSurfaceResource { void dropPendingBuffer(); void dropCurrentBuffer(); void commitPendingState(); - void bfHelper(std::vector> nodes, std::function, const Vector2D&, void*)> fn, void* data); + void bfHelper(std::vector> const& nodes, std::function, const Vector2D&, void*)> fn, void* data); void updateCursorShm(); friend class CWLPointerResource; diff --git a/src/render/decorations/DecorationPositioner.cpp b/src/render/decorations/DecorationPositioner.cpp index 3eb45546..995283c6 100644 --- a/src/render/decorations/DecorationPositioner.cpp +++ b/src/render/decorations/DecorationPositioner.cpp @@ -294,13 +294,11 @@ SBoxExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow } SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) { - CBox accum = pWindow->getWindowMainSurfaceBox(); + CBox const mainSurfaceBox = pWindow->getWindowMainSurfaceBox(); + CBox accum = mainSurfaceBox; for (auto const& data : m_vWindowPositioningDatas) { - if (!data->pDecoration) - continue; - - if (!(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT) && inputOnly) + if (!data->pDecoration || (inputOnly && !(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))) continue; auto const window = data->pWindow.lock(); @@ -308,31 +306,40 @@ SBoxExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, continue; CBox decoBox; - if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) { - decoBox = data->pWindow->getWindowMainSurfaceBox(); + decoBox = mainSurfaceBox; decoBox.addExtents(data->positioningInfo.desiredExtents); } else { - decoBox = data->lastReply.assignedGeometry; - const auto EDGEPOINT = getEdgeDefinedPoint(data->positioningInfo.edges, pWindow); - decoBox.translate(EDGEPOINT); + decoBox = data->lastReply.assignedGeometry; + decoBox.translate(getEdgeDefinedPoint(data->positioningInfo.edges, pWindow)); } + // Check bounds only if decoBox extends beyond accum SBoxExtents extentsToAdd; + bool needUpdate = false; - if (decoBox.x < accum.x) + if (decoBox.x < accum.x) { extentsToAdd.topLeft.x = accum.x - decoBox.x; - if (decoBox.y < accum.y) + needUpdate = true; + } + if (decoBox.y < accum.y) { extentsToAdd.topLeft.y = accum.y - decoBox.y; - if (decoBox.x + decoBox.w > accum.x + accum.w) + needUpdate = true; + } + if (decoBox.x + decoBox.w > accum.x + accum.w) { extentsToAdd.bottomRight.x = (decoBox.x + decoBox.w) - (accum.x + accum.w); - if (decoBox.y + decoBox.h > accum.y + accum.h) + needUpdate = true; + } + if (decoBox.y + decoBox.h > accum.y + accum.h) { extentsToAdd.bottomRight.y = (decoBox.y + decoBox.h) - (accum.y + accum.h); + needUpdate = true; + } - accum.addExtents(extentsToAdd); + if (needUpdate) + accum.addExtents(extentsToAdd); } - return accum.extentsFrom(pWindow->getWindowMainSurfaceBox()); + return accum.extentsFrom(mainSurfaceBox); } CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) {