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

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

Issue 1964633002: Fix mash shelf alignment change layout regression. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ash::Shell::GetInstance()->in_mus() instead. Created 4 years, 7 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 | « ash/shelf/shelf_layout_manager.h ('k') | 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 25 matching lines...) Expand all
36 #include "ash/wm/window_state_aura.h" 36 #include "ash/wm/window_state_aura.h"
37 #include "ash/wm/window_util.h" 37 #include "ash/wm/window_util.h"
38 #include "ash/wm/workspace_controller.h" 38 #include "ash/wm/workspace_controller.h"
39 #include "base/auto_reset.h" 39 #include "base/auto_reset.h"
40 #include "base/command_line.h" 40 #include "base/command_line.h"
41 #include "base/command_line.h" 41 #include "base/command_line.h"
42 #include "base/i18n/rtl.h" 42 #include "base/i18n/rtl.h"
43 #include "base/strings/string_number_conversions.h" 43 #include "base/strings/string_number_conversions.h"
44 #include "base/strings/string_util.h" 44 #include "base/strings/string_util.h"
45 #include "ui/aura/client/cursor_client.h" 45 #include "ui/aura/client/cursor_client.h"
46 #include "ui/aura/mus/mus_util.h"
47 #include "ui/aura/window_event_dispatcher.h" 46 #include "ui/aura/window_event_dispatcher.h"
48 #include "ui/base/ui_base_switches.h" 47 #include "ui/base/ui_base_switches.h"
49 #include "ui/compositor/layer.h" 48 #include "ui/compositor/layer.h"
50 #include "ui/compositor/layer_animation_observer.h" 49 #include "ui/compositor/layer_animation_observer.h"
51 #include "ui/compositor/layer_animator.h" 50 #include "ui/compositor/layer_animator.h"
52 #include "ui/compositor/scoped_layer_animation_settings.h" 51 #include "ui/compositor/scoped_layer_animation_settings.h"
53 #include "ui/display/screen.h" 52 #include "ui/display/screen.h"
54 #include "ui/events/event.h" 53 #include "ui/events/event.h"
55 #include "ui/events/event_handler.h" 54 #include "ui/events/event_handler.h"
56 #include "ui/keyboard/keyboard_util.h" 55 #include "ui/keyboard/keyboard_util.h"
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 513 }
515 } 514 }
516 515
517 void ShelfLayoutManager::OnLockStateChanged(bool locked) { 516 void ShelfLayoutManager::OnLockStateChanged(bool locked) {
518 // Force the shelf to layout for alignment (bottom if locked, restore 517 // Force the shelf to layout for alignment (bottom if locked, restore
519 // the previous alignment otherwise). 518 // the previous alignment otherwise).
520 state_.is_screen_locked = locked; 519 state_.is_screen_locked = locked;
521 UpdateShelfVisibilityAfterLoginUIChange(); 520 UpdateShelfVisibilityAfterLoginUIChange();
522 } 521 }
523 522
523 void ShelfLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) {
524 if (Shell::GetInstance()->in_mus())
525 LayoutShelf();
526 }
527
524 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged( 528 void ShelfLayoutManager::OnShelfAutoHideBehaviorChanged(
525 aura::Window* root_window) { 529 aura::Window* root_window) {
526 UpdateVisibilityState(); 530 UpdateVisibilityState();
527 } 531 }
528 532
529 void ShelfLayoutManager::OnWindowActivated( 533 void ShelfLayoutManager::OnWindowActivated(
530 aura::client::ActivationChangeObserver::ActivationReason reason, 534 aura::client::ActivationChangeObserver::ActivationReason reason,
531 aura::Window* gained_active, 535 aura::Window* gained_active,
532 aura::Window* lost_active) { 536 aura::Window* lost_active) {
533 UpdateAutoHideStateNow(); 537 UpdateAutoHideStateNow();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 } else { 671 } else {
668 StopAnimating(); 672 StopAnimating();
669 shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); 673 shelf_animation_setter.SetTransitionDuration(base::TimeDelta());
670 status_animation_setter.SetTransitionDuration(base::TimeDelta()); 674 status_animation_setter.SetTransitionDuration(base::TimeDelta());
671 } 675 }
672 if (observer) 676 if (observer)
673 status_animation_setter.AddObserver(observer); 677 status_animation_setter.AddObserver(observer);
674 678
675 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); 679 GetLayer(shelf_)->SetOpacity(target_bounds.opacity);
676 // mash::wm::ShelfLayout manages window bounds when running in mash. 680 // mash::wm::ShelfLayout manages window bounds when running in mash.
677 if (!aura::GetMusWindow(shelf_->GetNativeWindow())) { 681 if (!Shell::GetInstance()->in_mus()) {
678 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( 682 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen(
679 shelf_->GetNativeView()->parent(), 683 shelf_->GetNativeView()->parent(),
680 target_bounds.shelf_bounds_in_root)); 684 target_bounds.shelf_bounds_in_root));
681 } 685 }
682 686
683 GetLayer(shelf_->status_area_widget())->SetOpacity( 687 GetLayer(shelf_->status_area_widget())->SetOpacity(
684 target_bounds.status_opacity); 688 target_bounds.status_opacity);
685 689
686 // Having a window which is visible but does not have an opacity is an 690 // Having a window which is visible but does not have an opacity is an
687 // illegal state. We therefore hide the shelf here if required. 691 // illegal state. We therefore hide the shelf here if required.
688 if (!target_bounds.status_opacity) 692 if (!target_bounds.status_opacity)
689 shelf_->status_area_widget()->Hide(); 693 shelf_->status_area_widget()->Hide();
690 // Setting visibility during an animation causes the visibility property to 694 // Setting visibility during an animation causes the visibility property to
691 // animate. Override the animation settings to immediately set the 695 // animate. Override the animation settings to immediately set the
692 // visibility property. Opacity will still animate. 696 // visibility property. Opacity will still animate.
693 697
694 // TODO(harrym): Once status area widget is a child view of shelf 698 // TODO(harrym): Once status area widget is a child view of shelf
695 // this can be simplified. 699 // this can be simplified.
696 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; 700 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
697 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin()); 701 status_bounds.Offset(target_bounds.shelf_bounds_in_root.OffsetFromOrigin());
698 // mash::wm::ShelfLayout manages window bounds when running mash. 702 // mash::wm::ShelfLayout manages window bounds when running mash.
699 if (!aura::GetMusWindow(shelf_->GetNativeWindow())) { 703 if (!Shell::GetInstance()->in_mus()) {
700 shelf_->status_area_widget()->SetBounds( 704 shelf_->status_area_widget()->SetBounds(
701 ScreenUtil::ConvertRectToScreen( 705 ScreenUtil::ConvertRectToScreen(
702 shelf_->status_area_widget()->GetNativeView()->parent(), 706 shelf_->status_area_widget()->GetNativeView()->parent(),
703 status_bounds)); 707 status_bounds));
704 } 708 }
705 if (!state_.is_screen_locked) { 709 if (!state_.is_screen_locked) {
706 gfx::Insets insets; 710 gfx::Insets insets;
707 // If user session is blocked (login to new user session or add user to 711 // If user session is blocked (login to new user session or add user to
708 // the existing session - multi-profile) then give 100% of work area only 712 // the existing session - multi-profile) then give 100% of work area only
709 // if keyboard is not shown. 713 // if keyboard is not shown.
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 UpdateBoundsAndOpacity(target_bounds, true, NULL); 1145 UpdateBoundsAndOpacity(target_bounds, true, NULL);
1142 UpdateVisibilityState(); 1146 UpdateVisibilityState();
1143 } 1147 }
1144 1148
1145 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { 1149 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
1146 UpdateVisibilityState(); 1150 UpdateVisibilityState();
1147 LayoutShelf(); 1151 LayoutShelf();
1148 } 1152 }
1149 1153
1150 } // namespace ash 1154 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698