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/trace_event/trace_event.h" | 8 #include "base/trace_event/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/ime/input_method.h" | 18 #include "ui/base/ime/input_method.h" |
19 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.h" |
20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/display.h" | 21 #include "ui/gfx/display.h" |
22 #include "ui/gfx/geometry/point_conversions.h" | 22 #include "ui/gfx/geometry/point_conversions.h" |
23 #include "ui/gfx/geometry/rect.h" | 23 #include "ui/gfx/geometry/rect.h" |
24 #include "ui/gfx/geometry/size_conversions.h" | 24 #include "ui/gfx/geometry/size_conversions.h" |
25 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
26 #include "ui/native_theme/native_theme.h" | 26 #include "ui/native_theme/native_theme.h" |
27 #include "ui/views/corewm/tooltip.h" | 27 #include "ui/views/corewm/tooltip.h" |
28 #include "ui/views/corewm/tooltip_controller.h" | 28 #include "ui/views/corewm/tooltip_controller.h" |
29 #include "ui/views/drag_utils.h" | 29 #include "ui/views/drag_utils.h" |
30 #include "ui/views/ime/input_method_bridge.h" | |
31 #include "ui/views/ime/null_input_method.h" | |
32 #include "ui/views/view_constants_aura.h" | 30 #include "ui/views/view_constants_aura.h" |
33 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" | 31 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" |
34 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" | 32 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" |
35 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" | 33 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" |
36 #include "ui/views/widget/desktop_aura/desktop_event_client.h" | 34 #include "ui/views/widget/desktop_aura/desktop_event_client.h" |
37 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" | 35 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" |
38 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 36 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
39 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 37 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
40 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" | 38 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
41 #include "ui/views/widget/drop_helper.h" | 39 #include "ui/views/widget/drop_helper.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 View* view_for_activation = | 370 View* view_for_activation = |
373 GetWidget()->GetFocusManager()->GetFocusedView() ? | 371 GetWidget()->GetFocusManager()->GetFocusedView() ? |
374 GetWidget()->GetFocusManager()->GetFocusedView() : | 372 GetWidget()->GetFocusManager()->GetFocusedView() : |
375 GetWidget()->GetFocusManager()->GetStoredFocusView(); | 373 GetWidget()->GetFocusManager()->GetStoredFocusView(); |
376 if (!view_for_activation) | 374 if (!view_for_activation) |
377 view_for_activation = GetWidget()->GetRootView(); | 375 view_for_activation = GetWidget()->GetRootView(); |
378 activation_client->ActivateWindow( | 376 activation_client->ActivateWindow( |
379 view_for_activation->GetWidget()->GetNativeView()); | 377 view_for_activation->GetWidget()->GetNativeView()); |
380 // Refreshes the focus info to IMF in case that IMF cached the old info | 378 // Refreshes the focus info to IMF in case that IMF cached the old info |
381 // about focused text input client when it was "inactive". | 379 // about focused text input client when it was "inactive". |
382 GetHostInputMethod()->OnFocus(); | 380 GetInputMethod()->OnFocus(); |
James Su
2015/06/16 09:18:33
I'm wondering why this line is inside if (GetWidge
Shu Chen
2015/06/17 02:27:52
This CL doesn't change the original behaviors.
I
| |
383 } | 381 } |
384 } else { | 382 } else { |
385 // If we're not active we need to deactivate the corresponding | 383 // If we're not active we need to deactivate the corresponding |
386 // aura::Window. This way if a child widget is active it gets correctly | 384 // aura::Window. This way if a child widget is active it gets correctly |
387 // deactivated (child widgets don't get native desktop activation changes, | 385 // deactivated (child widgets don't get native desktop activation changes, |
388 // only aura activation changes). | 386 // only aura activation changes). |
389 aura::Window* active_window = activation_client->GetActiveWindow(); | 387 aura::Window* active_window = activation_client->GetActiveWindow(); |
390 if (active_window) { | 388 if (active_window) { |
391 activation_client->DeactivateWindow(active_window); | 389 activation_client->DeactivateWindow(active_window); |
392 GetHostInputMethod()->OnBlur(); | 390 GetInputMethod()->OnBlur(); |
James Su
2015/06/16 09:18:33
ditto
Shu Chen
2015/06/17 02:27:52
ditto.
| |
393 } | 391 } |
394 } | 392 } |
395 } | 393 } |
396 | 394 |
397 //////////////////////////////////////////////////////////////////////////////// | 395 //////////////////////////////////////////////////////////////////////////////// |
398 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: | 396 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: |
399 | 397 |
400 void DesktopNativeWidgetAura::InitNativeWidget( | 398 void DesktopNativeWidgetAura::InitNativeWidget( |
401 const Widget::InitParams& params) { | 399 const Widget::InitParams& params) { |
402 ownership_ = params.ownership; | 400 ownership_ = params.ownership; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
620 return; | 618 return; |
621 | 619 |
622 content_window_->ReleaseCapture(); | 620 content_window_->ReleaseCapture(); |
623 } | 621 } |
624 | 622 |
625 bool DesktopNativeWidgetAura::HasCapture() const { | 623 bool DesktopNativeWidgetAura::HasCapture() const { |
626 return content_window_ && content_window_->HasCapture() && | 624 return content_window_ && content_window_->HasCapture() && |
627 desktop_window_tree_host_->HasCapture(); | 625 desktop_window_tree_host_->HasCapture(); |
628 } | 626 } |
629 | 627 |
630 InputMethod* DesktopNativeWidgetAura::CreateInputMethod() { | 628 ui::InputMethod* DesktopNativeWidgetAura::GetInputMethod() { |
631 return new InputMethodBridge(this, GetHostInputMethod(), false); | 629 return host() ? host()->GetInputMethod() : nullptr; |
632 } | |
633 | |
634 internal::InputMethodDelegate* | |
635 DesktopNativeWidgetAura::GetInputMethodDelegate() { | |
636 return this; | |
637 } | |
638 | |
639 ui::InputMethod* DesktopNativeWidgetAura::GetHostInputMethod() { | |
640 return host()->GetInputMethod(); | |
641 } | 630 } |
642 | 631 |
643 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { | 632 void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) { |
644 if (content_window_) | 633 if (content_window_) |
645 desktop_window_tree_host_->CenterWindow(size); | 634 desktop_window_tree_host_->CenterWindow(size); |
646 } | 635 } |
647 | 636 |
648 void DesktopNativeWidgetAura::GetWindowPlacement( | 637 void DesktopNativeWidgetAura::GetWindowPlacement( |
649 gfx::Rect* bounds, | 638 gfx::Rect* bounds, |
650 ui::WindowShowState* maximized) const { | 639 ui::WindowShowState* maximized) const { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 // DesktopNativeWidgetAura, aura::WindowDelegate implementation: | 962 // DesktopNativeWidgetAura, aura::WindowDelegate implementation: |
974 | 963 |
975 gfx::Size DesktopNativeWidgetAura::GetMinimumSize() const { | 964 gfx::Size DesktopNativeWidgetAura::GetMinimumSize() const { |
976 return native_widget_delegate_->GetMinimumSize(); | 965 return native_widget_delegate_->GetMinimumSize(); |
977 } | 966 } |
978 | 967 |
979 gfx::Size DesktopNativeWidgetAura::GetMaximumSize() const { | 968 gfx::Size DesktopNativeWidgetAura::GetMaximumSize() const { |
980 return native_widget_delegate_->GetMaximumSize(); | 969 return native_widget_delegate_->GetMaximumSize(); |
981 } | 970 } |
982 | 971 |
983 ui::TextInputClient* DesktopNativeWidgetAura::GetFocusedTextInputClient() { | |
984 return GetWidget()->GetFocusedTextInputClient(); | |
985 } | |
986 | |
987 gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) { | 972 gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) { |
988 return cursor_; | 973 return cursor_; |
989 } | 974 } |
990 | 975 |
991 int DesktopNativeWidgetAura::GetNonClientComponent( | 976 int DesktopNativeWidgetAura::GetNonClientComponent( |
992 const gfx::Point& point) const { | 977 const gfx::Point& point) const { |
993 return native_widget_delegate_->GetNonClientComponent(point); | 978 return native_widget_delegate_->GetNonClientComponent(point); |
994 } | 979 } |
995 | 980 |
996 bool DesktopNativeWidgetAura::ShouldDescendIntoChildForEventHandling( | 981 bool DesktopNativeWidgetAura::ShouldDescendIntoChildForEventHandling( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1120 } | 1105 } |
1121 | 1106 |
1122 //////////////////////////////////////////////////////////////////////////////// | 1107 //////////////////////////////////////////////////////////////////////////////// |
1123 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: | 1108 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: |
1124 | 1109 |
1125 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, | 1110 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, |
1126 aura::Window* lost_focus) { | 1111 aura::Window* lost_focus) { |
1127 if (content_window_ == gained_focus) { | 1112 if (content_window_ == gained_focus) { |
1128 desktop_window_tree_host_->OnNativeWidgetFocus(); | 1113 desktop_window_tree_host_->OnNativeWidgetFocus(); |
1129 native_widget_delegate_->OnNativeFocus(); | 1114 native_widget_delegate_->OnNativeFocus(); |
1130 | |
1131 // If focus is moving from a descendant Window to |content_window_| then | |
1132 // native activation hasn't changed. Still, the InputMethod must be informed | |
1133 // of the Window focus change. | |
1134 InputMethod* input_method = GetWidget()->GetInputMethod(); | |
1135 if (input_method) | |
1136 input_method->OnFocus(); | |
1137 } else if (content_window_ == lost_focus) { | 1115 } else if (content_window_ == lost_focus) { |
1138 desktop_window_tree_host_->OnNativeWidgetBlur(); | 1116 desktop_window_tree_host_->OnNativeWidgetBlur(); |
1139 native_widget_delegate_->OnNativeBlur(); | 1117 native_widget_delegate_->OnNativeBlur(); |
1140 } | 1118 } |
1141 } | 1119 } |
1142 | 1120 |
1143 //////////////////////////////////////////////////////////////////////////////// | 1121 //////////////////////////////////////////////////////////////////////////////// |
1144 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: | |
1145 | |
1146 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { | |
1147 FocusManager* focus_manager = | |
1148 native_widget_delegate_->AsWidget()->GetFocusManager(); | |
1149 native_widget_delegate_->OnKeyEvent(const_cast<ui::KeyEvent*>(&key)); | |
1150 if (key.handled() || !focus_manager) | |
1151 return; | |
1152 focus_manager->OnKeyEvent(key); | |
1153 } | |
1154 | |
1155 //////////////////////////////////////////////////////////////////////////////// | |
1156 // DesktopNativeWidgetAura, aura::WindowDragDropDelegate implementation: | 1122 // DesktopNativeWidgetAura, aura::WindowDragDropDelegate implementation: |
1157 | 1123 |
1158 void DesktopNativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { | 1124 void DesktopNativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { |
1159 DCHECK(drop_helper_.get() != NULL); | 1125 DCHECK(drop_helper_.get() != NULL); |
1160 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), | 1126 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), |
1161 event.location(), event.source_operations()); | 1127 event.location(), event.source_operations()); |
1162 } | 1128 } |
1163 | 1129 |
1164 int DesktopNativeWidgetAura::OnDragUpdated(const ui::DropTargetEvent& event) { | 1130 int DesktopNativeWidgetAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
1165 DCHECK(drop_helper_.get() != NULL); | 1131 DCHECK(drop_helper_.get() != NULL); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1229 if (cursor_reference_count_ == 0) { | 1195 if (cursor_reference_count_ == 0) { |
1230 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1196 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1231 // for cleaning up |cursor_manager_|. | 1197 // for cleaning up |cursor_manager_|. |
1232 delete cursor_manager_; | 1198 delete cursor_manager_; |
1233 native_cursor_manager_ = NULL; | 1199 native_cursor_manager_ = NULL; |
1234 cursor_manager_ = NULL; | 1200 cursor_manager_ = NULL; |
1235 } | 1201 } |
1236 } | 1202 } |
1237 | 1203 |
1238 } // namespace views | 1204 } // namespace views |
OLD | NEW |