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

Unified Diff: ash/wm/maximize_mode/maximize_mode_controller.cc

Issue 291233002: Re-landing "Suppressed screen rotation notifications triggeres by the accelerometer." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ifdef'ed BlockRotationNotification test so it only runs on ChromeOS. Created 6 years, 7 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/wm/maximize_mode/maximize_mode_controller.cc
diff --git a/ash/wm/maximize_mode/maximize_mode_controller.cc b/ash/wm/maximize_mode/maximize_mode_controller.cc
index 61ce2f2205611a724a838ebb705b713a088f2055..a969a91a07eca81e03746771c5cca4be2365de9f 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc
@@ -11,6 +11,7 @@
#include "ash/display/display_manager.h"
#include "ash/shell.h"
#include "ash/wm/maximize_mode/maximize_mode_event_blocker.h"
+#include "base/auto_reset.h"
#include "base/command_line.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/events/event.h"
@@ -132,7 +133,8 @@ void ScreenshotActionHandler::OnKeyEvent(ui::KeyEvent* event) {
MaximizeModeController::MaximizeModeController()
: rotation_locked_(false),
- have_seen_accelerometer_data_(false) {
+ have_seen_accelerometer_data_(false),
+ in_set_screen_rotation_(false) {
Shell::GetInstance()->accelerometer_controller()->AddObserver(this);
}
@@ -235,8 +237,8 @@ void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) {
// Also, SetDisplayRotation will save the setting to the local store,
// this should be stored in a way that we can distinguish what the
// rotation was set by.
- display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
- gfx::Display::ROTATE_0);
+ SetDisplayRotation(display_manager,
+ gfx::Display::ROTATE_0);
}
rotation_locked_ = false;
return;
@@ -294,9 +296,18 @@ void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) {
// match screen orientation.
if (new_rotation == gfx::Display::ROTATE_0 ||
maximize_mode_engaged) {
- display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
- new_rotation);
+ SetDisplayRotation(display_manager,
+ new_rotation);
}
}
+void MaximizeModeController::SetDisplayRotation(
+ DisplayManager* display_manager,
+ gfx::Display::Rotation rotation) {
+ base::AutoReset<bool> auto_in_set_screen_rotation(
+ &in_set_screen_rotation_, true);
+ display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
+ rotation);
+}
+
} // namespace ash
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_controller.h ('k') | ash/wm/maximize_mode/maximize_mode_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698