mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
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:
parent
4775dad26c
commit
1f24eb2401
@ -162,10 +162,12 @@ class Wm::Window_registry
|
|||||||
Allocator &_alloc;
|
Allocator &_alloc;
|
||||||
Reporter &_window_list_reporter;
|
Reporter &_window_list_reporter;
|
||||||
|
|
||||||
enum { MAX_WINDOWS = 1024 };
|
static constexpr unsigned MAX_WINDOWS = 1024;
|
||||||
|
|
||||||
Genode::Bit_allocator<MAX_WINDOWS> _window_ids { };
|
Genode::Bit_allocator<MAX_WINDOWS> _window_ids { };
|
||||||
|
|
||||||
|
unsigned _next_id = 0; /* used to alloc subsequent numbers */
|
||||||
|
|
||||||
List<Window> _windows { };
|
List<Window> _windows { };
|
||||||
|
|
||||||
Window *_lookup(Id id)
|
Window *_lookup(Id id)
|
||||||
@ -213,7 +215,20 @@ class Wm::Window_registry
|
|||||||
|
|
||||||
Id create()
|
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);
|
_windows.insert(win);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user