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

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

Issue 175473003: Fixed incorrect resize of docked windows when locking screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
« 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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (!updating_bounds_ && 549 if (!updating_bounds_ &&
550 ((shelf_->GetNativeView() == child) || 550 ((shelf_->GetNativeView() == child) ||
551 (shelf_->status_area_widget()->GetNativeView() == child))) { 551 (shelf_->status_area_widget()->GetNativeView() == child))) {
552 LayoutShelf(); 552 LayoutShelf();
553 } 553 }
554 } 554 }
555 555
556 void ShelfLayoutManager::OnLockStateChanged(bool locked) { 556 void ShelfLayoutManager::OnLockStateChanged(bool locked) {
557 // Force the shelf to layout for alignment (bottom if locked, restore 557 // Force the shelf to layout for alignment (bottom if locked, restore
558 // the previous alignment otherwise). 558 // the previous alignment otherwise).
559 state_.is_screen_locked = locked;
559 shelf_->SetAlignment(locked ? SHELF_ALIGNMENT_BOTTOM : alignment_); 560 shelf_->SetAlignment(locked ? SHELF_ALIGNMENT_BOTTOM : alignment_);
560 UpdateVisibilityState(); 561 UpdateVisibilityState();
561 LayoutShelf(); 562 LayoutShelf();
562 } 563 }
563 564
564 void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active, 565 void ShelfLayoutManager::OnWindowActivated(aura::Window* gained_active,
565 aura::Window* lost_active) { 566 aura::Window* lost_active) {
566 UpdateAutoHideStateNow(); 567 UpdateAutoHideStateNow();
567 } 568 }
568 569
(...skipping 14 matching lines...) Expand all
583 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {} 584 ShelfLayoutManager::TargetBounds::TargetBounds() : opacity(0.0f) {}
584 ShelfLayoutManager::TargetBounds::~TargetBounds() {} 585 ShelfLayoutManager::TargetBounds::~TargetBounds() {}
585 586
586 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { 587 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
587 if (!shelf_->GetNativeView()) 588 if (!shelf_->GetNativeView())
588 return; 589 return;
589 590
590 State state; 591 State state;
591 state.visibility_state = visibility_state; 592 state.visibility_state = visibility_state;
592 state.auto_hide_state = CalculateAutoHideState(visibility_state); 593 state.auto_hide_state = CalculateAutoHideState(visibility_state);
593 state.is_screen_locked =
594 Shell::GetInstance()->session_state_delegate()->IsScreenLocked();
595 state.window_state = workspace_controller_ ? 594 state.window_state = workspace_controller_ ?
596 workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT; 595 workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT;
597 596
598 // Force an update because gesture drags affect the shelf bounds and we 597 // Force an update because gesture drags affect the shelf bounds and we
599 // should animate back to the normal bounds at the end of a gesture. 598 // should animate back to the normal bounds at the end of a gesture.
600 bool force_update = 599 bool force_update =
601 (gesture_drag_status_ == GESTURE_DRAG_CANCEL_IN_PROGRESS || 600 (gesture_drag_status_ == GESTURE_DRAG_CANCEL_IN_PROGRESS ||
602 gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS); 601 gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS);
603 602
604 if (!force_update && state_.Equals(state)) 603 if (!force_update && state_.Equals(state))
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 // this can be simplified. 713 // this can be simplified.
715 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; 714 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
716 status_bounds.set_x(status_bounds.x() + 715 status_bounds.set_x(status_bounds.x() +
717 target_bounds.shelf_bounds_in_root.x()); 716 target_bounds.shelf_bounds_in_root.x());
718 status_bounds.set_y(status_bounds.y() + 717 status_bounds.set_y(status_bounds.y() +
719 target_bounds.shelf_bounds_in_root.y()); 718 target_bounds.shelf_bounds_in_root.y());
720 shelf_->status_area_widget()->SetBounds( 719 shelf_->status_area_widget()->SetBounds(
721 ScreenUtil::ConvertRectToScreen( 720 ScreenUtil::ConvertRectToScreen(
722 shelf_->status_area_widget()->GetNativeView()->parent(), 721 shelf_->status_area_widget()->GetNativeView()->parent(),
723 status_bounds)); 722 status_bounds));
724 Shell::GetInstance()->SetDisplayWorkAreaInsets( 723 if (!state_.is_screen_locked) {
725 root_window_, target_bounds.work_area_insets); 724 Shell::GetInstance()->SetDisplayWorkAreaInsets(
725 root_window_, target_bounds.work_area_insets);
726 }
726 } 727 }
727 728
728 void ShelfLayoutManager::StopAnimating() { 729 void ShelfLayoutManager::StopAnimating() {
729 GetLayer(shelf_)->GetAnimator()->StopAnimating(); 730 GetLayer(shelf_)->GetAnimator()->StopAnimating();
730 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); 731 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating();
731 } 732 }
732 733
733 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { 734 void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
734 *width = *height = 0; 735 *width = *height = 0;
735 gfx::Size status_size( 736 gfx::Size status_size(
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 if (dock_bounds_ != dock_bounds) { 1141 if (dock_bounds_ != dock_bounds) {
1141 dock_bounds_ = dock_bounds; 1142 dock_bounds_ = dock_bounds;
1142 OnWindowResized(); 1143 OnWindowResized();
1143 UpdateVisibilityState(); 1144 UpdateVisibilityState();
1144 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE); 1145 UpdateShelfBackground(BACKGROUND_CHANGE_ANIMATE);
1145 } 1146 }
1146 } 1147 }
1147 1148
1148 void ShelfLayoutManager::OnLockStateEvent(LockStateObserver::EventType event) { 1149 void ShelfLayoutManager::OnLockStateEvent(LockStateObserver::EventType event) {
1149 if (event == EVENT_LOCK_ANIMATION_STARTED) { 1150 if (event == EVENT_LOCK_ANIMATION_STARTED) {
1151 // Enter the screen locked state as the animation starts to prevent
1152 // layout changes as the screen locks.
1153 state_.is_screen_locked = true;
1150 // Hide the status area widget (using auto hide animation). 1154 // Hide the status area widget (using auto hide animation).
1151 base::AutoReset<ShelfVisibilityState> state(&state_.visibility_state, 1155 base::AutoReset<ShelfVisibilityState> state(&state_.visibility_state,
1152 SHELF_HIDDEN); 1156 SHELF_HIDDEN);
1153 TargetBounds target_bounds; 1157 TargetBounds target_bounds;
1154 CalculateTargetBounds(state_, &target_bounds); 1158 CalculateTargetBounds(state_, &target_bounds);
1155 UpdateBoundsAndOpacity(target_bounds, true, NULL); 1159 UpdateBoundsAndOpacity(target_bounds, true, NULL);
1156 UpdateVisibilityState(); 1160 UpdateVisibilityState();
1157 } 1161 }
1158 } 1162 }
1159 1163
1160 gfx::Insets ShelfLayoutManager::GetInsetsForAlignment(int distance) const { 1164 gfx::Insets ShelfLayoutManager::GetInsetsForAlignment(int distance) const {
1161 switch (GetAlignment()) { 1165 switch (GetAlignment()) {
1162 case SHELF_ALIGNMENT_BOTTOM: 1166 case SHELF_ALIGNMENT_BOTTOM:
1163 return gfx::Insets(distance, 0, 0, 0); 1167 return gfx::Insets(distance, 0, 0, 0);
1164 case SHELF_ALIGNMENT_LEFT: 1168 case SHELF_ALIGNMENT_LEFT:
1165 return gfx::Insets(0, 0, 0, distance); 1169 return gfx::Insets(0, 0, 0, distance);
1166 case SHELF_ALIGNMENT_RIGHT: 1170 case SHELF_ALIGNMENT_RIGHT:
1167 return gfx::Insets(0, distance, 0, 0); 1171 return gfx::Insets(0, distance, 0, 0);
1168 case SHELF_ALIGNMENT_TOP: 1172 case SHELF_ALIGNMENT_TOP:
1169 return gfx::Insets(0, 0, distance, 0); 1173 return gfx::Insets(0, 0, distance, 0);
1170 } 1174 }
1171 NOTREACHED(); 1175 NOTREACHED();
1172 return gfx::Insets(); 1176 return gfx::Insets();
1173 } 1177 }
1174 1178
1175 } // namespace internal 1179 } // namespace internal
1176 } // namespace ash 1180 } // 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