summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorjonross@chromium.org <jonross@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-20 15:23:32 +0000
committerjonross@chromium.org <jonross@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-20 15:25:04 +0000
commit62e90d40bc221a4465987938e2089da1bf30e2d1 (patch)
treeb961f2bc301a4daa766bec58437724c6f38c97ec /ash
parentfe120441b24c53afc87733c9f533f3bd5fc955ef (diff)
downloadchromium_src-62e90d40bc221a4465987938e2089da1bf30e2d1.zip
chromium_src-62e90d40bc221a4465987938e2089da1bf30e2d1.tar.gz
chromium_src-62e90d40bc221a4465987938e2089da1bf30e2d1.tar.bz2
Rotation Locked saved through device shutdown
Add display rotation preferences to DisplayPreferences. Save the current rotation locked state, along with the screen orientation. These are re-applied upon device reboot, while the device is in maximize mode. Leaving maximize mode clears these settings. TEST=DisplayPreferencesTest.StoreRotationStateNoLogin, DisplayPreferencesTest.StoreRotationStateGuest, DisplayPreferencesTest.StoreRotationStateNormalUser, DisplayPreferencesTest.LoadRotationNoLogin, DisplayPreferencesTest.LoadRotationIgnoredInNormalMode, DisplayPreferencesTest.RotationLockTriggersSTore BUG=chrome-os-partner:30681 Review URL: https://codereview.chromium.org/440773005 Cr-Commit-Position: refs/heads/master@{#290842} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290842 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/display/display_manager.cc14
-rw-r--r--ash/display/display_manager.h22
-rw-r--r--ash/shell.cc3
-rw-r--r--ash/system/chromeos/tray_display.cc2
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller.cc56
-rw-r--r--ash/wm/maximize_mode/maximize_mode_controller.h18
6 files changed, 95 insertions, 20 deletions
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 6d64f36..8ad5738 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -161,7 +161,9 @@ DisplayManager::DisplayManager()
force_bounds_changed_(false),
change_display_upon_host_resize_(false),
second_display_mode_(EXTENDED),
- mirrored_display_id_(gfx::Display::kInvalidDisplayID) {
+ mirrored_display_id_(gfx::Display::kInvalidDisplayID),
+ registered_internal_display_rotation_lock_(false),
+ registered_internal_display_rotation_(gfx::Display::ROTATE_0) {
#if defined(OS_CHROMEOS)
change_display_upon_host_resize_ = !base::SysInfo::IsRunningOnChromeOS();
#endif
@@ -581,6 +583,16 @@ DisplayMode DisplayManager::GetActiveModeForDisplayId(int64 display_id) const {
return selected_mode;
}
+void DisplayManager::RegisterDisplayRotationProperties(bool rotation_lock,
+ gfx::Display::Rotation rotation) {
+ if (delegate_)
+ delegate_->PreDisplayConfigurationChange(false);
+ registered_internal_display_rotation_lock_ = rotation_lock;
+ registered_internal_display_rotation_ = rotation;
+ if (delegate_)
+ delegate_->PostDisplayConfigurationChange();
+}
+
bool DisplayManager::GetSelectedModeForDisplayId(int64 id,
DisplayMode* mode_out) const {
std::map<int64, DisplayMode>::const_iterator iter = display_modes_.find(id);
diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h
index 9c57fde21..a0ab7af 100644
--- a/ash/display/display_manager.h
+++ b/ash/display/display_manager.h
@@ -185,6 +185,22 @@ class ASH_EXPORT DisplayManager
float device_scale_factor,
ui::ColorCalibrationProfile color_profile);
+ // Register stored rotation properties for the internal display.
+ void RegisterDisplayRotationProperties(bool rotation_lock,
+ gfx::Display::Rotation rotation);
+
+ // Returns the stored rotation lock preference if it has been loaded,
+ // otherwise false.
+ bool registered_internal_display_rotation_lock() const {
+ return registered_internal_display_rotation_lock_;
+ }
+
+ // Returns the stored rotation preference for the internal display if it has
+ // been loaded, otherwise |gfx::Display::Rotate_0|.
+ gfx::Display::Rotation registered_internal_display_rotation() const {
+ return registered_internal_display_rotation_;
+ }
+
// Returns the display mode of |display_id| which is currently used.
DisplayMode GetActiveModeForDisplayId(int64 display_id) const;
@@ -375,6 +391,12 @@ private:
int64 mirrored_display_id_;
gfx::Display non_desktop_display_;
+ // User preference for rotation lock of the internal display.
+ bool registered_internal_display_rotation_lock_;
+
+ // User preference for the rotation of the internal display.
+ gfx::Display::Rotation registered_internal_display_rotation_;
+
DISALLOW_COPY_AND_ASSIGN(DisplayManager);
};
diff --git a/ash/shell.cc b/ash/shell.cc
index 453a008..3889571 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -485,7 +485,8 @@ void Shell::RemoveShellObserver(ShellObserver* observer) {
#if defined(OS_CHROMEOS)
bool Shell::ShouldSaveDisplaySettings() {
return !((maximize_mode_controller_->IsMaximizeModeWindowManagerEnabled() &&
- maximize_mode_controller_->in_set_screen_rotation()) ||
+ maximize_mode_controller_->
+ ignore_display_configuration_updates()) ||
resolution_notification_controller_->DoesNotificationTimeout());
}
#endif
diff --git a/ash/system/chromeos/tray_display.cc b/ash/system/chromeos/tray_display.cc
index d8cafb9..a02e0c8 100644
--- a/ash/system/chromeos/tray_display.cc
+++ b/ash/system/chromeos/tray_display.cc
@@ -381,7 +381,7 @@ void TrayDisplay::CreateOrUpdateNotification(
// Don't display notifications for accelerometer triggered screen rotations.
// See http://crbug.com/364949
if (Shell::GetInstance()->maximize_mode_controller()->
- in_set_screen_rotation()) {
+ ignore_display_configuration_updates()) {
return;
}
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc
index add7fb3..6f655b2 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc
@@ -156,7 +156,8 @@ void ScreenshotActionHandler::OnKeyEvent(ui::KeyEvent* event) {
MaximizeModeController::MaximizeModeController()
: rotation_locked_(false),
have_seen_accelerometer_data_(false),
- in_set_screen_rotation_(false),
+ ignore_display_configuration_updates_(false),
+ shutting_down_(false),
user_rotation_(gfx::Display::ROTATE_0),
last_touchview_transition_time_(base::Time::Now()),
tick_clock_(new base::DefaultTickClock()),
@@ -181,7 +182,11 @@ MaximizeModeController::~MaximizeModeController() {
void MaximizeModeController::SetRotationLocked(bool rotation_locked) {
if (rotation_locked_ == rotation_locked)
return;
+ base::AutoReset<bool> auto_ignore_display_configuration_updates(
+ &ignore_display_configuration_updates_, true);
rotation_locked_ = rotation_locked;
+ Shell::GetInstance()->display_manager()->
+ RegisterDisplayRotationProperties(rotation_locked_, current_rotation_);
FOR_EACH_OBSERVER(Observer, observers_,
OnRotationLockChanged(rotation_locked_));
}
@@ -226,13 +231,14 @@ void MaximizeModeController::AddWindow(aura::Window* window) {
}
void MaximizeModeController::Shutdown() {
- maximize_mode_window_manager_.reset();
- Shell::GetInstance()->OnMaximizeModeEnded();
+ shutting_down_ = true;
+ LeaveMaximizeMode();
}
void MaximizeModeController::OnAccelerometerUpdated(
const gfx::Vector3dF& base,
const gfx::Vector3dF& lid) {
+ bool first_accelerometer_update = !have_seen_accelerometer_data_;
have_seen_accelerometer_data_ = true;
// Ignore the reading if it appears unstable. The reading is considered
@@ -250,10 +256,18 @@ void MaximizeModeController::OnAccelerometerUpdated(
// affects screen rotation, so we handle hinge rotation first.
HandleHingeRotation(base, lid);
HandleScreenRotation(lid);
+
+ if (first_accelerometer_update) {
+ // On the first accelerometer update we will know if we have entered
+ // maximize mode or not. Update the preferences to reflect the current
+ // state.
+ Shell::GetInstance()->display_manager()->
+ RegisterDisplayRotationProperties(rotation_locked_, current_rotation_);
+ }
}
void MaximizeModeController::OnDisplayConfigurationChanged() {
- if (in_set_screen_rotation_)
+ if (ignore_display_configuration_updates_)
return;
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
gfx::Display::Rotation user_rotation = display_manager->
@@ -398,8 +412,8 @@ void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) {
void MaximizeModeController::SetDisplayRotation(
DisplayManager* display_manager,
gfx::Display::Rotation rotation) {
- base::AutoReset<bool> auto_in_set_screen_rotation(
- &in_set_screen_rotation_, true);
+ base::AutoReset<bool> auto_ignore_display_configuration_updates(
+ &ignore_display_configuration_updates_, true);
current_rotation_ = rotation;
display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
rotation);
@@ -409,8 +423,11 @@ void MaximizeModeController::EnterMaximizeMode() {
if (IsMaximizeModeWindowManagerEnabled())
return;
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- current_rotation_ = user_rotation_ = display_manager->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ if (display_manager->HasInternalDisplay()) {
+ current_rotation_ = user_rotation_ = display_manager->
+ GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ LoadDisplayRotationProperties();
+ }
EnableMaximizeModeWindowManager(true);
#if defined(USE_X11)
event_blocker_.reset(new ScopedDisableInternalMouseAndKeyboardX11);
@@ -425,11 +442,14 @@ void MaximizeModeController::LeaveMaximizeMode() {
if (!IsMaximizeModeWindowManagerEnabled())
return;
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- gfx::Display::Rotation current_rotation = display_manager->
- GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
- if (current_rotation != user_rotation_)
- SetDisplayRotation(display_manager, user_rotation_);
- rotation_locked_ = false;
+ if (display_manager->HasInternalDisplay()) {
+ gfx::Display::Rotation current_rotation = display_manager->
+ GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ if (current_rotation != user_rotation_)
+ SetDisplayRotation(display_manager, user_rotation_);
+ }
+ if (!shutting_down_)
+ SetRotationLocked(false);
EnableMaximizeModeWindowManager(false);
event_blocker_.reset();
event_handler_.reset();
@@ -462,6 +482,16 @@ void MaximizeModeController::RecordTouchViewStateTransition() {
}
}
+void MaximizeModeController::LoadDisplayRotationProperties() {
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager();
+ if (!display_manager->registered_internal_display_rotation_lock())
+ return;
+
+ SetDisplayRotation(display_manager,
+ display_manager->registered_internal_display_rotation());
+ SetRotationLocked(true);
+}
+
void MaximizeModeController::OnAppTerminating() {
if (CanEnterMaximizeMode()) {
RecordTouchViewStateTransition();
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.h b/ash/wm/maximize_mode/maximize_mode_controller.h
index bc4b224..326e8f8 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.h
+++ b/ash/wm/maximize_mode/maximize_mode_controller.h
@@ -62,8 +62,8 @@ class ASH_EXPORT MaximizeModeController
MaximizeModeController();
virtual ~MaximizeModeController();
- bool in_set_screen_rotation() const {
- return in_set_screen_rotation_;
+ bool ignore_display_configuration_updates() const {
+ return ignore_display_configuration_updates_;
}
// True if |rotation_lock_| has been set, and OnAccelerometerUpdated will not
@@ -164,6 +164,10 @@ class ASH_EXPORT MaximizeModeController
// Record UMA stats tracking touchview usage.
void RecordTouchViewStateTransition();
+ // Checks DisplayManager for registered rotation lock, and rotation,
+ // preferences. These are then applied.
+ void LoadDisplayRotationProperties();
+
// The maximized window manager (if enabled).
scoped_ptr<MaximizeModeWindowManager> maximize_mode_window_manager_;
@@ -180,8 +184,14 @@ class ASH_EXPORT MaximizeModeController
// Whether we have ever seen accelerometer data.
bool have_seen_accelerometer_data_;
- // True when the screen's orientation is being changed.
- bool in_set_screen_rotation_;
+ // True when changes being applied cause OnDisplayConfigurationChanged() to be
+ // called, and for which these changes should be ignored.
+ bool ignore_display_configuration_updates_;
+
+ // True when Shutdown has been called. When shutting down the non maximize
+ // mode state should be restored, however user preferences should not be
+ // altered.
+ bool shutting_down_;
// The rotation of the display set by the user. This rotation will be
// restored upon exiting maximize mode.