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/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "ui/aura/client/activation_client.h" | 9 #include "ui/aura/client/activation_client.h" |
10 #include "ui/aura/client/aura_constants.h" | 10 #include "ui/aura/client/aura_constants.h" |
11 #include "ui/aura/client/cursor_client.h" | 11 #include "ui/aura/client/cursor_client.h" |
12 #include "ui/aura/client/drag_drop_client.h" | 12 #include "ui/aura/client/drag_drop_client.h" |
13 #include "ui/aura/client/focus_client.h" | 13 #include "ui/aura/client/focus_client.h" |
14 #include "ui/aura/client/window_tree_client.h" | 14 #include "ui/aura/client/window_tree_client.h" |
15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
16 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
18 #include "ui/aura/window_property.h" | 18 #include "ui/aura/window_property.h" |
19 #include "ui/aura/window_tree_host.h" | 19 #include "ui/aura/window_tree_host.h" |
20 #include "ui/base/hit_test.h" | 20 #include "ui/base/hit_test.h" |
| 21 #include "ui/base/ui_base_switches_util.h" |
21 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
23 #include "ui/gfx/display.h" | 24 #include "ui/gfx/display.h" |
24 #include "ui/gfx/point_conversions.h" | 25 #include "ui/gfx/point_conversions.h" |
25 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
26 #include "ui/gfx/size_conversions.h" | 27 #include "ui/gfx/size_conversions.h" |
27 #include "ui/native_theme/native_theme.h" | 28 #include "ui/native_theme/native_theme.h" |
28 #include "ui/views/corewm/compound_event_filter.h" | 29 #include "ui/views/corewm/compound_event_filter.h" |
29 #include "ui/views/corewm/corewm_switches.h" | 30 #include "ui/views/corewm/corewm_switches.h" |
30 #include "ui/views/corewm/cursor_manager.h" | 31 #include "ui/views/corewm/cursor_manager.h" |
31 #include "ui/views/corewm/focus_controller.h" | 32 #include "ui/views/corewm/focus_controller.h" |
32 #include "ui/views/corewm/input_method_event_filter.h" | 33 #include "ui/views/corewm/input_method_event_filter.h" |
33 #include "ui/views/corewm/native_cursor_manager.h" | 34 #include "ui/views/corewm/native_cursor_manager.h" |
34 #include "ui/views/corewm/shadow_controller.h" | 35 #include "ui/views/corewm/shadow_controller.h" |
35 #include "ui/views/corewm/shadow_types.h" | 36 #include "ui/views/corewm/shadow_types.h" |
36 #include "ui/views/corewm/tooltip.h" | 37 #include "ui/views/corewm/tooltip.h" |
37 #include "ui/views/corewm/tooltip_controller.h" | 38 #include "ui/views/corewm/tooltip_controller.h" |
38 #include "ui/views/corewm/visibility_controller.h" | 39 #include "ui/views/corewm/visibility_controller.h" |
39 #include "ui/views/corewm/window_modality_controller.h" | 40 #include "ui/views/corewm/window_modality_controller.h" |
40 #include "ui/views/drag_utils.h" | 41 #include "ui/views/drag_utils.h" |
41 #include "ui/views/ime/input_method.h" | |
42 #include "ui/views/ime/input_method_bridge.h" | 42 #include "ui/views/ime/input_method_bridge.h" |
| 43 #include "ui/views/ime/null_input_method.h" |
43 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" | 44 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" |
44 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" | 45 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" |
45 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" | 46 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" |
46 #include "ui/views/widget/desktop_aura/desktop_event_client.h" | 47 #include "ui/views/widget/desktop_aura/desktop_event_client.h" |
47 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" | 48 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" |
48 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 49 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
49 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 50 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
50 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" | 51 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
51 #include "ui/views/widget/drop_helper.h" | 52 #include "ui/views/widget/drop_helper.h" |
52 #include "ui/views/widget/native_widget_aura.h" | 53 #include "ui/views/widget/native_widget_aura.h" |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 620 |
620 content_window_->ReleaseCapture(); | 621 content_window_->ReleaseCapture(); |
621 } | 622 } |
622 | 623 |
623 bool DesktopNativeWidgetAura::HasCapture() const { | 624 bool DesktopNativeWidgetAura::HasCapture() const { |
624 return content_window_ && content_window_->HasCapture() && | 625 return content_window_ && content_window_->HasCapture() && |
625 desktop_window_tree_host_->HasCapture(); | 626 desktop_window_tree_host_->HasCapture(); |
626 } | 627 } |
627 | 628 |
628 InputMethod* DesktopNativeWidgetAura::CreateInputMethod() { | 629 InputMethod* DesktopNativeWidgetAura::CreateInputMethod() { |
| 630 if (switches::IsTextInputFocusManagerEnabled()) |
| 631 return new NullInputMethod(); |
| 632 |
629 ui::InputMethod* host = input_method_event_filter_->input_method(); | 633 ui::InputMethod* host = input_method_event_filter_->input_method(); |
630 return new InputMethodBridge(this, host, false); | 634 return new InputMethodBridge(this, host, false); |
631 } | 635 } |
632 | 636 |
633 internal::InputMethodDelegate* | 637 internal::InputMethodDelegate* |
634 DesktopNativeWidgetAura::GetInputMethodDelegate() { | 638 DesktopNativeWidgetAura::GetInputMethodDelegate() { |
635 return this; | 639 return this; |
636 } | 640 } |
637 | 641 |
| 642 ui::InputMethod* DesktopNativeWidgetAura::GetHostInputMethod() { |
| 643 return input_method_event_filter_->input_method(); |
| 644 } |
| 645 |
638 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { | 646 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { |
639 if (content_window_) | 647 if (content_window_) |
640 desktop_window_tree_host_->CenterWindow(size); | 648 desktop_window_tree_host_->CenterWindow(size); |
641 } | 649 } |
642 | 650 |
643 void DesktopNativeWidgetAura::GetWindowPlacement( | 651 void DesktopNativeWidgetAura::GetWindowPlacement( |
644 gfx::Rect* bounds, | 652 gfx::Rect* bounds, |
645 ui::WindowShowState* maximized) const { | 653 ui::WindowShowState* maximized) const { |
646 if (content_window_) | 654 if (content_window_) |
647 desktop_window_tree_host_->GetWindowPlacement(bounds, maximized); | 655 desktop_window_tree_host_->GetWindowPlacement(bounds, maximized); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 | 1077 |
1070 //////////////////////////////////////////////////////////////////////////////// | 1078 //////////////////////////////////////////////////////////////////////////////// |
1071 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: | 1079 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: |
1072 | 1080 |
1073 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, | 1081 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
1074 aura::Window* lost_focus) { | 1082 aura::Window* lost_focus) { |
1075 if (content_window_ == gained_focus) { | 1083 if (content_window_ == gained_focus) { |
1076 desktop_window_tree_host_->OnNativeWidgetFocus(); | 1084 desktop_window_tree_host_->OnNativeWidgetFocus(); |
1077 native_widget_delegate_->OnNativeFocus(lost_focus); | 1085 native_widget_delegate_->OnNativeFocus(lost_focus); |
1078 | 1086 |
1079 // If focus is moving from a descendant Window to |content_window_| then | 1087 if (!switches::IsTextInputFocusManagerEnabled()) { |
1080 // native activation hasn't changed. We still need to inform the InputMethod | 1088 // If focus is moving from a descendant Window to |content_window_| then |
1081 // we've been focused though. | 1089 // native activation hasn't changed. We still need to inform the |
1082 InputMethod* input_method = GetWidget()->GetInputMethod(); | 1090 // InputMethod we've been focused though. |
1083 if (input_method) | 1091 InputMethod* input_method = GetWidget()->GetInputMethod(); |
1084 input_method->OnFocus(); | 1092 if (input_method) |
| 1093 input_method->OnFocus(); |
| 1094 } |
| 1095 |
| 1096 // Ensure the focused view's TextInputClient is used for text input. |
| 1097 views::FocusManager* focus_manager = GetWidget()->GetFocusManager(); |
| 1098 focus_manager->FocusTextInputClient(focus_manager->GetFocusedView()); |
1085 } else if (content_window_ == lost_focus) { | 1099 } else if (content_window_ == lost_focus) { |
1086 desktop_window_tree_host_->OnNativeWidgetBlur(); | 1100 desktop_window_tree_host_->OnNativeWidgetBlur(); |
1087 native_widget_delegate_->OnNativeBlur( | 1101 native_widget_delegate_->OnNativeBlur( |
1088 aura::client::GetFocusClient(content_window_)->GetFocusedWindow()); | 1102 aura::client::GetFocusClient(content_window_)->GetFocusedWindow()); |
| 1103 |
| 1104 // Ensure the focused view's TextInputClient is not used for text input. |
| 1105 views::FocusManager* focus_manager = GetWidget()->GetFocusManager(); |
| 1106 focus_manager->BlurTextInputClient(focus_manager->GetFocusedView()); |
1089 } | 1107 } |
1090 } | 1108 } |
1091 | 1109 |
1092 //////////////////////////////////////////////////////////////////////////////// | 1110 //////////////////////////////////////////////////////////////////////////////// |
1093 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: | 1111 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: |
1094 | 1112 |
1095 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | 1113 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { |
1096 FocusManager* focus_manager = | 1114 FocusManager* focus_manager = |
1097 native_widget_delegate_->AsWidget()->GetFocusManager(); | 1115 native_widget_delegate_->AsWidget()->GetFocusManager(); |
1098 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); | 1116 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1187 if (cursor_reference_count_ == 0) { | 1205 if (cursor_reference_count_ == 0) { |
1188 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1206 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1189 // for cleaning up |cursor_manager_|. | 1207 // for cleaning up |cursor_manager_|. |
1190 delete cursor_manager_; | 1208 delete cursor_manager_; |
1191 native_cursor_manager_ = NULL; | 1209 native_cursor_manager_ = NULL; |
1192 cursor_manager_ = NULL; | 1210 cursor_manager_ = NULL; |
1193 } | 1211 } |
1194 } | 1212 } |
1195 | 1213 |
1196 } // namespace views | 1214 } // namespace views |
OLD | NEW |