Chromium Code Reviews| Index: ash/wm/overview/window_grid.cc | 
| diff --git a/ash/wm/overview/window_grid.cc b/ash/wm/overview/window_grid.cc | 
| index 99ea37c2d1e54056e20674b2f1366eb468a595f8..1e08c76ab8de4d5a6e1079173ca43a5e0f6e0fc9 100644 | 
| --- a/ash/wm/overview/window_grid.cc | 
| +++ b/ash/wm/overview/window_grid.cc | 
| @@ -14,6 +14,9 @@ | 
| #include "ash/wm/overview/window_selector_window.h" | 
| #include "ash/wm/window_state.h" | 
| #include "base/memory/scoped_vector.h" | 
| +#include "base/strings/string_util.h" | 
| +#include "base/strings/utf_string_conversions.h" | 
| +#include "third_party/icu/source/i18n/unicode/translit.h" | 
| #include "third_party/skia/include/core/SkColor.h" | 
| #include "ui/aura/window.h" | 
| #include "ui/compositor/layer_animation_observer.h" | 
| @@ -128,7 +131,8 @@ WindowGrid::WindowGrid(aura::Window* root_window, | 
| const std::vector<aura::Window*>& windows, | 
| WindowSelector* window_selector) | 
| : root_window_(root_window), | 
| - window_selector_(window_selector) { | 
| + window_selector_(window_selector), | 
| + has_active_item_(true) { | 
| WindowSelectorPanels* panels_item = NULL; | 
| for (aura::Window::Windows::const_iterator iter = windows.begin(); | 
| iter != windows.end(); ++iter) { | 
| @@ -197,6 +201,7 @@ void WindowGrid::PositionWindows(bool animate) { | 
| (total_bounds.width() - num_columns_ * window_size.width())) / 2; | 
| int y_offset = total_bounds.y() + (total_bounds.height() - | 
| num_rows * window_size.height()) / 2; | 
| + | 
| for (size_t i = 0; i < window_list_.size(); ++i) { | 
| gfx::Transform transform; | 
| int column = i % num_columns_; | 
| @@ -219,6 +224,9 @@ void WindowGrid::PositionWindows(bool animate) { | 
| } | 
| bool WindowGrid::Move(WindowSelector::Direction direction) { | 
| + if (!has_active_item_) | 
| + return false; | 
| 
 
flackr
2014/06/26 17:33:07
Does this mean you could get stuck if you move the
 
Nina
2014/06/27 15:20:39
Yes. And panic, this is not the only multi monitor
 
 | 
| + | 
| bool recreate_selection_widget = false; | 
| bool out_of_bounds = false; | 
| if (!selection_widget_) { | 
| @@ -235,7 +243,8 @@ bool WindowGrid::Move(WindowSelector::Direction direction) { | 
| selected_index_ = 0; | 
| break; | 
| } | 
| - } else { | 
| + } | 
| + while (SelectedWindow()->dimmed() || selection_widget_) { | 
| switch (direction) { | 
| case WindowSelector::RIGHT: | 
| if (selected_index_ >= window_list_.size() - 1) | 
| @@ -272,6 +281,9 @@ bool WindowGrid::Move(WindowSelector::Direction direction) { | 
| } | 
| break; | 
| } | 
| + // Exit the loop if we broke free from the grid or found an active item. | 
| + if (out_of_bounds || !SelectedWindow()->dimmed()) | 
| + break; | 
| } | 
| MoveSelectionWidget(direction, recreate_selection_widget, out_of_bounds); | 
| @@ -289,6 +301,37 @@ bool WindowGrid::Contains(const aura::Window* window) const { | 
| window_list_.end(); | 
| } | 
| +void WindowGrid::FilterItems(const base::string16& pattern) { | 
| + has_active_item_ = false; | 
| + UErrorCode status = U_ZERO_ERROR; | 
| + | 
| + icu::Transliterator* translit = icu::Transliterator::createInstance( | 
| + "Lower (Upper); NFD; [:Nonspacing Mark:] Remove; NFC", | 
| + UTRANS_FORWARD, status); | 
| + icu::UnicodeString target(pattern.c_str()); | 
| + translit->transliterate(target); | 
| 
 
flackr
2014/06/26 17:33:07
I can't find any occurrences in chrome/ which dire
 
Nina
2014/06/27 15:20:39
OMG that function is pure awesomeness. Switched to
 
 | 
| + | 
| + for (ScopedVector<WindowSelectorItem>::iterator iter = window_list_.begin(); | 
| + iter != window_list_.end(); iter++) { | 
| + icu::UnicodeString title_string( | 
| + (*iter)->SelectionWindow()->title().c_str()); | 
| + translit->transliterate(title_string); | 
| + const base::string16& title(title_string.getTerminatedBuffer()); | 
| + if (title.find(target.getTerminatedBuffer()) != base::string16::npos) { | 
| 
 
flackr
2014/06/26 17:49:43
Presumably the empty string (i.e. when entire sear
 
Nina
2014/06/27 15:20:39
Added comment to header file.
 
 | 
| + (*iter)->SetDimmed(false); | 
| + has_active_item_ = true; | 
| + } else { | 
| + (*iter)->SetDimmed(true); | 
| + if (selection_widget_ && SelectedWindow() == *iter) | 
| + selection_widget_.reset(); | 
| + } | 
| + } | 
| + // If the selection widget is not active, execute a Move() command so that it | 
| + // shows up on the first undimmed item. | 
| + if (!selection_widget_) | 
| + Move(WindowSelector::RIGHT); | 
| 
 
flackr
2014/06/26 17:33:07
Just to check, we probably don't want this to do a
 
Nina
2014/06/27 15:20:39
Move() does animate it. Modified to receive a bool
 
 | 
| +} | 
| + | 
| void WindowGrid::OnWindowDestroying(aura::Window* window) { | 
| window->RemoveObserver(this); | 
| observed_windows_.erase(window); |