OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 base::Time::Now() + base::TimeDelta::FromMilliseconds(throttle_ms); | 218 base::Time::Now() + base::TimeDelta::FromMilliseconds(throttle_ms); |
219 } | 219 } |
220 | 220 |
221 bool DisplayController::DisplayChangeLimiter::IsThrottled() const { | 221 bool DisplayController::DisplayChangeLimiter::IsThrottled() const { |
222 return base::Time::Now() < throttle_timeout_; | 222 return base::Time::Now() < throttle_timeout_; |
223 } | 223 } |
224 | 224 |
225 //////////////////////////////////////////////////////////////////////////////// | 225 //////////////////////////////////////////////////////////////////////////////// |
226 // DisplayController | 226 // DisplayController |
227 | 227 |
228 DisplayController::DisplayController() | 228 DisplayController::DisplayController(ui::ContextFactory* context_factory) |
229 : primary_tree_host_for_replace_(NULL), | 229 : context_factory_(context_factory), |
| 230 primary_tree_host_for_replace_(NULL), |
230 focus_activation_store_(new FocusActivationStore()), | 231 focus_activation_store_(new FocusActivationStore()), |
231 cursor_window_controller_(new CursorWindowController()), | 232 cursor_window_controller_(new CursorWindowController()), |
232 mirror_window_controller_(new MirrorWindowController()) { | 233 mirror_window_controller_(new MirrorWindowController(context_factory)) { |
233 #if defined(OS_CHROMEOS) | 234 #if defined(OS_CHROMEOS) |
234 if (base::SysInfo::IsRunningOnChromeOS()) | 235 if (base::SysInfo::IsRunningOnChromeOS()) |
235 limiter_.reset(new DisplayChangeLimiter); | 236 limiter_.reset(new DisplayChangeLimiter); |
236 #endif | 237 #endif |
237 // Reset primary display to make sure that tests don't use | 238 // Reset primary display to make sure that tests don't use |
238 // stale display info from previous tests. | 239 // stale display info from previous tests. |
239 primary_display_id = gfx::Display::kInvalidDisplayID; | 240 primary_display_id = gfx::Display::kInvalidDisplayID; |
240 } | 241 } |
241 | 242 |
242 DisplayController::~DisplayController() { | 243 DisplayController::~DisplayController() { |
243 } | 244 } |
244 | 245 |
245 void DisplayController::Start() { | 246 void DisplayController::Start() { |
246 // Created here so that Shell has finished being created. Adds itself | 247 // Created here so that Shell has finished being created. Adds itself |
247 // as a ShellObserver. | 248 // as a ShellObserver. |
248 virtual_keyboard_window_controller_.reset( | 249 virtual_keyboard_window_controller_.reset( |
249 new VirtualKeyboardWindowController); | 250 new VirtualKeyboardWindowController(context_factory_)); |
250 Shell::GetScreen()->AddObserver(this); | 251 Shell::GetScreen()->AddObserver(this); |
251 Shell::GetInstance()->display_manager()->set_delegate(this); | 252 Shell::GetInstance()->display_manager()->set_delegate(this); |
252 } | 253 } |
253 | 254 |
254 void DisplayController::Shutdown() { | 255 void DisplayController::Shutdown() { |
255 // Unset the display manager's delegate here because | 256 // Unset the display manager's delegate here because |
256 // DisplayManager outlives DisplayController. | 257 // DisplayManager outlives DisplayController. |
257 Shell::GetInstance()->display_manager()->set_delegate(NULL); | 258 Shell::GetInstance()->display_manager()->set_delegate(NULL); |
258 | 259 |
259 cursor_window_controller_.reset(); | 260 cursor_window_controller_.reset(); |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 } | 706 } |
706 | 707 |
707 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( | 708 AshWindowTreeHost* DisplayController::AddWindowTreeHostForDisplay( |
708 const gfx::Display& display, | 709 const gfx::Display& display, |
709 const AshWindowTreeHostInitParams& init_params) { | 710 const AshWindowTreeHostInitParams& init_params) { |
710 static int host_count = 0; | 711 static int host_count = 0; |
711 const DisplayInfo& display_info = | 712 const DisplayInfo& display_info = |
712 GetDisplayManager()->GetDisplayInfo(display.id()); | 713 GetDisplayManager()->GetDisplayInfo(display.id()); |
713 AshWindowTreeHostInitParams params_with_bounds(init_params); | 714 AshWindowTreeHostInitParams params_with_bounds(init_params); |
714 params_with_bounds.initial_bounds = display_info.bounds_in_native(); | 715 params_with_bounds.initial_bounds = display_info.bounds_in_native(); |
| 716 params_with_bounds.context_factory = context_factory_; |
715 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); | 717 AshWindowTreeHost* ash_host = AshWindowTreeHost::Create(params_with_bounds); |
716 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); | 718 aura::WindowTreeHost* host = ash_host->AsWindowTreeHost(); |
717 | 719 |
718 host->window()->SetName(base::StringPrintf("RootWindow-%d", host_count++)); | 720 host->window()->SetName(base::StringPrintf("RootWindow-%d", host_count++)); |
719 host->compositor()->SetBackgroundColor(SK_ColorBLACK); | 721 host->compositor()->SetBackgroundColor(SK_ColorBLACK); |
720 // No need to remove our observer observer because the DisplayController | 722 // No need to remove our observer observer because the DisplayController |
721 // outlives the host. | 723 // outlives the host. |
722 host->AddObserver(this); | 724 host->AddObserver(this); |
723 InitRootWindowSettings(host->window())->display_id = display.id(); | 725 InitRootWindowSettings(host->window())->display_id = display.id(); |
724 host->InitHost(); | 726 host->InitHost(); |
(...skipping 30 matching lines...) Expand all Loading... |
755 std::string name = | 757 std::string name = |
756 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 758 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
757 gfx::AcceleratedWidget xwindow = | 759 gfx::AcceleratedWidget xwindow = |
758 root_windows[i]->GetHost()->GetAcceleratedWidget(); | 760 root_windows[i]->GetHost()->GetAcceleratedWidget(); |
759 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 761 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
760 } | 762 } |
761 #endif | 763 #endif |
762 } | 764 } |
763 | 765 |
764 } // namespace ash | 766 } // namespace ash |
OLD | NEW |