Chromium Code Reviews| 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/aura/mus/window_tree_host_mus.h" | 5 #include "ui/aura/mus/window_tree_host_mus.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/aura/env.h" | 8 #include "ui/aura/env.h" |
| 9 #include "ui/aura/mus/input_method_mus.h" | 9 #include "ui/aura/mus/input_method_mus.h" |
| 10 #include "ui/aura/mus/window_port_mus.h" | 10 #include "ui/aura/mus/window_port_mus.h" |
| 11 #include "ui/aura/mus/window_tree_client.h" | 11 #include "ui/aura/mus/window_tree_client.h" |
| 12 #include "ui/aura/mus/window_tree_host_mus_delegate.h" | 12 #include "ui/aura/mus/window_tree_host_mus_delegate.h" |
| 13 #include "ui/aura/mus/window_tree_host_mus_init_params.h" | 13 #include "ui/aura/mus/window_tree_host_mus_init_params.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/base/class_property.h" | 16 #include "ui/base/class_property.h" |
| 17 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 18 #include "ui/display/screen.h" | 18 #include "ui/display/screen.h" |
| 19 #include "ui/events/event.h" | 19 #include "ui/events/event.h" |
| 20 #include "ui/platform_window/stub/stub_window.h" | 20 #include "ui/platform_window/stub/stub_window.h" |
| 21 | 21 |
| 22 #if defined(OS_CHROMEOS) | |
| 23 #include "ui/base/ime/input_method_chromeos.h" | |
| 24 #endif | |
| 25 | |
| 22 DECLARE_UI_CLASS_PROPERTY_TYPE(aura::WindowTreeHostMus*); | 26 DECLARE_UI_CLASS_PROPERTY_TYPE(aura::WindowTreeHostMus*); |
| 23 | 27 |
| 24 namespace aura { | 28 namespace aura { |
| 25 | 29 |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| 28 DEFINE_UI_CLASS_PROPERTY_KEY( | 32 DEFINE_UI_CLASS_PROPERTY_KEY( |
| 29 WindowTreeHostMus*, kWindowTreeHostMusKey, nullptr); | 33 WindowTreeHostMus*, kWindowTreeHostMusKey, nullptr); |
| 30 | 34 |
| 31 static uint32_t accelerated_widget_count = 1; | 35 static uint32_t accelerated_widget_count = 1; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 OnAcceleratedWidgetAvailable(accelerated_widget, | 77 OnAcceleratedWidgetAvailable(accelerated_widget, |
| 74 GetDisplay().device_scale_factor()); | 78 GetDisplay().device_scale_factor()); |
| 75 | 79 |
| 76 delegate_->OnWindowTreeHostCreated(this); | 80 delegate_->OnWindowTreeHostCreated(this); |
| 77 | 81 |
| 78 // Do not advertise accelerated widget; already set manually. | 82 // Do not advertise accelerated widget; already set manually. |
| 79 const bool use_default_accelerated_widget = false; | 83 const bool use_default_accelerated_widget = false; |
| 80 SetPlatformWindow( | 84 SetPlatformWindow( |
| 81 base::MakeUnique<ui::StubWindow>(this, use_default_accelerated_widget)); | 85 base::MakeUnique<ui::StubWindow>(this, use_default_accelerated_widget)); |
| 82 | 86 |
| 83 input_method_ = base::MakeUnique<InputMethodMus>(this, window()); | 87 InitInputMethod(&init_params); |
| 84 input_method_->Init(init_params.window_tree_client->connector()); | |
| 85 SetSharedInputMethod(input_method_.get()); | |
| 86 | |
| 87 compositor()->SetHostHasTransparentBackground(true); | 88 compositor()->SetHostHasTransparentBackground(true); |
| 88 | 89 |
| 89 // Mus windows are assumed hidden. | 90 // Mus windows are assumed hidden. |
| 90 compositor()->SetVisible(false); | 91 compositor()->SetVisible(false); |
| 91 | 92 |
| 92 if (init_params.frame_sink_id.is_valid()) | 93 if (init_params.frame_sink_id.is_valid()) |
| 93 window_mus->SetFrameSinkIdFromServer(init_params.frame_sink_id); | 94 window_mus->SetFrameSinkIdFromServer(init_params.frame_sink_id); |
| 94 } | 95 } |
| 95 | 96 |
| 96 WindowTreeHostMus::~WindowTreeHostMus() { | 97 WindowTreeHostMus::~WindowTreeHostMus() { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 112 } | 113 } |
| 113 | 114 |
| 114 return root->GetProperty(kWindowTreeHostMusKey); | 115 return root->GetProperty(kWindowTreeHostMusKey); |
| 115 } | 116 } |
| 116 | 117 |
| 117 void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds_in_pixels) { | 118 void WindowTreeHostMus::SetBoundsFromServer(const gfx::Rect& bounds_in_pixels) { |
| 118 base::AutoReset<bool> resetter(&in_set_bounds_from_server_, true); | 119 base::AutoReset<bool> resetter(&in_set_bounds_from_server_, true); |
| 119 SetBoundsInPixels(bounds_in_pixels); | 120 SetBoundsInPixels(bounds_in_pixels); |
| 120 } | 121 } |
| 121 | 122 |
| 123 void WindowTreeHostMus::DispatchEventToInputMethod( | |
| 124 ui::KeyEvent* event, | |
| 125 std::unique_ptr<base::Callback<void(bool)>> ack_callback) { | |
| 126 #if defined(OS_CHROMEOS) | |
| 127 if (input_method_chromeos_) { | |
| 128 input_method_chromeos_->DispatchKeyEvent(event, std::move(ack_callback)); | |
| 129 return; | |
| 130 } | |
| 131 #endif | |
| 132 DCHECK(input_method_mus_); | |
| 133 input_method_mus_->DispatchKeyEvent(event, std::move(ack_callback)); | |
| 134 } | |
| 135 | |
| 122 void WindowTreeHostMus::SetClientArea( | 136 void WindowTreeHostMus::SetClientArea( |
| 123 const gfx::Insets& insets, | 137 const gfx::Insets& insets, |
| 124 const std::vector<gfx::Rect>& additional_client_area) { | 138 const std::vector<gfx::Rect>& additional_client_area) { |
| 125 delegate_->OnWindowTreeHostClientAreaWillChange(this, insets, | 139 delegate_->OnWindowTreeHostClientAreaWillChange(this, insets, |
| 126 additional_client_area); | 140 additional_client_area); |
| 127 } | 141 } |
| 128 | 142 |
| 129 void WindowTreeHostMus::SetHitTestMask(const base::Optional<gfx::Rect>& rect) { | 143 void WindowTreeHostMus::SetHitTestMask(const base::Optional<gfx::Rect>& rect) { |
| 130 delegate_->OnWindowTreeHostHitTestMaskWillChange(this, rect); | 144 delegate_->OnWindowTreeHostHitTestMaskWillChange(this, rect); |
| 131 } | 145 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 | 216 |
| 203 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( | 217 void WindowTreeHostMus::MoveCursorToScreenLocationInPixels( |
| 204 const gfx::Point& location_in_pixels) { | 218 const gfx::Point& location_in_pixels) { |
| 205 // TODO: this needs to message the server http://crbug.com/693340. Setting | 219 // TODO: this needs to message the server http://crbug.com/693340. Setting |
| 206 // the location is really only appropriate in tests, outside of tests this | 220 // the location is really only appropriate in tests, outside of tests this |
| 207 // value is ignored. | 221 // value is ignored. |
| 208 NOTIMPLEMENTED(); | 222 NOTIMPLEMENTED(); |
| 209 Env::GetInstance()->set_last_mouse_location(location_in_pixels); | 223 Env::GetInstance()->set_last_mouse_location(location_in_pixels); |
| 210 } | 224 } |
| 211 | 225 |
| 226 void WindowTreeHostMus::InitInputMethod( | |
| 227 WindowTreeHostMusInitParams* init_params) { | |
| 228 #if defined(OS_CHROMEOS) | |
| 229 if (init_params->use_classic_ime) { | |
| 230 input_method_chromeos_ = base::MakeUnique<ui::InputMethodChromeOS>(this); | |
|
sky
2017/04/20 20:18:49
Are you sure we need to set the input method at al
| |
| 231 SetSharedInputMethod(input_method_chromeos_.get()); | |
| 232 return; | |
| 233 } | |
| 234 #endif // defined(OS_CHROMEOS) | |
| 235 | |
| 236 input_method_mus_ = base::MakeUnique<InputMethodMus>(this, window()); | |
| 237 input_method_mus_->Init(init_params->window_tree_client->connector()); | |
| 238 SetSharedInputMethod(input_method_mus_.get()); | |
| 239 } | |
| 240 | |
| 212 } // namespace aura | 241 } // namespace aura |
| OLD | NEW |