OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "mandoline/ui/aura/native_widget_view_manager.h" | 5 #include "mandoline/ui/aura/native_widget_view_manager.h" |
6 | 6 |
| 7 #include "mandoline/ui/aura/input_method_mandoline.h" |
7 #include "mandoline/ui/aura/window_tree_host_mojo.h" | 8 #include "mandoline/ui/aura/window_tree_host_mojo.h" |
8 #include "mojo/converters/geometry/geometry_type_converters.h" | 9 #include "mojo/converters/geometry/geometry_type_converters.h" |
9 #include "mojo/converters/input_events/input_events_type_converters.h" | 10 #include "mojo/converters/input_events/input_events_type_converters.h" |
10 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
11 #include "ui/aura/client/default_capture_client.h" | 12 #include "ui/aura/client/default_capture_client.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
14 #include "ui/base/ime/input_method.h" | |
15 #include "ui/base/ime/input_method_base.h" | |
16 #include "ui/base/ime/input_method_delegate.h" | 15 #include "ui/base/ime/input_method_delegate.h" |
17 #include "ui/base/ime/input_method_factory.h" | |
18 #include "ui/base/ime/text_input_client.h" | |
19 #include "ui/wm/core/base_focus_rules.h" | 16 #include "ui/wm/core/base_focus_rules.h" |
20 #include "ui/wm/core/capture_controller.h" | 17 #include "ui/wm/core/capture_controller.h" |
21 #include "ui/wm/core/focus_controller.h" | 18 #include "ui/wm/core/focus_controller.h" |
22 | 19 |
23 #if defined(OS_LINUX) | |
24 #include "mandoline/ui/aura/input_method_mojo_linux.h" | |
25 #endif | |
26 | |
27 namespace mandoline { | 20 namespace mandoline { |
28 namespace { | 21 namespace { |
29 | 22 |
30 // TODO: figure out what this should be. | 23 // TODO: figure out what this should be. |
31 class FocusRulesImpl : public wm::BaseFocusRules { | 24 class FocusRulesImpl : public wm::BaseFocusRules { |
32 public: | 25 public: |
33 FocusRulesImpl() {} | 26 FocusRulesImpl() {} |
34 ~FocusRulesImpl() override {} | 27 ~FocusRulesImpl() override {} |
35 | 28 |
36 bool SupportsChildActivation(aura::Window* window) const override { | 29 bool SupportsChildActivation(aura::Window* window) const override { |
37 return true; | 30 return true; |
38 } | 31 } |
39 | 32 |
40 private: | 33 private: |
41 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); | 34 DISALLOW_COPY_AND_ASSIGN(FocusRulesImpl); |
42 }; | 35 }; |
43 | 36 |
44 class MinimalInputEventFilter : public ui::internal::InputMethodDelegate, | 37 class MinimalInputEventFilter : public ui::internal::InputMethodDelegate, |
45 public ui::EventHandler { | 38 public ui::EventHandler { |
46 public: | 39 public: |
47 explicit MinimalInputEventFilter(aura::Window* root) | 40 explicit MinimalInputEventFilter(aura::Window* root) |
48 : root_(root) { | 41 : root_(root) { |
49 ui::InitializeInputMethodForTesting(); | 42 input_method_.reset(new InputMethodMandoline(this)); |
50 #if defined(OS_LINUX) | 43 input_method_->OnFocus(); |
51 input_method_.reset(new InputMethodMojoLinux(this)); | |
52 #else | |
53 input_method_ = ui::CreateInputMethod(this, gfx::kNullAcceleratedWidget); | |
54 #endif | |
55 root_->AddPreTargetHandler(this); | 44 root_->AddPreTargetHandler(this); |
56 root_->SetProperty(aura::client::kRootWindowInputMethodKey, | 45 root_->SetProperty(aura::client::kRootWindowInputMethodKey, |
57 input_method_.get()); | 46 input_method_.get()); |
58 } | 47 } |
59 | 48 |
60 ~MinimalInputEventFilter() override { | 49 ~MinimalInputEventFilter() override { |
61 root_->RemovePreTargetHandler(this); | 50 root_->RemovePreTargetHandler(this); |
62 root_->SetProperty(aura::client::kRootWindowInputMethodKey, | 51 root_->SetProperty(aura::client::kRootWindowInputMethodKey, |
63 static_cast<ui::InputMethod*>(NULL)); | 52 static_cast<ui::InputMethod*>(NULL)); |
64 } | 53 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 144 } |
156 | 145 |
157 void NativeWidgetViewManager::OnViewInputEvent(mojo::View* view, | 146 void NativeWidgetViewManager::OnViewInputEvent(mojo::View* view, |
158 const mojo::EventPtr& event) { | 147 const mojo::EventPtr& event) { |
159 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event> >()); | 148 scoped_ptr<ui::Event> ui_event(event.To<scoped_ptr<ui::Event> >()); |
160 if (ui_event) | 149 if (ui_event) |
161 window_tree_host_->SendEventToProcessor(ui_event.get()); | 150 window_tree_host_->SendEventToProcessor(ui_event.get()); |
162 } | 151 } |
163 | 152 |
164 } // namespace mandoline | 153 } // namespace mandoline |
OLD | NEW |