| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/aura/event_filter.h" | 5 #include "ui/aura/event_filter.h" |
| 6 | 6 |
| 7 #include "ui/aura/desktop.h" | 7 #include "ui/aura/desktop.h" |
| 8 #include "ui/aura/event.h" | 8 #include "ui/aura/event.h" |
| 9 #include "ui/aura/focus_manager.h" | 9 #include "ui/aura/focus_manager.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 void EventFilter::ActivateIfNecessary( | 35 void EventFilter::ActivateIfNecessary( |
| 36 Window* window, | 36 Window* window, |
| 37 MouseEvent* event) { | 37 MouseEvent* event) { |
| 38 // TODO(beng): some windows (e.g. disabled ones, tooltips, etc) may not be | 38 // TODO(beng): some windows (e.g. disabled ones, tooltips, etc) may not be |
| 39 // focusable. | 39 // focusable. |
| 40 | 40 |
| 41 Window* active_window = Desktop::GetInstance()->active_window(); | 41 Window* active_window = Desktop::GetInstance()->active_window(); |
| 42 Window* toplevel_window = window; | 42 Window* toplevel_window = window; |
| 43 while (toplevel_window && toplevel_window != active_window && | 43 while (toplevel_window && toplevel_window != active_window && |
| 44 toplevel_window->parent() && | 44 toplevel_window->parent() && |
| 45 !toplevel_window->parent()->IsToplevelWindowContainer()) { | 45 !toplevel_window->parent()->AsToplevelWindowContainer()) { |
| 46 toplevel_window = toplevel_window->parent(); | 46 toplevel_window = toplevel_window->parent(); |
| 47 } | 47 } |
| 48 if (toplevel_window == active_window) { | 48 if (toplevel_window == active_window) { |
| 49 // |window| is a descendant of the active window, no need to activate. | 49 // |window| is a descendant of the active window, no need to activate. |
| 50 window->GetFocusManager()->SetFocusedWindow(window); | 50 window->GetFocusManager()->SetFocusedWindow(window); |
| 51 return; | 51 return; |
| 52 } | 52 } |
| 53 if (!toplevel_window) { | 53 if (!toplevel_window) { |
| 54 // |window| is not in a top level window. | 54 // |window| is not in a top level window. |
| 55 return; | 55 return; |
| 56 } | 56 } |
| 57 if (!toplevel_window->delegate() || | 57 if (!toplevel_window->delegate() || |
| 58 !toplevel_window->delegate()->ShouldActivate(event)) | 58 !toplevel_window->delegate()->ShouldActivate(event)) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 Desktop::GetInstance()->SetActiveWindow(toplevel_window, window); | 61 Desktop::GetInstance()->SetActiveWindow(toplevel_window, window); |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace aura | 64 } // namespace aura |
| OLD | NEW |