| 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/env.h" | 9 #include "ui/aura/env.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 SetPlatformWindow(base::MakeUnique<ui::StubWindow>( | 52 SetPlatformWindow(base::MakeUnique<ui::StubWindow>( |
| 53 this, | 53 this, |
| 54 false)); // Do not advertise accelerated widget; already set manually. | 54 false)); // Do not advertise accelerated widget; already set manually. |
| 55 | 55 |
| 56 compositor()->SetWindow(window); | 56 compositor()->SetWindow(window); |
| 57 | 57 |
| 58 // Initialize the stub platform window bounds to those of the ui::Window. | 58 // Initialize the stub platform window bounds to those of the ui::Window. |
| 59 platform_window()->SetBounds(window->bounds()); | 59 platform_window()->SetBounds(window->bounds()); |
| 60 | 60 |
| 61 compositor()->SetHostHasTransparentBackground(true); | 61 compositor()->SetHostHasTransparentBackground(true); |
| 62 | |
| 63 input_method_ = base::MakeUnique<InputMethodMus>(this, window); | |
| 64 SetSharedInputMethod(input_method_.get()); | |
| 65 } | 62 } |
| 66 | 63 |
| 67 WindowTreeHostMus::~WindowTreeHostMus() { | 64 WindowTreeHostMus::~WindowTreeHostMus() { |
| 68 DestroyCompositor(); | 65 DestroyCompositor(); |
| 69 DestroyDispatcher(); | 66 DestroyDispatcher(); |
| 70 } | 67 } |
| 71 | 68 |
| 72 void WindowTreeHostMus::InitInputMethod(service_manager::Connector* connector) { | |
| 73 input_method_->Init(connector); | |
| 74 } | |
| 75 | |
| 76 void WindowTreeHostMus::DispatchEvent(ui::Event* event) { | 69 void WindowTreeHostMus::DispatchEvent(ui::Event* event) { |
| 77 if (event->IsKeyEvent() && GetInputMethod()) { | 70 // Key events are sent to InputMethodMus directly from NativeWidgetMus. |
| 78 GetInputMethod()->DispatchKeyEvent(event->AsKeyEvent()); | 71 DCHECK(!event->IsKeyEvent()); |
| 79 return; | |
| 80 } | |
| 81 WindowTreeHostPlatform::DispatchEvent(event); | 72 WindowTreeHostPlatform::DispatchEvent(event); |
| 82 } | 73 } |
| 83 | 74 |
| 84 void WindowTreeHostMus::OnClosed() { | 75 void WindowTreeHostMus::OnClosed() { |
| 85 if (native_widget_) | 76 if (native_widget_) |
| 86 native_widget_->OnPlatformWindowClosed(); | 77 native_widget_->OnPlatformWindowClosed(); |
| 87 } | 78 } |
| 88 | 79 |
| 89 void WindowTreeHostMus::OnActivationChanged(bool active) { | 80 void WindowTreeHostMus::OnActivationChanged(bool active) { |
| 90 if (active) | 81 if (active) |
| 91 GetInputMethod()->OnFocus(); | 82 GetInputMethod()->OnFocus(); |
| 92 else | 83 else |
| 93 GetInputMethod()->OnBlur(); | 84 GetInputMethod()->OnBlur(); |
| 94 if (native_widget_) | 85 if (native_widget_) |
| 95 native_widget_->OnActivationChanged(active); | 86 native_widget_->OnActivationChanged(active); |
| 96 WindowTreeHostPlatform::OnActivationChanged(active); | 87 WindowTreeHostPlatform::OnActivationChanged(active); |
| 97 } | 88 } |
| 98 | 89 |
| 99 void WindowTreeHostMus::OnCloseRequest() { | 90 void WindowTreeHostMus::OnCloseRequest() { |
| 100 OnHostCloseRequested(); | 91 OnHostCloseRequested(); |
| 101 } | 92 } |
| 102 | 93 |
| 103 gfx::ICCProfile WindowTreeHostMus::GetICCProfileForCurrentDisplay() { | 94 gfx::ICCProfile WindowTreeHostMus::GetICCProfileForCurrentDisplay() { |
| 104 // TODO: This should read the profile from mus. crbug.com/647510 | 95 // TODO: This should read the profile from mus. crbug.com/647510 |
| 105 return gfx::ICCProfile(); | 96 return gfx::ICCProfile(); |
| 106 } | 97 } |
| 107 | 98 |
| 108 } // namespace views | 99 } // namespace views |
| OLD | NEW |