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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 Shell::GetInstance()->RemoveShellObserver(this); | 204 Shell::GetInstance()->RemoveShellObserver(this); |
205 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); | 205 aura::client::GetActivationClient(root_window_)->RemoveObserver(this); |
206 } | 206 } |
207 | 207 |
208 void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { | 208 void ShelfLayoutManager::SetAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
209 if (auto_hide_behavior_ == behavior) | 209 if (auto_hide_behavior_ == behavior) |
210 return; | 210 return; |
211 auto_hide_behavior_ = behavior; | 211 auto_hide_behavior_ = behavior; |
212 UpdateVisibilityState(); | 212 UpdateVisibilityState(); |
213 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 213 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 214 OnAutoHideStateChanged(state_.auto_hide_state)); |
| 215 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
214 OnAutoHideBehaviorChanged(root_window_, | 216 OnAutoHideBehaviorChanged(root_window_, |
215 auto_hide_behavior_)); | 217 auto_hide_behavior_)); |
216 } | 218 } |
217 | 219 |
218 void ShelfLayoutManager::PrepareForShutdown() { | 220 void ShelfLayoutManager::PrepareForShutdown() { |
219 // Clear all event filters, otherwise sometimes those filters may catch | 221 // Clear all event filters, otherwise sometimes those filters may catch |
220 // synthesized mouse event and cause crashes during the shutdown. | 222 // synthesized mouse event and cause crashes during the shutdown. |
221 set_workspace_controller(NULL); | 223 set_workspace_controller(NULL); |
222 auto_hide_event_filter_.reset(); | 224 auto_hide_event_filter_.reset(); |
223 bezel_event_filter_.reset(); | 225 bezel_event_filter_.reset(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 326 } |
325 } | 327 } |
326 | 328 |
327 void ShelfLayoutManager::UpdateAutoHideState() { | 329 void ShelfLayoutManager::UpdateAutoHideState() { |
328 ShelfAutoHideState auto_hide_state = | 330 ShelfAutoHideState auto_hide_state = |
329 CalculateAutoHideState(state_.visibility_state); | 331 CalculateAutoHideState(state_.visibility_state); |
330 if (auto_hide_state != state_.auto_hide_state) { | 332 if (auto_hide_state != state_.auto_hide_state) { |
331 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { | 333 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
332 // Hides happen immediately. | 334 // Hides happen immediately. |
333 SetState(state_.visibility_state); | 335 SetState(state_.visibility_state); |
| 336 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 337 OnAutoHideStateChanged(auto_hide_state)); |
334 } else { | 338 } else { |
335 auto_hide_timer_.Stop(); | 339 auto_hide_timer_.Stop(); |
336 auto_hide_timer_.Start( | 340 auto_hide_timer_.Start( |
337 FROM_HERE, | 341 FROM_HERE, |
338 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), | 342 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), |
339 this, &ShelfLayoutManager::UpdateAutoHideStateNow); | 343 this, &ShelfLayoutManager::UpdateAutoHideStateNow); |
| 344 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 345 OnAutoHideStateChanged( |
| 346 CalculateAutoHideState(state_.visibility_state))); |
340 } | 347 } |
341 } else { | 348 } else { |
342 auto_hide_timer_.Stop(); | 349 auto_hide_timer_.Stop(); |
343 } | 350 } |
344 } | 351 } |
345 | 352 |
346 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { | 353 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { |
347 window_overlaps_shelf_ = value; | 354 window_overlaps_shelf_ = value; |
348 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); | 355 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); |
349 } | 356 } |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 target_bounds.shelf_bounds_in_root.x()); | 651 target_bounds.shelf_bounds_in_root.x()); |
645 status_bounds.set_y(status_bounds.y() + | 652 status_bounds.set_y(status_bounds.y() + |
646 target_bounds.shelf_bounds_in_root.y()); | 653 target_bounds.shelf_bounds_in_root.y()); |
647 layer->SetBounds(status_bounds); | 654 layer->SetBounds(status_bounds); |
648 layer->SetOpacity(target_bounds.status_opacity); | 655 layer->SetOpacity(target_bounds.status_opacity); |
649 Shell::GetInstance()->SetDisplayWorkAreaInsets( | 656 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
650 root_window_, target_bounds.work_area_insets); | 657 root_window_, target_bounds.work_area_insets); |
651 UpdateHitTestBounds(); | 658 UpdateHitTestBounds(); |
652 if (!delay_shelf_update) | 659 if (!delay_shelf_update) |
653 UpdateShelfBackground(change_type); | 660 UpdateShelfBackground(change_type); |
654 | |
655 // OnAutoHideStateChanged Should be emitted when: | |
656 // - firstly state changed to auto-hide from other state | |
657 // - or, auto_hide_state has changed | |
658 if ((old_state.visibility_state != state_.visibility_state && | |
659 state_.visibility_state == SHELF_AUTO_HIDE) || | |
660 old_state.auto_hide_state != state_.auto_hide_state) { | |
661 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | |
662 OnAutoHideStateChanged(state_.auto_hide_state)); | |
663 } | |
664 } | 661 } |
665 | 662 |
666 void ShelfLayoutManager::StopAnimating() { | 663 void ShelfLayoutManager::StopAnimating() { |
667 GetLayer(shelf_)->GetAnimator()->StopAnimating(); | 664 GetLayer(shelf_)->GetAnimator()->StopAnimating(); |
668 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); | 665 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); |
669 } | 666 } |
670 | 667 |
671 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { | 668 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { |
672 *width = *height = 0; | 669 *width = *height = 0; |
673 gfx::Size status_size( | 670 gfx::Size status_size( |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 return gfx::Insets(0, distance, 0, 0); | 1017 return gfx::Insets(0, distance, 0, 0); |
1021 case SHELF_ALIGNMENT_TOP: | 1018 case SHELF_ALIGNMENT_TOP: |
1022 return gfx::Insets(0, 0, distance, 0); | 1019 return gfx::Insets(0, 0, distance, 0); |
1023 } | 1020 } |
1024 NOTREACHED(); | 1021 NOTREACHED(); |
1025 return gfx::Insets(); | 1022 return gfx::Insets(); |
1026 } | 1023 } |
1027 | 1024 |
1028 } // namespace internal | 1025 } // namespace internal |
1029 } // namespace ash | 1026 } // namespace ash |
OLD | NEW |