mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 08:05:58 +01:00
screencopy: fix screencopy frames not being cleaned up (#8017)
--------- Co-authored-by: Vaxry <vaxry@vaxry.net>
This commit is contained in:
parent
6807430b18
commit
657aeb3946
5 changed files with 24 additions and 15 deletions
|
@ -394,12 +394,12 @@ void CScreencopyProtocol::bindManager(wl_client* client, void* data, uint32_t ve
|
|||
void CScreencopyProtocol::destroyResource(CScreencopyClient* client) {
|
||||
std::erase_if(m_vClients, [&](const auto& other) { return other.get() == client; });
|
||||
std::erase_if(m_vFrames, [&](const auto& other) { return other->client.get() == client; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return other->client.get() == client; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other->client.get() == client; });
|
||||
}
|
||||
|
||||
void CScreencopyProtocol::destroyResource(CScreencopyFrame* frame) {
|
||||
std::erase_if(m_vFrames, [&](const auto& other) { return other.get() == frame; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return other.get() == frame; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other.get() == frame; });
|
||||
}
|
||||
|
||||
void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||
|
@ -412,8 +412,11 @@ void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
|
|||
|
||||
// share frame if correct output
|
||||
for (auto const& f : m_vFramesAwaitingWrite) {
|
||||
if (!f)
|
||||
continue;
|
||||
|
||||
if (!f->pMonitor || !f->buffer) {
|
||||
framesToRemove.push_back(f);
|
||||
framesToRemove.emplace_back(f);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -425,10 +428,10 @@ void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
|
|||
f->client->lastFrame.reset();
|
||||
++f->client->frameCounter;
|
||||
|
||||
framesToRemove.push_back(f);
|
||||
framesToRemove.emplace_back(f);
|
||||
}
|
||||
|
||||
for (auto const& f : framesToRemove) {
|
||||
destroyResource(f.get());
|
||||
std::erase(m_vFramesAwaitingWrite, f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class CScreencopyFrame {
|
|||
|
||||
bool good();
|
||||
|
||||
SP<CScreencopyFrame> self;
|
||||
WP<CScreencopyFrame> self;
|
||||
WP<CScreencopyClient> client;
|
||||
|
||||
private:
|
||||
|
@ -92,7 +92,7 @@ class CScreencopyProtocol : public IWaylandProtocol {
|
|||
|
||||
private:
|
||||
std::vector<SP<CScreencopyFrame>> m_vFrames;
|
||||
std::vector<SP<CScreencopyFrame>> m_vFramesAwaitingWrite;
|
||||
std::vector<WP<CScreencopyFrame>> m_vFramesAwaitingWrite;
|
||||
std::vector<SP<CScreencopyClient>> m_vClients;
|
||||
|
||||
SP<CEventLoopTimer> m_pSoftwareCursorTimer;
|
||||
|
|
|
@ -354,12 +354,12 @@ void CToplevelExportProtocol::bindManager(wl_client* client, void* data, uint32_
|
|||
void CToplevelExportProtocol::destroyResource(CToplevelExportClient* client) {
|
||||
std::erase_if(m_vClients, [&](const auto& other) { return other.get() == client; });
|
||||
std::erase_if(m_vFrames, [&](const auto& other) { return other->client.get() == client; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return other->client.get() == client; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other->client.get() == client; });
|
||||
}
|
||||
|
||||
void CToplevelExportProtocol::destroyResource(CToplevelExportFrame* frame) {
|
||||
std::erase_if(m_vFrames, [&](const auto& other) { return other.get() == frame; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return other.get() == frame; });
|
||||
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other.get() == frame; });
|
||||
}
|
||||
|
||||
void CToplevelExportProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||
|
@ -370,11 +370,17 @@ void CToplevelExportProtocol::onOutputCommit(CMonitor* pMonitor) {
|
|||
|
||||
// share frame if correct output
|
||||
for (auto const& f : m_vFramesAwaitingWrite) {
|
||||
if (!f->pWindow || !validMapped(f->pWindow)) {
|
||||
framesToRemove.push_back(f);
|
||||
if (!f)
|
||||
continue;
|
||||
|
||||
if (!validMapped(f->pWindow)) {
|
||||
framesToRemove.emplace_back(f);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!f->pWindow)
|
||||
continue;
|
||||
|
||||
const auto PWINDOW = f->pWindow;
|
||||
|
||||
if (pMonitor != g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID))
|
||||
|
@ -394,7 +400,7 @@ void CToplevelExportProtocol::onOutputCommit(CMonitor* pMonitor) {
|
|||
}
|
||||
|
||||
for (auto const& f : framesToRemove) {
|
||||
destroyResource(f.get());
|
||||
std::erase(m_vFramesAwaitingWrite, f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class CToplevelExportFrame {
|
|||
|
||||
bool good();
|
||||
|
||||
SP<CToplevelExportFrame> self;
|
||||
WP<CToplevelExportFrame> self;
|
||||
WP<CToplevelExportClient> client;
|
||||
|
||||
private:
|
||||
|
@ -85,7 +85,7 @@ class CToplevelExportProtocol : IWaylandProtocol {
|
|||
private:
|
||||
std::vector<SP<CToplevelExportClient>> m_vClients;
|
||||
std::vector<SP<CToplevelExportFrame>> m_vFrames;
|
||||
std::vector<SP<CToplevelExportFrame>> m_vFramesAwaitingWrite;
|
||||
std::vector<WP<CToplevelExportFrame>> m_vFramesAwaitingWrite;
|
||||
|
||||
void shareFrame(CToplevelExportFrame* frame);
|
||||
bool copyFrameDmabuf(CToplevelExportFrame* frame, timespec* now);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e06482e0e611130cd1929f75e8c1cf679e57d161
|
||||
Subproject commit c7c3f4cd0faed21fc90ba6bd06fe4f3e0e057ea8
|
Loading…
Reference in a new issue