OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "views/widget/native_widget_views.h" | 5 #include "views/widget/native_widget_views.h" |
6 | 6 |
7 #include "ui/gfx/compositor/compositor.h" | 7 #include "ui/gfx/compositor/compositor.h" |
8 #include "views/desktop/desktop_window_view.h" | 8 #include "views/desktop/desktop_window_view.h" |
9 #include "views/view.h" | 9 #include "views/view.h" |
10 #include "views/views_delegate.h" | 10 #include "views/views_delegate.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 return; | 62 return; |
63 active_ = active; | 63 active_ = active; |
64 delegate_->OnNativeWidgetActivationChanged(active); | 64 delegate_->OnNativeWidgetActivationChanged(active); |
65 | 65 |
66 // TODO(oshima): Focus change should be separated from window activation. | 66 // TODO(oshima): Focus change should be separated from window activation. |
67 // This will be fixed when we have WM API. | 67 // This will be fixed when we have WM API. |
68 Widget* widget = GetWidget(); | 68 Widget* widget = GetWidget(); |
69 if (widget->is_top_level()) { | 69 if (widget->is_top_level()) { |
70 InputMethod* input_method = widget->GetInputMethodDirect(); | 70 InputMethod* input_method = widget->GetInputMethodDirect(); |
71 if (active) { | 71 if (active) { |
72 input_method->OnFocus(); | 72 if (input_method) |
| 73 input_method->OnFocus(); |
73 // See description of got_initial_focus_in_ for details on this. | 74 // See description of got_initial_focus_in_ for details on this. |
74 widget->GetFocusManager()->RestoreFocusedView(); | 75 widget->GetFocusManager()->RestoreFocusedView(); |
75 } else { | 76 } else { |
76 input_method->OnBlur(); | 77 if (input_method) |
| 78 input_method->OnBlur(); |
77 widget->GetFocusManager()->StoreFocusedView(); | 79 widget->GetFocusManager()->StoreFocusedView(); |
78 } | 80 } |
79 } | 81 } |
80 view_->SchedulePaint(); | 82 view_->SchedulePaint(); |
81 } | 83 } |
82 | 84 |
83 bool NativeWidgetViews::OnKeyEvent(const KeyEvent& key_event) { | 85 bool NativeWidgetViews::OnKeyEvent(const KeyEvent& key_event) { |
84 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); | 86 InputMethod* input_method = GetWidget()->GetInputMethod(); |
85 DCHECK(input_method); | 87 DCHECK(input_method); |
86 input_method->DispatchKeyEvent(key_event); | 88 input_method->DispatchKeyEvent(key_event); |
87 return true; | 89 return true; |
88 } | 90 } |
89 | 91 |
90 void NativeWidgetViews::DispatchKeyEventPostIME(const KeyEvent& key) { | 92 void NativeWidgetViews::DispatchKeyEventPostIME(const KeyEvent& key) { |
91 // TODO(oshima): GTK impl handles menu_key in special way. This may be | 93 // TODO(oshima): GTK impl handles menu_key in special way. This may be |
92 // necessary when running under NativeWidgetX. | 94 // necessary when running under NativeWidgetX. |
93 delegate_->OnKeyEvent(key); | 95 delegate_->OnKeyEvent(key); |
94 } | 96 } |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 510 |
509 const internal::NativeWidgetPrivate* | 511 const internal::NativeWidgetPrivate* |
510 NativeWidgetViews::GetParentNativeWidget() const { | 512 NativeWidgetViews::GetParentNativeWidget() const { |
511 const Widget* containing_widget = view_ ? view_->GetWidget() : NULL; | 513 const Widget* containing_widget = view_ ? view_->GetWidget() : NULL; |
512 return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>( | 514 return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>( |
513 containing_widget->native_widget()) : | 515 containing_widget->native_widget()) : |
514 NULL; | 516 NULL; |
515 } | 517 } |
516 | 518 |
517 } // namespace views | 519 } // namespace views |
OLD | NEW |