| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 WINDOW_MANAGER_SCREEN_LOCKER_HANDLER_H_ | 5 #ifndef WINDOW_MANAGER_SCREEN_LOCKER_HANDLER_H_ |
| 6 #define WINDOW_MANAGER_SCREEN_LOCKER_HANDLER_H_ | 6 #define WINDOW_MANAGER_SCREEN_LOCKER_HANDLER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include <gtest/gtest_prod.h> // for FRIEND_TEST() macro | 10 #include <gtest/gtest_prod.h> // for FRIEND_TEST() macro |
| 11 | 11 |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "window_manager/compositor.h" | 13 #include "window_manager/compositor.h" |
| 14 #include "window_manager/event_consumer.h" | 14 #include "window_manager/event_consumer.h" |
| 15 #include "window_manager/x_types.h" | 15 #include "window_manager/x_types.h" |
| 16 | 16 |
| 17 namespace window_manager { | 17 namespace window_manager { |
| 18 | 18 |
| 19 class EventConsumerRegistrar; | 19 class EventConsumerRegistrar; |
| 20 class WindowManager; | 20 class WindowManager; |
| 21 class Window; | 21 class Window; |
| 22 | 22 |
| 23 // ScreenLockerHandler is an event consumer that hides all other actors | 23 // ScreenLockerHandler is an event consumer that hides all other actors |
| 24 // when a screen locker window gets mapped and unhides them when the locker | 24 // when a screen locker window gets mapped and unhides them when the locker |
| 25 // window is unmapped. It also handles messages sent by the power manager | 25 // window is unmapped. It also handles messages sent by the power manager when |
| 26 // when the power button is pressed or unpressed. | 26 // the power button is pressed or unpressed or the system is shutting down, and |
| 27 // messages sent by Chrome when the user is signing out. |
| 27 class ScreenLockerHandler : public EventConsumer { | 28 class ScreenLockerHandler : public EventConsumer { |
| 28 public: | 29 public: |
| 29 explicit ScreenLockerHandler(WindowManager* wm); | 30 explicit ScreenLockerHandler(WindowManager* wm); |
| 30 ~ScreenLockerHandler(); | 31 ~ScreenLockerHandler(); |
| 31 | 32 |
| 32 bool shutting_down() const { return shutting_down_; } | 33 bool session_ending() const { return session_ending_; } |
| 33 | 34 |
| 34 // Begin EventConsumer implementation. | 35 // Begin EventConsumer implementation. |
| 35 virtual bool IsInputWindow(XWindow xid) { return false; } | 36 virtual bool IsInputWindow(XWindow xid) { return false; } |
| 36 virtual void HandleScreenResize(); | 37 virtual void HandleScreenResize(); |
| 37 virtual void HandleLoggedInStateChange() {} | 38 virtual void HandleLoggedInStateChange() {} |
| 38 virtual bool HandleWindowMapRequest(Window* win); | 39 virtual bool HandleWindowMapRequest(Window* win); |
| 39 virtual void HandleWindowMap(Window* win); | 40 virtual void HandleWindowMap(Window* win); |
| 40 virtual void HandleWindowUnmap(Window* win); | 41 virtual void HandleWindowUnmap(Window* win); |
| 41 virtual void HandleWindowInitialPixmap(Window* win); | 42 virtual void HandleWindowInitialPixmap(Window* win); |
| 42 virtual void HandleWindowConfigureRequest(Window* win, | 43 virtual void HandleWindowConfigureRequest(Window* win, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // locked state, or while not logged in. We take a snapshot of the | 116 // locked state, or while not logged in. We take a snapshot of the |
| 116 // screen, display only it, and make it slowly zoom away from the user. | 117 // screen, display only it, and make it slowly zoom away from the user. |
| 117 void HandlePreShutdown(); | 118 void HandlePreShutdown(); |
| 118 | 119 |
| 119 // Handle the power button having been released while in the pre-shutdown | 120 // Handle the power button having been released while in the pre-shutdown |
| 120 // state. We animate the snapshot scaling back to its normal size and | 121 // state. We animate the snapshot scaling back to its normal size and |
| 121 // set a timer to destroy it and switch back to displaying the screen | 122 // set a timer to destroy it and switch back to displaying the screen |
| 122 // locker window (if locked) or all actors (if unlocked). | 123 // locker window (if locked) or all actors (if unlocked). |
| 123 void HandleAbortedShutdown(); | 124 void HandleAbortedShutdown(); |
| 124 | 125 |
| 125 // Handle notification that the system is shutting down. We make the | 126 // Handle notification that the current session is ending (either due to |
| 126 // snapshot from the pre-shutdown state zoom quickly down to the center | 127 // shutdown if 'shutting_down' is true or due to signout otherwise). We set |
| 127 // of the screen, set pointer to use a transparent cursor, and grab the | 128 // the pointer to use a transparent cursor, grab the keyboard and pointer, and |
| 128 // keyboard and pointer. | 129 // display an animation. |
| 129 void HandleShuttingDown(); | 130 void HandleSessionEnding(bool shutting_down); |
| 130 | 131 |
| 131 // Take a snapshot of the screen if we don't already have one and animate | 132 // If 'snapshot_actor_' is unset, grab and display a snapshot of the current |
| 132 // it slowly scaling down to kSlowCloseSizeRatio. | 133 // contents of the screen. |
| 134 void SetUpSnapshot(); |
| 135 |
| 136 // Animate a snapshot of the screen slowly scaling down to |
| 137 // kSlowCloseSizeRatio. |
| 133 void StartSlowCloseAnimation(); | 138 void StartSlowCloseAnimation(); |
| 134 | 139 |
| 135 // Start an animation undoing the scaling from StartSlowCloseAnimation() | 140 // Start an animation undoing the scaling from StartSlowCloseAnimation() |
| 136 // and register a timeout to call | 141 // and register a timeout to call |
| 137 // DestroySnapshotAndUpdateVisibilityGroup() when it's done. | 142 // DestroySnapshotAndUpdateVisibilityGroup() when it's done. |
| 138 void StartUndoSlowCloseAnimation(); | 143 void StartUndoSlowCloseAnimation(); |
| 139 | 144 |
| 140 // Take a snapshot of the screen if we don't already have one and make it | 145 // Animate a snapshot of the screen quickly getting scaled down to the center |
| 141 // quickly get scaled down to the center of the screen. If | 146 // of the screen. If 'destroy_snapshot_when_done' is true, also register a |
| 142 // 'destroy_snapshot_when_done' is true, also register a timeout to call | 147 // timeout to call DestroySnapshotAndUpdateVisibilityGroup() when it's done. |
| 143 // DestroySnapshotAndUpdateVisibilityGroup() when it's done. | 148 // If there's an existing snapshot (from an in-progress slow-close animation), |
| 149 // we use it. |
| 144 void StartFastCloseAnimation(bool destroy_snapshot_when_done); | 150 void StartFastCloseAnimation(bool destroy_snapshot_when_done); |
| 145 | 151 |
| 152 // Animate a snapshot of the screen quickly fading out to black. |
| 153 void StartFadeoutAnimation(); |
| 154 |
| 146 // Destroy 'snapshot_actor_' and 'snapshot_pixmap_'. | 155 // Destroy 'snapshot_actor_' and 'snapshot_pixmap_'. |
| 147 void DestroySnapshot(); | 156 void DestroySnapshot(); |
| 148 | 157 |
| 149 // Call DestroySnapshot() and also reset the active visibility groups to | 158 // Call DestroySnapshot() and also reset the active visibility groups to |
| 150 // show all actors (if the screen is unlocked) or just the screen locker | 159 // show all actors (if the screen is unlocked) or just the screen locker |
| 151 // window (if the screen is locked). | 160 // window (if the screen is locked). |
| 152 void DestroySnapshotAndUpdateVisibilityGroup(); | 161 void DestroySnapshotAndUpdateVisibilityGroup(); |
| 153 | 162 |
| 154 // Reset 'destroy_snapshot_timeout_id_' to -1 and call | 163 // Reset 'destroy_snapshot_timeout_id_' to -1 and call |
| 155 // DestroySnapshotAndUpdateVisibilityGroup(). | 164 // DestroySnapshotAndUpdateVisibilityGroup(). |
| (...skipping 16 matching lines...) Expand all Loading... |
| 172 | 181 |
| 173 // Timeout for calling DestroySnapshotAndUpdateVisibilityGroup(), or -1 | 182 // Timeout for calling DestroySnapshotAndUpdateVisibilityGroup(), or -1 |
| 174 // if unset. | 183 // if unset. |
| 175 int destroy_snapshot_timeout_id_; | 184 int destroy_snapshot_timeout_id_; |
| 176 | 185 |
| 177 // Is the screen currently locked? We only consider the screen to be | 186 // Is the screen currently locked? We only consider the screen to be |
| 178 // locked if a screen locker window has been mapped and we've loaded a | 187 // locked if a screen locker window has been mapped and we've loaded a |
| 179 // pixmap for it. | 188 // pixmap for it. |
| 180 bool is_locked_; | 189 bool is_locked_; |
| 181 | 190 |
| 182 // Is the system shutting down? Set to true in response to a | 191 // Is the current X session ending? Set to true in response to a |
| 192 // WM_IPC_MESSAGE_WM_NOTIFY_SIGNING_OUT or |
| 183 // WM_IPC_MESSAGE_WM_NOTIFY_SHUTTING_DOWN message and never unset. | 193 // WM_IPC_MESSAGE_WM_NOTIFY_SHUTTING_DOWN message and never unset. |
| 184 bool shutting_down_; | 194 bool session_ending_; |
| 185 | 195 |
| 186 DISALLOW_COPY_AND_ASSIGN(ScreenLockerHandler); | 196 DISALLOW_COPY_AND_ASSIGN(ScreenLockerHandler); |
| 187 }; | 197 }; |
| 188 | 198 |
| 189 } // namespace window_manager | 199 } // namespace window_manager |
| 190 | 200 |
| 191 #endif // WINDOW_MANAGER_SCREEN_LOCKER_HANDLER_H_ | 201 #endif // WINDOW_MANAGER_SCREEN_LOCKER_HANDLER_H_ |
| OLD | NEW |