From 2d7cd1c7368868fc8ff550853531df6caa090654 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Mon, 21 Oct 2024 18:46:06 +0200 Subject: [PATCH] nitpicker: fix stale pixels on view removal Sometimes when removing the popup window in Sculpt's Leitzentrale, a few residual pixels remained. This is caused by the too strict coupling of drawing and sync handling, effectively executing the fb-sync handler repeatedly via 'Main::mark_as_damaged' during 'refresh_view' calls. This tight coupling has two unwelcome effects. First, the sync handling is executed more often than needed. Second, the sync handling (and fb flushing) happens at intermediate states when view-stack changes are applied (like changing a view geometry). This patch uses a local signal handler to defer the execution of the sync code until all drawing has finished. Issue #5347 Issue #5356 --- .../os/src/server/nitpicker/capture_session.h | 3 ++- repos/os/src/server/nitpicker/main.cc | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/repos/os/src/server/nitpicker/capture_session.h b/repos/os/src/server/nitpicker/capture_session.h index 48b0e02f4d..ea6cc6765e 100644 --- a/repos/os/src/server/nitpicker/capture_session.h +++ b/repos/os/src/server/nitpicker/capture_session.h @@ -165,9 +165,10 @@ class Nitpicker::Capture_session : public Session_object void mark_as_damaged(Rect rect) { _dirty_rect.mark_as_dirty(rect); - _wakeup_if_needed(); } + void process_damage() { _wakeup_if_needed(); } + void screen_size_changed() { if (_screen_size_sigh.valid()) diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index b0de908ba5..5a5993395d 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -348,6 +348,12 @@ class Nitpicker::Capture_root : public Root_component session.mark_as_damaged(rect); }); } + void process_damage() + { + _sessions.for_each([&] (Capture_session &session) { + session.process_damage(); }); + } + void report_displays(Xml_generator &xml, Rect const domain_panorama) const { gen_attr(xml, domain_panorama); @@ -524,7 +530,10 @@ struct Nitpicker::Main : Focus_updater, Hover_updater, void mark_as_dirty(Rect rect) { _dirty_rect.mark_as_dirty(rect); + } + void process_damage() + { if (_main._now().ms - _previous_sync.ms > 40) _handle_sync(); } @@ -641,6 +650,16 @@ struct Nitpicker::Main : Focus_updater, Hover_updater, } } + Signal_handler
_damage_handler { _env.ep(), *this, &Main::_handle_damage }; + + void _handle_damage() + { + if (_fb_screen.constructed()) + _fb_screen->process_damage(); + + _capture_root.process_damage(); + } + /** * View_stack::Damage interface */ @@ -650,6 +669,8 @@ struct Nitpicker::Main : Focus_updater, Hover_updater, _fb_screen->mark_as_dirty(rect); _capture_root.mark_as_damaged(rect); + + _damage_handler.local_submit(); } void _update_input_connection()