| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/window_manager/basic_focus_rules.h" | 5 #include "mojo/services/window_manager/basic_focus_rules.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "mojo/services/public/cpp/view_manager/view.h" | 8 #include "mojo/services/public/cpp/view_manager/view.h" |
| 9 #include "mojo/services/window_manager/window_manager_app.h" | |
| 10 | 9 |
| 11 namespace mojo { | 10 namespace mojo { |
| 12 | 11 |
| 13 BasicFocusRules::BasicFocusRules(mojo::WindowManagerApp* window_manager_app, | 12 BasicFocusRules::BasicFocusRules(mojo::View* window_container) |
| 14 mojo::View* window_container) | 13 : window_container_(window_container) { |
| 15 : window_container_(window_container), | 14 } |
| 16 window_manager_app_(window_manager_app) {} | |
| 17 | 15 |
| 18 BasicFocusRules::~BasicFocusRules() {} | 16 BasicFocusRules::~BasicFocusRules() {} |
| 19 | 17 |
| 20 bool BasicFocusRules::IsToplevelView(mojo::View* view) const { | 18 bool BasicFocusRules::IsToplevelView(mojo::View* view) const { |
| 21 return view->parent() == window_container_; | 19 return view->parent() == window_container_; |
| 22 } | 20 } |
| 23 | 21 |
| 24 bool BasicFocusRules::CanActivateView(mojo::View* view) const { | 22 bool BasicFocusRules::CanActivateView(mojo::View* view) const { |
| 25 // TODO(erg): This needs to check visibility, along with focus, and several | 23 // TODO(erg): This needs to check visibility, along with focus, and several |
| 26 // other things (see wm::BaseFocusRules). | 24 // other things (see wm::BaseFocusRules). |
| (...skipping 28 matching lines...) Expand all Loading... |
| 55 const mojo::View::Children& children = activatable->parent()->children(); | 53 const mojo::View::Children& children = activatable->parent()->children(); |
| 56 for (mojo::View::Children::const_reverse_iterator it = children.rbegin(); | 54 for (mojo::View::Children::const_reverse_iterator it = children.rbegin(); |
| 57 it != children.rend(); ++it) { | 55 it != children.rend(); ++it) { |
| 58 if (*it != activatable) | 56 if (*it != activatable) |
| 59 return *it; | 57 return *it; |
| 60 } | 58 } |
| 61 return nullptr; | 59 return nullptr; |
| 62 } | 60 } |
| 63 | 61 |
| 64 } // namespace mojo | 62 } // namespace mojo |
| OLD | NEW |