mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-29 22:05:58 +01:00
Wrap adding to fading out
needed to avoid memory safety issues, because sometimes there would be duplicates.
This commit is contained in:
parent
cde39e0b6e
commit
c998e946aa
4 changed files with 27 additions and 5 deletions
|
@ -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();
|
||||
|
|
|
@ -146,6 +146,8 @@ public:
|
|||
void moveUnmanagedX11ToWindows(CWindow*);
|
||||
CWindow* getX11Parent(CWindow*);
|
||||
void scheduleFrameForMonitor(SMonitor*);
|
||||
void addToFadingOutSafe(SLayerSurface*);
|
||||
void addToFadingOutSafe(CWindow*);
|
||||
|
||||
std::string explicitConfigPath;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ void Events::listener_destroyLayerSurface(void* owner, void* data) {
|
|||
Debug::log(LOG, "Removing LayerSurface that wasn't mapped.");
|
||||
layersurface->alpha.setValueAndWarp(0.f);
|
||||
layersurface->fadingOut = true;
|
||||
g_pCompositor->m_vSurfacesFadingOut.push_back(layersurface);
|
||||
g_pCompositor->addToFadingOutSafe(layersurface);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
|||
if (!g_pCompositor->getMonitorFromID(layersurface->monitorID)) {
|
||||
Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring.");
|
||||
|
||||
g_pCompositor->m_vSurfacesFadingOut.push_back(layersurface);
|
||||
g_pCompositor->addToFadingOutSafe(layersurface);
|
||||
|
||||
layersurface->mapped = false;
|
||||
|
||||
|
@ -176,7 +176,7 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
|||
|
||||
layersurface->fadingOut = true;
|
||||
|
||||
g_pCompositor->m_vSurfacesFadingOut.push_back(layersurface);
|
||||
g_pCompositor->addToFadingOutSafe(layersurface);
|
||||
|
||||
if (layersurface->layerSurface->mapped)
|
||||
layersurface->layerSurface->mapped = false;
|
||||
|
|
|
@ -368,7 +368,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
|||
|
||||
PWINDOW->m_bFadingOut = true;
|
||||
|
||||
g_pCompositor->m_vWindowsFadingOut.emplace_back(PWINDOW);
|
||||
g_pCompositor->addToFadingOutSafe(PWINDOW);
|
||||
|
||||
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID));
|
||||
|
||||
|
|
Loading…
Reference in a new issue