mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 15:45: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) {
|
void CScreencopyProtocol::destroyResource(CScreencopyClient* client) {
|
||||||
std::erase_if(m_vClients, [&](const auto& other) { return other.get() == 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_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) {
|
void CScreencopyProtocol::destroyResource(CScreencopyFrame* frame) {
|
||||||
std::erase_if(m_vFrames, [&](const auto& other) { return other.get() == 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) {
|
void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||||
|
@ -412,8 +412,11 @@ void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||||
|
|
||||||
// share frame if correct output
|
// share frame if correct output
|
||||||
for (auto const& f : m_vFramesAwaitingWrite) {
|
for (auto const& f : m_vFramesAwaitingWrite) {
|
||||||
|
if (!f)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!f->pMonitor || !f->buffer) {
|
if (!f->pMonitor || !f->buffer) {
|
||||||
framesToRemove.push_back(f);
|
framesToRemove.emplace_back(f);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,10 +428,10 @@ void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||||
f->client->lastFrame.reset();
|
f->client->lastFrame.reset();
|
||||||
++f->client->frameCounter;
|
++f->client->frameCounter;
|
||||||
|
|
||||||
framesToRemove.push_back(f);
|
framesToRemove.emplace_back(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& f : framesToRemove) {
|
for (auto const& f : framesToRemove) {
|
||||||
destroyResource(f.get());
|
std::erase(m_vFramesAwaitingWrite, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class CScreencopyFrame {
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
|
|
||||||
SP<CScreencopyFrame> self;
|
WP<CScreencopyFrame> self;
|
||||||
WP<CScreencopyClient> client;
|
WP<CScreencopyClient> client;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -92,7 +92,7 @@ class CScreencopyProtocol : public IWaylandProtocol {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SP<CScreencopyFrame>> m_vFrames;
|
std::vector<SP<CScreencopyFrame>> m_vFrames;
|
||||||
std::vector<SP<CScreencopyFrame>> m_vFramesAwaitingWrite;
|
std::vector<WP<CScreencopyFrame>> m_vFramesAwaitingWrite;
|
||||||
std::vector<SP<CScreencopyClient>> m_vClients;
|
std::vector<SP<CScreencopyClient>> m_vClients;
|
||||||
|
|
||||||
SP<CEventLoopTimer> m_pSoftwareCursorTimer;
|
SP<CEventLoopTimer> m_pSoftwareCursorTimer;
|
||||||
|
|
|
@ -354,12 +354,12 @@ void CToplevelExportProtocol::bindManager(wl_client* client, void* data, uint32_
|
||||||
void CToplevelExportProtocol::destroyResource(CToplevelExportClient* client) {
|
void CToplevelExportProtocol::destroyResource(CToplevelExportClient* client) {
|
||||||
std::erase_if(m_vClients, [&](const auto& other) { return other.get() == 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_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) {
|
void CToplevelExportProtocol::destroyResource(CToplevelExportFrame* frame) {
|
||||||
std::erase_if(m_vFrames, [&](const auto& other) { return other.get() == 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) {
|
void CToplevelExportProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||||
|
@ -370,11 +370,17 @@ void CToplevelExportProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||||
|
|
||||||
// share frame if correct output
|
// share frame if correct output
|
||||||
for (auto const& f : m_vFramesAwaitingWrite) {
|
for (auto const& f : m_vFramesAwaitingWrite) {
|
||||||
if (!f->pWindow || !validMapped(f->pWindow)) {
|
if (!f)
|
||||||
framesToRemove.push_back(f);
|
continue;
|
||||||
|
|
||||||
|
if (!validMapped(f->pWindow)) {
|
||||||
|
framesToRemove.emplace_back(f);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!f->pWindow)
|
||||||
|
continue;
|
||||||
|
|
||||||
const auto PWINDOW = f->pWindow;
|
const auto PWINDOW = f->pWindow;
|
||||||
|
|
||||||
if (pMonitor != g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID))
|
if (pMonitor != g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID))
|
||||||
|
@ -394,7 +400,7 @@ void CToplevelExportProtocol::onOutputCommit(CMonitor* pMonitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& f : framesToRemove) {
|
for (auto const& f : framesToRemove) {
|
||||||
destroyResource(f.get());
|
std::erase(m_vFramesAwaitingWrite, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class CToplevelExportFrame {
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
|
|
||||||
SP<CToplevelExportFrame> self;
|
WP<CToplevelExportFrame> self;
|
||||||
WP<CToplevelExportClient> client;
|
WP<CToplevelExportClient> client;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -85,7 +85,7 @@ class CToplevelExportProtocol : IWaylandProtocol {
|
||||||
private:
|
private:
|
||||||
std::vector<SP<CToplevelExportClient>> m_vClients;
|
std::vector<SP<CToplevelExportClient>> m_vClients;
|
||||||
std::vector<SP<CToplevelExportFrame>> m_vFrames;
|
std::vector<SP<CToplevelExportFrame>> m_vFrames;
|
||||||
std::vector<SP<CToplevelExportFrame>> m_vFramesAwaitingWrite;
|
std::vector<WP<CToplevelExportFrame>> m_vFramesAwaitingWrite;
|
||||||
|
|
||||||
void shareFrame(CToplevelExportFrame* frame);
|
void shareFrame(CToplevelExportFrame* frame);
|
||||||
bool copyFrameDmabuf(CToplevelExportFrame* frame, timespec* now);
|
bool copyFrameDmabuf(CToplevelExportFrame* frame, timespec* now);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e06482e0e611130cd1929f75e8c1cf679e57d161
|
Subproject commit c7c3f4cd0faed21fc90ba6bd06fe4f3e0e057ea8
|
Loading…
Reference in a new issue