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/native_widget_aura.h" | 5 #include "ui/views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "third_party/skia/include/core/SkRegion.h" | 9 #include "third_party/skia/include/core/SkRegion.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/focus_client.h" | 12 #include "ui/aura/client/focus_client.h" |
13 #include "ui/aura/client/screen_position_client.h" | 13 #include "ui/aura/client/screen_position_client.h" |
14 #include "ui/aura/client/window_tree_client.h" | 14 #include "ui/aura/client/window_tree_client.h" |
15 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
16 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
17 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
18 #include "ui/aura/window_observer.h" | 18 #include "ui/aura/window_observer.h" |
19 #include "ui/base/dragdrop/os_exchange_data.h" | 19 #include "ui/base/dragdrop/os_exchange_data.h" |
| 20 #include "ui/base/ui_base_switches_util.h" |
20 #include "ui/base/ui_base_types.h" | 21 #include "ui/base/ui_base_types.h" |
21 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
22 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
23 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
24 #include "ui/gfx/font_list.h" | 25 #include "ui/gfx/font_list.h" |
25 #include "ui/gfx/screen.h" | 26 #include "ui/gfx/screen.h" |
26 #include "ui/native_theme/native_theme_aura.h" | 27 #include "ui/native_theme/native_theme_aura.h" |
27 #include "ui/views/drag_utils.h" | 28 #include "ui/views/drag_utils.h" |
28 #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" |
29 #include "ui/views/views_delegate.h" | 31 #include "ui/views/views_delegate.h" |
30 #include "ui/views/widget/drop_helper.h" | 32 #include "ui/views/widget/drop_helper.h" |
31 #include "ui/views/widget/native_widget_delegate.h" | 33 #include "ui/views/widget/native_widget_delegate.h" |
32 #include "ui/views/widget/root_view.h" | 34 #include "ui/views/widget/root_view.h" |
33 #include "ui/views/widget/tooltip_manager_aura.h" | 35 #include "ui/views/widget/tooltip_manager_aura.h" |
34 #include "ui/views/widget/widget_aura_utils.h" | 36 #include "ui/views/widget/widget_aura_utils.h" |
35 #include "ui/views/widget/widget_delegate.h" | 37 #include "ui/views/widget/widget_delegate.h" |
36 #include "ui/views/widget/window_reorderer.h" | 38 #include "ui/views/widget/window_reorderer.h" |
37 #include "ui/wm/core/window_util.h" | 39 #include "ui/wm/core/window_util.h" |
38 #include "ui/wm/public/activation_client.h" | 40 #include "ui/wm/public/activation_client.h" |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 window_->ReleaseCapture(); | 265 window_->ReleaseCapture(); |
264 } | 266 } |
265 | 267 |
266 bool NativeWidgetAura::HasCapture() const { | 268 bool NativeWidgetAura::HasCapture() const { |
267 return window_ && window_->HasCapture(); | 269 return window_ && window_->HasCapture(); |
268 } | 270 } |
269 | 271 |
270 InputMethod* NativeWidgetAura::CreateInputMethod() { | 272 InputMethod* NativeWidgetAura::CreateInputMethod() { |
271 if (!window_) | 273 if (!window_) |
272 return NULL; | 274 return NULL; |
| 275 |
| 276 if (switches::IsTextInputFocusManagerEnabled()) |
| 277 return new NullInputMethod(); |
| 278 |
273 aura::Window* root_window = window_->GetRootWindow(); | 279 aura::Window* root_window = window_->GetRootWindow(); |
274 ui::InputMethod* host = | 280 ui::InputMethod* host = |
275 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 281 root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
276 return new InputMethodBridge(this, host, true); | 282 return new InputMethodBridge(this, host, true); |
277 } | 283 } |
278 | 284 |
279 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() { | 285 internal::InputMethodDelegate* NativeWidgetAura::GetInputMethodDelegate() { |
280 return this; | 286 return this; |
281 } | 287 } |
282 | 288 |
| 289 ui::InputMethod* NativeWidgetAura::GetHostInputMethod() { |
| 290 aura::Window* root_window = window_->GetRootWindow(); |
| 291 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
| 292 } |
| 293 |
283 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { | 294 void NativeWidgetAura::CenterWindow(const gfx::Size& size) { |
284 if (!window_) | 295 if (!window_) |
285 return; | 296 return; |
286 | 297 |
287 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); | 298 gfx::Rect parent_bounds(window_->parent()->GetBoundsInRootWindow()); |
288 // When centering window, we take the intersection of the host and | 299 // When centering window, we take the intersection of the host and |
289 // the parent. We assume the root window represents the visible | 300 // the parent. We assume the root window represents the visible |
290 // rect of a single screen. | 301 // rect of a single screen. |
291 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)-> | 302 gfx::Rect work_area = gfx::Screen::GetScreenFor(window_)-> |
292 GetDisplayNearestWindow(window_).work_area(); | 303 GetDisplayNearestWindow(window_).work_area(); |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 // events are handled inside the object and are not passed to this function. | 825 // events are handled inside the object and are not passed to this function. |
815 // If such object is not attached, character events might be sent (e.g. on | 826 // If such object is not attached, character events might be sent (e.g. on |
816 // Windows). In this case, we just skip these. | 827 // Windows). In this case, we just skip these. |
817 return; | 828 return; |
818 } | 829 } |
819 // Renderer may send a key event back to us if the key event wasn't handled, | 830 // Renderer may send a key event back to us if the key event wasn't handled, |
820 // and the window may be invisible by that time. | 831 // and the window may be invisible by that time. |
821 if (!window_->IsVisible()) | 832 if (!window_->IsVisible()) |
822 return; | 833 return; |
823 GetWidget()->GetInputMethod()->DispatchKeyEvent(*event); | 834 GetWidget()->GetInputMethod()->DispatchKeyEvent(*event); |
| 835 if (switches::IsTextInputFocusManagerEnabled()) { |
| 836 FocusManager* focus_manager = GetWidget()->GetFocusManager(); |
| 837 delegate_->OnKeyEvent(event); |
| 838 if (!event->handled() && focus_manager) |
| 839 focus_manager->OnKeyEvent(*event); |
| 840 } |
824 event->SetHandled(); | 841 event->SetHandled(); |
825 } | 842 } |
826 | 843 |
827 void NativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { | 844 void NativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { |
828 DCHECK(window_); | 845 DCHECK(window_); |
829 DCHECK(window_->IsVisible()); | 846 DCHECK(window_->IsVisible()); |
830 if (event->type() == ui::ET_MOUSEWHEEL) { | 847 if (event->type() == ui::ET_MOUSEWHEEL) { |
831 delegate_->OnMouseEvent(event); | 848 delegate_->OnMouseEvent(event); |
832 if (event->handled()) | 849 if (event->handled()) |
833 return; | 850 return; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 1157 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
1141 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 1158 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
1142 return gfx::FontList(gfx::Font(caption_font)); | 1159 return gfx::FontList(gfx::Font(caption_font)); |
1143 #else | 1160 #else |
1144 return gfx::FontList(); | 1161 return gfx::FontList(); |
1145 #endif | 1162 #endif |
1146 } | 1163 } |
1147 | 1164 |
1148 } // namespace internal | 1165 } // namespace internal |
1149 } // namespace views | 1166 } // namespace views |
OLD | NEW |