| OLD | NEW |
| 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_widget()) { |
| 429 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForShelf( | 429 ShelfLayoutManager* shelf_layout_manager = |
| 430 shelf_->shelf_widget()->GetNativeWindow()); | 430 shelf_->shelf_widget()->shelf_layout_manager(); |
| 431 shelf_layout_manager->RemoveObserver(this); | 431 shelf_layout_manager->RemoveObserver(this); |
| 432 shelf_observer_.reset(); | 432 shelf_observer_.reset(); |
| 433 } | 433 } |
| 434 shelf_ = NULL; | 434 shelf_ = NULL; |
| 435 for (size_t i = 0; i < dock_container_->children().size(); ++i) { | 435 for (size_t i = 0; i < dock_container_->children().size(); ++i) { |
| 436 aura::Window* child = dock_container_->children()[i]; | 436 aura::Window* child = dock_container_->children()[i]; |
| 437 child->RemoveObserver(this); | 437 child->RemoveObserver(this); |
| 438 wm::GetWindowState(child)->RemoveObserver(this); | 438 wm::GetWindowState(child)->RemoveObserver(this); |
| 439 } | 439 } |
| 440 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 440 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 dragged_bounds_ = gfx::Rect(); | 533 dragged_bounds_ = gfx::Rect(); |
| 534 Relayout(); | 534 Relayout(); |
| 535 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); | 535 UpdateDockBounds(DockedWindowLayoutManagerObserver::CHILD_CHANGED); |
| 536 RecordUmaAction(action, source); | 536 RecordUmaAction(action, source); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { | 539 void DockedWindowLayoutManager::SetShelf(Shelf* shelf) { |
| 540 DCHECK(!shelf_); | 540 DCHECK(!shelf_); |
| 541 shelf_ = shelf; | 541 shelf_ = shelf; |
| 542 if (shelf_->shelf_widget()) { | 542 if (shelf_->shelf_widget()) { |
| 543 ShelfLayoutManager* shelf_layout_manager = ShelfLayoutManager::ForShelf( | 543 ShelfLayoutManager* shelf_layout_manager = |
| 544 shelf_->shelf_widget()->GetNativeWindow()); | 544 shelf_->shelf_widget()->shelf_layout_manager(); |
| 545 shelf_layout_manager->AddObserver(this); | 545 shelf_layout_manager->AddObserver(this); |
| 546 shelf_observer_.reset(new ShelfWindowObserver(this)); | 546 shelf_observer_.reset(new ShelfWindowObserver(this)); |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 | 549 |
| 550 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( | 550 DockedAlignment DockedWindowLayoutManager::GetAlignmentOfWindow( |
| 551 const aura::Window* window) const { | 551 const aura::Window* window) const { |
| 552 const gfx::Rect& bounds(window->GetBoundsInScreen()); | 552 const gfx::Rect& bounds(window->GetBoundsInScreen()); |
| 553 | 553 |
| 554 // Test overlap with an existing docked area first. | 554 // Test overlap with an existing docked area first. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 actual_new_bounds.set_height( | 749 actual_new_bounds.set_height( |
| 750 std::max(min_size.height(), actual_new_bounds.height())); | 750 std::max(min_size.height(), actual_new_bounds.height())); |
| 751 } | 751 } |
| 752 if (IsWindowDocked(child) && child != dragged_window_) | 752 if (IsWindowDocked(child) && child != dragged_window_) |
| 753 return; | 753 return; |
| 754 SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds); | 754 SnapToPixelLayoutManager::SetChildBounds(child, actual_new_bounds); |
| 755 if (IsPopupOrTransient(child)) | 755 if (IsPopupOrTransient(child)) |
| 756 return; | 756 return; |
| 757 // Whenever one of our windows is moved or resized enforce layout. | 757 // Whenever one of our windows is moved or resized enforce layout. |
| 758 ShelfLayoutManager* shelf_layout = | 758 ShelfLayoutManager* shelf_layout = |
| 759 ShelfLayoutManager::ForShelf(dock_container_); | 759 shelf_->shelf_widget()->shelf_layout_manager(); |
| 760 if (shelf_layout) | 760 if (shelf_layout) |
| 761 shelf_layout->UpdateVisibilityState(); | 761 shelf_layout->UpdateVisibilityState(); |
| 762 } | 762 } |
| 763 | 763 |
| 764 //////////////////////////////////////////////////////////////////////////////// | 764 //////////////////////////////////////////////////////////////////////////////// |
| 765 // DockedWindowLayoutManager, ash::ShellObserver implementation: | 765 // DockedWindowLayoutManager, ash::ShellObserver implementation: |
| 766 | 766 |
| 767 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { | 767 void DockedWindowLayoutManager::OnDisplayWorkAreaInsetsChanged() { |
| 768 Relayout(); | 768 Relayout(); |
| 769 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); | 769 UpdateDockBounds(DockedWindowLayoutManagerObserver::DISPLAY_INSETS_CHANGED); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1366 | 1366 |
| 1367 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( | 1367 void DockedWindowLayoutManager::OnKeyboardBoundsChanging( |
| 1368 const gfx::Rect& keyboard_bounds) { | 1368 const gfx::Rect& keyboard_bounds) { |
| 1369 // This bounds change will have caused a change to the Shelf which does not | 1369 // This bounds change will have caused a change to the Shelf which does not |
| 1370 // propagate automatically to this class, so manually recalculate bounds. | 1370 // propagate automatically to this class, so manually recalculate bounds. |
| 1371 Relayout(); | 1371 Relayout(); |
| 1372 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); | 1372 UpdateDockBounds(DockedWindowLayoutManagerObserver::KEYBOARD_BOUNDS_CHANGING); |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 } // namespace ash | 1375 } // namespace ash |
| OLD | NEW |