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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.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 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 void Widget::OnNativeWidgetActivationChanged(bool active) { | 1024 void Widget::OnNativeWidgetActivationChanged(bool active) { |
1025 // On windows we may end up here before we've completed initialization (from | 1025 // On windows we may end up here before we've completed initialization (from |
1026 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know | 1026 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know |
1027 // the Widget and will crash attempting to access it. | 1027 // the Widget and will crash attempting to access it. |
1028 if (!active && native_widget_initialized_) | 1028 if (!active && native_widget_initialized_) |
1029 SaveWindowPlacement(); | 1029 SaveWindowPlacement(); |
1030 | 1030 |
1031 FOR_EACH_OBSERVER(WidgetObserver, observers_, | 1031 FOR_EACH_OBSERVER(WidgetObserver, observers_, |
1032 OnWidgetActivationChanged(this, active)); | 1032 OnWidgetActivationChanged(this, active)); |
1033 | 1033 |
| 1034 // During window creation, the widget gets focused without activation, and in |
| 1035 // that case, the focus manager cannot set the appropriate text input client |
| 1036 // because the widget is not active. Thus we have to notify the focus manager |
| 1037 // not only when the focus changes but also when the widget gets activated. |
| 1038 // See crbug.com/377479 for details. |
| 1039 views::FocusManager* focus_manager = GetFocusManager(); |
| 1040 if (focus_manager) { |
| 1041 if (active) |
| 1042 focus_manager->FocusTextInputClient(focus_manager->GetFocusedView()); |
| 1043 else |
| 1044 focus_manager->BlurTextInputClient(focus_manager->GetFocusedView()); |
| 1045 } |
| 1046 |
1034 if (IsVisible() && non_client_view()) | 1047 if (IsVisible() && non_client_view()) |
1035 non_client_view()->frame_view()->SchedulePaint(); | 1048 non_client_view()->frame_view()->SchedulePaint(); |
1036 } | 1049 } |
1037 | 1050 |
1038 void Widget::OnNativeFocus(gfx::NativeView old_focused_view) { | 1051 void Widget::OnNativeFocus(gfx::NativeView old_focused_view) { |
1039 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view, | 1052 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view, |
1040 GetNativeView()); | 1053 GetNativeView()); |
1041 } | 1054 } |
1042 | 1055 |
1043 void Widget::OnNativeBlur(gfx::NativeView new_focused_view) { | 1056 void Widget::OnNativeBlur(gfx::NativeView new_focused_view) { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 | 1518 |
1506 //////////////////////////////////////////////////////////////////////////////// | 1519 //////////////////////////////////////////////////////////////////////////////// |
1507 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1520 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1508 | 1521 |
1509 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1522 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1510 return this; | 1523 return this; |
1511 } | 1524 } |
1512 | 1525 |
1513 } // namespace internal | 1526 } // namespace internal |
1514 } // namespace views | 1527 } // namespace views |
OLD | NEW |