From 2bff4a45215514e89e045e07878537105fde021d Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sun, 18 Aug 2024 19:24:52 +0100 Subject: [PATCH] drm: don't schedule new frame events on disabled outputs (#52) * drm: don't schedule new frame events on disabled outputs * e * test --- include/aquamarine/backend/DRM.hpp | 2 ++ src/backend/drm/DRM.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/aquamarine/backend/DRM.hpp b/include/aquamarine/backend/DRM.hpp index 7847eac..3b97348 100644 --- a/include/aquamarine/backend/DRM.hpp +++ b/include/aquamarine/backend/DRM.hpp @@ -209,6 +209,8 @@ namespace Aquamarine { Hyprutils::Math::Vector2D cursorPos; // without hotspot Hyprutils::Math::Vector2D cursorHotspot; + bool enabledState = true; // actual enabled state. Should be synced with state->state().enabled after a new frame + private: CDRMOutput(const std::string& name_, Hyprutils::Memory::CWeakPointer backend_, Hyprutils::Memory::CSharedPointer connector_); diff --git a/src/backend/drm/DRM.cpp b/src/backend/drm/DRM.cpp index 89aaa6a..ba45ea9 100644 --- a/src/backend/drm/DRM.cpp +++ b/src/backend/drm/DRM.cpp @@ -822,7 +822,7 @@ static void handlePF(int fd, unsigned seq, unsigned tv_sec, unsigned tv_usec, un .flags = flags, }); - if (BACKEND->sessionActive() && !pageFlip->connector->frameEventScheduled) + if (BACKEND->sessionActive() && !pageFlip->connector->frameEventScheduled && pageFlip->connector->output->enabledState) pageFlip->connector->output->events.frame.emit(); } @@ -1322,6 +1322,8 @@ void Aquamarine::SDRMConnector::applyCommit(const SDRMConnectorCommitData& data) if (output->state->state().committed & COutputState::AQ_OUTPUT_STATE_MODE) refresh = calculateRefresh(data.modeInfo); + + output->enabledState = output->state->state().enabled; } void Aquamarine::SDRMConnector::rollbackCommit(const SDRMConnectorCommitData& data) { @@ -1683,7 +1685,7 @@ void Aquamarine::CDRMOutput::scheduleFrame(const scheduleFrameReason reason) { connector->isPageFlipPending, connector->frameEventScheduled))); needsFrame = true; - if (connector->isPageFlipPending || connector->frameEventScheduled) + if (connector->isPageFlipPending || connector->frameEventScheduled || !enabledState) return; connector->frameEventScheduled = true;