summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-25 21:08:54 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-07-25 21:08:54 +0200
commitc998e946aae7e4633def6e3c7a925d828fbc7fea (patch)
tree895474f1aeba77450ef6c2d194475a0db4c0f4c1 /src/Compositor.cpp
parentcde39e0b6eba385d3eab4c524b6de80121c174f5 (diff)
Wrap adding to fading out
needed to avoid memory safety issues, because sometimes there would be duplicates.
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 175cb66d..34955eca 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -901,8 +901,10 @@ void CCompositor::cleanupFadingOut(const int& monid) {
for (auto& m : m_vMonitors) {
for (auto& lsl : m->m_aLayerSurfaceLists) {
- if (!lsl.empty() && std::find_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }) != lsl.end())
+ if (!lsl.empty() && std::find_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }) != lsl.end()) {
lsl.erase(std::remove_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }));
+ return;
+ }
}
}
@@ -914,6 +916,24 @@ void CCompositor::cleanupFadingOut(const int& monid) {
}
}
+void CCompositor::addToFadingOutSafe(SLayerSurface* pLS) {
+ const auto FOUND = std::find_if(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), [&](SLayerSurface* other) { return other == pLS; });
+
+ if (FOUND != m_vSurfacesFadingOut.end())
+ return; // if it's already added, don't add it.
+
+ m_vSurfacesFadingOut.emplace_back(pLS);
+}
+
+void CCompositor::addToFadingOutSafe(CWindow* pWindow) {
+ const auto FOUND = std::find_if(m_vWindowsFadingOut.begin(), m_vWindowsFadingOut.end(), [&](CWindow* other) { return other == pWindow; });
+
+ if (FOUND != m_vWindowsFadingOut.end())
+ return; // if it's already added, don't add it.
+
+ m_vWindowsFadingOut.emplace_back(pWindow);
+}
+
CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
const auto WINDOWIDEALBB = pWindow->getWindowIdealBoundingBoxIgnoreReserved();