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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 void Widget::OnNativeWidgetActivationChanged(bool active) { | 1008 void Widget::OnNativeWidgetActivationChanged(bool active) { |
1009 // On windows we may end up here before we've completed initialization (from | 1009 // On windows we may end up here before we've completed initialization (from |
1010 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know | 1010 // an WM_NCACTIVATE). If that happens the WidgetDelegate likely doesn't know |
1011 // the Widget and will crash attempting to access it. | 1011 // the Widget and will crash attempting to access it. |
1012 if (!active && native_widget_initialized_) | 1012 if (!active && native_widget_initialized_) |
1013 SaveWindowPlacement(); | 1013 SaveWindowPlacement(); |
1014 | 1014 |
1015 FOR_EACH_OBSERVER(WidgetObserver, observers_, | 1015 FOR_EACH_OBSERVER(WidgetObserver, observers_, |
1016 OnWidgetActivationChanged(this, active)); | 1016 OnWidgetActivationChanged(this, active)); |
1017 | 1017 |
| 1018 // During window creation, the widget gets focused without activation, and in |
| 1019 // that case, the focus manager cannot set the appropriate text input client |
| 1020 // because the widget is not active. Thus we have to notify the focus manager |
| 1021 // not only when the focus changes but also when the widget gets activated. |
| 1022 // See crbug.com/377479 for details. |
| 1023 views::FocusManager* focus_manager = GetFocusManager(); |
| 1024 if (focus_manager) { |
| 1025 if (active) |
| 1026 focus_manager->FocusTextInputClient(focus_manager->GetFocusedView()); |
| 1027 else |
| 1028 focus_manager->BlurTextInputClient(focus_manager->GetFocusedView()); |
| 1029 } |
| 1030 |
1018 if (IsVisible() && non_client_view()) | 1031 if (IsVisible() && non_client_view()) |
1019 non_client_view()->frame_view()->SchedulePaint(); | 1032 non_client_view()->frame_view()->SchedulePaint(); |
1020 } | 1033 } |
1021 | 1034 |
1022 void Widget::OnNativeFocus(gfx::NativeView old_focused_view) { | 1035 void Widget::OnNativeFocus(gfx::NativeView old_focused_view) { |
1023 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view, | 1036 WidgetFocusManager::GetInstance()->OnWidgetFocusEvent(old_focused_view, |
1024 GetNativeView()); | 1037 GetNativeView()); |
1025 } | 1038 } |
1026 | 1039 |
1027 void Widget::OnNativeBlur(gfx::NativeView new_focused_view) { | 1040 void Widget::OnNativeBlur(gfx::NativeView new_focused_view) { |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 | 1502 |
1490 //////////////////////////////////////////////////////////////////////////////// | 1503 //////////////////////////////////////////////////////////////////////////////// |
1491 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1504 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1492 | 1505 |
1493 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1506 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1494 return this; | 1507 return this; |
1495 } | 1508 } |
1496 | 1509 |
1497 } // namespace internal | 1510 } // namespace internal |
1498 } // namespace views | 1511 } // namespace views |
OLD | NEW |