| 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/widget/desktop_aura/desktop_focus_rules.h" | 5 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" |
| 6 | 6 |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/aura/window_event_dispatcher.h" | 8 #include "ui/aura/window_event_dispatcher.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| 11 | 11 |
| 12 DesktopFocusRules::DesktopFocusRules(aura::Window* content_window) | 12 DesktopFocusRules::DesktopFocusRules(aura::Window* content_window) |
| 13 : content_window_(content_window) {} | 13 : content_window_(content_window) {} |
| 14 | 14 |
| 15 DesktopFocusRules::~DesktopFocusRules() {} | 15 DesktopFocusRules::~DesktopFocusRules() {} |
| 16 | 16 |
| 17 bool DesktopFocusRules::CanActivateWindow(aura::Window* window) const { | 17 bool DesktopFocusRules::CanActivateWindow(aura::Window* window) const { |
| 18 if (!BaseFocusRules::CanActivateWindow(window)) | 18 if (!BaseFocusRules::CanActivateWindow(window)) |
| 19 return false; | 19 return false; |
| 20 // Never activate a window that is not a child of the root window. Transients | 20 // Never activate a window that is not a child of the root window. Transients |
| 21 // spanning different DesktopNativeWidgetAuras may trigger this. | 21 // spanning different DesktopNativeWidgetAuras may trigger this. |
| 22 return !window || content_window_->GetRootWindow()->Contains(window); | 22 return !window || content_window_->GetRootWindow()->Contains(window); |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool DesktopFocusRules::SupportsChildActivation(aura::Window* window) const { | 25 bool DesktopFocusRules::SupportsChildActivation(aura::Window* window) const { |
| 26 // In Desktop-Aura, only the content_window or children of the RootWindow are | 26 // In Desktop-Aura, only the content_window or children of the RootWindow are |
| 27 // activatable. | 27 // activatable. |
| 28 return window == content_window_->parent() || | 28 return window->IsRootWindow(); |
| 29 window->GetRootWindow() == window; | |
| 30 } | 29 } |
| 31 | 30 |
| 32 bool DesktopFocusRules::IsWindowConsideredVisibleForActivation( | 31 bool DesktopFocusRules::IsWindowConsideredVisibleForActivation( |
| 33 aura::Window* window) const { | 32 aura::Window* window) const { |
| 34 // |content_window_| is initially hidden and made visible from Show(). Even in | 33 // |content_window_| is initially hidden and made visible from Show(). Even in |
| 35 // this state we still want it to be active. | 34 // this state we still want it to be active. |
| 36 return BaseFocusRules::IsWindowConsideredVisibleForActivation(window) || | 35 return BaseFocusRules::IsWindowConsideredVisibleForActivation(window) || |
| 37 (window == content_window_); | 36 (window == content_window_); |
| 38 } | 37 } |
| 39 | 38 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 55 // In Desktop-Aura the content_window_'s parent is a dummy window and thus | 54 // In Desktop-Aura the content_window_'s parent is a dummy window and thus |
| 56 // should never be activated. We should return the content_window_ if it | 55 // should never be activated. We should return the content_window_ if it |
| 57 // can be activated in this case. | 56 // can be activated in this case. |
| 58 if (next_activatable_window == content_window_->parent() && | 57 if (next_activatable_window == content_window_->parent() && |
| 59 CanActivateWindow(content_window_)) | 58 CanActivateWindow(content_window_)) |
| 60 return content_window_; | 59 return content_window_; |
| 61 return next_activatable_window; | 60 return next_activatable_window; |
| 62 } | 61 } |
| 63 | 62 |
| 64 } // namespace views | 63 } // namespace views |
| OLD | NEW |