| Index: ui/wm/core/window_modality_controller.cc
|
| diff --git a/ui/wm/core/window_modality_controller.cc b/ui/wm/core/window_modality_controller.cc
|
| index 094acc49189b86f2d21d4dbade56e7b8b7e1486d..51bd566b4f8c8758c5b8b5ed645364b187fa3444 100644
|
| --- a/ui/wm/core/window_modality_controller.cc
|
| +++ b/ui/wm/core/window_modality_controller.cc
|
| @@ -23,6 +23,8 @@
|
|
|
| namespace wm {
|
|
|
| +const char kAllowTransientParentEventsKey[] = "__ALLOW_PARENT_EVENTS__";
|
| +
|
| // Transient child's modal parent.
|
| extern const aura::WindowProperty<aura::Window*>* const kModalParentKey;
|
| DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kModalParentKey, NULL);
|
| @@ -54,11 +56,21 @@ aura::Window* GetModalParent(aura::Window* window) {
|
| }
|
|
|
| bool IsModalTransientChild(aura::Window* transient, aura::Window* original) {
|
| + return (transient->IsVisible() &&
|
| + ((TransientChildIsWindowModal(transient) &&
|
| + !transient->GetNativeWindowProperty(kAllowTransientParentEventsKey))
|
| + || TransientChildIsSystemModal(transient)
|
| + || ((TransientChildIsChildModal(transient) ||
|
| + transient->GetNativeWindowProperty(kAllowTransientParentEventsKey))
|
| + && (HasAncestor(original, GetModalParent(transient))))));
|
| +}
|
| +
|
| +bool IsModalTransientChildOld(aura::Window* transient, aura::Window* original) {
|
| return transient->IsVisible() &&
|
| - (TransientChildIsWindowModal(transient) ||
|
| - TransientChildIsSystemModal(transient) ||
|
| - (TransientChildIsChildModal(transient) &&
|
| - (HasAncestor(original, GetModalParent(transient)))));
|
| + (TransientChildIsWindowModal(transient) ||
|
| + TransientChildIsSystemModal(transient) ||
|
| + (TransientChildIsChildModal(transient) &&
|
| + (HasAncestor(original, GetModalParent(transient)))));
|
| }
|
|
|
| aura::Window* GetModalTransientChild(
|
| @@ -80,6 +92,26 @@ aura::Window* GetModalTransientChild(
|
| return NULL;
|
| }
|
|
|
| +aura::Window* GetModalTransientChildOld(
|
| + aura::Window* activatable,
|
| + aura::Window* original) {
|
| + for (aura::Window::Windows::const_iterator it =
|
| + GetTransientChildren(activatable).begin();
|
| + it != GetTransientChildren(activatable).end();
|
| + ++it) {
|
| + aura::Window* transient = *it;
|
| + if (IsModalTransientChildOld(transient, original)) {
|
| + if (GetTransientChildren(transient).empty())
|
| + return transient;
|
| +
|
| + aura::Window* modal_child =
|
| + GetModalTransientChildOld(transient, original);
|
| + return modal_child ? modal_child : transient;
|
| + }
|
| + }
|
| + return NULL;
|
| +}
|
| +
|
| } // namespace
|
|
|
| void SetModalParent(aura::Window* child, aura::Window* parent) {
|
| @@ -98,6 +130,17 @@ aura::Window* GetModalTransient(aura::Window* window) {
|
| return GetModalTransientChild(toplevel, window);
|
| }
|
|
|
| +aura::Window* HasWindowModalTransient(aura::Window* window) {
|
| + if (!window)
|
| + return NULL;
|
| +
|
| + aura::Window* toplevel = GetToplevelWindow(window);
|
| + if (!toplevel)
|
| + return NULL;
|
| +
|
| + return GetModalTransientChildOld(toplevel, window);
|
| +}
|
| +
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // WindowModalityController, public:
|
|
|
| @@ -128,7 +171,7 @@ void WindowModalityController::OnKeyEvent(ui::KeyEvent* event) {
|
| void WindowModalityController::OnMouseEvent(ui::MouseEvent* event) {
|
| aura::Window* target = static_cast<aura::Window*>(event->target());
|
| if (ProcessLocatedEvent(target, event))
|
| - event->SetHandled();
|
| + event->SetHandled();
|
| }
|
|
|
| void WindowModalityController::OnTouchEvent(ui::TouchEvent* event) {
|
| @@ -172,8 +215,11 @@ void WindowModalityController::OnWindowVisibilityChanged(
|
| aura::Window* capture_window = aura::client::GetCaptureWindow(window);
|
| if (capture_window) {
|
| bool should_release_capture = true;
|
| - if (window->GetProperty(aura::client::kModalKey) ==
|
| - ui::MODAL_TYPE_CHILD &&
|
| + if (((window->GetProperty(aura::client::kModalKey) ==
|
| + ui::MODAL_TYPE_CHILD) ||
|
| + (window->GetProperty(aura::client::kModalKey) ==
|
| + ui::MODAL_TYPE_WINDOW &&
|
| + window->GetNativeWindowProperty(kAllowTransientParentEventsKey))) &&
|
| !HasAncestor(capture_window, GetModalParent(window))) {
|
| // For child modal windows we only need ensure capture is not on a
|
| // descendant of the modal parent. This way we block events to the
|
| @@ -200,7 +246,9 @@ bool WindowModalityController::ProcessLocatedEvent(aura::Window* target,
|
| if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED ||
|
| event->type() == ui::ET_TOUCH_PRESSED)) {
|
| // Activate top window if transient child window is window modal.
|
| - if (TransientChildIsWindowModal(modal_transient_child)) {
|
| + if (TransientChildIsWindowModal(modal_transient_child) &&
|
| + !modal_transient_child->GetNativeWindowProperty(
|
| + kAllowTransientParentEventsKey)) {
|
| aura::Window* toplevel = GetToplevelWindow(target);
|
| DCHECK(toplevel);
|
| ActivateWindow(toplevel);
|
|
|