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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller.cc

Issue 267743010: Suppressed screen rotation notifications triggeres by the accelerometer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed maximize_mode_controller to use it's own SetDisplayRotation method. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/accelerometer/accelerometer_controller.h" 9 #include "ash/accelerometer/accelerometer_controller.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 ash::TAKE_SCREENSHOT, ui::Accelerator()); 125 ash::TAKE_SCREENSHOT, ui::Accelerator());
126 } 126 }
127 } 127 }
128 128
129 #endif // OS_CHROMEOS 129 #endif // OS_CHROMEOS
130 130
131 } // namespace 131 } // namespace
132 132
133 MaximizeModeController::MaximizeModeController() 133 MaximizeModeController::MaximizeModeController()
134 : rotation_locked_(false), 134 : rotation_locked_(false),
135 have_seen_accelerometer_data_(false) { 135 have_seen_accelerometer_data_(false),
136 show_display_notifications_(true) {
136 Shell::GetInstance()->accelerometer_controller()->AddObserver(this); 137 Shell::GetInstance()->accelerometer_controller()->AddObserver(this);
137 } 138 }
138 139
139 MaximizeModeController::~MaximizeModeController() { 140 MaximizeModeController::~MaximizeModeController() {
140 Shell::GetInstance()->accelerometer_controller()->RemoveObserver(this); 141 Shell::GetInstance()->accelerometer_controller()->RemoveObserver(this);
141 } 142 }
142 143
143 bool MaximizeModeController::CanEnterMaximizeMode() { 144 bool MaximizeModeController::CanEnterMaximizeMode() {
144 // If we have ever seen accelerometer data, then HandleHingeRotation may 145 // If we have ever seen accelerometer data, then HandleHingeRotation may
145 // trigger maximize mode at some point in the future. 146 // trigger maximize mode at some point in the future.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // If maximize mode is not engaged, ensure the screen is not rotated and 229 // If maximize mode is not engaged, ensure the screen is not rotated and
229 // do not rotate to match the current device orientation. 230 // do not rotate to match the current device orientation.
230 if (!maximize_mode_engaged) { 231 if (!maximize_mode_engaged) {
231 if (current_rotation != gfx::Display::ROTATE_0) { 232 if (current_rotation != gfx::Display::ROTATE_0) {
232 // TODO(flackr): Currently this will prevent setting a manual rotation on 233 // TODO(flackr): Currently this will prevent setting a manual rotation on
233 // the screen of a device with an accelerometer, this should only set it 234 // the screen of a device with an accelerometer, this should only set it
234 // back to ROTATE_0 if it was last set by the accelerometer. 235 // back to ROTATE_0 if it was last set by the accelerometer.
235 // Also, SetDisplayRotation will save the setting to the local store, 236 // Also, SetDisplayRotation will save the setting to the local store,
236 // this should be stored in a way that we can distinguish what the 237 // this should be stored in a way that we can distinguish what the
237 // rotation was set by. 238 // rotation was set by.
238 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 239 SetDisplayRotation(display_manager,
239 gfx::Display::ROTATE_0); 240 gfx::Display::InternalDisplayId(),
241 gfx::Display::ROTATE_0);
240 } 242 }
241 rotation_locked_ = false; 243 rotation_locked_ = false;
242 return; 244 return;
243 } 245 }
244 246
245 if (rotation_locked_) 247 if (rotation_locked_)
246 return; 248 return;
247 249
248 // After determining maximize mode state, determine if the screen should 250 // After determining maximize mode state, determine if the screen should
249 // be rotated. 251 // be rotated.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 new_rotation = gfx::Display::ROTATE_0; 289 new_rotation = gfx::Display::ROTATE_0;
288 else if (angle < 180.0f) 290 else if (angle < 180.0f)
289 new_rotation = gfx::Display::ROTATE_270; 291 new_rotation = gfx::Display::ROTATE_270;
290 else if (angle < 270.0f) 292 else if (angle < 270.0f)
291 new_rotation = gfx::Display::ROTATE_180; 293 new_rotation = gfx::Display::ROTATE_180;
292 294
293 // When exiting maximize mode return rotation to 0. When entering, rotate to 295 // When exiting maximize mode return rotation to 0. When entering, rotate to
294 // match screen orientation. 296 // match screen orientation.
295 if (new_rotation == gfx::Display::ROTATE_0 || 297 if (new_rotation == gfx::Display::ROTATE_0 ||
296 maximize_mode_engaged) { 298 maximize_mode_engaged) {
297 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), 299 SetDisplayRotation(display_manager,
298 new_rotation); 300 gfx::Display::InternalDisplayId(),
301 new_rotation);
299 } 302 }
300 } 303 }
301 304
305 void MaximizeModeController::SetDisplayRotation(
306 DisplayManager* display_manager,
307 int64 display_id,
jonross 2014/05/14 01:00:39 We only ever operate on the internal display, this
bruthig 2014/05/14 18:48:49 Done.
308 gfx::Display::Rotation rotation) {
309 // Suppress message centre notifications for screen rotations caused
310 // by accelerometer events because it should be obvious why the orientation
311 // changed.
312 show_display_notifications_ = false;
flackr 2014/05/14 01:48:33 nit: Use base::AutoReset.
bruthig 2014/05/14 18:48:49 Done.
313 display_manager->SetDisplayRotation(display_id, rotation);
314 show_display_notifications_ = true;
315 }
316
302 } // namespace ash 317 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698