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

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

Issue 267743010: Suppressed screen rotation notifications triggeres by the accelerometer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed MaximizeModeNotifcationBlocker to only filter notifcations from "ash.display" 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 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ 5 #ifndef ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_
6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ 6 #define ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_
7 7
8 #include "ash/accelerometer/accelerometer_observer.h" 8 #include "ash/accelerometer/accelerometer_observer.h"
9 #include "ash/ash_export.h" 9 #include "ash/ash_export.h"
10 #include "ash/display/display_manager.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "ui/message_center/message_center.h"
12 14
13 namespace ash { 15 namespace ash {
14 16
15 class MaximizeModeEventBlocker; 17 class MaximizeModeEventBlocker;
16 18
17 // MaximizeModeController listens to accelerometer events and automatically 19 // MaximizeModeController listens to accelerometer events and automatically
18 // enters and exits maximize mode when the lid is opened beyond the triggering 20 // enters and exits maximize mode when the lid is opened beyond the triggering
19 // angle and rotates the display to match the device when in maximize mode. 21 // angle and rotates the display to match the device when in maximize mode.
20 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver { 22 class ASH_EXPORT MaximizeModeController : public AccelerometerObserver {
21 public: 23 public:
(...skipping 10 matching lines...) Expand all
32 // change the display rotation. 34 // change the display rotation.
33 void set_rotation_locked(bool rotation_locked) { 35 void set_rotation_locked(bool rotation_locked) {
34 rotation_locked_ = rotation_locked; 36 rotation_locked_ = rotation_locked;
35 } 37 }
36 38
37 // AccelerometerObserver: 39 // AccelerometerObserver:
38 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base, 40 virtual void OnAccelerometerUpdated(const gfx::Vector3dF& base,
39 const gfx::Vector3dF& lid) OVERRIDE; 41 const gfx::Vector3dF& lid) OVERRIDE;
40 42
41 private: 43 private:
44 // A message center notification blocker used to suppress screen rotation
45 // events caused by accelerometer events.
46 class MaximizeModeNotificationBlocker
flackr 2014/05/08 18:04:00 Can you forward declare the class here, and put fu
bruthig 2014/05/08 21:15:33 Done.
47 : public message_center::NotificationBlocker {
48 public:
49 MaximizeModeNotificationBlocker();
50 virtual ~MaximizeModeNotificationBlocker();
51
52 virtual void SetShouldShowNotification(bool should_show);
flackr 2014/05/08 18:04:00 nit: Short comment.
bruthig 2014/05/08 21:15:33 Done.
53
54 // message_center::NotificationBlocker:
55 virtual bool ShouldShowNotificationAsPopup(
56 const message_center::NotifierId& notifier_id) const OVERRIDE;
57 virtual bool ShouldShowNotification(
58 const message_center::NotifierId& notifier_id) const OVERRIDE;
59
60 private:
61 // When true will display notifications
62 bool show_notifications_;
63
64 DISALLOW_COPY_AND_ASSIGN(MaximizeModeNotificationBlocker);
65 };
42 // Detect hinge rotation from |base| and |lid| accelerometers and 66 // Detect hinge rotation from |base| and |lid| accelerometers and
43 // automatically start / stop maximize mode. 67 // automatically start / stop maximize mode.
44 void HandleHingeRotation(const gfx::Vector3dF& base, 68 void HandleHingeRotation(const gfx::Vector3dF& base,
45 const gfx::Vector3dF& lid); 69 const gfx::Vector3dF& lid);
46 70
47 // Detect screen rotation from |lid| accelerometer and automatically rotate 71 // Detect screen rotation from |lid| accelerometer and automatically rotate
48 // screen. 72 // screen.
49 void HandleScreenRotation(const gfx::Vector3dF& lid); 73 void HandleScreenRotation(const gfx::Vector3dF& lid);
50 74
75 // Sets the display rotation and suppresses display notifications.
76 void SetDisplayRotation(DisplayManager* display_manager,
77 int64 display_id,
78 gfx::Display::Rotation rotation);
79
51 // Enables MaximizeModeWindowManager, and determines the current state of 80 // Enables MaximizeModeWindowManager, and determines the current state of
52 // rotation lock. 81 // rotation lock.
53 void EnterMaximizeMode(); 82 void EnterMaximizeMode();
54 83
55 // Removes MaximizeModeWindowManager and resets the display rotation if there 84 // Removes MaximizeModeWindowManager and resets the display rotation if there
56 // is no rotation lock. 85 // is no rotation lock.
57 void LeaveMaximizeMode(); 86 void LeaveMaximizeMode();
58 87
59 // An event handler which traps mouse and keyboard events while maximize 88 // An event handler which traps mouse and keyboard events while maximize
60 // mode is engaged. 89 // mode is engaged.
61 scoped_ptr<MaximizeModeEventBlocker> event_blocker_; 90 scoped_ptr<MaximizeModeEventBlocker> event_blocker_;
62 91
92 // Notification blocker to prevent display notifications in
93 // the message center.
94 MaximizeModeNotificationBlocker notification_blocker_;
95
63 // When true calls to OnAccelerometerUpdated will not rotate the display. 96 // When true calls to OnAccelerometerUpdated will not rotate the display.
64 bool rotation_locked_; 97 bool rotation_locked_;
65 98
66 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController); 99 DISALLOW_COPY_AND_ASSIGN(MaximizeModeController);
67 }; 100 };
68 101
69 } // namespace ash 102 } // namespace ash
70 103
71 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_ 104 #endif // ASH_WM_MAXIMIZE_MODE_MAXIMIZE_MODE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698