| 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/views/corewm/window_modality_controller.h" | 5 #include "ui/views/corewm/window_modality_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/capture_client.h" | 10 #include "ui/aura/client/capture_client.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return ProcessLocatedEvent(target, event) ? ui::ER_CONSUMED : | 113 return ProcessLocatedEvent(target, event) ? ui::ER_CONSUMED : |
| 114 ui::ER_UNHANDLED; | 114 ui::ER_UNHANDLED; |
| 115 } | 115 } |
| 116 | 116 |
| 117 ui::EventResult WindowModalityController::OnTouchEvent(ui::TouchEvent* event) { | 117 ui::EventResult WindowModalityController::OnTouchEvent(ui::TouchEvent* event) { |
| 118 aura::Window* target = static_cast<aura::Window*>(event->target()); | 118 aura::Window* target = static_cast<aura::Window*>(event->target()); |
| 119 return ProcessLocatedEvent(target, event) ? ui::ER_CONSUMED : | 119 return ProcessLocatedEvent(target, event) ? ui::ER_CONSUMED : |
| 120 ui::ER_UNHANDLED; | 120 ui::ER_UNHANDLED; |
| 121 } | 121 } |
| 122 | 122 |
| 123 //////////////////////////////////////////////////////////////////////////////// |
| 124 // WindowModalityController, aura::EnvObserver implementation: |
| 125 |
| 123 void WindowModalityController::OnWindowInitialized(aura::Window* window) { | 126 void WindowModalityController::OnWindowInitialized(aura::Window* window) { |
| 124 windows_.push_back(window); | 127 windows_.push_back(window); |
| 125 window->AddObserver(this); | 128 window->AddObserver(this); |
| 126 } | 129 } |
| 127 | 130 |
| 131 //////////////////////////////////////////////////////////////////////////////// |
| 132 // WindowModalityController, aura::WindowObserver implementation: |
| 133 |
| 134 void WindowModalityController::OnWindowPropertyChanged(aura::Window* window, |
| 135 const void* key, |
| 136 intptr_t old) { |
| 137 // In tests, we sometimes create the modality relationship after a window is |
| 138 // visible. |
| 139 if (key == aura::client::kModalKey && |
| 140 window->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE && |
| 141 window->IsVisible()) { |
| 142 ActivateWindow(window); |
| 143 } |
| 144 } |
| 145 |
| 128 void WindowModalityController::OnWindowVisibilityChanged( | 146 void WindowModalityController::OnWindowVisibilityChanged( |
| 129 aura::Window* window, | 147 aura::Window* window, |
| 130 bool visible) { | 148 bool visible) { |
| 131 if (visible && window->GetProperty(aura::client::kModalKey) == | 149 if (visible && window->GetProperty(aura::client::kModalKey) == |
| 132 ui::MODAL_TYPE_WINDOW) { | 150 ui::MODAL_TYPE_WINDOW) { |
| 133 // Make sure no other window has capture, otherwise |window| won't get mouse | 151 // Make sure no other window has capture, otherwise |window| won't get mouse |
| 134 // events. | 152 // events. |
| 135 aura::Window* capture_window = aura::client::GetCaptureWindow(window); | 153 aura::Window* capture_window = aura::client::GetCaptureWindow(window); |
| 136 if (capture_window) | 154 if (capture_window) |
| 137 capture_window->ReleaseCapture(); | 155 capture_window->ReleaseCapture(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 148 aura::Window* modal_transient_child = GetModalTransient(target); | 166 aura::Window* modal_transient_child = GetModalTransient(target); |
| 149 if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED || | 167 if (modal_transient_child && (event->type() == ui::ET_MOUSE_PRESSED || |
| 150 event->type() == ui::ET_TOUCH_PRESSED)) { | 168 event->type() == ui::ET_TOUCH_PRESSED)) { |
| 151 AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE); | 169 AnimateWindow(modal_transient_child, WINDOW_ANIMATION_TYPE_BOUNCE); |
| 152 } | 170 } |
| 153 return !!modal_transient_child; | 171 return !!modal_transient_child; |
| 154 } | 172 } |
| 155 | 173 |
| 156 } // namespace corewm | 174 } // namespace corewm |
| 157 } // namespace views | 175 } // namespace views |
| OLD | NEW |