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/widget.h" | 5 #include "ui/views/widget/widget.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1296 | 1296 |
1297 Widget* Widget::AsWidget() { | 1297 Widget* Widget::AsWidget() { |
1298 return this; | 1298 return this; |
1299 } | 1299 } |
1300 | 1300 |
1301 const Widget* Widget::AsWidget() const { | 1301 const Widget* Widget::AsWidget() const { |
1302 return this; | 1302 return this; |
1303 } | 1303 } |
1304 | 1304 |
1305 bool Widget::SetInitialFocus(ui::WindowShowState show_state) { | 1305 bool Widget::SetInitialFocus(ui::WindowShowState show_state) { |
1306 FocusManager* focus_manager = GetFocusManager(); | |
1307 if (!focus_manager) | |
1308 return false; | |
tapted
2017/01/06 11:45:15
oh drat - I missed that this early exit would chan
Patti Lor
2017/01/12 02:16:22
Yeah, I read the comment description for this meth
tapted
2017/01/12 02:25:43
yep - this seems good/safest
| |
1309 | |
1306 View* v = widget_delegate_->GetInitiallyFocusedView(); | 1310 View* v = widget_delegate_->GetInitiallyFocusedView(); |
1307 if (!focus_on_creation_ || show_state == ui::SHOW_STATE_INACTIVE || | 1311 if (!focus_on_creation_ || show_state == ui::SHOW_STATE_INACTIVE || |
1308 show_state == ui::SHOW_STATE_MINIMIZED) { | 1312 show_state == ui::SHOW_STATE_MINIMIZED) { |
1309 // If not focusing the window now, tell the focus manager which view to | 1313 // If not focusing the window now, tell the focus manager which view to |
1310 // focus when the window is restored. | 1314 // focus when the window is restored. |
1311 if (v && focus_manager_.get()) | 1315 if (v) |
1312 focus_manager_->SetStoredFocusView(v); | 1316 focus_manager->SetStoredFocusView(v); |
1313 return true; | 1317 return true; |
1314 } | 1318 } |
1315 if (v) | 1319 if (v) { |
1316 v->RequestFocus(); | 1320 v->RequestFocus(); |
1321 // If the request for focus was unsuccessful, fall back to using the first | |
1322 // focusable View instead. | |
1323 if (v != focus_manager->GetFocusedView()) | |
1324 focus_manager->AdvanceFocus(false); | |
1325 } | |
1317 return !!v; | 1326 return !!v; |
1318 } | 1327 } |
1319 | 1328 |
1320 //////////////////////////////////////////////////////////////////////////////// | 1329 //////////////////////////////////////////////////////////////////////////////// |
1321 // Widget, ui::EventSource implementation: | 1330 // Widget, ui::EventSource implementation: |
1322 ui::EventProcessor* Widget::GetEventProcessor() { | 1331 ui::EventProcessor* Widget::GetEventProcessor() { |
1323 return root_view_.get(); | 1332 return root_view_.get(); |
1324 } | 1333 } |
1325 | 1334 |
1326 //////////////////////////////////////////////////////////////////////////////// | 1335 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1490 | 1499 |
1491 //////////////////////////////////////////////////////////////////////////////// | 1500 //////////////////////////////////////////////////////////////////////////////// |
1492 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1501 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1493 | 1502 |
1494 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1503 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1495 return this; | 1504 return this; |
1496 } | 1505 } |
1497 | 1506 |
1498 } // namespace internal | 1507 } // namespace internal |
1499 } // namespace views | 1508 } // namespace views |
OLD | NEW |