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

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

Issue 2015043002: mash: Convert shelf to wm::WmWindow types, part 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unused include 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_widget.h ('k') | ash/shell.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
10 #include "ash/session/session_state_delegate.h" 9 #include "ash/session/session_state_delegate.h"
11 #include "ash/shelf/shelf_constants.h" 10 #include "ash/shelf/shelf_constants.h"
12 #include "ash/shelf/shelf_delegate.h" 11 #include "ash/shelf/shelf_delegate.h"
13 #include "ash/shelf/shelf_layout_manager.h" 12 #include "ash/shelf/shelf_layout_manager.h"
14 #include "ash/shelf/shelf_model.h" 13 #include "ash/shelf/shelf_model.h"
15 #include "ash/shelf/shelf_navigator.h" 14 #include "ash/shelf/shelf_navigator.h"
16 #include "ash/shelf/shelf_util.h" 15 #include "ash/shelf/shelf_util.h"
17 #include "ash/shelf/shelf_view.h" 16 #include "ash/shelf/shelf_view.h"
18 #include "ash/shelf/shelf_widget.h" 17 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell.h" 18 #include "ash/shell.h"
20 #include "ash/shell_window_ids.h" 19 #include "ash/shell_window_ids.h"
21 #include "ash/system/tray/system_tray_delegate.h" 20 #include "ash/system/tray/system_tray_delegate.h"
21 #include "ash/wm/aura/wm_window_aura.h"
22 #include "ash/wm/common/shelf/wm_shelf_constants.h" 22 #include "ash/wm/common/shelf/wm_shelf_constants.h"
23 #include "ash/wm/common/shelf/wm_shelf_util.h" 23 #include "ash/wm/common/shelf/wm_shelf_util.h"
24 #include "ash/wm/common/wm_root_window_controller.h"
24 #include "ash/wm/status_area_layout_manager.h" 25 #include "ash/wm/status_area_layout_manager.h"
25 #include "ash/wm/window_properties.h" 26 #include "ash/wm/window_properties.h"
26 #include "ash/wm/workspace_controller.h" 27 #include "ash/wm/workspace_controller.h"
27 #include "grit/ash_resources.h" 28 #include "grit/ash_resources.h"
28 #include "grit/ash_wm_common_resources.h" 29 #include "grit/ash_wm_common_resources.h"
29 #include "ui/aura/window.h" 30 #include "ui/aura/window.h"
30 #include "ui/aura/window_event_dispatcher.h" 31 #include "ui/aura/window_event_dispatcher.h"
31 #include "ui/aura/window_observer.h" 32 #include "ui/aura/window_observer.h"
32 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
33 #include "ui/compositor/layer.h" 34 #include "ui/compositor/layer.h"
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 if (GetDimmed()) 551 if (GetDimmed())
551 return dimmer_view_->GetBoundsInScreen(); 552 return dimmer_view_->GetBoundsInScreen();
552 return gfx::Rect(); 553 return gfx::Rect();
553 } 554 }
554 555
555 void ShelfWidget::DelegateView::UpdateBackground(int alpha) { 556 void ShelfWidget::DelegateView::UpdateBackground(int alpha) {
556 alpha_ = alpha; 557 alpha_ = alpha;
557 SchedulePaint(); 558 SchedulePaint();
558 } 559 }
559 560
560 ShelfWidget::ShelfWidget(aura::Window* shelf_container, 561 ShelfWidget::ShelfWidget(wm::WmWindow* wm_shelf_container,
561 aura::Window* status_container, 562 wm::WmWindow* wm_status_container,
562 WorkspaceController* workspace_controller) 563 WorkspaceController* workspace_controller)
563 : delegate_view_(new DelegateView(this)), 564 : delegate_view_(new DelegateView(this)),
564 background_animator_(delegate_view_, 0, wm::kShelfBackgroundAlpha), 565 background_animator_(delegate_view_, 0, wm::kShelfBackgroundAlpha),
565 activating_as_fallback_(false), 566 activating_as_fallback_(false) {
566 window_container_(shelf_container) {
567 views::Widget::InitParams params( 567 views::Widget::InitParams params(
568 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 568 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
569 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 569 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
570 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 570 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
571 params.parent = shelf_container;
572 params.delegate = delegate_view_; 571 params.delegate = delegate_view_;
572 wm_shelf_container->GetRootWindowController()
573 ->ConfigureWidgetInitParamsForContainer(
574 this, wm_shelf_container->GetShellWindowId(), &params);
573 Init(params); 575 Init(params);
574 576
575 // The shelf should not take focus when initially shown. 577 // The shelf should not take focus when initially shown.
576 set_focus_on_creation(false); 578 set_focus_on_creation(false);
577 SetContentsView(delegate_view_); 579 SetContentsView(delegate_view_);
578 delegate_view_->SetParentLayer(GetLayer()); 580 delegate_view_->SetParentLayer(GetLayer());
579 581
580 shelf_layout_manager_ = new ShelfLayoutManager(this); 582 shelf_layout_manager_ = new ShelfLayoutManager(this);
581 shelf_layout_manager_->AddObserver(this); 583 shelf_layout_manager_->AddObserver(this);
584 aura::Window* shelf_container =
585 wm::WmWindowAura::GetAuraWindow(wm_shelf_container);
582 shelf_container->SetLayoutManager(shelf_layout_manager_); 586 shelf_container->SetLayoutManager(shelf_layout_manager_);
583 shelf_layout_manager_->set_workspace_controller(workspace_controller); 587 shelf_layout_manager_->set_workspace_controller(workspace_controller);
584 workspace_controller->SetShelf(shelf_layout_manager_); 588 workspace_controller->SetShelf(shelf_layout_manager_);
585 589
586 status_area_widget_ = new StatusAreaWidget(status_container, this); 590 status_area_widget_ = new StatusAreaWidget(wm_status_container, this);
587 status_area_widget_->CreateTrayViews(); 591 status_area_widget_->CreateTrayViews();
588 if (Shell::GetInstance()->session_state_delegate()-> 592 if (Shell::GetInstance()->session_state_delegate()->
589 IsActiveUserSessionStarted()) { 593 IsActiveUserSessionStarted()) {
590 status_area_widget_->Show(); 594 status_area_widget_->Show();
591 } 595 }
592 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); 596 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_);
593 597
598 aura::Window* status_container =
599 wm::WmWindowAura::GetAuraWindow(wm_status_container);
594 status_container->SetLayoutManager( 600 status_container->SetLayoutManager(
595 new StatusAreaLayoutManager(status_container, this)); 601 new StatusAreaLayoutManager(status_container, this));
596 602
597 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( 603 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
598 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); 604 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_)));
599 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( 605 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>(
600 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); 606 new ShelfWindowTargeter(status_container, shelf_layout_manager_)));
601 607
602 views::Widget::AddObserver(this); 608 views::Widget::AddObserver(this);
603 } 609 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 if (shelf_) 713 if (shelf_)
708 shelf_->SchedulePaint(); 714 shelf_->SchedulePaint();
709 status_area_widget_->SchedulePaint(); 715 status_area_widget_->SchedulePaint();
710 } 716 }
711 717
712 bool ShelfWidget::GetDimsShelf() const { 718 bool ShelfWidget::GetDimsShelf() const {
713 return delegate_view_->GetDimmed(); 719 return delegate_view_->GetDimmed();
714 } 720 }
715 721
716 void ShelfWidget::CreateShelf() { 722 void ShelfWidget::CreateShelf() {
717 if (shelf_) 723 DCHECK(!shelf_);
718 return;
719 724
720 Shell* shell = Shell::GetInstance(); 725 Shell* shell = Shell::GetInstance();
721 ShelfDelegate* delegate = shell->GetShelfDelegate(); 726 ShelfDelegate* delegate = shell->GetShelfDelegate();
722 shelf_.reset(new Shelf(shell->shelf_model(), delegate, this)); 727 shelf_.reset(new Shelf(shell->shelf_model(), delegate, this));
723 delegate->OnShelfCreated(shelf_.get()); 728 delegate->OnShelfCreated(shelf_.get());
724 729
725 SetFocusCycler(shell->focus_cycler()); 730 SetFocusCycler(shell->focus_cycler());
731 }
726 732
727 // Inform the root window controller. 733 void ShelfWidget::PostCreateShelf() {
James Cook 2016/05/26 22:16:56 This method is unfortunate, but I need it to prese
728 RootWindowController::ForWindow(window_container_)->OnShelfCreated(); 734 shelf_->SetVisible(Shell::GetInstance()
729 735 ->session_state_delegate()
730 shelf_->SetVisible( 736 ->IsActiveUserSessionStarted());
731 shell->session_state_delegate()->IsActiveUserSessionStarted());
732 shelf_layout_manager_->LayoutShelf(); 737 shelf_layout_manager_->LayoutShelf();
733 shelf_layout_manager_->UpdateAutoHideState(); 738 shelf_layout_manager_->UpdateAutoHideState();
734 Show(); 739 Show();
735 } 740 }
736 741
737 bool ShelfWidget::IsShelfVisible() const { 742 bool ShelfWidget::IsShelfVisible() const {
738 return shelf_.get() && shelf_->IsVisible(); 743 return shelf_.get() && shelf_->IsVisible();
739 } 744 }
740 745
741 void ShelfWidget::SetShelfVisibility(bool visible) { 746 void ShelfWidget::SetShelfVisibility(bool visible) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event); 814 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event);
810 } 815 }
811 816
812 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) { 817 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) {
813 Widget::OnGestureEvent(event); 818 Widget::OnGestureEvent(event);
814 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) 819 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_)
815 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event); 820 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event);
816 } 821 }
817 822
818 } // namespace ash 823 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_widget.h ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698