OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <string> | 10 #include <string> |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 mouse_over_shelf_when_auto_hide_timer_started_(false), | 206 mouse_over_shelf_when_auto_hide_timer_started_(false), |
207 bezel_event_filter_(new ShelfBezelEventFilter(this)), | 207 bezel_event_filter_(new ShelfBezelEventFilter(this)), |
208 gesture_drag_status_(GESTURE_DRAG_NONE), | 208 gesture_drag_status_(GESTURE_DRAG_NONE), |
209 gesture_drag_amount_(0.f), | 209 gesture_drag_amount_(0.f), |
210 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), | 210 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), |
211 update_shelf_observer_(NULL), | 211 update_shelf_observer_(NULL), |
212 duration_override_in_ms_(0) { | 212 duration_override_in_ms_(0) { |
213 Shell::GetInstance()->AddShellObserver(this); | 213 Shell::GetInstance()->AddShellObserver(this); |
214 Shell::GetInstance()->lock_state_controller()->AddObserver(this); | 214 Shell::GetInstance()->lock_state_controller()->AddObserver(this); |
215 aura::client::GetActivationClient(root_window_)->AddObserver(this); | 215 aura::client::GetActivationClient(root_window_)->AddObserver(this); |
| 216 Shell::GetInstance()->session_state_delegate()->AddSessionStateObserver(this); |
216 } | 217 } |
217 | 218 |
218 ShelfLayoutManager::~ShelfLayoutManager() { | 219 ShelfLayoutManager::~ShelfLayoutManager() { |
219 if (update_shelf_observer_) | 220 if (update_shelf_observer_) |
220 update_shelf_observer_->Detach(); | 221 update_shelf_observer_->Detach(); |
221 | 222 |
222 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, WillDeleteShelf()); | 223 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, WillDeleteShelf()); |
223 Shell::GetInstance()->RemoveShellObserver(this); | 224 Shell::GetInstance()->RemoveShellObserver(this); |
224 Shell::GetInstance()->lock_state_controller()->RemoveObserver(this); | 225 Shell::GetInstance()->lock_state_controller()->RemoveObserver(this); |
225 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); | 226 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); |
| 227 Shell::GetInstance()-> |
| 228 session_state_delegate()->RemoveSessionStateObserver(this); |
226 } | 229 } |
227 | 230 |
228 void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { | 231 void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
229 if (auto_hide_behavior_ == behavior) | 232 if (auto_hide_behavior_ == behavior) |
230 return; | 233 return; |
231 auto_hide_behavior_ = behavior; | 234 auto_hide_behavior_ = behavior; |
232 UpdateVisibilityState(); | 235 UpdateVisibilityState(); |
233 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 236 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
234 OnAutoHideBehaviorChanged(root_window_, | 237 OnAutoHideBehaviorChanged(root_window_, |
235 auto_hide_behavior_)); | 238 auto_hide_behavior_)); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 status_bounds.set_x(status_bounds.x() + | 736 status_bounds.set_x(status_bounds.x() + |
734 target_bounds.shelf_bounds_in_root.x()); | 737 target_bounds.shelf_bounds_in_root.x()); |
735 status_bounds.set_y(status_bounds.y() + | 738 status_bounds.set_y(status_bounds.y() + |
736 target_bounds.shelf_bounds_in_root.y()); | 739 target_bounds.shelf_bounds_in_root.y()); |
737 shelf_->status_area_widget()->SetBounds( | 740 shelf_->status_area_widget()->SetBounds( |
738 ScreenUtil::ConvertRectToScreen( | 741 ScreenUtil::ConvertRectToScreen( |
739 shelf_->status_area_widget()->GetNativeView()->parent(), | 742 shelf_->status_area_widget()->GetNativeView()->parent(), |
740 status_bounds)); | 743 status_bounds)); |
741 SessionStateDelegate* session_state_delegate = | 744 SessionStateDelegate* session_state_delegate = |
742 Shell::GetInstance()->session_state_delegate(); | 745 Shell::GetInstance()->session_state_delegate(); |
743 if (!state_.is_screen_locked && | 746 if (!state_.is_screen_locked) { |
744 (session_state_delegate->IsActiveUserSessionStarted() || | 747 gfx::Insets insets; |
745 !keyboard_bounds_.IsEmpty())) { | 748 // If user session is blocked (login to new user session or add user to |
746 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 749 // the existing session - multi-profile) then give 100% of work area only if |
747 root_window_, target_bounds.work_area_insets); | 750 // keyboard is not shown. |
| 751 if (!session_state_delegate->IsUserSessionBlocked() || |
| 752 !keyboard_bounds_.IsEmpty()) { |
| 753 insets = target_bounds.work_area_insets; |
| 754 } |
| 755 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets); |
748 } | 756 } |
749 } | 757 } |
750 | 758 |
751 void ShelfLayoutManager::StopAnimating() { | 759 void ShelfLayoutManager::StopAnimating() { |
752 GetLayer(shelf_)->GetAnimator()->StopAnimating(); | 760 GetLayer(shelf_)->GetAnimator()->StopAnimating(); |
753 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); | 761 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); |
754 } | 762 } |
755 | 763 |
756 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { | 764 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { |
757 *width = *height = 0; | 765 *width = *height = 0; |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 | 1166 |
1159 keyboard_bounds_ = new_bounds; | 1167 keyboard_bounds_ = new_bounds; |
1160 OnWindowResized(); | 1168 OnWindowResized(); |
1161 | 1169 |
1162 SessionStateDelegate* session_state_delegate = | 1170 SessionStateDelegate* session_state_delegate = |
1163 Shell::GetInstance()->session_state_delegate(); | 1171 Shell::GetInstance()->session_state_delegate(); |
1164 | 1172 |
1165 // On login screen if keyboard has been just hidden, update bounds just once | 1173 // On login screen if keyboard has been just hidden, update bounds just once |
1166 // but ignore target_bounds.work_area_insets since shelf overlaps with login | 1174 // but ignore target_bounds.work_area_insets since shelf overlaps with login |
1167 // window. | 1175 // window. |
1168 if (!session_state_delegate->IsActiveUserSessionStarted() && | 1176 if (session_state_delegate->IsUserSessionBlocked() && |
1169 keyboard_is_about_to_hide) { | 1177 keyboard_is_about_to_hide) { |
1170 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, gfx::Insets()); | 1178 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, gfx::Insets()); |
1171 } | 1179 } |
1172 } | 1180 } |
1173 | 1181 |
1174 void ShelfLayoutManager::OnDockBoundsChanging( | 1182 void ShelfLayoutManager::OnDockBoundsChanging( |
1175 const gfx::Rect& dock_bounds, | 1183 const gfx::Rect& dock_bounds, |
1176 DockedWindowLayoutManagerObserver::Reason reason) { | 1184 DockedWindowLayoutManagerObserver::Reason reason) { |
1177 // Skip shelf layout in case docked notification originates from this class. | 1185 // Skip shelf layout in case docked notification originates from this class. |
1178 if (reason == DISPLAY_INSETS_CHANGED) | 1186 if (reason == DISPLAY_INSETS_CHANGED) |
(...skipping 14 matching lines...) Expand all Loading... |
1193 // Hide the status area widget (using auto hide animation). | 1201 // Hide the status area widget (using auto hide animation). |
1194 base::AutoReset<ShelfVisibilityState> state(&state_.visibility_state, | 1202 base::AutoReset<ShelfVisibilityState> state(&state_.visibility_state, |
1195 SHELF_HIDDEN); | 1203 SHELF_HIDDEN); |
1196 TargetBounds target_bounds; | 1204 TargetBounds target_bounds; |
1197 CalculateTargetBounds(state_, &target_bounds); | 1205 CalculateTargetBounds(state_, &target_bounds); |
1198 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1206 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
1199 UpdateVisibilityState(); | 1207 UpdateVisibilityState(); |
1200 } | 1208 } |
1201 } | 1209 } |
1202 | 1210 |
| 1211 void ShelfLayoutManager::SessionStateChanged( |
| 1212 SessionStateDelegate::SessionState state) { |
| 1213 TargetBounds target_bounds; |
| 1214 CalculateTargetBounds(state_, &target_bounds); |
| 1215 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
| 1216 UpdateVisibilityState(); |
| 1217 } |
| 1218 |
1203 } // namespace ash | 1219 } // namespace ash |
OLD | NEW |