Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: ash/display/display_controller.cc

Issue 12047111: Set scale/orientation property to aura root window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/display/display_controller.cc
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 6a985223e0bc3cc8362ea6aa450544a6f3c6b1fb..98752a2273e92e4e843bdcdf8ee93e3d23935651 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();
}
+// 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 degree clock wise), 2=(180 degree) or 3=(270 degree).
+// The value of the scale factor is in percent (100, 140, 200 etc).
+const char kRotationProp[] = "CHROME_DISPLAY_ROTATION";
Daniel Erat 2013/01/30 21:04:27 either move these to the top of the file or into t
oshima 2013/01/30 23:45:53 Done.
+const char kScaleFactorProp[] = "CHROME_DISPLAY_SCALE_FACTOR";
+
+void SetDisplayPropertiesToHostWindow(aura::RootWindow* root,
Daniel Erat 2013/01/30 21:04:27 nit: s/To/On/
oshima 2013/01/30 23:45:53 Done.
+ const gfx::Display& display) {
Daniel Erat 2013/01/30 21:04:27 nit: fix indenting
oshima 2013/01/30 23:45:53 Done.
+ 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->SetHostWindowProperty(kRotationProp, rotation);
+ root->SetHostWindowProperty(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());
oshima 2013/01/29 21:20:38 the bound is already set in AddRootWnidowForDispla
+ 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()];
+ SetDisplayPropertiesToHostWindow(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;
+ SetDisplayPropertiesToHostWindow(root, display);
#if defined(OS_CHROMEOS)
static bool force_constrain_pointer_to_root =

Powered by Google App Engine
This is Rietveld 408576698