| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // TODO(oshima): find out if we should check toplevel here. | 60 // TODO(oshima): find out if we should check toplevel here. |
| 61 if (active_ == active) | 61 if (active_ == active) |
| 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->GetInputMethod(); |
| 71 if (active) { | 71 if (active) { |
| 72 if (input_method) | 72 input_method->OnFocus(); |
| 73 input_method->OnFocus(); | |
| 74 // See description of got_initial_focus_in_ for details on this. | 73 // See description of got_initial_focus_in_ for details on this. |
| 75 widget->GetFocusManager()->RestoreFocusedView(); | 74 widget->GetFocusManager()->RestoreFocusedView(); |
| 76 } else { | 75 } else { |
| 77 if (input_method) | 76 input_method->OnBlur(); |
| 78 input_method->OnBlur(); | |
| 79 widget->GetFocusManager()->StoreFocusedView(); | 77 widget->GetFocusManager()->StoreFocusedView(); |
| 80 } | 78 } |
| 81 } | 79 } |
| 82 view_->SchedulePaint(); | 80 view_->SchedulePaint(); |
| 83 } | 81 } |
| 84 | 82 |
| 85 bool NativeWidgetViews::OnKeyEvent(const KeyEvent& key_event) { | 83 bool NativeWidgetViews::OnKeyEvent(const KeyEvent& key_event) { |
| 86 InputMethod* input_method = GetWidget()->GetInputMethod(); | 84 InputMethod* input_method = GetWidget()->GetInputMethod(); |
| 87 DCHECK(input_method); | 85 DCHECK(input_method); |
| 88 input_method->DispatchKeyEvent(key_event); | 86 input_method->DispatchKeyEvent(key_event); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 | 508 |
| 511 const internal::NativeWidgetPrivate* | 509 const internal::NativeWidgetPrivate* |
| 512 NativeWidgetViews::GetParentNativeWidget() const { | 510 NativeWidgetViews::GetParentNativeWidget() const { |
| 513 const Widget* containing_widget = view_ ? view_->GetWidget() : NULL; | 511 const Widget* containing_widget = view_ ? view_->GetWidget() : NULL; |
| 514 return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>( | 512 return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>( |
| 515 containing_widget->native_widget()) : | 513 containing_widget->native_widget()) : |
| 516 NULL; | 514 NULL; |
| 517 } | 515 } |
| 518 | 516 |
| 519 } // namespace views | 517 } // namespace views |
| OLD | NEW |