Skip to content

Commit

Permalink
Use XRANR definition for rotation
Browse files Browse the repository at this point in the history
Changed to use xrandr's definition as discussed offline.
Removed command line switch as this is no longer needed.


BUG=196434
TEST=none

Review URL: https://chromiumcodereview.appspot.com/12700024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189123 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
oshima@chromium.org committed Mar 19, 2013
1 parent eeb9ccb commit 1d5d999
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
6 changes: 0 additions & 6 deletions ash/ash_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ const char kAshImmersiveHideTabIndicators[] =
// Specifies the internal display's ui scale.
const char kAshInternalDisplayUIScale[] = "ash-internal-display-ui-scale";

// Overrides all displays' orientation. The value should be one of 0
// (normal), 1 (90 degrees clockwise), 2 (180 degrees) or 3 (270
// degrees clockwise).
const char kAshOverrideDisplayOrientation[] =
"ash-override-display-orientation";

// Specifies the layout mode and offsets for the secondary display for
// testing. The format is "<t|r|b|l>,<offset>" where t=TOP, r=RIGHT,
// b=BOTTOM and L=LEFT. For example, 'r,-100' means the secondary display
Expand Down
1 change: 0 additions & 1 deletion ash/ash_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ ASH_EXPORT extern const char kAshInternalDisplayUIScale[];
ASH_EXPORT extern const char kAshSecondaryDisplayLayout[];
ASH_EXPORT extern const char kAshTouchHud[];
ASH_EXPORT extern const char kAuraLegacyPowerButton[];
ASH_EXPORT extern const char kAshOverrideDisplayOrientation[];

} // namespace switches
} // namespace ash
Expand Down
33 changes: 21 additions & 12 deletions ash/display/display_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
#include "base/time.h"
#include "chromeos/display/output_configurator.h"
#include "ui/base/x/x11_util.h"

// Including this at the bottom to avoid other
// potential conflict with chrome headers.
#include <X11/extensions/Xrandr.h>
#undef RootWindow
#endif // defined(OS_CHROMEOS)

DECLARE_WINDOW_PROPERTY_TYPE(gfx::Display::Rotation);
Expand Down Expand Up @@ -161,22 +166,26 @@ void SetDisplayPropertiesOnHostWindow(aura::RootWindow* root,
const char kScaleFactorProp[] = "_CHROME_DISPLAY_SCALE_FACTOR";
const char kInternalProp[] = "_CHROME_DISPLAY_INTERNAL";
const char kCARDINAL[] = "CARDINAL";

CommandLine* command_line = CommandLine::ForCurrentProcess();
int rotation = static_cast<int>(info.rotation());
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;
int xrandr_rotation = RR_Rotate_0;
switch (info.rotation()) {
case gfx::Display::ROTATE_0:
xrandr_rotation = RR_Rotate_0;
break;
case gfx::Display::ROTATE_90:
xrandr_rotation = RR_Rotate_90;
break;
case gfx::Display::ROTATE_180:
xrandr_rotation = RR_Rotate_180;
break;
case gfx::Display::ROTATE_270:
xrandr_rotation = RR_Rotate_270;
break;
}

int internal = display.IsInternal() ? 1 : 0;
gfx::AcceleratedWidget xwindow = root->GetAcceleratedWidget();
ui::SetIntProperty(xwindow, kInternalProp, kCARDINAL, internal);
ui::SetIntProperty(xwindow, kRotationProp, kCARDINAL, rotation);
ui::SetIntProperty(xwindow, kRotationProp, kCARDINAL, xrandr_rotation);
ui::SetIntProperty(xwindow,
kScaleFactorProp,
kCARDINAL,
Expand Down

0 comments on commit 1d5d999

Please sign in to comment.