Chromium Code Reviews| Index: ash/display/display_controller.cc |
| diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc |
| index 6a985223e0bc3cc8362ea6aa450544a6f3c6b1fb..eb8d98be92c7ea3141211c9b5d4db989e2507256 100644 |
| --- a/ash/display/display_controller.cc |
| +++ b/ash/display/display_controller.cc |
| @@ -16,6 +16,7 @@ |
| #include "ash/wm/window_util.h" |
| #include "base/command_line.h" |
| #include "base/json/json_value_converter.h" |
| +#include "base/string_number_conversions.h" |
| #include "base/string_piece.h" |
| #include "base/stringprintf.h" |
| #include "base/values.h" |
| @@ -103,6 +104,32 @@ internal::DisplayManager* GetDisplayManager() { |
| return Shell::GetInstance()->display_manager(); |
| } |
| +void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root, |
| + const gfx::Display& display) { |
| + // Native window property (Atom in X11) that specifies the display's |
| + // rotation and scale factor. The value of the rotation is one of 0 |
| + // (normal), 1 (90 degrees clockwise), 2 (180 degree) or 3 (270 |
|
Daniel Erat
2013/01/30 23:52:46
nit: s/180 degree/180 degrees/
oshima
2013/01/31 00:04:56
Done.
|
| + // degrees clockwise). The value of the scale factor is in |
| + // percent (100, 140, 200 etc). |
| + const char kRotationProp[] = "_CHROME_DISPLAY_ROTATION"; |
| + const char kScaleFactorProp[] = "_CHROME_DISPLAY_SCALE_FACTOR"; |
| + |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + int rotation = 0; |
| + if (command_line->HasSwitch(switches::kAshOverrideDisplayOrientation)) { |
| + std::string value = command_line-> |
| + GetSwitchValueASCII(switches::kAshOverrideDisplayOrientation); |
| + DCHECK(base::StringToInt(value, &rotation)); |
| + DCHECK(0 <= rotation && rotation <= 3) << "Invalid rotation value=" |
| + << rotation; |
| + if (rotation < 0 || rotation > 3) |
| + rotation = 0; |
| + } |
| + root->SetHostWindowIntProperty(kRotationProp, rotation); |
|
Ben Goodger (Google)
2013/01/31 16:57:13
Where is this property read, since you don't provi
oshima
2013/01/31 17:12:53
This will be read by touchpad/mouse driver to
cont
|
| + root->SetHostWindowIntProperty(kScaleFactorProp, |
| + 100 * display.device_scale_factor()); |
| +} |
| + |
| } // namespace |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -276,8 +303,7 @@ void DisplayController::InitPrimaryDisplay() { |
| } |
| #endif |
| primary_display_id = primary_candidate->id(); |
| - aura::RootWindow* root = AddRootWindowForDisplay(*primary_candidate); |
| - root->SetHostBounds(primary_candidate->bounds_in_pixel()); |
| + AddRootWindowForDisplay(*primary_candidate); |
| UpdateDisplayBoundsForLayout(); |
| } |
| @@ -540,7 +566,9 @@ void DisplayController::OnDisplayBoundsChanged(const gfx::Display& display) { |
| NotifyDisplayConfigurationChanging(); |
| UpdateDisplayBoundsForLayout(); |
| - root_windows_[display.id()]->SetHostBounds(display.bounds_in_pixel()); |
| + aura::RootWindow* root = root_windows_[display.id()]; |
| + SetDisplayPropertiesOnHostWindow(root, display); |
| + root->SetHostBounds(display.bounds_in_pixel()); |
| } |
| void DisplayController::OnDisplayAdded(const gfx::Display& display) { |
| @@ -619,6 +647,7 @@ aura::RootWindow* DisplayController::AddRootWindowForDisplay( |
| aura::RootWindow* root = |
| GetDisplayManager()->CreateRootWindowForDisplay(display); |
| root_windows_[display.id()] = root; |
| + SetDisplayPropertiesOnHostWindow(root, display); |
| #if defined(OS_CHROMEOS) |
| static bool force_constrain_pointer_to_root = |