| 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 "services/window_manager/focus_controller.h" | 5 #include "services/window_manager/focus_controller.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "mojo/services/view_manager/public/cpp/view_property.h" | 8 #include "mojo/services/view_manager/public/cpp/view_property.h" |
| 9 #include "mojo/services/view_manager/public/cpp/view_tracker.h" | 9 #include "mojo/services/view_manager/public/cpp/view_tracker.h" |
| 10 #include "services/window_manager/focus_controller_observer.h" | 10 #include "services/window_manager/focus_controller_observer.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 bool FocusController::CanActivateView(View* view) const { | 67 bool FocusController::CanActivateView(View* view) const { |
| 68 return rules_->CanActivateView(view); | 68 return rules_->CanActivateView(view); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void FocusController::FocusView(View* view) { | 71 void FocusController::FocusView(View* view) { |
| 72 if (view && | 72 if (view && |
| 73 (view->Contains(focused_view_) || view->Contains(active_view_))) { | 73 (view->Contains(focused_view_) || view->Contains(active_view_))) { |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 | 76 |
| 77 // TODO(erg): We need to early abort in the of a view having | |
| 78 // capture. However, we currently don't have a capture client here. | |
| 79 | |
| 80 // Focusing a window also activates its containing activatable window. Note | 77 // Focusing a window also activates its containing activatable window. Note |
| 81 // that the rules could redirect activation activation and/or focus. | 78 // that the rules could redirect activation activation and/or focus. |
| 82 View* focusable = rules_->GetFocusableView(view); | 79 View* focusable = rules_->GetFocusableView(view); |
| 83 View* activatable = | 80 View* activatable = |
| 84 focusable ? rules_->GetActivatableView(focusable) : nullptr; | 81 focusable ? rules_->GetActivatableView(focusable) : nullptr; |
| 85 | 82 |
| 86 // We need valid focusable/activatable windows in the event we're not clearing | 83 // We need valid focusable/activatable windows in the event we're not clearing |
| 87 // focus. "Clearing focus" is inferred by whether or not |window| passed to | 84 // focus. "Clearing focus" is inferred by whether or not |window| passed to |
| 88 // this function is non-null. | 85 // this function is non-null. |
| 89 if (view && (!focusable || !activatable)) | 86 if (view && (!focusable || !activatable)) |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } | 310 } |
| 314 | 311 |
| 315 FocusController* GetFocusController(View* root_view) { | 312 FocusController* GetFocusController(View* root_view) { |
| 316 if (root_view) | 313 if (root_view) |
| 317 DCHECK_EQ(root_view->GetRoot(), root_view); | 314 DCHECK_EQ(root_view->GetRoot(), root_view); |
| 318 return root_view ? | 315 return root_view ? |
| 319 root_view->GetLocalProperty(kRootViewFocusController) : nullptr; | 316 root_view->GetLocalProperty(kRootViewFocusController) : nullptr; |
| 320 } | 317 } |
| 321 | 318 |
| 322 } // namespace window_manager | 319 } // namespace window_manager |
| OLD | NEW |