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