OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chromecast/graphics/cast_focus_client_aura.h" | 5 #include "chromecast/graphics/cast_focus_client_aura.h" |
6 #include "base/stl_util.h" | |
alokp
2017/06/02 04:59:35
add a line here.
Tripta
2017/06/02 08:08:02
Have made the changes. Please check.
| |
6 | 7 |
alokp
2017/06/02 04:59:35
remove this line
Tripta
2017/06/02 08:08:02
Have made the changes. Please check.
| |
7 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
8 | 9 |
9 #define LOG_WINDOW_INFO(top_level, window) \ | 10 #define LOG_WINDOW_INFO(top_level, window) \ |
10 "top-level: " << (top_level)->id() << ": '" << (top_level)->GetName() \ | 11 "top-level: " << (top_level)->id() << ": '" << (top_level)->GetName() \ |
11 << "', window: " << (window)->id() << ": '" \ | 12 << "', window: " << (window)->id() << ": '" \ |
12 << (window)->GetName() << "'" | 13 << (window)->GetName() << "'" |
13 | 14 |
14 namespace chromecast { | 15 namespace chromecast { |
15 | 16 |
16 CastFocusClientAura::CastFocusClientAura() : focused_window_(nullptr) {} | 17 CastFocusClientAura::CastFocusClientAura() : focused_window_(nullptr) {} |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 // focus request if it isn't for the topmost window. If it is for a lower | 118 // focus request if it isn't for the topmost window. If it is for a lower |
118 // window, then we'll track it to focus it later when it rises to the top. | 119 // window, then we'll track it to focus it later when it rises to the top. |
119 void CastFocusClientAura::FocusWindow(aura::Window* window) { | 120 void CastFocusClientAura::FocusWindow(aura::Window* window) { |
120 if (window) { | 121 if (window) { |
121 if (!window->CanFocus()) { | 122 if (!window->CanFocus()) { |
122 return; | 123 return; |
123 } | 124 } |
124 aura::Window* top_level = GetZOrderWindow(window); | 125 aura::Window* top_level = GetZOrderWindow(window); |
125 DCHECK(top_level); | 126 DCHECK(top_level); |
126 DLOG(INFO) << "Requesting focus for " << LOG_WINDOW_INFO(top_level, window); | 127 DLOG(INFO) << "Requesting focus for " << LOG_WINDOW_INFO(top_level, window); |
127 auto iter = | 128 if(!base::ContainsValue(focusable_windows_, window)) { |
128 std::find(focusable_windows_.begin(), focusable_windows_.end(), window); | |
129 if (iter == focusable_windows_.end()) { | |
130 // We're not yet tracking this focusable window, so start tracking it as a | 129 // We're not yet tracking this focusable window, so start tracking it as a |
131 // potential focus target. | 130 // potential focus target. |
132 window->AddObserver(this); | 131 window->AddObserver(this); |
133 focusable_windows_.push_back(window); | 132 focusable_windows_.push_back(window); |
134 } | 133 } |
135 } | 134 } |
136 | 135 |
137 // Check whether this new window is the most appropriate to focus. | 136 // Check whether this new window is the most appropriate to focus. |
138 UpdateWindowFocus(); | 137 UpdateWindowFocus(); |
139 } | 138 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 | 241 |
243 aura::Window* CastFocusClientAura::GetToplevelWindow(aura::Window* window) { | 242 aura::Window* CastFocusClientAura::GetToplevelWindow(aura::Window* window) { |
244 return GetZOrderWindow(window); | 243 return GetZOrderWindow(window); |
245 } | 244 } |
246 | 245 |
247 bool CastFocusClientAura::CanActivateWindow(aura::Window* window) const { | 246 bool CastFocusClientAura::CanActivateWindow(aura::Window* window) const { |
248 return true; | 247 return true; |
249 } | 248 } |
250 | 249 |
251 } // namespace chromecast | 250 } // namespace chromecast |
OLD | NEW |