| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/common/wm/overview/window_selector.h" | 5 #include "ash/common/wm/overview/window_selector.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> |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 274 } |
| 275 | 275 |
| 276 WindowSelector::WindowSelector(WindowSelectorDelegate* delegate) | 276 WindowSelector::WindowSelector(WindowSelectorDelegate* delegate) |
| 277 : delegate_(delegate), | 277 : delegate_(delegate), |
| 278 restore_focus_window_(WmShell::Get()->GetFocusedWindow()), | 278 restore_focus_window_(WmShell::Get()->GetFocusedWindow()), |
| 279 ignore_activations_(false), | 279 ignore_activations_(false), |
| 280 selected_grid_index_(0), | 280 selected_grid_index_(0), |
| 281 overview_start_time_(base::Time::Now()), | 281 overview_start_time_(base::Time::Now()), |
| 282 num_key_presses_(0), | 282 num_key_presses_(0), |
| 283 num_items_(0), | 283 num_items_(0), |
| 284 showing_selection_widget_(false), | 284 showing_text_filter_(false), |
| 285 text_filter_string_length_(0), | 285 text_filter_string_length_(0), |
| 286 num_times_textfield_cleared_(0), | 286 num_times_textfield_cleared_(0), |
| 287 restoring_minimized_windows_(false), | 287 restoring_minimized_windows_(false), |
| 288 text_filter_bottom_(0) { | 288 text_filter_bottom_(0) { |
| 289 DCHECK(delegate_); | 289 DCHECK(delegate_); |
| 290 } | 290 } |
| 291 | 291 |
| 292 WindowSelector::~WindowSelector() { | 292 WindowSelector::~WindowSelector() { |
| 293 RemoveAllObservers(); | 293 RemoveAllObservers(); |
| 294 } | 294 } |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 auto grid = | 602 auto grid = |
| 603 std::find_if(grid_list_.begin(), grid_list_.end(), | 603 std::find_if(grid_list_.begin(), grid_list_.end(), |
| 604 RootWindowGridComparator(gained_active->GetRootWindow())); | 604 RootWindowGridComparator(gained_active->GetRootWindow())); |
| 605 if (grid == grid_list_.end()) | 605 if (grid == grid_list_.end()) |
| 606 return; | 606 return; |
| 607 const std::vector<WindowSelectorItem*> windows = (*grid)->window_list(); | 607 const std::vector<WindowSelectorItem*> windows = (*grid)->window_list(); |
| 608 | 608 |
| 609 auto iter = std::find_if(windows.begin(), windows.end(), | 609 auto iter = std::find_if(windows.begin(), windows.end(), |
| 610 WindowSelectorItemTargetComparator(gained_active)); | 610 WindowSelectorItemTargetComparator(gained_active)); |
| 611 | 611 |
| 612 if (iter != windows.end()) | 612 if (iter != windows.end()) { |
| 613 (*iter)->ShowWindowOnExit(); | 613 (*iter)->ShowWindowOnExit(); |
| 614 } else if (showing_text_filter_ && |
| 615 lost_active == GetTextFilterWidgetWindow()) { |
| 616 return; |
| 617 } |
| 614 | 618 |
| 615 // Don't restore focus on exit if a window was just activated. | 619 // Don't restore focus on exit if a window was just activated. |
| 616 ResetFocusRestoreWindow(false); | 620 ResetFocusRestoreWindow(false); |
| 617 CancelSelection(); | 621 CancelSelection(); |
| 618 } | 622 } |
| 619 | 623 |
| 620 void WindowSelector::OnAttemptToReactivateWindow(WmWindow* request_active, | 624 void WindowSelector::OnAttemptToReactivateWindow(WmWindow* request_active, |
| 621 WmWindow* actual_active) { | 625 WmWindow* actual_active) { |
| 622 OnWindowActivated(request_active, actual_active); | 626 OnWindowActivated(request_active, actual_active); |
| 623 } | 627 } |
| 624 | 628 |
| 625 void WindowSelector::ContentsChanged(views::Textfield* sender, | 629 void WindowSelector::ContentsChanged(views::Textfield* sender, |
| 626 const base::string16& new_contents) { | 630 const base::string16& new_contents) { |
| 627 text_filter_string_length_ = new_contents.length(); | 631 text_filter_string_length_ = new_contents.length(); |
| 628 if (!text_filter_string_length_) | 632 if (!text_filter_string_length_) |
| 629 num_times_textfield_cleared_++; | 633 num_times_textfield_cleared_++; |
| 630 | 634 |
| 631 bool should_show_selection_widget = !new_contents.empty(); | 635 bool should_show_text_filter = !new_contents.empty(); |
| 632 if (showing_selection_widget_ != should_show_selection_widget) { | 636 if (showing_text_filter_ != should_show_text_filter) { |
| 633 WmWindow* text_filter_widget_window = GetTextFilterWidgetWindow(); | 637 WmWindow* text_filter_widget_window = GetTextFilterWidgetWindow(); |
| 634 ui::ScopedLayerAnimationSettings animation_settings( | 638 ui::ScopedLayerAnimationSettings animation_settings( |
| 635 text_filter_widget_window->GetLayer()->GetAnimator()); | 639 text_filter_widget_window->GetLayer()->GetAnimator()); |
| 636 animation_settings.SetPreemptionStrategy( | 640 animation_settings.SetPreemptionStrategy( |
| 637 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 641 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 638 animation_settings.SetTweenType(showing_selection_widget_ | 642 animation_settings.SetTweenType(showing_text_filter_ |
| 639 ? gfx::Tween::FAST_OUT_LINEAR_IN | 643 ? gfx::Tween::FAST_OUT_LINEAR_IN |
| 640 : gfx::Tween::LINEAR_OUT_SLOW_IN); | 644 : gfx::Tween::LINEAR_OUT_SLOW_IN); |
| 641 | 645 |
| 642 gfx::Transform transform; | 646 gfx::Transform transform; |
| 643 if (should_show_selection_widget) { | 647 if (should_show_text_filter) { |
| 644 transform.Translate(0, 0); | 648 transform.Translate(0, 0); |
| 645 text_filter_widget_window->SetOpacity(1); | 649 text_filter_widget_window->SetOpacity(1); |
| 646 } else { | 650 } else { |
| 647 transform.Translate(0, -text_filter_bottom_); | 651 transform.Translate(0, -text_filter_bottom_); |
| 648 text_filter_widget_window->SetOpacity(0); | 652 text_filter_widget_window->SetOpacity(0); |
| 649 } | 653 } |
| 650 | 654 |
| 651 text_filter_widget_window->SetTransform(transform); | 655 text_filter_widget_window->SetTransform(transform); |
| 652 showing_selection_widget_ = should_show_selection_widget; | 656 showing_text_filter_ = should_show_text_filter; |
| 653 } | 657 } |
| 654 for (auto iter = grid_list_.begin(); iter != grid_list_.end(); iter++) | 658 for (auto iter = grid_list_.begin(); iter != grid_list_.end(); iter++) |
| 655 (*iter)->FilterItems(new_contents); | 659 (*iter)->FilterItems(new_contents); |
| 656 | 660 |
| 657 // If the selection widget is not active, execute a Move() command so that it | 661 // If the selection widget is not active, execute a Move() command so that it |
| 658 // shows up on the first undimmed item. | 662 // shows up on the first undimmed item. |
| 659 if (grid_list_[selected_grid_index_]->is_selecting()) | 663 if (grid_list_[selected_grid_index_]->is_selecting()) |
| 660 return; | 664 return; |
| 661 Move(WindowSelector::RIGHT, false); | 665 Move(WindowSelector::RIGHT, false); |
| 662 } | 666 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 for (size_t i = 0; i <= grid_list_.size() && | 718 for (size_t i = 0; i <= grid_list_.size() && |
| 715 grid_list_[selected_grid_index_]->Move(direction, animate); | 719 grid_list_[selected_grid_index_]->Move(direction, animate); |
| 716 i++) { | 720 i++) { |
| 717 selected_grid_index_ = | 721 selected_grid_index_ = |
| 718 (selected_grid_index_ + display_direction + grid_list_.size()) % | 722 (selected_grid_index_ + display_direction + grid_list_.size()) % |
| 719 grid_list_.size(); | 723 grid_list_.size(); |
| 720 } | 724 } |
| 721 } | 725 } |
| 722 | 726 |
| 723 } // namespace ash | 727 } // namespace ash |
| OLD | NEW |