From 3f1759a4d1a875bdd6b8dc67346bc003aa321b2c Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 16 Sep 2024 15:28:06 +0200 Subject: [PATCH] capture_session: detection of idle capture server This patch enhances the Capture::Connection::Screen such that the bounding box of the affected pixels can be tracked by the caller, which can use this information to adjust its behavior to the activity/inactivity of the capture server. Issue #5344 --- repos/os/include/capture_session/connection.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/repos/os/include/capture_session/connection.h b/repos/os/include/capture_session/connection.h index 2ae0463fb7..b97ac73e13 100644 --- a/repos/os/include/capture_session/connection.h +++ b/repos/os/include/capture_session/connection.h @@ -117,8 +117,10 @@ class Capture::Connection::Screen void with_texture(auto const &fn) const { fn(_texture); } - void apply_to_surface(Surface &surface) + Rect apply_to_surface(Surface &surface) { + Rect bounding_box { }; + using Affected_rects = Session::Affected_rects; Affected_rects const affected = _connection.capture_at(Capture::Point(0, 0)); @@ -130,8 +132,13 @@ class Capture::Connection::Screen surface.clip(rect); Blit_painter::paint(surface, texture, Capture::Point(0, 0)); + + bounding_box = bounding_box.area.count() + ? Rect::compound(bounding_box, rect) + : rect; }); }); + return bounding_box; } };