OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ash/display/mirror_window_controller.h" | 5 #include "ash/display/mirror_window_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #if defined(USE_X11) | 9 #if defined(USE_X11) |
10 #include <X11/extensions/XInput2.h> | 10 #include <X11/extensions/XInput2.h> |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 transformer.reset(CreateRootWindowTransformerForUnifiedDesktop( | 166 transformer.reset(CreateRootWindowTransformerForUnifiedDesktop( |
167 primary.bounds(), display)); | 167 primary.bounds(), display)); |
168 } else { | 168 } else { |
169 NOTREACHED(); | 169 NOTREACHED(); |
170 } | 170 } |
171 | 171 |
172 if (mirroring_host_info_map_.find(display_info.id()) == | 172 if (mirroring_host_info_map_.find(display_info.id()) == |
173 mirroring_host_info_map_.end()) { | 173 mirroring_host_info_map_.end()) { |
174 AshWindowTreeHostInitParams init_params; | 174 AshWindowTreeHostInitParams init_params; |
175 init_params.initial_bounds = display_info.bounds_in_native(); | 175 init_params.initial_bounds = display_info.bounds_in_native(); |
| 176 init_params.display_id = display_info.id(); |
| 177 init_params.device_scale_factor = display_info.device_scale_factor(); |
| 178 init_params.ui_scale_factor = display_info.configured_ui_scale(); |
176 MirroringHostInfo* host_info = new MirroringHostInfo; | 179 MirroringHostInfo* host_info = new MirroringHostInfo; |
177 host_info->ash_host = AshWindowTreeHost::Create(init_params); | 180 host_info->ash_host = AshWindowTreeHost::Create(init_params); |
178 mirroring_host_info_map_[display_info.id()] = host_info; | 181 mirroring_host_info_map_[display_info.id()] = host_info; |
179 | 182 |
180 aura::WindowTreeHost* host = host_info->ash_host->AsWindowTreeHost(); | 183 aura::WindowTreeHost* host = host_info->ash_host->AsWindowTreeHost(); |
181 host->SetSharedInputMethod( | 184 // XXX figure this out! |
182 Shell::Get()->window_tree_host_manager()->input_method()); | 185 if (!host->has_input_method()) { |
| 186 host->SetSharedInputMethod( |
| 187 Shell::Get()->window_tree_host_manager()->input_method()); |
| 188 } |
183 host->window()->SetName( | 189 host->window()->SetName( |
184 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); | 190 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); |
185 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 191 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
186 // No need to remove the observer because the WindowTreeHostManager | 192 // No need to remove the observer because the WindowTreeHostManager |
187 // outlives the host. | 193 // outlives the host. |
188 host->AddObserver(Shell::Get()->window_tree_host_manager()); | 194 host->AddObserver(Shell::Get()->window_tree_host_manager()); |
189 host->AddObserver(this); | 195 host->AddObserver(this); |
190 // TODO(oshima): TouchHUD is using idkey. | 196 // TODO(oshima): TouchHUD is using idkey. |
191 InitRootWindowSettings(host->window())->display_id = display_info.id(); | 197 InitRootWindowSettings(host->window())->display_id = display_info.id(); |
192 host->InitHost(); | 198 host->InitHost(); |
(...skipping 22 matching lines...) Expand all Loading... |
215 | 221 |
216 aura::Window* mirror_window = host_info->mirror_window = | 222 aura::Window* mirror_window = host_info->mirror_window = |
217 new aura::Window(nullptr); | 223 new aura::Window(nullptr); |
218 mirror_window->Init(ui::LAYER_SOLID_COLOR); | 224 mirror_window->Init(ui::LAYER_SOLID_COLOR); |
219 host->window()->AddChild(mirror_window); | 225 host->window()->AddChild(mirror_window); |
220 host_info->ash_host->SetRootWindowTransformer(std::move(transformer)); | 226 host_info->ash_host->SetRootWindowTransformer(std::move(transformer)); |
221 mirror_window->SetBounds(host->window()->bounds()); | 227 mirror_window->SetBounds(host->window()->bounds()); |
222 mirror_window->Show(); | 228 mirror_window->Show(); |
223 if (reflector_) { | 229 if (reflector_) { |
224 reflector_->AddMirroringLayer(mirror_window->layer()); | 230 reflector_->AddMirroringLayer(mirror_window->layer()); |
225 } else { | 231 } else if (aura::Env::GetInstance()->context_factory_private()) { |
226 reflector_ = | 232 reflector_ = |
227 aura::Env::GetInstance() | 233 aura::Env::GetInstance() |
228 ->context_factory_private() | 234 ->context_factory_private() |
229 ->CreateReflector( | 235 ->CreateReflector( |
230 Shell::GetPrimaryRootWindow()->GetHost()->compositor(), | 236 Shell::GetPrimaryRootWindow()->GetHost()->compositor(), |
231 mirror_window->layer()); | 237 mirror_window->layer()); |
| 238 } else { |
| 239 NOTIMPLEMENTED(); |
232 } | 240 } |
233 } else { | 241 } else { |
234 AshWindowTreeHost* ash_host = | 242 AshWindowTreeHost* ash_host = |
235 mirroring_host_info_map_[display_info.id()]->ash_host.get(); | 243 mirroring_host_info_map_[display_info.id()]->ash_host.get(); |
236 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 244 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
237 GetRootWindowSettings(host->window())->display_id = display_info.id(); | 245 GetRootWindowSettings(host->window())->display_id = display_info.id(); |
238 ash_host->SetRootWindowTransformer(std::move(transformer)); | 246 ash_host->SetRootWindowTransformer(std::move(transformer)); |
239 host->SetBoundsInPixels(display_info.bounds_in_native()); | 247 host->SetBoundsInPixels(display_info.bounds_in_native()); |
240 } | 248 } |
241 } | 249 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } | 295 } |
288 } | 296 } |
289 | 297 |
290 void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) { | 298 void MirrorWindowController::OnHostResized(const aura::WindowTreeHost* host) { |
291 for (auto& pair : mirroring_host_info_map_) { | 299 for (auto& pair : mirroring_host_info_map_) { |
292 MirroringHostInfo* info = pair.second; | 300 MirroringHostInfo* info = pair.second; |
293 if (info->ash_host->AsWindowTreeHost() == host) { | 301 if (info->ash_host->AsWindowTreeHost() == host) { |
294 if (info->mirror_window_host_size == host->GetBoundsInPixels().size()) | 302 if (info->mirror_window_host_size == host->GetBoundsInPixels().size()) |
295 return; | 303 return; |
296 info->mirror_window_host_size = host->GetBoundsInPixels().size(); | 304 info->mirror_window_host_size = host->GetBoundsInPixels().size(); |
297 reflector_->OnMirroringCompositorResized(); | 305 if (reflector_) |
| 306 reflector_->OnMirroringCompositorResized(); |
298 // No need to update the transformer as new transformer is already set | 307 // No need to update the transformer as new transformer is already set |
299 // in UpdateWindow. | 308 // in UpdateWindow. |
300 Shell::Get() | 309 Shell::Get() |
301 ->window_tree_host_manager() | 310 ->window_tree_host_manager() |
302 ->cursor_window_controller() | 311 ->cursor_window_controller() |
303 ->UpdateLocation(); | 312 ->UpdateLocation(); |
304 return; | 313 return; |
305 } | 314 } |
306 } | 315 } |
307 } | 316 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 aura::client::SetScreenPositionClient(host->window(), nullptr); | 364 aura::client::SetScreenPositionClient(host->window(), nullptr); |
356 | 365 |
357 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>( | 366 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>( |
358 aura::client::GetCaptureClient(host->window())); | 367 aura::client::GetCaptureClient(host->window())); |
359 aura::client::SetCaptureClient(host->window(), nullptr); | 368 aura::client::SetCaptureClient(host->window(), nullptr); |
360 delete capture_client; | 369 delete capture_client; |
361 | 370 |
362 host->RemoveObserver(Shell::Get()->window_tree_host_manager()); | 371 host->RemoveObserver(Shell::Get()->window_tree_host_manager()); |
363 host->RemoveObserver(this); | 372 host->RemoveObserver(this); |
364 host_info->ash_host->PrepareForShutdown(); | 373 host_info->ash_host->PrepareForShutdown(); |
365 reflector_->RemoveMirroringLayer(host_info->mirror_window->layer()); | 374 if (reflector_) |
| 375 reflector_->RemoveMirroringLayer(host_info->mirror_window->layer()); |
366 | 376 |
367 // EventProcessor may be accessed after this call if the mirroring window | 377 // EventProcessor may be accessed after this call if the mirroring window |
368 // was deleted as a result of input event (e.g. shortcut), so don't delete | 378 // was deleted as a result of input event (e.g. shortcut), so don't delete |
369 // now. | 379 // now. |
370 if (delay_host_deletion) | 380 if (delay_host_deletion) |
371 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); | 381 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); |
372 else | 382 else |
373 delete host_info; | 383 delete host_info; |
374 } | 384 } |
375 | 385 |
376 } // namespace ash | 386 } // namespace ash |
OLD | NEW |