diff options
| author | Pppp1116 <pcaiadoguerreiro@gmail.com> | 2026-04-03 13:24:22 +0100 |
|---|---|---|
| committer | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2026-04-04 08:26:24 -0400 |
| commit | 0647b5449c5e5d7d314b03793232a13097fe753f (patch) | |
| tree | fc7c35b47d6d7a616eba1173d2a03fcf78eb3725 /src/protocols | |
| parent | 4c897c2d476d42c716dee254d151ff23c66ef53b (diff) | |
protocols: avoid repeated per-client work in hot paths
Diffstat (limited to 'src/protocols')
| -rw-r--r-- | src/protocols/RelativePointer.cpp | 19 | ||||
| -rw-r--r-- | src/protocols/RelativePointer.hpp | 3 | ||||
| -rw-r--r-- | src/protocols/core/Output.cpp | 14 |
3 files changed, 24 insertions, 12 deletions
diff --git a/src/protocols/RelativePointer.cpp b/src/protocols/RelativePointer.cpp index 67bff46e..39a96309 100644 --- a/src/protocols/RelativePointer.cpp +++ b/src/protocols/RelativePointer.cpp @@ -22,8 +22,12 @@ wl_client* CRelativePointer::client() { } void CRelativePointer::sendRelativeMotion(uint64_t time, const Vector2D& delta, const Vector2D& deltaUnaccel) { - m_resource->sendRelativeMotion(time >> 32, time & 0xFFFFFFFF, wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y), wl_fixed_from_double(deltaUnaccel.x), - wl_fixed_from_double(deltaUnaccel.y)); + sendRelativeMotion(time >> 32, time & 0xFFFFFFFF, wl_fixed_from_double(delta.x), wl_fixed_from_double(delta.y), wl_fixed_from_double(deltaUnaccel.x), + wl_fixed_from_double(deltaUnaccel.y)); +} + +void CRelativePointer::sendRelativeMotion(uint32_t timeHi, uint32_t timeLo, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dxUnaccel, wl_fixed_t dyUnaccel) { + m_resource->sendRelativeMotion(timeHi, timeLo, dx, dy, dxUnaccel, dyUnaccel); } CRelativePointerProtocol::CRelativePointerProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { @@ -58,16 +62,21 @@ void CRelativePointerProtocol::onGetRelativePointer(CZwpRelativePointerManagerV1 } void CRelativePointerProtocol::sendRelativeMotion(uint64_t time, const Vector2D& delta, const Vector2D& deltaUnaccel) { - if (!g_pSeatManager->m_state.pointerFocusResource) return; - const auto FOCUSED = g_pSeatManager->m_state.pointerFocusResource->client(); + const auto FOCUSED = g_pSeatManager->m_state.pointerFocusResource->client(); + const auto TIMEHI = sc<uint32_t>(time >> 32); + const auto TIMELO = sc<uint32_t>(time & 0xFFFFFFFF); + const auto DX = wl_fixed_from_double(delta.x); + const auto DY = wl_fixed_from_double(delta.y); + const auto DXUNACCEL = wl_fixed_from_double(deltaUnaccel.x); + const auto DYUNACCEL = wl_fixed_from_double(deltaUnaccel.y); for (auto const& rp : m_relativePointers) { if (FOCUSED != rp->client()) continue; - rp->sendRelativeMotion(time, delta, deltaUnaccel); + rp->sendRelativeMotion(TIMEHI, TIMELO, DX, DY, DXUNACCEL, DYUNACCEL); } } diff --git a/src/protocols/RelativePointer.hpp b/src/protocols/RelativePointer.hpp index 3d6a3e30..d422aab5 100644 --- a/src/protocols/RelativePointer.hpp +++ b/src/protocols/RelativePointer.hpp @@ -11,6 +11,7 @@ class CRelativePointer { CRelativePointer(SP<CZwpRelativePointerV1> resource_); void sendRelativeMotion(uint64_t time, const Vector2D& delta, const Vector2D& deltaUnaccel); + void sendRelativeMotion(uint32_t timeHi, uint32_t timeLo, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dxUnaccel, wl_fixed_t dyUnaccel); bool good(); wl_client* client(); @@ -42,4 +43,4 @@ class CRelativePointerProtocol : public IWaylandProtocol { namespace PROTO { inline UP<CRelativePointerProtocol> relativePointer; -};
\ No newline at end of file +}; diff --git a/src/protocols/core/Output.cpp b/src/protocols/core/Output.cpp index dd9c3166..9278eb95 100644 --- a/src/protocols/core/Output.cpp +++ b/src/protocols/core/Output.cpp @@ -30,7 +30,11 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonito updateState(); - PROTO::compositor->forEachSurface([](SP<CWLSurfaceResource> surf) { + const auto PMONITOR = m_monitor.lock(); + if (!PMONITOR) + return; + + PROTO::compositor->forEachSurface([PMONITOR](SP<CWLSurfaceResource> surf) { auto HLSurf = Desktop::View::CWLSurface::fromResource(surf); if (!HLSurf) @@ -41,12 +45,10 @@ CWLOutputResource::CWLOutputResource(SP<CWlOutput> resource_, PHLMONITOR pMonito if (!GEOMETRY.has_value()) return; - for (auto& m : g_pCompositor->m_monitors) { - if (!m->logicalBox().expand(-4).overlaps(*GEOMETRY)) - continue; + if (!PMONITOR->logicalBox().expand(-4).overlaps(*GEOMETRY)) + return; - surf->enter(m); - } + surf->enter(PMONITOR); }); } |
