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
This commit is contained in:
Norman Feske 2024-12-03 12:48:47 +01:00 committed by Christian Helmuth
parent 96d9f5d317
commit 010847b69c
2 changed files with 24 additions and 20 deletions

View File

@ -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;

View File

@ -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;