| 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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 void Widget::OnNativeWidgetActivationChanged(bool active) { | 1044 void Widget::OnNativeWidgetActivationChanged(bool active) { |
| 1045 // On windows we may end up here before we've completed initialization (from | 1045 // On windows we may end up here before we've completed initialization (from |
| 1046 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know | 1046 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know |
| 1047 // the Widget and will crash attempting to access it. | 1047 // the Widget and will crash attempting to access it. |
| 1048 if (!active && native_widget_initialized_) | 1048 if (!active && native_widget_initialized_) |
| 1049 SaveWindowPlacement(); | 1049 SaveWindowPlacement(); |
| 1050 | 1050 |
| 1051 FOR_EACH_OBSERVER(WidgetObserver, observers_, | 1051 FOR_EACH_OBSERVER(WidgetObserver, observers_, |
| 1052 OnWidgetActivationChanged(this, active)); | 1052 OnWidgetActivationChanged(this, active)); |
| 1053 | 1053 |
| 1054 // During window creation, the widget gets focused without activation, and in | |
| 1055 // that case, the focus manager cannot set the appropriate text input client | |
| 1056 // because the widget is not active. Thus we have to notify the focus manager | |
| 1057 // not only when the focus changes but also when the widget gets activated. | |
| 1058 // See crbug.com/377479 for details. | |
| 1059 views::FocusManager* focus_manager = GetFocusManager(); | |
| 1060 if (focus_manager) { | |
| 1061 if (active) | |
| 1062 focus_manager->FocusTextInputClient(focus_manager->GetFocusedView()); | |
| 1063 else | |
| 1064 focus_manager->BlurTextInputClient(focus_manager->GetFocusedView()); | |
| 1065 } | |
| 1066 | |
| 1067 if (IsVisible() && non_client_view()) | 1054 if (IsVisible() && non_client_view()) |
| 1068 non_client_view()->frame_view()->SchedulePaint(); | 1055 non_client_view()->frame_view()->SchedulePaint(); |
| 1069 } | 1056 } |
| 1070 | 1057 |
| 1071 void Widget::OnNativeFocus() { | 1058 void Widget::OnNativeFocus() { |
| 1072 WidgetFocusManager::GetInstance()->OnNativeFocusChanged(GetNativeView()); | 1059 WidgetFocusManager::GetInstance()->OnNativeFocusChanged(GetNativeView()); |
| 1073 } | 1060 } |
| 1074 | 1061 |
| 1075 void Widget::OnNativeBlur() { | 1062 void Widget::OnNativeBlur() { |
| 1076 WidgetFocusManager::GetInstance()->OnNativeFocusChanged(nullptr); | 1063 WidgetFocusManager::GetInstance()->OnNativeFocusChanged(nullptr); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1530 | 1517 |
| 1531 //////////////////////////////////////////////////////////////////////////////// | 1518 //////////////////////////////////////////////////////////////////////////////// |
| 1532 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1519 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1533 | 1520 |
| 1534 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1521 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1535 return this; | 1522 return this; |
| 1536 } | 1523 } |
| 1537 | 1524 |
| 1538 } // namespace internal | 1525 } // namespace internal |
| 1539 } // namespace views | 1526 } // namespace views |
| OLD | NEW |