| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/wm/core/window_modality_controller.h" | 5 #include "ui/wm/core/window_modality_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 12 #include "ui/aura/client/capture_client.h" | 12 #include "ui/aura/client/capture_client.h" |
| 13 #include "ui/aura/env.h" | 13 #include "ui/aura/env.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/aura/window_property.h" | 16 #include "ui/aura/window_property.h" |
| 17 #include "ui/base/ui_base_types.h" | 17 #include "ui/base/ui_base_types.h" |
| 18 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 19 #include "ui/events/event_target.h" | 19 #include "ui/events/event_target.h" |
| 20 #include "ui/events/gestures/gesture_recognizer.h" | 20 #include "ui/events/gestures/gesture_recognizer.h" |
| 21 #include "ui/wm/core/window_animations.h" | 21 #include "ui/wm/core/window_animations.h" |
| 22 #include "ui/wm/core/window_util.h" | 22 #include "ui/wm/core/window_util.h" |
| 23 | 23 |
| 24 namespace wm { | 24 namespace wm { |
| 25 // const char kHasIndependentBoundsKey[] = "INDEPENDENT_BOUNDS"; |
| 25 | 26 |
| 26 // Transient child's modal parent. | 27 // Transient child's modal parent. |
| 27 extern const aura::WindowProperty<aura::Window*>* const kModalParentKey; | 28 extern const aura::WindowProperty<aura::Window*>* const kModalParentKey; |
| 28 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kModalParentKey, NULL); | 29 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kModalParentKey, NULL); |
| 29 | |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 bool HasAncestor(aura::Window* window, aura::Window* ancestor) { | 32 bool HasAncestor(aura::Window* window, aura::Window* ancestor) { |
| 33 if (!window) | 33 if (!window) |
| 34 return false; | 34 return false; |
| 35 if (window == ancestor) | 35 if (window == ancestor) |
| 36 return true; | 36 return true; |
| 37 return HasAncestor(window->parent(), ancestor); | 37 return HasAncestor(window->parent(), ancestor); |
| 38 } | 38 } |
| 39 | 39 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 aura::Window* modal_child = GetModalTransientChild(transient, original); | 76 aura::Window* modal_child = GetModalTransientChild(transient, original); |
| 77 return modal_child ? modal_child : transient; | 77 return modal_child ? modal_child : transient; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 return NULL; | 80 return NULL; |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace | 83 } // namespace |
| 84 | 84 |
| 85 void SetModalParent(aura::Window* child, aura::Window* parent) { | 85 void SetModalParent(aura::Window* child, aura::Window* parent, |
| 86 bool* independent, const char * kHasIndependentBoundsKey) { |
| 86 child->SetProperty(kModalParentKey, parent); | 87 child->SetProperty(kModalParentKey, parent); |
| 88 if (kHasIndependentBoundsKey) |
| 89 child->SetNativeWindowProperty(kHasIndependentBoundsKey, independent); |
| 87 } | 90 } |
| 88 | 91 |
| 89 aura::Window* GetModalTransient(aura::Window* window) { | 92 aura::Window* GetModalTransient(aura::Window* window) { |
| 90 if (!window) | 93 if (!window) |
| 91 return NULL; | 94 return NULL; |
| 92 | 95 |
| 93 // We always want to check the for the transient child of the toplevel window. | 96 // We always want to check the for the transient child of the toplevel window. |
| 94 aura::Window* toplevel = GetToplevelWindow(window); | 97 aura::Window* toplevel = GetToplevelWindow(window); |
| 95 if (!toplevel) | 98 if (!toplevel) |
| 96 return NULL; | 99 return NULL; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 210 } |
| 208 | 211 |
| 209 AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE); | 212 AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE); |
| 210 } | 213 } |
| 211 if (event->type() == ui::ET_TOUCH_CANCELLED) | 214 if (event->type() == ui::ET_TOUCH_CANCELLED) |
| 212 return false; | 215 return false; |
| 213 return !!modal_transient_child; | 216 return !!modal_transient_child; |
| 214 } | 217 } |
| 215 | 218 |
| 216 } // namespace wm | 219 } // namespace wm |
| OLD | NEW |