From 7a84686b4a6dbf7df0bfb4856e6299f995c50d15 Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Sat, 20 Jul 2024 21:56:18 +0300 Subject: [PATCH] output: remove redundant needsFrame, allow skip on mouse event (#21) --- include/aquamarine/backend/DRM.hpp | 4 ++-- include/aquamarine/backend/Wayland.hpp | 2 +- include/aquamarine/backend/drm/Atomic.hpp | 2 +- include/aquamarine/backend/drm/Legacy.hpp | 7 +++---- include/aquamarine/output/Output.hpp | 4 +++- src/backend/Wayland.cpp | 2 +- src/backend/drm/DRM.cpp | 10 ++++------ src/backend/drm/impl/Atomic.cpp | 8 +++++--- src/backend/drm/impl/Legacy.cpp | 6 +++--- src/output/Output.cpp | 2 +- 10 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/aquamarine/backend/DRM.hpp b/include/aquamarine/backend/DRM.hpp index 14f2444..43a6c0b 100644 --- a/include/aquamarine/backend/DRM.hpp +++ b/include/aquamarine/backend/DRM.hpp @@ -194,7 +194,7 @@ namespace Aquamarine { virtual bool test(); virtual Hyprutils::Memory::CSharedPointer getBackend(); virtual bool setCursor(Hyprutils::Memory::CSharedPointer buffer, const Hyprutils::Math::Vector2D& hotspot); - virtual void moveCursor(const Hyprutils::Math::Vector2D& coord); + virtual void moveCursor(const Hyprutils::Math::Vector2D& coord, bool skipShedule = false); virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN); virtual void setCursorVisible(bool visible); virtual Hyprutils::Math::Vector2D cursorPlaneSize(); @@ -324,7 +324,7 @@ namespace Aquamarine { virtual bool reset() = 0; // moving a cursor IIRC is almost instant on most hardware so we don't have to wait for a commit. - virtual bool moveCursor(Hyprutils::Memory::CSharedPointer connector) = 0; + virtual bool moveCursor(Hyprutils::Memory::CSharedPointer connector, bool skipShedule = false) = 0; }; class CDRMBackend : public IBackendImplementation { diff --git a/include/aquamarine/backend/Wayland.hpp b/include/aquamarine/backend/Wayland.hpp index bdc3468..e2e1e20 100644 --- a/include/aquamarine/backend/Wayland.hpp +++ b/include/aquamarine/backend/Wayland.hpp @@ -45,7 +45,7 @@ namespace Aquamarine { virtual bool test(); virtual Hyprutils::Memory::CSharedPointer getBackend(); virtual bool setCursor(Hyprutils::Memory::CSharedPointer buffer, const Hyprutils::Math::Vector2D& hotspot); - virtual void moveCursor(const Hyprutils::Math::Vector2D& coord); + virtual void moveCursor(const Hyprutils::Math::Vector2D& coord, bool skipShedule = false); virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN); virtual Hyprutils::Math::Vector2D cursorPlaneSize(); virtual bool destroy(); diff --git a/include/aquamarine/backend/drm/Atomic.hpp b/include/aquamarine/backend/drm/Atomic.hpp index 400932a..e051e64 100644 --- a/include/aquamarine/backend/drm/Atomic.hpp +++ b/include/aquamarine/backend/drm/Atomic.hpp @@ -8,7 +8,7 @@ namespace Aquamarine { CDRMAtomicImpl(Hyprutils::Memory::CSharedPointer backend_); virtual bool commit(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data); virtual bool reset(); - virtual bool moveCursor(Hyprutils::Memory::CSharedPointer connector); + virtual bool moveCursor(Hyprutils::Memory::CSharedPointer connector, bool skipShedule = false); private: bool prepareConnector(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data); diff --git a/include/aquamarine/backend/drm/Legacy.hpp b/include/aquamarine/backend/drm/Legacy.hpp index 530dccb..12b36a0 100644 --- a/include/aquamarine/backend/drm/Legacy.hpp +++ b/include/aquamarine/backend/drm/Legacy.hpp @@ -8,12 +8,11 @@ namespace Aquamarine { CDRMLegacyImpl(Hyprutils::Memory::CSharedPointer backend_); virtual bool commit(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data); virtual bool reset(); - virtual bool moveCursor(Hyprutils::Memory::CSharedPointer connector); + virtual bool moveCursor(Hyprutils::Memory::CSharedPointer connector, bool skipShedule = false); private: - - bool commitInternal(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data); - bool testInternal(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data); + bool commitInternal(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data); + bool testInternal(Hyprutils::Memory::CSharedPointer connector, SDRMConnectorCommitData& data); Hyprutils::Memory::CWeakPointer backend; }; diff --git a/include/aquamarine/output/Output.hpp b/include/aquamarine/output/Output.hpp index 97f7932..6474516 100644 --- a/include/aquamarine/output/Output.hpp +++ b/include/aquamarine/output/Output.hpp @@ -113,6 +113,8 @@ namespace Aquamarine { AQ_SCHEDULE_NEW_MONITOR, AQ_SCHEDULE_RENDER_MONITOR, AQ_SCHEDULE_NEEDS_FRAME, + AQ_SCHEDULE_ANIMATION, + AQ_SCHEDULE_ANIMATION_DAMAGE, }; virtual bool commit() = 0; @@ -121,7 +123,7 @@ namespace Aquamarine { virtual std::vector getRenderFormats() = 0; virtual Hyprutils::Memory::CSharedPointer preferredMode(); virtual bool setCursor(Hyprutils::Memory::CSharedPointer buffer, const Hyprutils::Math::Vector2D& hotspot); - virtual void moveCursor(const Hyprutils::Math::Vector2D& coord); // includes the hotspot + virtual void moveCursor(const Hyprutils::Math::Vector2D& coord, bool skipShedule = false); // includes the hotspot virtual void setCursorVisible(bool visible); // moving the cursor will make it visible again without this util virtual Hyprutils::Math::Vector2D cursorPlaneSize(); // -1, -1 means no set size, 0, 0 means error virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN); diff --git a/src/backend/Wayland.cpp b/src/backend/Wayland.cpp index 1a50b6e..4debc1f 100644 --- a/src/backend/Wayland.cpp +++ b/src/backend/Wayland.cpp @@ -724,7 +724,7 @@ bool Aquamarine::CWaylandOutput::setCursor(Hyprutils::Memory::CSharedPointer buffer, const Vector2D& hotsp cursorVisible = true; } - needsFrame = true; scheduleFrame(AQ_SCHEDULE_CURSOR_SHAPE); return true; } -void Aquamarine::CDRMOutput::moveCursor(const Vector2D& coord) { - cursorPos = coord; - cursorVisible = true; - backend->impl->moveCursor(connector); +void Aquamarine::CDRMOutput::moveCursor(const Vector2D& coord, bool skipShedule) { + cursorPos = coord; + // cursorVisible = true; + backend->impl->moveCursor(connector, skipShedule); } void Aquamarine::CDRMOutput::scheduleFrame(const scheduleFrameReason reason) { diff --git a/src/backend/drm/impl/Atomic.cpp b/src/backend/drm/impl/Atomic.cpp index 430ee17..84efceb 100644 --- a/src/backend/drm/impl/Atomic.cpp +++ b/src/backend/drm/impl/Atomic.cpp @@ -324,12 +324,14 @@ bool Aquamarine::CDRMAtomicImpl::reset() { return request.commit(DRM_MODE_ATOMIC_ALLOW_MODESET); } -bool Aquamarine::CDRMAtomicImpl::moveCursor(SP connector) { +bool Aquamarine::CDRMAtomicImpl::moveCursor(SP connector, bool skipShedule) { if (!connector->output->cursorVisible || !connector->output->state->state().enabled || !connector->crtc || !connector->crtc->cursor) return true; - connector->output->needsFrame = true; - connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE); + if (!skipShedule) { + TRACE(connector->backend->log(AQ_LOG_TRACE, "atomic moveCursor")); + connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE); + } return true; } \ No newline at end of file diff --git a/src/backend/drm/impl/Legacy.cpp b/src/backend/drm/impl/Legacy.cpp index bb7f47e..17074b3 100644 --- a/src/backend/drm/impl/Legacy.cpp +++ b/src/backend/drm/impl/Legacy.cpp @@ -14,12 +14,12 @@ Aquamarine::CDRMLegacyImpl::CDRMLegacyImpl(Hyprutils::Memory::CSharedPointer connector) { +bool Aquamarine::CDRMLegacyImpl::moveCursor(Hyprutils::Memory::CSharedPointer connector, bool skipShedule) { if (!connector->output->cursorVisible || !connector->output->state->state().enabled || !connector->crtc || !connector->crtc->cursor) return true; - connector->output->needsFrame = true; - connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE); + if (!skipShedule) + connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE); return true; } diff --git a/src/output/Output.cpp b/src/output/Output.cpp index 20e39ce..c6d242e 100644 --- a/src/output/Output.cpp +++ b/src/output/Output.cpp @@ -11,7 +11,7 @@ Hyprutils::Memory::CSharedPointer Aquamarine::IOutput::preferredMod return nullptr; } -void Aquamarine::IOutput::moveCursor(const Hyprutils::Math::Vector2D& coord) { +void Aquamarine::IOutput::moveCursor(const Hyprutils::Math::Vector2D& coord, bool skipShedule) { ; }