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

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

Issue 289583002: Lock rotation when screen is manually rotated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define sources for rotation 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..068172087ad2797b42039f8c64c5fce2ef4f01ed 100644
--- a/ash/wm/maximize_mode/maximize_mode_controller.cc
+++ b/ash/wm/maximize_mode/maximize_mode_controller.cc
@@ -13,6 +13,7 @@
#include "ash/wm/maximize_mode/maximize_mode_event_blocker.h"
#include "base/command_line.h"
#include "ui/base/accelerators/accelerator.h"
+#include "ui/display/types/display_constants.h"
#include "ui/events/event.h"
#include "ui/events/event_handler.h"
#include "ui/events/keycodes/keyboard_codes.h"
@@ -203,16 +204,10 @@ void MaximizeModeController::HandleHingeRotation(const gfx::Vector3dF& base,
if (maximize_mode_engaged &&
angle > kFullyOpenAngleErrorTolerance &&
angle < kExitMaximizeModeAngle) {
- Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
- event_blocker_.reset();
- event_handler_.reset();
+ LeaveMaximizeMode();
} else if (!maximize_mode_engaged &&
angle > kEnterMaximizeModeAngle) {
- Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
- event_blocker_.reset(new MaximizeModeEventBlocker);
-#if defined(OS_CHROMEOS)
- event_handler_.reset(new ScreenshotActionHandler);
-#endif
+ EnterMaximizeMode();
}
}
@@ -220,31 +215,14 @@ void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) {
bool maximize_mode_engaged =
Shell::GetInstance()->IsMaximizeModeWindowManagerEnabled();
+ if (!maximize_mode_engaged || rotation_locked_)
+ return;
+
DisplayManager* display_manager =
Shell::GetInstance()->display_manager();
gfx::Display::Rotation current_rotation = display_manager->GetDisplayInfo(
gfx::Display::InternalDisplayId()).rotation();
- // If maximize mode is not engaged, ensure the screen is not rotated and
- // do not rotate to match the current device orientation.
- if (!maximize_mode_engaged) {
- if (current_rotation != gfx::Display::ROTATE_0) {
- // TODO(flackr): Currently this will prevent setting a manual rotation on
- // the screen of a device with an accelerometer, this should only set it
- // back to ROTATE_0 if it was last set by the accelerometer.
- // 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);
- }
- rotation_locked_ = false;
- return;
- }
-
- if (rotation_locked_)
- return;
-
// After determining maximize mode state, determine if the screen should
// be rotated.
gfx::Vector3dF lid_flattened(lid.x(), lid.y(), 0.0f);
@@ -295,8 +273,37 @@ void MaximizeModeController::HandleScreenRotation(const gfx::Vector3dF& lid) {
if (new_rotation == gfx::Display::ROTATE_0 ||
maximize_mode_engaged) {
display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
- new_rotation);
+ new_rotation,
+ ui::ACCELEROMETER);
}
}
+void MaximizeModeController::EnterMaximizeMode() {
+ // TODO(jonross): Listen for display configuration changes. If the user
+ // causes a rotation change a rotation lock should be applied.
+ // https://crbug.com/369505
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager();
+ gfx::Display::Rotation current_rotation = display_manager->
+ GetDisplayInfo(gfx::Display::InternalDisplayId()).rotation();
+ rotation_locked_ = current_rotation != gfx::Display::ROTATE_0;
flackr 2014/05/16 16:00:22 What do you think of not locking on non-zero rotat
jonross 2014/05/16 17:25:28 Considering that the user is enacting a state chan
+ Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
+ event_blocker_.reset(new MaximizeModeEventBlocker);
+#if defined(OS_CHROMEOS)
+ event_handler_.reset(new ScreenshotActionHandler);
+#endif
+}
+
+void MaximizeModeController::LeaveMaximizeMode() {
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager();
+ DisplayInfo info = display_manager->
+ GetDisplayInfo(gfx::Display::InternalDisplayId());
+ gfx::Display::Rotation user_rotation = info.GetRotation(ui::USER);
+ display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
+ user_rotation,
+ ui::USER);
+ Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
+ event_blocker_.reset();
+ event_handler_.reset();
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698