From 010847b69ce62295e447d3c24c83f71942ae8c38 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 3 Dec 2024 12:48:47 +0100 Subject: [PATCH] decorator: fix sync-handling corner case This patch fixes the corner case where a call of 'trigger_gui_sync' unexpectedly did not result in the execution of '_handle_gui_sync'. When sporadically called (w/o having installed a period sync handler) in a time window shortly after a previous '_handle_gui_sync' that just switched back to sporadic mode, the situation was considered as !idle. So the 'local_submit' was skipped. The patch fixes the issue by always issuing a 'local_submit' except when operating in period mode. The '_gui_sync_enabled' state is now driven only by '_handle_gui_sync' to make the intent more clear. Fixes #5396 --- repos/gems/src/app/decorator/main.cc | 22 +++++++++++---------- repos/gems/src/app/themed_decorator/main.cc | 22 +++++++++++---------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/repos/gems/src/app/decorator/main.cc b/repos/gems/src/app/decorator/main.cc index 0013a91c66..7ec8beca58 100644 --- a/repos/gems/src/app/decorator/main.cc +++ b/repos/gems/src/app/decorator/main.cc @@ -166,12 +166,7 @@ struct Decorator::Main : Window_factory_base Ticks const now = _now(); bool const idle = now.cs - _previous_sync.cs > 3; - if (!_gui_sync_enabled) { - _gui.framebuffer.sync_sigh(_gui_sync_handler); - _gui_sync_enabled = true; - } - - if (idle) { + if (!_gui_sync_enabled || idle) { _previous_sync = now; _gui_sync_handler.local_submit(); } @@ -358,11 +353,18 @@ void Decorator::Main::_handle_gui_sync() } /* - * Disable sync handling when becoming idle + * Enable/disable periodic sync depending on animation state */ - if (!_animator.active()) { - _gui.framebuffer.sync_sigh(Signal_context_capability()); - _gui_sync_enabled = false; + if (_gui_sync_enabled) { + if (!_animator.active()) { + _gui.framebuffer.sync_sigh(Signal_context_capability()); + _gui_sync_enabled = false; + } + } else { + if (_animator.active()) { + _gui.framebuffer.sync_sigh(_gui_sync_handler); + _gui_sync_enabled = true; + } } _previous_sync = now; diff --git a/repos/gems/src/app/themed_decorator/main.cc b/repos/gems/src/app/themed_decorator/main.cc index 5bcbe84687..edf44d3bca 100644 --- a/repos/gems/src/app/themed_decorator/main.cc +++ b/repos/gems/src/app/themed_decorator/main.cc @@ -107,12 +107,7 @@ struct Decorator::Main : Window_factory_base Ticks const now = _now(); bool const idle = now.cs - _previous_sync.cs > 3; - if (!_gui_sync_enabled) { - _gui.framebuffer.sync_sigh(_gui_sync_handler); - _gui_sync_enabled = true; - } - - if (idle) { + if (!_gui_sync_enabled || idle) { _previous_sync = now; _gui_sync_handler.local_submit(); } @@ -308,11 +303,18 @@ void Decorator::Main::_handle_gui_sync() } /* - * Disable sync handling when becoming idle + * Enable/disable periodic sync depending on animation state */ - if (!_animator.active()) { - _gui.framebuffer.sync_sigh(Signal_context_capability()); - _gui_sync_enabled = false; + if (_gui_sync_enabled) { + if (!_animator.active()) { + _gui.framebuffer.sync_sigh(Signal_context_capability()); + _gui_sync_enabled = false; + } + } else { + if (_animator.active()) { + _gui.framebuffer.sync_sigh(_gui_sync_handler); + _gui_sync_enabled = true; + } } _previous_sync = now;