From 77b134e23baf769aecdf2ea8ed14d55d00228ce1 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 22 Jul 2024 17:24:24 +0200 Subject: [PATCH] virtual-pointer: fixup virtual pointer warp events fixes #6976 --- src/devices/VirtualPointer.cpp | 7 ++++++- src/managers/PointerManager.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/devices/VirtualPointer.cpp b/src/devices/VirtualPointer.cpp index faca27dc..f9a1c409 100644 --- a/src/devices/VirtualPointer.cpp +++ b/src/devices/VirtualPointer.cpp @@ -20,7 +20,12 @@ CVirtualPointer::CVirtualPointer(SP resource) : point }); listeners.motion = pointer->events.move.registerListener([this](std::any d) { pointerEvents.motion.emit(d); }); - listeners.motionAbsolute = pointer->events.warp.registerListener([this](std::any d) { pointerEvents.motionAbsolute.emit(d); }); + listeners.motionAbsolute = pointer->events.warp.registerListener([this](std::any d) { + // we need to unpack the event and add our device here because it's required to calculate the position correctly + auto E = std::any_cast(d); + E.device = self.lock(); + pointerEvents.motionAbsolute.emit(E); + }); listeners.button = pointer->events.button.registerListener([this](std::any d) { pointerEvents.button.emit(d); }); listeners.axis = pointer->events.axis.registerListener([this](std::any d) { pointerEvents.axis.emit(d); }); listeners.frame = pointer->events.frame.registerListener([this](std::any d) { pointerEvents.frame.emit(); }); diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index cf10db71..b1542fed 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -620,7 +620,7 @@ void CPointerManager::move(const Vector2D& deltaLogical) { void CPointerManager::warpAbsolute(Vector2D abs, SP dev) { SP currentMonitor = g_pCompositor->m_pLastMonitor.lock(); - if (!currentMonitor) + if (!currentMonitor || !dev) return; if (!std::isnan(abs.x))