From 49967afc51d415d717096251fa7f548b84d04cda Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Sat, 11 Jul 2020 14:41:57 +0300
Subject: [PATCH] Fix data not cleared bug in frame

---
 .../sources/screencapture/screencapture.cpp   | 23 +++++--------------
 components/structures/src/new_frame.cpp       |  4 ++--
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp
index 4f59d7e38..6ade3f14e 100644
--- a/components/rgbd-sources/src/sources/screencapture/screencapture.cpp
+++ b/components/rgbd-sources/src/sources/screencapture/screencapture.cpp
@@ -203,23 +203,11 @@ void ScreenCapture::_mouseClick(int button, int x, int y) {
 
 	auto &s = *impl_state_;
 
-	//ftl::pool.push([this,x,y](int id) {
-		//auto &s = *impl_state_;
+	XTestFakeMotionEvent (s.display, 0, x, y, CurrentTime);
+	XSync(s.display, 0);
 
-		//std::this_thread::sleep_for(std::chrono::milliseconds(100));
-
-		XTestFakeMotionEvent (s.display, 0, x, y, CurrentTime);
-		XSync(s.display, 0);
-
-		//std::this_thread::sleep_for(std::chrono::milliseconds(100));
-		//XTestFakeButtonEvent (s.display, Button1, False, CurrentTime);
-		//XSync(s.display, 0);
-
-		XTestFakeButtonEvent (s.display, Button1, True,  CurrentTime);
-		//XSync(s.display, 0);
-		XTestFakeButtonEvent (s.display, Button1, False, CurrentTime);
-		//XSync(s.display, 0);
-	//});
+	XTestFakeButtonEvent (s.display, Button1, True,  CurrentTime);
+	XTestFakeButtonEvent (s.display, Button1, False, CurrentTime);
 
 	#endif
 }
@@ -230,8 +218,9 @@ bool ScreenCapture::retrieve(ftl::rgbd::Frame &frame) {
 
 	if (host_->value("enable_touch", false)) {
 		if (frame.changed(Channel::Touch)) {
-			LOG(INFO) << "GOT TOUCH DATA";
 			const auto &touches = frame.get<std::vector<ftl::codecs::Touch>>(Channel::Touch);
+			LOG(INFO) << "GOT TOUCH DATA " << touches.size();
+
 			for (const auto &t : touches) {
 				LOG(INFO) << " -- " << t.x << "," << t.y;
 			}
diff --git a/components/structures/src/new_frame.cpp b/components/structures/src/new_frame.cpp
index 46df69496..88619e19e 100644
--- a/components/structures/src/new_frame.cpp
+++ b/components/structures/src/new_frame.cpp
@@ -365,8 +365,8 @@ void Frame::reset() {
 		d.second.status = ChannelStatus::INVALID;
 		d.second.encoded.clear();
 
-		// Note: Aggregate channels cannot memory pool and must be cleared.
-		if (ftl::data::isAggregate(d.first)) d.second.data.reset();
+		// Note: Data channels should be cleared
+		if ((int)d.first >= 32) d.second.data.reset();
 	}
 	changed_.clear();
 	status_ = FrameStatus::CREATED;
-- 
GitLab