| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 gfx::Insets GetInsetsForAlignment(int distance, | 258 gfx::Insets GetInsetsForAlignment(int distance, |
| 259 wm::ShelfAlignment alignment) { | 259 wm::ShelfAlignment alignment) { |
| 260 if (alignment == wm::SHELF_ALIGNMENT_LEFT) | 260 if (alignment == wm::SHELF_ALIGNMENT_LEFT) |
| 261 return gfx::Insets(0, 0, 0, distance); | 261 return gfx::Insets(0, 0, 0, distance); |
| 262 if (alignment == wm::SHELF_ALIGNMENT_RIGHT) | 262 if (alignment == wm::SHELF_ALIGNMENT_RIGHT) |
| 263 return gfx::Insets(0, distance, 0, 0); | 263 return gfx::Insets(0, distance, 0, 0); |
| 264 return gfx::Insets(distance, 0, 0, 0); | 264 return gfx::Insets(distance, 0, 0, 0); |
| 265 } | 265 } |
| 266 | 266 |
| 267 // ShelfLayoutManagerObserver: | 267 // ShelfLayoutManagerObserver: |
| 268 void WillDeleteShelf() override { | 268 void WillDeleteShelfLayoutManager() override { |
| 269 shelf_->RemoveObserver(this); | 269 shelf_->RemoveObserver(this); |
| 270 shelf_ = NULL; | 270 shelf_ = NULL; |
| 271 } | 271 } |
| 272 | 272 |
| 273 void WillChangeVisibilityState(ShelfVisibilityState new_state) override { | 273 void WillChangeVisibilityState(ShelfVisibilityState new_state) override { |
| 274 gfx::Insets mouse_insets; | 274 gfx::Insets mouse_insets; |
| 275 gfx::Insets touch_insets; | 275 gfx::Insets touch_insets; |
| 276 if (new_state == SHELF_VISIBLE) { | 276 if (new_state == SHELF_VISIBLE) { |
| 277 // Let clicks at the very top of the shelf through so windows can be | 277 // Let clicks at the very top of the shelf through so windows can be |
| 278 // resized with the bottom-right corner and bottom edge. | 278 // resized with the bottom-right corner and bottom edge. |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 | 596 |
| 597 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 597 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 598 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); | 598 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); |
| 599 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 599 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 600 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); | 600 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); |
| 601 | 601 |
| 602 views::Widget::AddObserver(this); | 602 views::Widget::AddObserver(this); |
| 603 } | 603 } |
| 604 | 604 |
| 605 ShelfWidget::~ShelfWidget() { | 605 ShelfWidget::~ShelfWidget() { |
| 606 // Must call Shutdown() before destruction. |
| 607 DCHECK(!status_area_widget_); |
| 606 Shell::GetInstance()->focus_cycler()->RemoveWidget(this); | 608 Shell::GetInstance()->focus_cycler()->RemoveWidget(this); |
| 607 SetFocusCycler(nullptr); | 609 SetFocusCycler(nullptr); |
| 608 RemoveObserver(this); | 610 RemoveObserver(this); |
| 609 } | 611 } |
| 610 | 612 |
| 611 void ShelfWidget::SetPaintsBackground( | 613 void ShelfWidget::SetPaintsBackground( |
| 612 wm::ShelfBackgroundType background_type, | 614 wm::ShelfBackgroundType background_type, |
| 613 BackgroundAnimatorChangeType change_type) { | 615 BackgroundAnimatorChangeType change_type) { |
| 614 ui::Layer* opaque_background = delegate_view_->opaque_background(); | 616 ui::Layer* opaque_background = delegate_view_->opaque_background(); |
| 615 float target_opacity = | 617 float target_opacity = |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 void ShelfWidget::SetFocusCycler(FocusCycler* focus_cycler) { | 746 void ShelfWidget::SetFocusCycler(FocusCycler* focus_cycler) { |
| 745 delegate_view_->set_focus_cycler(focus_cycler); | 747 delegate_view_->set_focus_cycler(focus_cycler); |
| 746 if (focus_cycler) | 748 if (focus_cycler) |
| 747 focus_cycler->AddWidget(this); | 749 focus_cycler->AddWidget(this); |
| 748 } | 750 } |
| 749 | 751 |
| 750 FocusCycler* ShelfWidget::GetFocusCycler() { | 752 FocusCycler* ShelfWidget::GetFocusCycler() { |
| 751 return delegate_view_->focus_cycler(); | 753 return delegate_view_->focus_cycler(); |
| 752 } | 754 } |
| 753 | 755 |
| 754 void ShelfWidget::ShutdownStatusAreaWidget() { | 756 void ShelfWidget::Shutdown() { |
| 757 // Shutting down the status area widget may cause some widgets (e.g. bubbles) |
| 758 // to close, so uninstall the ShelfLayoutManager event filters first. Don't |
| 759 // reset the pointer until later because other widgets (e.g. app list) may |
| 760 // access it later in shutdown. |
| 761 if (shelf_layout_manager_) |
| 762 shelf_layout_manager_->PrepareForShutdown(); |
| 763 |
| 755 if (status_area_widget_) { | 764 if (status_area_widget_) { |
| 756 Shell::GetInstance()->focus_cycler()->RemoveWidget(status_area_widget_); | 765 Shell::GetInstance()->focus_cycler()->RemoveWidget(status_area_widget_); |
| 757 status_area_widget_->Shutdown(); | 766 status_area_widget_->Shutdown(); |
| 767 status_area_widget_ = nullptr; |
| 758 } | 768 } |
| 759 status_area_widget_ = NULL; | |
| 760 } | 769 } |
| 761 | 770 |
| 762 void ShelfWidget::ForceUndimming(bool force) { | 771 void ShelfWidget::ForceUndimming(bool force) { |
| 763 delegate_view_->ForceUndimming(force); | 772 delegate_view_->ForceUndimming(force); |
| 764 } | 773 } |
| 765 | 774 |
| 766 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, | 775 void ShelfWidget::OnWidgetActivationChanged(views::Widget* widget, |
| 767 bool active) { | 776 bool active) { |
| 768 activating_as_fallback_ = false; | 777 activating_as_fallback_ = false; |
| 769 if (active) | 778 if (active) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 782 if (delegate_view_) | 791 if (delegate_view_) |
| 783 return delegate_view_->GetDimmerBoundsForTest(); | 792 return delegate_view_->GetDimmerBoundsForTest(); |
| 784 return gfx::Rect(); | 793 return gfx::Rect(); |
| 785 } | 794 } |
| 786 | 795 |
| 787 void ShelfWidget::DisableDimmingAnimationsForTest() { | 796 void ShelfWidget::DisableDimmingAnimationsForTest() { |
| 788 DCHECK(delegate_view_); | 797 DCHECK(delegate_view_); |
| 789 return delegate_view_->disable_dimming_animations_for_test(); | 798 return delegate_view_->disable_dimming_animations_for_test(); |
| 790 } | 799 } |
| 791 | 800 |
| 792 void ShelfWidget::WillDeleteShelf() { | 801 void ShelfWidget::WillDeleteShelfLayoutManager() { |
| 793 shelf_layout_manager_->RemoveObserver(this); | 802 shelf_layout_manager_->RemoveObserver(this); |
| 794 shelf_layout_manager_ = NULL; | 803 shelf_layout_manager_ = NULL; |
| 795 } | 804 } |
| 796 | 805 |
| 797 } // namespace ash | 806 } // namespace ash |
| OLD | NEW |