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 #if defined(USE_X11) | 7 #if defined(USE_X11) |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 // Xlib.h defines RootWindow. | 10 // Xlib.h defines RootWindow. |
11 #undef RootWindow | 11 #undef RootWindow |
12 #endif | 12 #endif |
13 | 13 |
14 #include "ash/display/cursor_window_controller.h" | 14 #include "ash/display/cursor_window_controller.h" |
15 #include "ash/display/display_controller.h" | 15 #include "ash/display/display_controller.h" |
16 #include "ash/display/display_info.h" | 16 #include "ash/display/display_info.h" |
17 #include "ash/display/display_manager.h" | 17 #include "ash/display/display_manager.h" |
18 #include "ash/display/root_window_transformers.h" | 18 #include "ash/display/root_window_transformers.h" |
19 #include "ash/host/ash_window_tree_host.h" | 19 #include "ash/host/ash_window_tree_host.h" |
20 #include "ash/host/ash_window_tree_host_init_params.h" | 20 #include "ash/host/ash_window_tree_host_init_params.h" |
21 #include "ash/host/root_window_transformer.h" | 21 #include "ash/host/root_window_transformer.h" |
22 #include "ash/root_window_settings.h" | 22 #include "ash/root_window_settings.h" |
23 #include "ash/shell.h" | 23 #include "ash/shell.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "ui/aura/client/capture_client.h" | 25 #include "ui/aura/client/capture_client.h" |
| 26 #include "ui/aura/env.h" |
26 #include "ui/aura/window_delegate.h" | 27 #include "ui/aura/window_delegate.h" |
27 #include "ui/aura/window_event_dispatcher.h" | 28 #include "ui/aura/window_event_dispatcher.h" |
28 #include "ui/aura/window_tree_host.h" | 29 #include "ui/aura/window_tree_host.h" |
29 #include "ui/base/layout.h" | 30 #include "ui/base/layout.h" |
30 #include "ui/compositor/reflector.h" | 31 #include "ui/compositor/reflector.h" |
31 #include "ui/gfx/canvas.h" | 32 #include "ui/gfx/canvas.h" |
32 #include "ui/gfx/native_widget_types.h" | 33 #include "ui/gfx/native_widget_types.h" |
33 | 34 |
34 #if defined(USE_X11) | 35 #if defined(USE_X11) |
35 #include "ui/gfx/x/x11_types.h" | 36 #include "ui/gfx/x/x11_types.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 aura::client::SetCaptureClient(host->window(), new NoneCaptureClient()); | 104 aura::client::SetCaptureClient(host->window(), new NoneCaptureClient()); |
104 host->Show(); | 105 host->Show(); |
105 | 106 |
106 // TODO(oshima): Start mirroring. | 107 // TODO(oshima): Start mirroring. |
107 aura::Window* mirror_window = new aura::Window(NULL); | 108 aura::Window* mirror_window = new aura::Window(NULL); |
108 mirror_window->Init(aura::WINDOW_LAYER_TEXTURED); | 109 mirror_window->Init(aura::WINDOW_LAYER_TEXTURED); |
109 host->window()->AddChild(mirror_window); | 110 host->window()->AddChild(mirror_window); |
110 mirror_window->SetBounds(host->window()->bounds()); | 111 mirror_window->SetBounds(host->window()->bounds()); |
111 mirror_window->Show(); | 112 mirror_window->Show(); |
112 reflector_ = ui::ContextFactory::GetInstance()->CreateReflector( | 113 reflector_ = aura::Env::GetInstance()->context_factory()->CreateReflector( |
113 Shell::GetPrimaryRootWindow()->GetHost()->compositor(), | 114 Shell::GetPrimaryRootWindow()->GetHost()->compositor(), |
114 mirror_window->layer()); | 115 mirror_window->layer()); |
115 } else { | 116 } else { |
116 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost(); | 117 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost(); |
117 GetRootWindowSettings(host->window())->display_id = display_info.id(); | 118 GetRootWindowSettings(host->window())->display_id = display_info.id(); |
118 host->SetBounds(display_info.bounds_in_native()); | 119 host->SetBounds(display_info.bounds_in_native()); |
119 } | 120 } |
120 | 121 |
121 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 122 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
122 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 123 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
(...skipping 10 matching lines...) Expand all Loading... |
133 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 134 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
134 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo( | 135 const DisplayInfo& mirror_display_info = display_manager->GetDisplayInfo( |
135 display_manager->mirrored_display_id()); | 136 display_manager->mirrored_display_id()); |
136 UpdateWindow(mirror_display_info); | 137 UpdateWindow(mirror_display_info); |
137 } | 138 } |
138 } | 139 } |
139 | 140 |
140 void MirrorWindowController::Close() { | 141 void MirrorWindowController::Close() { |
141 if (ash_host_.get()) { | 142 if (ash_host_.get()) { |
142 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost(); | 143 aura::WindowTreeHost* host = ash_host_->AsWindowTreeHost(); |
143 ui::ContextFactory::GetInstance()->RemoveReflector(reflector_); | 144 aura::Env::GetInstance()->context_factory()->RemoveReflector(reflector_); |
144 reflector_ = NULL; | 145 reflector_ = NULL; |
145 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>( | 146 NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>( |
146 aura::client::GetCaptureClient(host->window())); | 147 aura::client::GetCaptureClient(host->window())); |
147 aura::client::SetCaptureClient(host->window(), NULL); | 148 aura::client::SetCaptureClient(host->window(), NULL); |
148 delete capture_client; | 149 delete capture_client; |
149 | 150 |
150 host->RemoveObserver(Shell::GetInstance()->display_controller()); | 151 host->RemoveObserver(Shell::GetInstance()->display_controller()); |
151 host->RemoveObserver(this); | 152 host->RemoveObserver(this); |
152 ash_host_.reset(); | 153 ash_host_.reset(); |
153 } | 154 } |
(...skipping 20 matching lines...) Expand all Loading... |
174 display_manager->mirrored_display_id()); | 175 display_manager->mirrored_display_id()); |
175 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( | 176 const DisplayInfo& source_display_info = display_manager->GetDisplayInfo( |
176 Shell::GetScreen()->GetPrimaryDisplay().id()); | 177 Shell::GetScreen()->GetPrimaryDisplay().id()); |
177 DCHECK(display_manager->IsMirrored()); | 178 DCHECK(display_manager->IsMirrored()); |
178 return scoped_ptr<RootWindowTransformer>( | 179 return scoped_ptr<RootWindowTransformer>( |
179 CreateRootWindowTransformerForMirroredDisplay(source_display_info, | 180 CreateRootWindowTransformerForMirroredDisplay(source_display_info, |
180 mirror_display_info)); | 181 mirror_display_info)); |
181 } | 182 } |
182 | 183 |
183 } // namespace ash | 184 } // namespace ash |
OLD | NEW |