wm: avoid eager reuse of window IDs

The existing allocation scheme of window IDs has the unwelcome effect
that a re-appearing window would not always result in a visible change
of the window list. In such cases, the layouter and decorator would not
be prompted to do their job. This effect could be observered with the
multi-dialog version of menu view in Sculpt OS when manually enforcing
the restart of the runtime_view. Sometimes the panel would not re-appear
after the restart.

This patch changes the allocation of window ID such that new windows get
fresh IDs instead of reusing an ID of a recently disappeared window.

Issue #5170
This commit is contained in:
Norman Feske 2024-04-04 11:58:55 +02:00 committed by Christian Helmuth
parent 4775dad26c
commit 1f24eb2401

View File

@ -162,10 +162,12 @@ class Wm::Window_registry
Allocator &_alloc;
Reporter &_window_list_reporter;
enum { MAX_WINDOWS = 1024 };
static constexpr unsigned MAX_WINDOWS = 1024;
Genode::Bit_allocator<MAX_WINDOWS> _window_ids { };
unsigned _next_id = 0; /* used to alloc subsequent numbers */
List<Window> _windows { };
Window *_lookup(Id id)
@ -213,7 +215,20 @@ class Wm::Window_registry
Id create()
{
Window * const win = new (_alloc) Window((unsigned)_window_ids.alloc());
auto alloc_id = [&]
{
for (;;) {
unsigned try_id = _next_id;
_next_id = (_next_id + 1) % MAX_WINDOWS;
try {
_window_ids.alloc_addr(try_id);
return try_id;
}
catch (...) { }
}
};
Window * const win = new (_alloc) Window(alloc_id());
_windows.insert(win);