| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/overview/window_grid.h" | 5 #include "ash/wm/overview/window_grid.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
| 14 #include "ash/public/cpp/shelf_types.h" | 14 #include "ash/public/cpp/shelf_types.h" |
| 15 #include "ash/public/cpp/shell_window_ids.h" | 15 #include "ash/public/cpp/shell_window_ids.h" |
| 16 #include "ash/root_window_controller.h" | 16 #include "ash/root_window_controller.h" |
| 17 #include "ash/screen_util.h" | 17 #include "ash/screen_util.h" |
| 18 #include "ash/shelf/wm_shelf.h" | 18 #include "ash/shelf/wm_shelf.h" |
| 19 #include "ash/wm/overview/cleanup_animation_observer.h" | 19 #include "ash/wm/overview/cleanup_animation_observer.h" |
| 20 #include "ash/wm/overview/scoped_overview_animation_settings.h" | 20 #include "ash/wm/overview/scoped_overview_animation_settings.h" |
| 21 #include "ash/wm/overview/scoped_overview_animation_settings_factory.h" | |
| 22 #include "ash/wm/overview/window_selector.h" | 21 #include "ash/wm/overview/window_selector.h" |
| 23 #include "ash/wm/overview/window_selector_delegate.h" | 22 #include "ash/wm/overview/window_selector_delegate.h" |
| 24 #include "ash/wm/overview/window_selector_item.h" | 23 #include "ash/wm/overview/window_selector_item.h" |
| 25 #include "ash/wm/window_state.h" | 24 #include "ash/wm/window_state.h" |
| 26 #include "ash/wm_window.h" | 25 #include "ash/wm_window.h" |
| 27 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 28 #include "base/i18n/string_search.h" | 27 #include "base/i18n/string_search.h" |
| 29 #include "base/memory/ptr_util.h" | 28 #include "base/memory/ptr_util.h" |
| 30 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
| 31 #include "third_party/skia/include/core/SkColor.h" | 30 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 #include "ui/views/view.h" | 42 #include "ui/views/view.h" |
| 44 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
| 45 #include "ui/wm/core/coordinate_conversion.h" | 44 #include "ui/wm/core/coordinate_conversion.h" |
| 46 #include "ui/wm/core/shadow.h" | 45 #include "ui/wm/core/shadow.h" |
| 47 #include "ui/wm/core/shadow_types.h" | 46 #include "ui/wm/core/shadow_types.h" |
| 48 #include "ui/wm/core/window_animations.h" | 47 #include "ui/wm/core/window_animations.h" |
| 49 | 48 |
| 50 namespace ash { | 49 namespace ash { |
| 51 namespace { | 50 namespace { |
| 52 | 51 |
| 53 using Windows = aura::Window::Windows; | |
| 54 | |
| 55 // A comparator for locating a given target window. | |
| 56 struct WindowSelectorItemComparator { | |
| 57 explicit WindowSelectorItemComparator(const aura::Window* target_window) | |
| 58 : target(target_window) {} | |
| 59 | |
| 60 bool operator()(std::unique_ptr<WindowSelectorItem>& window) const { | |
| 61 return window->GetWindow() == target; | |
| 62 } | |
| 63 | |
| 64 const aura::Window* target; | |
| 65 }; | |
| 66 | |
| 67 // Time it takes for the selector widget to move to the next target. The same | 52 // Time it takes for the selector widget to move to the next target. The same |
| 68 // time is used for fading out shield widget when the overview mode is opened | 53 // time is used for fading out shield widget when the overview mode is opened |
| 69 // or closed. | 54 // or closed. |
| 70 const int kOverviewSelectorTransitionMilliseconds = 250; | 55 const int kOverviewSelectorTransitionMilliseconds = 250; |
| 71 | 56 |
| 72 // The color and opacity of the screen shield in overview. | 57 // The color and opacity of the screen shield in overview. |
| 73 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); | 58 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); |
| 74 const float kShieldOpacity = 0.7f; | 59 const float kShieldOpacity = 0.7f; |
| 75 | 60 |
| 76 // The color and opacity of the overview selector. | 61 // The color and opacity of the overview selector. |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 selector_shadow_.reset(); | 535 selector_shadow_.reset(); |
| 551 } | 536 } |
| 552 } | 537 } |
| 553 } | 538 } |
| 554 } | 539 } |
| 555 | 540 |
| 556 void WindowGrid::WindowClosing(WindowSelectorItem* window) { | 541 void WindowGrid::WindowClosing(WindowSelectorItem* window) { |
| 557 if (!selection_widget_ || SelectedWindow() != window) | 542 if (!selection_widget_ || SelectedWindow() != window) |
| 558 return; | 543 return; |
| 559 aura::Window* selection_widget_window = selection_widget_->GetNativeWindow(); | 544 aura::Window* selection_widget_window = selection_widget_->GetNativeWindow(); |
| 560 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = | 545 ScopedOverviewAnimationSettings animation_settings_label( |
| 561 ScopedOverviewAnimationSettingsFactory::Get() | 546 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM, |
| 562 ->CreateOverviewAnimationSettings( | 547 selection_widget_window); |
| 563 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM, | |
| 564 selection_widget_window); | |
| 565 selection_widget_->SetOpacity(0.f); | 548 selection_widget_->SetOpacity(0.f); |
| 566 } | 549 } |
| 567 | 550 |
| 568 void WindowGrid::OnWindowDestroying(aura::Window* window) { | 551 void WindowGrid::OnWindowDestroying(aura::Window* window) { |
| 569 window_observer_.Remove(window); | 552 window_observer_.Remove(window); |
| 570 window_state_observer_.Remove(wm::GetWindowState(window)); | 553 window_state_observer_.Remove(wm::GetWindowState(window)); |
| 571 auto iter = std::find_if(window_list_.begin(), window_list_.end(), | 554 auto iter = std::find_if(window_list_.begin(), window_list_.end(), |
| 572 WindowSelectorItemComparator(window)); | 555 [window](std::unique_ptr<WindowSelectorItem>& item) { |
| 573 | 556 return item->GetWindow() == window; |
| 557 }); |
| 574 DCHECK(iter != window_list_.end()); | 558 DCHECK(iter != window_list_.end()); |
| 575 | 559 |
| 576 size_t removed_index = iter - window_list_.begin(); | 560 size_t removed_index = iter - window_list_.begin(); |
| 577 window_list_.erase(iter); | 561 window_list_.erase(iter); |
| 578 | 562 |
| 579 if (empty()) { | 563 if (empty()) { |
| 580 // If the grid is now empty, notify the window selector so that it erases us | 564 // If the grid is now empty, notify the window selector so that it erases us |
| 581 // from its grid list. | 565 // from its grid list. |
| 582 window_selector_->OnGridEmpty(this); | 566 window_selector_->OnGridEmpty(this); |
| 583 return; | 567 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 598 | 582 |
| 599 void WindowGrid::OnWindowBoundsChanged(aura::Window* window, | 583 void WindowGrid::OnWindowBoundsChanged(aura::Window* window, |
| 600 const gfx::Rect& old_bounds, | 584 const gfx::Rect& old_bounds, |
| 601 const gfx::Rect& new_bounds) { | 585 const gfx::Rect& new_bounds) { |
| 602 // During preparation, window bounds can change. Ignore bounds | 586 // During preparation, window bounds can change. Ignore bounds |
| 603 // change notifications in this case; we'll reposition soon. | 587 // change notifications in this case; we'll reposition soon. |
| 604 if (!prepared_for_overview_) | 588 if (!prepared_for_overview_) |
| 605 return; | 589 return; |
| 606 | 590 |
| 607 auto iter = std::find_if(window_list_.begin(), window_list_.end(), | 591 auto iter = std::find_if(window_list_.begin(), window_list_.end(), |
| 608 WindowSelectorItemComparator(window)); | 592 [window](std::unique_ptr<WindowSelectorItem>& item) { |
| 593 return item->GetWindow() == window; |
| 594 }); |
| 609 DCHECK(iter != window_list_.end()); | 595 DCHECK(iter != window_list_.end()); |
| 610 | 596 |
| 611 // Immediately finish any active bounds animation. | 597 // Immediately finish any active bounds animation. |
| 612 window->layer()->GetAnimator()->StopAnimatingProperty( | 598 window->layer()->GetAnimator()->StopAnimatingProperty( |
| 613 ui::LayerAnimationElement::BOUNDS); | 599 ui::LayerAnimationElement::BOUNDS); |
| 614 PositionWindows(false); | 600 PositionWindows(false); |
| 615 } | 601 } |
| 616 | 602 |
| 617 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state, | 603 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state, |
| 618 wm::WindowStateType old_type) { | 604 wm::WindowStateType old_type) { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 *min_right = left; | 819 *min_right = left; |
| 834 if (*max_right < left) | 820 if (*max_right < left) |
| 835 *max_right = left; | 821 *max_right = left; |
| 836 } | 822 } |
| 837 *max_bottom = top + height; | 823 *max_bottom = top + height; |
| 838 } | 824 } |
| 839 return windows_fit; | 825 return windows_fit; |
| 840 } | 826 } |
| 841 | 827 |
| 842 } // namespace ash | 828 } // namespace ash |
| OLD | NEW |