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

WindowServer: Fixes for modal windows

This fixes a few problems with modal windows:

* If any child window, or any child window further down the
  tree is considered modal, then all windows in that chain
  are modal.
* When trying to activate a window blocked by a modal child
  bring the entire stack of modal windows to the front and
  activate the modal window.
* A window is modal if it has a parent and it's flagged as
  modal, regardless of whether the ClientConnection has
  created modal windows.

This technically supports diverging modal window trees as well,
where two modal windows share the same parent, allowing both to
be activated (including for input) but not the parent. And it
should also support modal window stacks of arbitrary depth.
This commit is contained in:
Tom 2020-07-15 14:21:42 -06:00 committed by Andreas Kling
parent a038f82326
commit 862ab82c19
6 changed files with 63 additions and 42 deletions

View file

@ -387,16 +387,20 @@ bool Window::is_active() const
return WindowManager::the().active_window() == this;
}
bool Window::is_blocked_by_modal_window() const
Window* Window::is_blocked_by_modal_window()
{
bool is_any_modal = false;
const Window* next = this;
while (!is_any_modal && next) {
is_any_modal = next->is_modal();
next = next->parent_window();
// A window is blocked if any immediate child, or any child further
// down the chain is modal
for (auto& window: m_child_windows) {
if (window) {
if (window->is_modal())
return window;
if (auto* blocking_modal_window = window->is_blocked_by_modal_window())
return blocking_modal_window;
}
}
return !is_any_modal && client() && client()->is_showing_modal_window();
return nullptr;
}
void Window::set_default_icon()