Chromium Code Reviews| 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) | |
| 10 #include <X11/extensions/XInput2.h> | 9 #include <X11/extensions/XInput2.h> |
| 11 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
| 12 | 11 |
| 13 // Xlib.h defines RootWindow. | 12 // Xlib.h defines RootWindow. |
| 14 #undef RootWindow | 13 #undef RootWindow |
| 15 #endif | |
| 16 | 14 |
| 17 #include "ash/display/cursor_window_controller.h" | 15 #include "ash/display/cursor_window_controller.h" |
| 18 #include "ash/display/root_window_transformers.h" | 16 #include "ash/display/root_window_transformers.h" |
| 19 #include "ash/display/screen_position_controller.h" | 17 #include "ash/display/screen_position_controller.h" |
| 20 #include "ash/display/window_tree_host_manager.h" | 18 #include "ash/display/window_tree_host_manager.h" |
| 21 #include "ash/host/ash_window_tree_host.h" | 19 #include "ash/host/ash_window_tree_host.h" |
| 22 #include "ash/host/ash_window_tree_host_init_params.h" | 20 #include "ash/host/ash_window_tree_host_init_params.h" |
| 23 #include "ash/host/root_window_transformer.h" | 21 #include "ash/host/root_window_transformer.h" |
| 24 #include "ash/root_window_settings.h" | 22 #include "ash/root_window_settings.h" |
| 25 #include "ash/shell.h" | 23 #include "ash/shell.h" |
| 26 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "ui/aura/client/capture_client.h" | 26 #include "ui/aura/client/capture_client.h" |
| 29 #include "ui/aura/env.h" | 27 #include "ui/aura/env.h" |
| 30 #include "ui/aura/window_delegate.h" | 28 #include "ui/aura/window_delegate.h" |
| 31 #include "ui/aura/window_event_dispatcher.h" | 29 #include "ui/aura/window_event_dispatcher.h" |
| 32 #include "ui/aura/window_tree_host.h" | 30 #include "ui/aura/window_tree_host.h" |
| 31 #include "ui/aura/window_tree_host_x11.h" | |
| 33 #include "ui/base/layout.h" | 32 #include "ui/base/layout.h" |
| 34 #include "ui/compositor/reflector.h" | 33 #include "ui/compositor/reflector.h" |
| 35 #include "ui/display/display_layout.h" | 34 #include "ui/display/display_layout.h" |
| 36 #include "ui/display/manager/display_manager.h" | 35 #include "ui/display/manager/display_manager.h" |
| 37 #include "ui/display/manager/managed_display_info.h" | 36 #include "ui/display/manager/managed_display_info.h" |
| 38 #include "ui/display/screen.h" | 37 #include "ui/display/screen.h" |
| 39 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
| 40 #include "ui/gfx/native_widget_types.h" | 39 #include "ui/gfx/native_widget_types.h" |
| 41 | |
| 42 #if defined(USE_X11) | |
|
Evan Stade
2017/01/13 17:19:34
Am I correct in thinking OS_CHROMEOS implies USE_X
James Cook
2017/01/13 20:19:31
No, real Chromebooks don't run X. They use our own
Evan Stade
2017/01/19 00:36:21
ah, ok. restored
| |
| 43 #include "ui/aura/window_tree_host_x11.h" | |
| 44 #include "ui/gfx/x/x11_types.h" // nogncheck | 40 #include "ui/gfx/x/x11_types.h" // nogncheck |
| 45 #endif | |
| 46 | 41 |
| 47 namespace ash { | 42 namespace ash { |
| 48 namespace { | 43 namespace { |
| 49 | 44 |
| 50 // ScreenPositionClient for mirroring windows. | 45 // ScreenPositionClient for mirroring windows. |
| 51 class MirroringScreenPositionClient | 46 class MirroringScreenPositionClient |
| 52 : public aura::client::ScreenPositionClient { | 47 : public aura::client::ScreenPositionClient { |
| 53 public: | 48 public: |
| 54 explicit MirroringScreenPositionClient(MirrorWindowController* controller) | 49 explicit MirroringScreenPositionClient(MirrorWindowController* controller) |
| 55 : controller_(controller) {} | 50 : controller_(controller) {} |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); | 181 base::StringPrintf("MirrorRootWindow-%d", mirror_host_count++)); |
| 187 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 182 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
| 188 // No need to remove the observer because the WindowTreeHostManager | 183 // No need to remove the observer because the WindowTreeHostManager |
| 189 // outlives the host. | 184 // outlives the host. |
| 190 host->AddObserver(Shell::GetInstance()->window_tree_host_manager()); | 185 host->AddObserver(Shell::GetInstance()->window_tree_host_manager()); |
| 191 host->AddObserver(this); | 186 host->AddObserver(this); |
| 192 // TODO(oshima): TouchHUD is using idkey. | 187 // TODO(oshima): TouchHUD is using idkey. |
| 193 InitRootWindowSettings(host->window())->display_id = display_info.id(); | 188 InitRootWindowSettings(host->window())->display_id = display_info.id(); |
| 194 host->InitHost(); | 189 host->InitHost(); |
| 195 host->window()->Show(); | 190 host->window()->Show(); |
| 196 #if defined(USE_X11) | |
| 197 if (!display_manager->IsInUnifiedMode()) { | 191 if (!display_manager->IsInUnifiedMode()) { |
| 198 // Mirror window shouldn't handle input events. | 192 // Mirror window shouldn't handle input events. |
| 199 static_cast<aura::WindowTreeHostX11*>(host)->DisableInput(); | 193 static_cast<aura::WindowTreeHostX11*>(host)->DisableInput(); |
| 200 } | 194 } |
| 201 #endif | |
| 202 | 195 |
| 203 #if defined(OS_CHROMEOS) | |
| 204 if (display_manager->IsInUnifiedMode()) { | 196 if (display_manager->IsInUnifiedMode()) { |
| 205 host_info->ash_host->ConfineCursorToRootWindow(); | 197 host_info->ash_host->ConfineCursorToRootWindow(); |
| 206 AshWindowTreeHost* unified_ash_host = | 198 AshWindowTreeHost* unified_ash_host = |
| 207 Shell::GetInstance() | 199 Shell::GetInstance() |
| 208 ->window_tree_host_manager() | 200 ->window_tree_host_manager() |
| 209 ->GetAshWindowTreeHostForDisplayId( | 201 ->GetAshWindowTreeHostForDisplayId( |
| 210 display::Screen::GetScreen()->GetPrimaryDisplay().id()); | 202 display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 211 unified_ash_host->RegisterMirroringHost(host_info->ash_host.get()); | 203 unified_ash_host->RegisterMirroringHost(host_info->ash_host.get()); |
| 212 aura::client::SetScreenPositionClient(host->window(), | 204 aura::client::SetScreenPositionClient(host->window(), |
| 213 screen_position_client_.get()); | 205 screen_position_client_.get()); |
| 214 } | 206 } |
| 215 #endif | |
| 216 | 207 |
| 217 aura::client::SetCaptureClient(host->window(), new NoneCaptureClient()); | 208 aura::client::SetCaptureClient(host->window(), new NoneCaptureClient()); |
| 218 host->Show(); | 209 host->Show(); |
| 219 | 210 |
| 220 aura::Window* mirror_window = host_info->mirror_window = | 211 aura::Window* mirror_window = host_info->mirror_window = |
| 221 new aura::Window(nullptr); | 212 new aura::Window(nullptr); |
| 222 mirror_window->Init(ui::LAYER_SOLID_COLOR); | 213 mirror_window->Init(ui::LAYER_SOLID_COLOR); |
| 223 host->window()->AddChild(mirror_window); | 214 host->window()->AddChild(mirror_window); |
| 224 host_info->ash_host->SetRootWindowTransformer(std::move(transformer)); | 215 host_info->ash_host->SetRootWindowTransformer(std::move(transformer)); |
| 225 mirror_window->SetBounds(host->window()->bounds()); | 216 mirror_window->SetBounds(host->window()->bounds()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 // EventProcessor may be accessed after this call if the mirroring window | 365 // EventProcessor may be accessed after this call if the mirroring window |
| 375 // was deleted as a result of input event (e.g. shortcut), so don't delete | 366 // was deleted as a result of input event (e.g. shortcut), so don't delete |
| 376 // now. | 367 // now. |
| 377 if (delay_host_deletion) | 368 if (delay_host_deletion) |
| 378 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); | 369 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, host_info); |
| 379 else | 370 else |
| 380 delete host_info; | 371 delete host_info; |
| 381 } | 372 } |
| 382 | 373 |
| 383 } // namespace ash | 374 } // namespace ash |
| OLD | NEW |