1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:27:35 +00:00

WindowServer: Remove misbehavior conditions for modals

This was too restrictive and there are already UI elements that rely
on this behavior. Now Blocking modals will preempt interaction with
all windows in their modal chain except those descending from them.
Fixes crashing in FilePicker when permission is denied.
This commit is contained in:
thankyouverycool 2022-08-27 16:48:11 -04:00 committed by Linus Groh
parent b2b68a7551
commit 1dd9086e1a
5 changed files with 14 additions and 18 deletions

View file

@ -241,24 +241,24 @@ public:
template<typename Callback>
Window* for_each_window_in_modal_chain(Window& window, Callback callback)
{
Window* maybe_break = nullptr;
Function<Window*(Window&)> recurse = [&](Window& w) -> Window* {
if (!w.is_modal()) {
auto decision = callback(w);
if (decision == IterationDecision::Break)
return maybe_break = &w;
return &w;
}
for (auto& child : w.child_windows()) {
if (!child || child->is_destroyed() || !child->is_modal())
continue;
auto decision = callback(*child);
if (auto* result = recurse(*child))
return result;
if (decision == IterationDecision::Break)
return maybe_break = child;
recurse(*child);
return child;
}
return maybe_break;
return nullptr;
};
if (auto* modeless = window.modeless_ancestor(); modeless)
if (auto* modeless = window.modeless_ancestor())
return recurse(*modeless);
return nullptr;
}