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()); |
73 event->StopPropagation(); | |
sky
2016/08/25 20:17:53
I tend to think this should be in InputMethodMus::
Hadi
2016/08/26 15:57:07
Move it. Also I added a temporary check so we only
| |
69 return; | 74 return; |
70 } | 75 } |
71 WindowTreeHostPlatform::DispatchEvent(event); | 76 WindowTreeHostPlatform::DispatchEvent(event); |
72 } | 77 } |
73 | 78 |
74 void WindowTreeHostMus::OnClosed() { | 79 void WindowTreeHostMus::OnClosed() { |
75 if (native_widget_) | 80 if (native_widget_) |
76 native_widget_->OnPlatformWindowClosed(); | 81 native_widget_->OnPlatformWindowClosed(); |
77 } | 82 } |
78 | 83 |
79 void WindowTreeHostMus::OnActivationChanged(bool active) { | 84 void WindowTreeHostMus::OnActivationChanged(bool active) { |
80 if (active) | 85 if (active) |
81 GetInputMethod()->OnFocus(); | 86 GetInputMethod()->OnFocus(); |
82 else | 87 else |
83 GetInputMethod()->OnBlur(); | 88 GetInputMethod()->OnBlur(); |
84 if (native_widget_) | 89 if (native_widget_) |
85 native_widget_->OnActivationChanged(active); | 90 native_widget_->OnActivationChanged(active); |
86 WindowTreeHostPlatform::OnActivationChanged(active); | 91 WindowTreeHostPlatform::OnActivationChanged(active); |
87 } | 92 } |
88 | 93 |
89 void WindowTreeHostMus::OnCloseRequest() { | 94 void WindowTreeHostMus::OnCloseRequest() { |
90 OnHostCloseRequested(); | 95 OnHostCloseRequested(); |
91 } | 96 } |
92 | 97 |
93 } // namespace views | 98 } // namespace views |
OLD | NEW |