mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-08 12:58:03 +02:00
protocols: avoid repeated per-client work in hot paths
This commit is contained in:
parent
4c897c2d47
commit
0647b5449c
3 changed files with 24 additions and 12 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue