Index: ash/display/display_controller.cc |
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc |
index 8e3c696c9b9fcada01ca56752413ca59c6f6ca90..9cd1760a1e678cda15a82b01ae8a377efe093387 100644 |
--- a/ash/display/display_controller.cc |
+++ b/ash/display/display_controller.cc |
@@ -36,7 +36,6 @@ |
#include "ui/base/x/x11_util.h" |
#endif // defined(OS_CHROMEOS) |
- |
namespace ash { |
namespace { |
@@ -105,6 +104,31 @@ internal::DisplayManager* GetDisplayManager() { |
return Shell::GetInstance()->display_manager(); |
} |
+void RotateRootWindow(aura::RootWindow* root_window, |
+ const gfx::Display& display, |
+ const internal::DisplayInfo& info) { |
+ // TODO(oshima): Add animation. (crossfade+rotation, or just cross-fade) |
+ gfx::Transform rotate; |
+ gfx::Transform translate; |
+ switch (info.rotation()) { |
+ case internal::DisplayInfo::Rotate0: |
+ break; |
+ case internal::DisplayInfo::Rotate90: |
+ rotate.Rotate(90); |
+ translate.Translate(display.bounds().height(), 0); |
+ break; |
+ case internal::DisplayInfo::Rotate270: |
+ rotate.Rotate(270); |
+ translate.Translate(0, display.bounds().width()); |
+ break; |
+ case internal::DisplayInfo::Rotate180: |
+ rotate.Rotate(180); |
+ translate.Translate(display.bounds().width(), display.bounds().height()); |
+ break; |
+ } |
+ root_window->SetTransform(translate* rotate); |
+} |
+ |
void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, |
const gfx::Display& display) { |
#if defined(OS_CHROMEOS) |
@@ -137,6 +161,7 @@ void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, |
kCARDINAL, |
100 * display.device_scale_factor()); |
#endif |
+ RotateRootWindow(root, display, GetDisplayManager()->GetDisplayInfo(display)); |
} |
} // namespace |
@@ -237,12 +262,29 @@ bool DisplayController::DisplayChangeLimiter::IsThrottled() const { |
DisplayController::DisplayController() |
: desired_primary_display_id_(gfx::Display::kInvalidDisplayID), |
primary_root_window_for_replace_(NULL) { |
-#if defined(OS_CHROMEOS) |
CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+#if defined(OS_CHROMEOS) |
if (!command_line->HasSwitch(switches::kAshDisableDisplayChangeLimiter) && |
base::chromeos::IsRunningOnChromeOS()) |
limiter_.reset(new DisplayChangeLimiter); |
#endif |
+ if (command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) { |
+ std::string value = command_line->GetSwitchValueASCII( |
+ switches::kAshSecondaryDisplayLayout); |
+ char layout; |
+ int offset = 0; |
+ if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) { |
+ if (layout == 't') |
+ default_display_layout_.position = DisplayLayout::TOP; |
+ else if (layout == 'b') |
+ default_display_layout_.position = DisplayLayout::BOTTOM; |
+ else if (layout == 'r') |
+ default_display_layout_.position = DisplayLayout::RIGHT; |
+ else if (layout == 'l') |
+ default_display_layout_.position = DisplayLayout::LEFT; |
+ default_display_layout_.offset = offset; |
+ } |
+ } |
// Reset primary display to make sure that tests don't use |
// stale display info from previous tests. |
primary_display_id = gfx::Display::kInvalidDisplayID; |
@@ -312,24 +354,6 @@ void DisplayController::InitSecondaryDisplays() { |
Shell::GetInstance()->InitRootWindowForSecondaryDisplay(root); |
} |
} |
- CommandLine* command_line = CommandLine::ForCurrentProcess(); |
- if (command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) { |
- std::string value = command_line->GetSwitchValueASCII( |
- switches::kAshSecondaryDisplayLayout); |
- char layout; |
- int offset; |
- if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) { |
- if (layout == 't') |
- default_display_layout_.position = DisplayLayout::TOP; |
- else if (layout == 'b') |
- default_display_layout_.position = DisplayLayout::BOTTOM; |
- else if (layout == 'r') |
- default_display_layout_.position = DisplayLayout::RIGHT; |
- else if (layout == 'l') |
- default_display_layout_.position = DisplayLayout::LEFT; |
- default_display_layout_.offset = offset; |
- } |
- } |
UpdateDisplayBoundsForLayout(); |
} |
@@ -608,15 +632,16 @@ gfx::Display* DisplayController::GetSecondaryDisplay() { |
void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { |
if (limiter_.get()) |
limiter_->SetThrottleTimeout(kAfterDisplayChangeThrottleTimeoutMs); |
- DCHECK(!GetDisplayManager()->GetDisplayInfo(display). |
- bounds_in_pixel().IsEmpty()); |
+ const internal::DisplayInfo& display_info = |
+ GetDisplayManager()->GetDisplayInfo(display); |
+ DCHECK(!display_info.bounds_in_pixel().IsEmpty()); |
NotifyDisplayConfigurationChanging(); |
UpdateDisplayBoundsForLayout(); |
aura::RootWindow* root = root_windows_[display.id()]; |
+ root->SetHostBoundsAndInsets(display_info.bounds_in_pixel(), |
+ display_info.GetOverscanInsetsInPixel()); |
SetDisplayPropertiesOnHostWindow(root, display); |
- root->SetHostBounds( |
- GetDisplayManager()->GetDisplayInfo(display).bounds_in_pixel()); |
} |
void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
@@ -632,8 +657,11 @@ void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
internal::kDisplayIdKey, display.id()); |
primary_root_window_for_replace_ = NULL; |
UpdateDisplayBoundsForLayout(); |
- root_windows_[display.id()]->SetHostBounds( |
- GetDisplayManager()->GetDisplayInfo(display).bounds_in_pixel()); |
+ const internal::DisplayInfo& display_info = |
+ GetDisplayManager()->GetDisplayInfo(display); |
+ root_windows_[display.id()]->SetHostBoundsAndInsets( |
+ display_info.bounds_in_pixel(), |
+ display_info.GetOverscanInsetsInPixel()); |
} else { |
DCHECK(!root_windows_.empty()); |
aura::RootWindow* root = AddRootWindowForDisplay(display); |
@@ -711,7 +739,6 @@ aura::RootWindow* DisplayController::AddRootWindowForDisplay( |
void DisplayController::UpdateDisplayBoundsForLayout() { |
if (Shell::GetScreen()->GetNumDisplays() <= 1) |
return; |
- |
DCHECK_EQ(2, Shell::GetScreen()->GetNumDisplays()); |
const gfx::Rect& primary_bounds = GetPrimaryDisplay().bounds(); |
@@ -750,6 +777,7 @@ void DisplayController::UpdateDisplayBoundsForLayout() { |
new_secondary_origin.Offset(-secondary_bounds.width(), offset); |
break; |
} |
+ |
gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
secondary_display->set_bounds( |
gfx::Rect(new_secondary_origin, secondary_bounds.size())); |