diff options
Diffstat (limited to 'src/protocols/Screencopy.cpp')
| -rw-r--r-- | src/protocols/Screencopy.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 5cc884de..825939ef 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -13,10 +13,7 @@ CScreencopyClient::CScreencopyClient(SP<CZwlrScreencopyManagerV1> resource_) : m return; m_resource->setDestroy([this](CZwlrScreencopyManagerV1* pMgr) { PROTO::screencopy->destroyResource(this); }); - m_resource->setOnDestroy([this](CZwlrScreencopyManagerV1* pMgr) { - Screenshare::mgr()->destroyClientSessions(m_savedClient); - PROTO::screencopy->destroyResource(this); - }); + m_resource->setOnDestroy([this](CZwlrScreencopyManagerV1* pMgr) { PROTO::screencopy->destroyResource(this); }); m_resource->setCaptureOutput( [this](CZwlrScreencopyManagerV1* pMgr, uint32_t frame, int32_t overlayCursor, wl_resource* output) { captureOutput(frame, overlayCursor, output, {}); }); m_resource->setCaptureOutputRegion([this](CZwlrScreencopyManagerV1* pMgr, uint32_t frame, int32_t overlayCursor, wl_resource* output, int32_t x, int32_t y, int32_t w, @@ -25,10 +22,6 @@ CScreencopyClient::CScreencopyClient(SP<CZwlrScreencopyManagerV1> resource_) : m m_savedClient = m_resource->client(); } -CScreencopyClient::~CScreencopyClient() { - Screenshare::mgr()->destroyClientSessions(m_savedClient); -} - void CScreencopyClient::captureOutput(uint32_t frame, int32_t overlayCursor_, wl_resource* output, CBox box) { const auto PMONITORRES = CWLOutputResource::fromResource(output); if (!PMONITORRES || !PMONITORRES->m_monitor) { @@ -69,11 +62,6 @@ CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, WP<CScr m_resource->setCopy([this](CZwlrScreencopyFrameV1* pFrame, wl_resource* res) { shareFrame(pFrame, res, false); }); m_resource->setCopyWithDamage([this](CZwlrScreencopyFrameV1* pFrame, wl_resource* res) { shareFrame(pFrame, res, true); }); - m_listeners.stopped = m_session->m_events.stopped.listen([this]() { - if (good()) - m_resource->sendFailed(); - }); - m_frame = m_session->nextFrame(overlayCursor); auto formats = m_session->allowedFormats(); @@ -111,6 +99,12 @@ void CScreencopyFrame::shareFrame(CZwlrScreencopyFrameV1* pFrame, wl_resource* b return; } + if UNLIKELY (m_session.expired() || !m_session->monitor()) { + LOGM(Log::ERR, "Session stopped for frame {:x}", (uintptr_t)this); + m_resource->sendFailed(); + return; + } + if UNLIKELY (m_buffer) { LOGM(Log::ERR, "Buffer used in {:x}", (uintptr_t)this); m_resource->error(ZWLR_SCREENCOPY_FRAME_V1_ERROR_ALREADY_USED, "frame already used"); |
