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 |
11 #include "ash/ash_switches.h" | 11 #include "ash/ash_switches.h" |
| 12 #include "ash/display/cursor_window_controller.h" |
12 #include "ash/display/display_layout_store.h" | 13 #include "ash/display/display_layout_store.h" |
13 #include "ash/display/display_manager.h" | 14 #include "ash/display/display_manager.h" |
14 #include "ash/display/mirror_window_controller.h" | 15 #include "ash/display/mirror_window_controller.h" |
15 #include "ash/display/root_window_transformers.h" | 16 #include "ash/display/root_window_transformers.h" |
16 #include "ash/display/virtual_keyboard_window_controller.h" | 17 #include "ash/display/virtual_keyboard_window_controller.h" |
17 #include "ash/host/root_window_host_factory.h" | 18 #include "ash/host/root_window_host_factory.h" |
18 #include "ash/root_window_controller.h" | 19 #include "ash/root_window_controller.h" |
19 #include "ash/root_window_settings.h" | 20 #include "ash/root_window_settings.h" |
20 #include "ash/screen_util.h" | 21 #include "ash/screen_util.h" |
21 #include "ash/shell.h" | 22 #include "ash/shell.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 bool DisplayController::DisplayChangeLimiter::IsThrottled() const { | 210 bool DisplayController::DisplayChangeLimiter::IsThrottled() const { |
210 return base::Time::Now() < throttle_timeout_; | 211 return base::Time::Now() < throttle_timeout_; |
211 } | 212 } |
212 | 213 |
213 //////////////////////////////////////////////////////////////////////////////// | 214 //////////////////////////////////////////////////////////////////////////////// |
214 // DisplayController | 215 // DisplayController |
215 | 216 |
216 DisplayController::DisplayController() | 217 DisplayController::DisplayController() |
217 : primary_root_window_for_replace_(NULL), | 218 : primary_root_window_for_replace_(NULL), |
218 focus_activation_store_(new internal::FocusActivationStore()), | 219 focus_activation_store_(new internal::FocusActivationStore()), |
| 220 cursor_window_controller_(new internal::CursorWindowController(false)), |
219 mirror_window_controller_(new internal::MirrorWindowController), | 221 mirror_window_controller_(new internal::MirrorWindowController), |
220 virtual_keyboard_window_controller_( | 222 virtual_keyboard_window_controller_( |
221 new internal::VirtualKeyboardWindowController) { | 223 new internal::VirtualKeyboardWindowController) { |
222 #if defined(OS_CHROMEOS) | 224 #if defined(OS_CHROMEOS) |
223 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 225 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
224 if (!command_line->HasSwitch(switches::kAshDisableDisplayChangeLimiter) && | 226 if (!command_line->HasSwitch(switches::kAshDisableDisplayChangeLimiter) && |
225 base::SysInfo::IsRunningOnChromeOS()) | 227 base::SysInfo::IsRunningOnChromeOS()) |
226 limiter_.reset(new DisplayChangeLimiter); | 228 limiter_.reset(new DisplayChangeLimiter); |
227 #endif | 229 #endif |
228 // Reset primary display to make sure that tests don't use | 230 // Reset primary display to make sure that tests don't use |
(...skipping 13 matching lines...) Expand all Loading... |
242 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); | 244 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanging()); |
243 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); | 245 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayConfigurationChanged()); |
244 } | 246 } |
245 } | 247 } |
246 | 248 |
247 void DisplayController::Shutdown() { | 249 void DisplayController::Shutdown() { |
248 // Unset the display manager's delegate here because | 250 // Unset the display manager's delegate here because |
249 // DisplayManager outlives DisplayController. | 251 // DisplayManager outlives DisplayController. |
250 Shell::GetInstance()->display_manager()->set_delegate(NULL); | 252 Shell::GetInstance()->display_manager()->set_delegate(NULL); |
251 | 253 |
| 254 cursor_window_controller_.reset(); |
252 mirror_window_controller_.reset(); | 255 mirror_window_controller_.reset(); |
253 virtual_keyboard_window_controller_.reset(); | 256 virtual_keyboard_window_controller_.reset(); |
254 | 257 |
255 Shell::GetScreen()->RemoveObserver(this); | 258 Shell::GetScreen()->RemoveObserver(this); |
256 // Delete all root window controllers, which deletes root window | 259 // Delete all root window controllers, which deletes root window |
257 // from the last so that the primary root window gets deleted last. | 260 // from the last so that the primary root window gets deleted last. |
258 for (std::map<int64, aura::Window*>::const_reverse_iterator it = | 261 for (std::map<int64, aura::Window*>::const_reverse_iterator it = |
259 root_windows_.rbegin(); it != root_windows_.rend(); ++it) { | 262 root_windows_.rbegin(); it != root_windows_.rend(); ++it) { |
260 internal::RootWindowController* controller = | 263 internal::RootWindowController* controller = |
261 internal::GetRootWindowController(it->second); | 264 internal::GetRootWindowController(it->second); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 base::Unretained(this))); | 396 base::Unretained(this))); |
394 } else { | 397 } else { |
395 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 398 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
396 } | 399 } |
397 #else | 400 #else |
398 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); | 401 SetPrimaryDisplay(ScreenUtil::GetSecondaryDisplay()); |
399 #endif | 402 #endif |
400 } | 403 } |
401 } | 404 } |
402 | 405 |
| 406 void DisplayController::EnableCompositedCursor(aura::Window* container) { |
| 407 cursor_window_controller_->InitCursorWindow(container); |
| 408 } |
| 409 |
403 void DisplayController::SetPrimaryDisplayId(int64 id) { | 410 void DisplayController::SetPrimaryDisplayId(int64 id) { |
404 DCHECK_NE(gfx::Display::kInvalidDisplayID, id); | 411 DCHECK_NE(gfx::Display::kInvalidDisplayID, id); |
405 if (id == gfx::Display::kInvalidDisplayID || primary_display_id == id) | 412 if (id == gfx::Display::kInvalidDisplayID || primary_display_id == id) |
406 return; | 413 return; |
407 | 414 |
408 const gfx::Display& display = GetDisplayManager()->GetDisplayForId(id); | 415 const gfx::Display& display = GetDisplayManager()->GetDisplayForId(id); |
409 if (display.is_valid()) | 416 if (display.is_valid()) |
410 SetPrimaryDisplay(display); | 417 SetPrimaryDisplay(display); |
411 } | 418 } |
412 | 419 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 std::string name = | 742 std::string name = |
736 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; | 743 root_windows[i] == primary ? "aura_root_0" : "aura_root_x"; |
737 gfx::AcceleratedWidget xwindow = | 744 gfx::AcceleratedWidget xwindow = |
738 root_windows[i]->GetDispatcher()->host()->GetAcceleratedWidget(); | 745 root_windows[i]->GetDispatcher()->host()->GetAcceleratedWidget(); |
739 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); | 746 XStoreName(gfx::GetXDisplay(), xwindow, name.c_str()); |
740 } | 747 } |
741 #endif | 748 #endif |
742 } | 749 } |
743 | 750 |
744 } // namespace ash | 751 } // namespace ash |
OLD | NEW |