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(); | |
1306 View* v = widget_delegate_->GetInitiallyFocusedView(); | 1307 View* v = widget_delegate_->GetInitiallyFocusedView(); |
1307 if (!focus_on_creation_ || show_state == ui::SHOW_STATE_INACTIVE || | 1308 if (!focus_on_creation_ || show_state == ui::SHOW_STATE_INACTIVE || |
1308 show_state == ui::SHOW_STATE_MINIMIZED) { | 1309 show_state == ui::SHOW_STATE_MINIMIZED) { |
1309 // If not focusing the window now, tell the focus manager which view to | 1310 // If not focusing the window now, tell the focus manager which view to |
1310 // focus when the window is restored. | 1311 // focus when the window is restored. |
1311 if (v && focus_manager_.get()) | 1312 if (v && focus_manager) |
1312 focus_manager_->SetStoredFocusView(v); | 1313 focus_manager->SetStoredFocusView(v); |
1313 return true; | 1314 return true; |
1314 } | 1315 } |
1315 if (v) | 1316 if (v) { |
1316 v->RequestFocus(); | 1317 v->RequestFocus(); |
1318 // If the request for focus was unsuccessful, fall back to using the first | |
1319 // focusable View instead. | |
1320 if (focus_manager && v != focus_manager->GetFocusedView()) | |
sky
2017/01/12 16:34:13
Rather than checking |v|, how about checking for n
Patti Lor
2017/01/13 04:19:02
Done, thanks.
| |
1321 focus_manager->AdvanceFocus(false); | |
1322 } | |
1317 return !!v; | 1323 return !!v; |
sky
2017/01/12 16:34:13
The return value should be true if any view got fo
Patti Lor
2017/01/13 04:19:02
Done.
| |
1318 } | 1324 } |
1319 | 1325 |
1320 //////////////////////////////////////////////////////////////////////////////// | 1326 //////////////////////////////////////////////////////////////////////////////// |
1321 // Widget, ui::EventSource implementation: | 1327 // Widget, ui::EventSource implementation: |
1322 ui::EventProcessor* Widget::GetEventProcessor() { | 1328 ui::EventProcessor* Widget::GetEventProcessor() { |
1323 return root_view_.get(); | 1329 return root_view_.get(); |
1324 } | 1330 } |
1325 | 1331 |
1326 //////////////////////////////////////////////////////////////////////////////// | 1332 //////////////////////////////////////////////////////////////////////////////// |
1327 // Widget, FocusTraversable implementation: | 1333 // Widget, FocusTraversable implementation: |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1490 | 1496 |
1491 //////////////////////////////////////////////////////////////////////////////// | 1497 //////////////////////////////////////////////////////////////////////////////// |
1492 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1498 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1493 | 1499 |
1494 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1500 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1495 return this; | 1501 return this; |
1496 } | 1502 } |
1497 | 1503 |
1498 } // namespace internal | 1504 } // namespace internal |
1499 } // namespace views | 1505 } // namespace views |
OLD | NEW |