aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-08-30 15:50:25 +0200
committerVaxry <[email protected]>2024-08-30 15:53:45 +0200
commitfbd63543930417f3cefe36bdb9f2cdd20fc3693a (patch)
treef55748b6e99de9e26fabad4bcad03883a2b83daf
parentfd8d8e122ed9cf49f3f84d4d264f1b810c355a07 (diff)
downloadHyprland-fbd63543930417f3cefe36bdb9f2cdd20fc3693a.tar.gz
Hyprland-fbd63543930417f3cefe36bdb9f2cdd20fc3693a.zip
presentation-feedback: minor fixups
-rw-r--r--src/helpers/Monitor.cpp4
-rw-r--r--src/protocols/PresentationTime.cpp12
-rw-r--r--src/protocols/PresentationTime.hpp8
-rw-r--r--src/protocols/core/Compositor.cpp2
-rw-r--r--src/protocols/core/Compositor.hpp2
-rw-r--r--src/render/Renderer.cpp4
6 files changed, 18 insertions, 14 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index 8af0bc62..685009fd 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -47,7 +47,7 @@ void CMonitor::onConnect(bool noRule) {
listeners.presented = output->events.present.registerListener([this](std::any d) {
auto E = std::any_cast<Aquamarine::IOutput::SPresentEvent>(d);
- PROTO::presentation->onPresented(this, E.when, E.refresh, E.seq, E.flags);
+ PROTO::presentation->onPresented(self.lock(), E.when, E.refresh, E.seq, E.flags);
});
listeners.destroy = output->events.destroy.registerListener([this](std::any d) {
@@ -861,7 +861,7 @@ bool CMonitor::attemptDirectScanout() {
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
- PSURFACE->presentFeedback(&now, this);
+ PSURFACE->presentFeedback(&now, self.lock());
output->state->addDamage(CBox{{}, vecPixelSize});
output->state->resetExplicitFences();
diff --git a/src/protocols/PresentationTime.cpp b/src/protocols/PresentationTime.cpp
index b1108042..e1ff52cd 100644
--- a/src/protocols/PresentationTime.cpp
+++ b/src/protocols/PresentationTime.cpp
@@ -14,7 +14,7 @@ void CQueuedPresentationData::setPresentationType(bool zeroCopy_) {
zeroCopy = zeroCopy_;
}
-void CQueuedPresentationData::attachMonitor(CMonitor* pMonitor_) {
+void CQueuedPresentationData::attachMonitor(SP<CMonitor> pMonitor_) {
pMonitor = pMonitor_;
}
@@ -67,12 +67,14 @@ void CPresentationFeedback::sendQueued(SP<CQueuedPresentationData> data, timespe
(uint32_t)(seq & 0xFFFFFFFF), (wpPresentationFeedbackKind)flags);
else
resource->sendDiscarded();
+
+ done = true;
}
CPresentationProtocol::CPresentationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
static auto P = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
const auto PMONITOR = std::any_cast<CMonitor*>(param);
- std::erase_if(m_vQueue, [PMONITOR](const auto& other) { return !other->surface || other->pMonitor == PMONITOR; });
+ std::erase_if(m_vQueue, [PMONITOR](const auto& other) { return !other->surface || other->pMonitor.get() == PMONITOR; });
});
}
@@ -105,7 +107,7 @@ void CPresentationProtocol::onGetFeedback(CWpPresentation* pMgr, wl_resource* su
}
}
-void CPresentationProtocol::onPresented(CMonitor* pMonitor, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags) {
+void CPresentationProtocol::onPresented(SP<CMonitor> pMonitor, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags) {
timespec now;
timespec* presentedAt = when;
if (!presentedAt) {
@@ -119,7 +121,7 @@ void CPresentationProtocol::onPresented(CMonitor* pMonitor, timespec* when, uint
continue;
for (auto const& data : m_vQueue) {
- if (!data->surface || data->surface != feedback->surface)
+ if (!data->surface || data->surface != feedback->surface || (data->pMonitor && data->pMonitor != pMonitor))
continue;
feedback->sendQueued(data, when, untilRefreshNs, seq, reportedFlags);
@@ -129,7 +131,7 @@ void CPresentationProtocol::onPresented(CMonitor* pMonitor, timespec* when, uint
}
std::erase_if(m_vFeedbacks, [](const auto& other) { return !other->surface || other->done; });
- std::erase_if(m_vQueue, [pMonitor](const auto& other) { return !other->surface || other->pMonitor == pMonitor || !other->pMonitor; });
+ std::erase_if(m_vQueue, [pMonitor](const auto& other) { return !other->surface || other->pMonitor == pMonitor || !other->pMonitor || other->done; });
}
void CPresentationProtocol::queueData(SP<CQueuedPresentationData> data) {
diff --git a/src/protocols/PresentationTime.hpp b/src/protocols/PresentationTime.hpp
index 2c6ce3e9..06c71c9a 100644
--- a/src/protocols/PresentationTime.hpp
+++ b/src/protocols/PresentationTime.hpp
@@ -14,15 +14,17 @@ class CQueuedPresentationData {
CQueuedPresentationData(SP<CWLSurfaceResource> surf);
void setPresentationType(bool zeroCopy);
- void attachMonitor(CMonitor* pMonitor);
+ void attachMonitor(SP<CMonitor> pMonitor);
void presented();
void discarded();
+ bool done = false;
+
private:
bool wasPresented = false;
bool zeroCopy = false;
- CMonitor* pMonitor = nullptr;
+ WP<CMonitor> pMonitor;
WP<CWLSurfaceResource> surface;
DYNLISTENER(destroySurface);
@@ -53,7 +55,7 @@ class CPresentationProtocol : public IWaylandProtocol {
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
- void onPresented(CMonitor* pMonitor, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
+ void onPresented(SP<CMonitor> pMonitor, timespec* when, uint32_t untilRefreshNs, uint64_t seq, uint32_t reportedFlags);
void queueData(SP<CQueuedPresentationData> data);
private:
diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp
index f7f6dcda..37a4bdf1 100644
--- a/src/protocols/core/Compositor.cpp
+++ b/src/protocols/core/Compositor.cpp
@@ -509,7 +509,7 @@ void CWLSurfaceResource::updateCursorShm() {
memcpy(shmData.data(), pixelData, bufLen);
}
-void CWLSurfaceResource::presentFeedback(timespec* when, CMonitor* pMonitor) {
+void CWLSurfaceResource::presentFeedback(timespec* when, SP<CMonitor> pMonitor) {
frame(when);
auto FEEDBACK = makeShared<CQueuedPresentationData>(self.lock());
FEEDBACK->attachMonitor(pMonitor);
diff --git a/src/protocols/core/Compositor.hpp b/src/protocols/core/Compositor.hpp
index a3245399..dc1c851f 100644
--- a/src/protocols/core/Compositor.hpp
+++ b/src/protocols/core/Compositor.hpp
@@ -124,7 +124,7 @@ class CWLSurfaceResource {
void breadthfirst(std::function<void(SP<CWLSurfaceResource>, const Vector2D&, void*)> fn, void* data);
CRegion accumulateCurrentBufferDamage();
- void presentFeedback(timespec* when, CMonitor* pMonitor);
+ void presentFeedback(timespec* when, SP<CMonitor> pMonitor);
void lockPendingState();
void unlockPendingState();
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 2854a973..420f8d4c 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -185,7 +185,7 @@ static void renderSurface(SP<CWLSurfaceResource> surface, int x, int y, void* da
if (windowBox.width <= 1 || windowBox.height <= 1) {
if (!g_pHyprRenderer->m_bBlockSurfaceFeedback) {
Debug::log(TRACE, "presentFeedback for invisible surface");
- surface->presentFeedback(RDATA->when, RDATA->pMonitor);
+ surface->presentFeedback(RDATA->when, RDATA->pMonitor->self.lock());
}
return; // invisible
@@ -240,7 +240,7 @@ static void renderSurface(SP<CWLSurfaceResource> surface, int x, int y, void* da
}
if (!g_pHyprRenderer->m_bBlockSurfaceFeedback)
- surface->presentFeedback(RDATA->when, RDATA->pMonitor);
+ surface->presentFeedback(RDATA->when, RDATA->pMonitor->self.lock());
g_pHyprOpenGL->blend(true);