From 1104e4fd95c56fc5be81ed6a13f2a2f6e3002969 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Fri, 14 Aug 2020 10:25:05 +0300
Subject: [PATCH] Fixes for screen touching

---
 .../src/sources/screencapture/screencapture.cpp             | 4 ++--
 components/streams/src/renderers/collisions.cpp             | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp
index 87b34497b..ab3465af1 100644
--- a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp
+++ b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp
@@ -233,7 +233,7 @@ void ScreenCapture::_release() {
 	pressed_ = false;
 	#ifdef HAVE_X11
 	auto &s = *impl_state_;
-	//XTestFakeButtonEvent (s.display, Button1, False, CurrentTime);
+	XTestFakeButtonEvent (s.display, Button1, False, CurrentTime);
 	#endif
 }
 
@@ -241,7 +241,7 @@ void ScreenCapture::_press() {
 	pressed_ = true;
 	#ifdef HAVE_X11
 	auto &s = *impl_state_;
-	//XTestFakeButtonEvent (s.display, Button1, True, CurrentTime);
+	XTestFakeButtonEvent (s.display, Button1, True, CurrentTime);
 	#endif
 
 	LOG(INFO) << "PRESS";
diff --git a/components/streams/src/renderers/collisions.cpp b/components/streams/src/renderers/collisions.cpp
index ddb5c2d5b..aedd31c2e 100644
--- a/components/streams/src/renderers/collisions.cpp
+++ b/components/streams/src/renderers/collisions.cpp
@@ -47,7 +47,11 @@ void ftl::render::collision2touch(const ftl::rgbd::Frame &rgbdframe,
 						const auto &rgbdf = f.cast<ftl::rgbd::Frame>();
 
 						// TODO: Use Eigen directly.
-						auto pose = MatrixConversion::toCUDA((rgbdf.getPose().inverse() * rgbdframe.getPose()).cast<float>());
+						auto fpose = rgbdf.getPose();
+						if (s->hasChannel(Channel::Pose)) {
+							fpose = s->cast<ftl::rgbd::Frame>().getPose() * fpose;
+						}
+						auto pose = MatrixConversion::toCUDA((fpose.inverse() * rgbdframe.getPose()).cast<float>());
 						float3 campos = pose * rgbdframe.getLeft().screenToCam(clusters[0].x, clusters[0].y, clusters[0].z);
 						const auto &cam = rgbdf.getLeft();
 						int2 pt = cam.camToScreen<int2>(campos);
-- 
GitLab