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 "ui/views/mus/window_tree_host_mus.h" | 5 #include "ui/views/mus/window_tree_host_mus.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "services/ui/public/cpp/window.h" | 8 #include "services/ui/public/cpp/window.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_event_dispatcher.h" | 10 #include "ui/aura/window_event_dispatcher.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // Initialize the stub platform window bounds to those of the ui::Window. | 47 // Initialize the stub platform window bounds to those of the ui::Window. |
48 platform_window()->SetBounds(window->bounds()); | 48 platform_window()->SetBounds(window->bounds()); |
49 | 49 |
50 // The location of events is already transformed, and there is no way to | 50 // The location of events is already transformed, and there is no way to |
51 // correctly determine the reverse transform. So, don't attempt to transform | 51 // correctly determine the reverse transform. So, don't attempt to transform |
52 // event locations, else the root location is wrong. | 52 // event locations, else the root location is wrong. |
53 // TODO(sky): we need to transform for device scale though. | 53 // TODO(sky): we need to transform for device scale though. |
54 dispatcher()->set_transform_events(false); | 54 dispatcher()->set_transform_events(false); |
55 compositor()->SetHostHasTransparentBackground(true); | 55 compositor()->SetHostHasTransparentBackground(true); |
56 | 56 |
57 input_method_.reset(new InputMethodMUS(this, window)); | 57 input_method_.reset(new InputMethodMus(this, window)); |
58 SetSharedInputMethod(input_method_.get()); | 58 SetSharedInputMethod(input_method_.get()); |
59 } | 59 } |
60 | 60 |
61 WindowTreeHostMus::~WindowTreeHostMus() { | 61 WindowTreeHostMus::~WindowTreeHostMus() { |
62 DestroyCompositor(); | 62 DestroyCompositor(); |
63 DestroyDispatcher(); | 63 DestroyDispatcher(); |
64 } | 64 } |
65 | 65 |
| 66 void WindowTreeHostMus::InitInputMethod(shell::Connector* connector) { |
| 67 input_method_->Init(connector); |
| 68 } |
| 69 |
66 void WindowTreeHostMus::DispatchEvent(ui::Event* event) { | 70 void WindowTreeHostMus::DispatchEvent(ui::Event* event) { |
67 if (event->IsKeyEvent() && GetInputMethod()) { | 71 if (event->IsKeyEvent() && GetInputMethod()) { |
68 GetInputMethod()->DispatchKeyEvent(event->AsKeyEvent()); | 72 GetInputMethod()->DispatchKeyEvent(event->AsKeyEvent()); |
69 return; | 73 return; |
70 } | 74 } |
71 WindowTreeHostPlatform::DispatchEvent(event); | 75 WindowTreeHostPlatform::DispatchEvent(event); |
72 } | 76 } |
73 | 77 |
74 void WindowTreeHostMus::OnClosed() { | 78 void WindowTreeHostMus::OnClosed() { |
75 if (native_widget_) | 79 if (native_widget_) |
76 native_widget_->OnPlatformWindowClosed(); | 80 native_widget_->OnPlatformWindowClosed(); |
77 } | 81 } |
78 | 82 |
79 void WindowTreeHostMus::OnActivationChanged(bool active) { | 83 void WindowTreeHostMus::OnActivationChanged(bool active) { |
80 if (active) | 84 if (active) |
81 GetInputMethod()->OnFocus(); | 85 GetInputMethod()->OnFocus(); |
82 else | 86 else |
83 GetInputMethod()->OnBlur(); | 87 GetInputMethod()->OnBlur(); |
84 if (native_widget_) | 88 if (native_widget_) |
85 native_widget_->OnActivationChanged(active); | 89 native_widget_->OnActivationChanged(active); |
86 WindowTreeHostPlatform::OnActivationChanged(active); | 90 WindowTreeHostPlatform::OnActivationChanged(active); |
87 } | 91 } |
88 | 92 |
89 void WindowTreeHostMus::OnCloseRequest() { | 93 void WindowTreeHostMus::OnCloseRequest() { |
90 OnHostCloseRequested(); | 94 OnHostCloseRequested(); |
91 } | 95 } |
92 | 96 |
93 } // namespace views | 97 } // namespace views |
OLD | NEW |