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

Side by Side Diff: ash/wm/dock/docked_window_layout_manager.cc

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 years, 9 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/wm/app_list_controller.cc ('k') | ash/wm/panels/panel_layout_manager.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/wm/dock/docked_window_layout_manager.h" 5 #include "ash/wm/dock/docked_window_layout_manager.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/shelf/shelf.h" 8 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_constants.h" 9 #include "ash/shelf/shelf_constants.h"
10 #include "ash/shelf/shelf_layout_manager.h" 10 #include "ash/shelf/shelf_layout_manager.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 418 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
419 AddObserver(this); 419 AddObserver(this);
420 Shell::GetInstance()->AddShellObserver(this); 420 Shell::GetInstance()->AddShellObserver(this);
421 } 421 }
422 422
423 DockedWindowLayoutManager::~DockedWindowLayoutManager() { 423 DockedWindowLayoutManager::~DockedWindowLayoutManager() {
424 Shutdown(); 424 Shutdown();
425 } 425 }
426 426
427 void DockedWindowLayoutManager::Shutdown() { 427 void DockedWindowLayoutManager::Shutdown() {
428 if (shelf_ && shelf_->shelf_widget()) { 428 if (shelf_ && shelf_->shelf_layout_manager()) {
429 ShelfLayoutManager* shelf_layout_manager = 429 shelf_->shelf_layout_manager()->RemoveObserver(this);
430 shelf_->shelf_widget()->shelf_layout_manager();
431 shelf_layout_manager->RemoveObserver(this);
432 shelf_observer_.reset(); 430 shelf_observer_.reset();
433 } 431 }
434 shelf_ = NULL; 432 shelf_ = NULL;
435 for (size_t i = 0; i < dock_container_->children().size(); ++i) { 433 for (size_t i = 0; i < dock_container_->children().size(); ++i) {
436 aura::Window* child = dock_container_->children()[i]; 434 aura::Window* child = dock_container_->children()[i];
437 child->RemoveObserver(this); 435 child->RemoveObserver(this);
438 wm::GetWindowState(child)->RemoveObserver(this); 436 wm::GetWindowState(child)->RemoveObserver(this);
439 } 437 }
440 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> 438 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())->
441 RemoveObserver(this); 439 RemoveObserver(this);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 dragged_window_ = NULL; 530 dragged_window_ = NULL;
533 dragged_bounds_ = gfx::Rect(); 531 dragged_bounds_ = gfx::Rect();
534 Relayout(); 532 Relayout();
535 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 533 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
536 RecordUmaAction(action, source); 534 RecordUmaAction(action, source);
537 } 535 }
538 536
539 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { 537 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) {
540 DCHECK(!shelf_); 538 DCHECK(!shelf_);
541 shelf_ = shelf; 539 shelf_ = shelf;
542 if (shelf_->shelf_widget()) { 540 if (shelf_->shelf_layout_manager()) {
543 ShelfLayoutManager* shelf_layout_manager = 541 shelf_->shelf_layout_manager()->AddObserver(this);
544 shelf_->shelf_widget()->shelf_layout_manager();
545 shelf_layout_manager->AddObserver(this);
546 shelf_observer_.reset(new ShelfWindowObserver(this)); 542 shelf_observer_.reset(new ShelfWindowObserver(this));
547 } 543 }
548 } 544 }
549 545
550 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( 546 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow(
551 const aura::Window* window) const { 547 const aura::Window* window) const {
552 const gfx::Rect& bounds(window->GetBoundsInScreen()); 548 const gfx::Rect& bounds(window->GetBoundsInScreen());
553 549
554 // Test overlap with an existing docked area first. 550 // Test overlap with an existing docked area first.
555 if (docked_bounds_.Intersects(bounds) && 551 if (docked_bounds_.Intersects(bounds) &&
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 std::max(min_size.width(), actual_new_bounds.width())); 744 std::max(min_size.width(), actual_new_bounds.width()));
749 actual_new_bounds.set_height( 745 actual_new_bounds.set_height(
750 std::max(min_size.height(), actual_new_bounds.height())); 746 std::max(min_size.height(), actual_new_bounds.height()));
751 } 747 }
752 if (IsWindowDocked(child) && child != dragged_window_) 748 if (IsWindowDocked(child) && child != dragged_window_)
753 return; 749 return;
754 SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds); 750 SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds);
755 if (IsPopupOrTransient(child)) 751 if (IsPopupOrTransient(child))
756 return; 752 return;
757 // Whenever one of our windows is moved or resized enforce layout. 753 // Whenever one of our windows is moved or resized enforce layout.
758 ShelfLayoutManager* shelf_layout = 754 ShelfLayoutManager* shelf_layout = shelf_->shelf_layout_manager();
759 shelf_->shelf_widget()->shelf_layout_manager();
760 if (shelf_layout) 755 if (shelf_layout)
761 shelf_layout->UpdateVisibilityState(); 756 shelf_layout->UpdateVisibilityState();
762 } 757 }
763 758
764 //////////////////////////////////////////////////////////////////////////////// 759 ////////////////////////////////////////////////////////////////////////////////
765 // DockedWindowLayoutManager, ash::ShellObserver implementation: 760 // DockedWindowLayoutManager, ash::ShellObserver implementation:
766 761
767 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { 762 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() {
768 Relayout(); 763 Relayout();
769 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); 764 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED);
(...skipping 30 matching lines...) Expand all
800 } 795 }
801 Relayout(); 796 Relayout();
802 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); 797 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED);
803 } 798 }
804 799
805 void DockedWindowLayoutManager::OnShelfAlignmentChanged( 800 void DockedWindowLayoutManager::OnShelfAlignmentChanged(
806 aura::Window* root_window) { 801 aura::Window* root_window) {
807 if (dock_container_->GetRootWindow() != root_window) 802 if (dock_container_->GetRootWindow() != root_window)
808 return; 803 return;
809 804
810 if (!shelf_ || !shelf_->shelf_widget()) 805 if (!shelf_ || alignment_ == DOCKED_ALIGNMENT_NONE)
811 return;
812
813 if (alignment_ == DOCKED_ALIGNMENT_NONE)
814 return; 806 return;
815 807
816 // Do not allow shelf and dock on the same side. Switch side that 808 // Do not allow shelf and dock on the same side. Switch side that
817 // the dock is attached to and move all dock windows to that new side. 809 // the dock is attached to and move all dock windows to that new side.
818 ShelfAlignment shelf_alignment = shelf_->shelf_widget()->GetAlignment(); 810 ShelfAlignment shelf_alignment = shelf_->alignment();
819 if (alignment_ == DOCKED_ALIGNMENT_LEFT && 811 if (alignment_ == DOCKED_ALIGNMENT_LEFT &&
820 shelf_alignment == SHELF_ALIGNMENT_LEFT) { 812 shelf_alignment == SHELF_ALIGNMENT_LEFT) {
821 alignment_ = DOCKED_ALIGNMENT_RIGHT; 813 alignment_ = DOCKED_ALIGNMENT_RIGHT;
822 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT && 814 } else if (alignment_ == DOCKED_ALIGNMENT_RIGHT &&
823 shelf_alignment == SHELF_ALIGNMENT_RIGHT) { 815 shelf_alignment == SHELF_ALIGNMENT_RIGHT) {
824 alignment_ = DOCKED_ALIGNMENT_LEFT; 816 alignment_ = DOCKED_ALIGNMENT_LEFT;
825 } 817 }
826 Relayout(); 818 Relayout();
827 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED); 819 UpdateDockBounds(DockedWindowLayoutManagerObserver::SHELF_ALIGNMENT_CHANGED);
828 } 820 }
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 1358
1367 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( 1359 void DockedWindowLayoutManager::OnKeyboardBoundsChanging(
1368 const gfx::Rect& keyboard_bounds) { 1360 const gfx::Rect& keyboard_bounds) {
1369 // This bounds change will have caused a change to the Shelf which does not 1361 // This bounds change will have caused a change to the Shelf which does not
1370 // propagate automatically to this class, so manually recalculate bounds. 1362 // propagate automatically to this class, so manually recalculate bounds.
1371 Relayout(); 1363 Relayout();
1372 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); 1364 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING);
1373 } 1365 }
1374 1366
1375 } // namespace ash 1367 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/app_list_controller.cc ('k') | ash/wm/panels/panel_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698