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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 20056003: Moves calling OnAutoHideState to when exactly the state has changed (2nd) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_,
216 OnAutoHideBehaviorChanged(root_window_, 214 OnAutoHideBehaviorChanged(root_window_,
217 auto_hide_behavior_)); 215 auto_hide_behavior_));
218 } 216 }
219 217
220 void ShelfLayoutManager::PrepareForShutdown() { 218 void ShelfLayoutManager::PrepareForShutdown() {
221 // Clear all event filters, otherwise sometimes those filters may catch 219 // Clear all event filters, otherwise sometimes those filters may catch
222 // synthesized mouse event and cause crashes during the shutdown. 220 // synthesized mouse event and cause crashes during the shutdown.
223 set_workspace_controller(NULL); 221 set_workspace_controller(NULL);
224 auto_hide_event_filter_.reset(); 222 auto_hide_event_filter_.reset();
225 bezel_event_filter_.reset(); 223 bezel_event_filter_.reset();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 324 }
327 } 325 }
328 326
329 void ShelfLayoutManager::UpdateAutoHideState() { 327 void ShelfLayoutManager::UpdateAutoHideState() {
330 ShelfAutoHideState auto_hide_state = 328 ShelfAutoHideState auto_hide_state =
331 CalculateAutoHideState(state_.visibility_state); 329 CalculateAutoHideState(state_.visibility_state);
332 if (auto_hide_state != state_.auto_hide_state) { 330 if (auto_hide_state != state_.auto_hide_state) {
333 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { 331 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) {
334 // Hides happen immediately. 332 // Hides happen immediately.
335 SetState(state_.visibility_state); 333 SetState(state_.visibility_state);
336 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
337 OnAutoHideStateChanged(auto_hide_state));
338 } else { 334 } else {
339 auto_hide_timer_.Stop(); 335 auto_hide_timer_.Stop();
340 auto_hide_timer_.Start( 336 auto_hide_timer_.Start(
341 FROM_HERE, 337 FROM_HERE,
342 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), 338 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS),
343 this, &ShelfLayoutManager::UpdateAutoHideStateNow); 339 this, &ShelfLayoutManager::UpdateAutoHideStateNow);
344 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
345 OnAutoHideStateChanged(
346 CalculateAutoHideState(state_.visibility_state)));
347 } 340 }
348 } else { 341 } else {
349 auto_hide_timer_.Stop(); 342 auto_hide_timer_.Stop();
350 } 343 }
351 } 344 }
352 345
353 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) { 346 void ShelfLayoutManager::SetWindowOverlapsShelf(bool value) {
354 window_overlaps_shelf_ = value; 347 window_overlaps_shelf_ = value;
355 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); 348 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE);
356 } 349 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 target_bounds.shelf_bounds_in_root.x()); 644 target_bounds.shelf_bounds_in_root.x());
652 status_bounds.set_y(status_bounds.y() + 645 status_bounds.set_y(status_bounds.y() +
653 target_bounds.shelf_bounds_in_root.y()); 646 target_bounds.shelf_bounds_in_root.y());
654 layer->SetBounds(status_bounds); 647 layer->SetBounds(status_bounds);
655 layer->SetOpacity(target_bounds.status_opacity); 648 layer->SetOpacity(target_bounds.status_opacity);
656 Shell::GetInstance()->SetDisplayWorkAreaInsets( 649 Shell::GetInstance()->SetDisplayWorkAreaInsets(
657 root_window_, target_bounds.work_area_insets); 650 root_window_, target_bounds.work_area_insets);
658 UpdateHitTestBounds(); 651 UpdateHitTestBounds();
659 if (!delay_shelf_update) 652 if (!delay_shelf_update)
660 UpdateShelfBackground(change_type); 653 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 }
661 } 664 }
662 665
663 void ShelfLayoutManager::StopAnimating() { 666 void ShelfLayoutManager::StopAnimating() {
664 GetLayer(shelf_)->GetAnimator()->StopAnimating(); 667 GetLayer(shelf_)->GetAnimator()->StopAnimating();
665 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); 668 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating();
666 } 669 }
667 670
668 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { 671 void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
669 *width = *height = 0; 672 *width = *height = 0;
670 gfx::Size status_size( 673 gfx::Size status_size(
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 return gfx::Insets(0, distance, 0, 0); 1020 return gfx::Insets(0, distance, 0, 0);
1018 case SHELF_ALIGNMENT_TOP: 1021 case SHELF_ALIGNMENT_TOP:
1019 return gfx::Insets(0, 0, distance, 0); 1022 return gfx::Insets(0, 0, distance, 0);
1020 } 1023 }
1021 NOTREACHED(); 1024 NOTREACHED();
1022 return gfx::Insets(); 1025 return gfx::Insets();
1023 } 1026 }
1024 1027
1025 } // namespace internal 1028 } // namespace internal
1026 } // namespace ash 1029 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698