output: remove redundant needsFrame, allow skip on mouse event (#21)

This commit is contained in:
UjinT34 2024-07-20 21:56:18 +03:00 committed by GitHub
parent acfea3bd1d
commit 7a84686b4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 24 additions and 23 deletions

View file

@ -194,7 +194,7 @@ namespace Aquamarine {
virtual bool test(); virtual bool test();
virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend(); virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend();
virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> buffer, const Hyprutils::Math::Vector2D& hotspot); virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> 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 scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN);
virtual void setCursorVisible(bool visible); virtual void setCursorVisible(bool visible);
virtual Hyprutils::Math::Vector2D cursorPlaneSize(); virtual Hyprutils::Math::Vector2D cursorPlaneSize();
@ -324,7 +324,7 @@ namespace Aquamarine {
virtual bool reset() = 0; virtual bool reset() = 0;
// moving a cursor IIRC is almost instant on most hardware so we don't have to wait for a commit. // 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<SDRMConnector> connector) = 0; virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, bool skipShedule = false) = 0;
}; };
class CDRMBackend : public IBackendImplementation { class CDRMBackend : public IBackendImplementation {

View file

@ -45,7 +45,7 @@ namespace Aquamarine {
virtual bool test(); virtual bool test();
virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend(); virtual Hyprutils::Memory::CSharedPointer<IBackendImplementation> getBackend();
virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> buffer, const Hyprutils::Math::Vector2D& hotspot); virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> 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 scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN);
virtual Hyprutils::Math::Vector2D cursorPlaneSize(); virtual Hyprutils::Math::Vector2D cursorPlaneSize();
virtual bool destroy(); virtual bool destroy();

View file

@ -8,7 +8,7 @@ namespace Aquamarine {
CDRMAtomicImpl(Hyprutils::Memory::CSharedPointer<CDRMBackend> backend_); CDRMAtomicImpl(Hyprutils::Memory::CSharedPointer<CDRMBackend> backend_);
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data); virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);
virtual bool reset(); virtual bool reset();
virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector); virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, bool skipShedule = false);
private: private:
bool prepareConnector(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data); bool prepareConnector(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);

View file

@ -8,12 +8,11 @@ namespace Aquamarine {
CDRMLegacyImpl(Hyprutils::Memory::CSharedPointer<CDRMBackend> backend_); CDRMLegacyImpl(Hyprutils::Memory::CSharedPointer<CDRMBackend> backend_);
virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data); virtual bool commit(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);
virtual bool reset(); virtual bool reset();
virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector); virtual bool moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, bool skipShedule = false);
private: private:
bool commitInternal(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);
bool commitInternal(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data); bool testInternal(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);
bool testInternal(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, SDRMConnectorCommitData& data);
Hyprutils::Memory::CWeakPointer<CDRMBackend> backend; Hyprutils::Memory::CWeakPointer<CDRMBackend> backend;
}; };

View file

@ -113,6 +113,8 @@ namespace Aquamarine {
AQ_SCHEDULE_NEW_MONITOR, AQ_SCHEDULE_NEW_MONITOR,
AQ_SCHEDULE_RENDER_MONITOR, AQ_SCHEDULE_RENDER_MONITOR,
AQ_SCHEDULE_NEEDS_FRAME, AQ_SCHEDULE_NEEDS_FRAME,
AQ_SCHEDULE_ANIMATION,
AQ_SCHEDULE_ANIMATION_DAMAGE,
}; };
virtual bool commit() = 0; virtual bool commit() = 0;
@ -121,7 +123,7 @@ namespace Aquamarine {
virtual std::vector<SDRMFormat> getRenderFormats() = 0; virtual std::vector<SDRMFormat> getRenderFormats() = 0;
virtual Hyprutils::Memory::CSharedPointer<SOutputMode> preferredMode(); virtual Hyprutils::Memory::CSharedPointer<SOutputMode> preferredMode();
virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> buffer, const Hyprutils::Math::Vector2D& hotspot); virtual bool setCursor(Hyprutils::Memory::CSharedPointer<IBuffer> 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 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 Hyprutils::Math::Vector2D cursorPlaneSize(); // -1, -1 means no set size, 0, 0 means error
virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN); virtual void scheduleFrame(const scheduleFrameReason reason = AQ_SCHEDULE_UNKNOWN);

View file

@ -724,7 +724,7 @@ bool Aquamarine::CWaylandOutput::setCursor(Hyprutils::Memory::CSharedPointer<IBu
return true; return true;
} }
void Aquamarine::CWaylandOutput::moveCursor(const Hyprutils::Math::Vector2D& coord) { void Aquamarine::CWaylandOutput::moveCursor(const Hyprutils::Math::Vector2D& coord, bool skipShedule) {
return; return;
} }

View file

@ -1289,7 +1289,6 @@ bool Aquamarine::CDRMOutput::test() {
void Aquamarine::CDRMOutput::setCursorVisible(bool visible) { void Aquamarine::CDRMOutput::setCursorVisible(bool visible) {
cursorVisible = visible; cursorVisible = visible;
needsFrame = true;
scheduleFrame(AQ_SCHEDULE_CURSOR_VISIBLE); scheduleFrame(AQ_SCHEDULE_CURSOR_VISIBLE);
} }
@ -1552,15 +1551,14 @@ bool Aquamarine::CDRMOutput::setCursor(SP<IBuffer> buffer, const Vector2D& hotsp
cursorVisible = true; cursorVisible = true;
} }
needsFrame = true;
scheduleFrame(AQ_SCHEDULE_CURSOR_SHAPE); scheduleFrame(AQ_SCHEDULE_CURSOR_SHAPE);
return true; return true;
} }
void Aquamarine::CDRMOutput::moveCursor(const Vector2D& coord) { void Aquamarine::CDRMOutput::moveCursor(const Vector2D& coord, bool skipShedule) {
cursorPos = coord; cursorPos = coord;
cursorVisible = true; // cursorVisible = true;
backend->impl->moveCursor(connector); backend->impl->moveCursor(connector, skipShedule);
} }
void Aquamarine::CDRMOutput::scheduleFrame(const scheduleFrameReason reason) { void Aquamarine::CDRMOutput::scheduleFrame(const scheduleFrameReason reason) {

View file

@ -324,12 +324,14 @@ bool Aquamarine::CDRMAtomicImpl::reset() {
return request.commit(DRM_MODE_ATOMIC_ALLOW_MODESET); return request.commit(DRM_MODE_ATOMIC_ALLOW_MODESET);
} }
bool Aquamarine::CDRMAtomicImpl::moveCursor(SP<SDRMConnector> connector) { bool Aquamarine::CDRMAtomicImpl::moveCursor(SP<SDRMConnector> connector, bool skipShedule) {
if (!connector->output->cursorVisible || !connector->output->state->state().enabled || !connector->crtc || !connector->crtc->cursor) if (!connector->output->cursorVisible || !connector->output->state->state().enabled || !connector->crtc || !connector->crtc->cursor)
return true; return true;
connector->output->needsFrame = true; if (!skipShedule) {
connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE); TRACE(connector->backend->log(AQ_LOG_TRACE, "atomic moveCursor"));
connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE);
}
return true; return true;
} }

View file

@ -14,12 +14,12 @@ Aquamarine::CDRMLegacyImpl::CDRMLegacyImpl(Hyprutils::Memory::CSharedPointer<CDR
; ;
} }
bool Aquamarine::CDRMLegacyImpl::moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector) { bool Aquamarine::CDRMLegacyImpl::moveCursor(Hyprutils::Memory::CSharedPointer<SDRMConnector> connector, bool skipShedule) {
if (!connector->output->cursorVisible || !connector->output->state->state().enabled || !connector->crtc || !connector->crtc->cursor) if (!connector->output->cursorVisible || !connector->output->state->state().enabled || !connector->crtc || !connector->crtc->cursor)
return true; return true;
connector->output->needsFrame = true; if (!skipShedule)
connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE); connector->output->scheduleFrame(IOutput::AQ_SCHEDULE_CURSOR_MOVE);
return true; return true;
} }

View file

@ -11,7 +11,7 @@ Hyprutils::Memory::CSharedPointer<SOutputMode> Aquamarine::IOutput::preferredMod
return nullptr; return nullptr;
} }
void Aquamarine::IOutput::moveCursor(const Hyprutils::Math::Vector2D& coord) { void Aquamarine::IOutput::moveCursor(const Hyprutils::Math::Vector2D& coord, bool skipShedule) {
; ;
} }