| Index: components/mus/ws/server_window.cc
|
| diff --git a/components/mus/ws/server_window.cc b/components/mus/ws/server_window.cc
|
| index 51d4faecdc18f253231133bb4d9ebf5e2d4c7ef4..eeb5d7d44929e0275c949faff176438dcd2b5b56 100644
|
| --- a/components/mus/ws/server_window.cc
|
| +++ b/components/mus/ws/server_window.cc
|
| @@ -17,6 +17,28 @@
|
| namespace mus {
|
|
|
| namespace ws {
|
| +
|
| +namespace {
|
| +
|
| +const ServerWindow* GetModalChildForWindowAncestor(const ServerWindow* window) {
|
| + for (const ServerWindow* ancestor = window; ancestor;
|
| + ancestor = ancestor->parent()) {
|
| + for (const auto& transient_child : ancestor->transient_children()) {
|
| + if (transient_child->is_modal() && transient_child->IsDrawn())
|
| + return transient_child;
|
| + }
|
| + }
|
| + return nullptr;
|
| +}
|
| +
|
| +const ServerWindow* GetModalTargetForWindow(const ServerWindow* window) {
|
| + const ServerWindow* modal_window = GetModalChildForWindowAncestor(window);
|
| + if (!modal_window)
|
| + return window;
|
| + return GetModalTargetForWindow(modal_window);
|
| +}
|
| +
|
| +} // namespace
|
|
|
| ServerWindow::ServerWindow(ServerWindowDelegate* delegate, const WindowId& id)
|
| : ServerWindow(delegate, id, Properties()) {}
|
| @@ -206,11 +228,7 @@
|
| return nullptr;
|
| }
|
|
|
| -bool ServerWindow::AddTransientWindow(ServerWindow* child) {
|
| - // A system modal window cannot become a transient child.
|
| - if (child->is_modal() && !child->transient_parent())
|
| - return false;
|
| -
|
| +void ServerWindow::AddTransientWindow(ServerWindow* child) {
|
| if (child->transient_parent())
|
| child->transient_parent()->RemoveTransientWindow(child);
|
|
|
| @@ -226,7 +244,6 @@
|
|
|
| FOR_EACH_OBSERVER(ServerWindowObserver, observers_,
|
| OnTransientWindowAdded(this, child));
|
| - return true;
|
| }
|
|
|
| void ServerWindow::RemoveTransientWindow(ServerWindow* child) {
|
| @@ -249,6 +266,14 @@
|
|
|
| void ServerWindow::SetModal() {
|
| is_modal_ = true;
|
| +}
|
| +
|
| +bool ServerWindow::IsBlockedByModalWindow() const {
|
| + return !!GetModalChildForWindowAncestor(this);
|
| +}
|
| +
|
| +const ServerWindow* ServerWindow::GetModalTarget() const {
|
| + return GetModalTargetForWindow(this);
|
| }
|
|
|
| bool ServerWindow::Contains(const ServerWindow* window) const {
|
|
|