Index: ash/wm/overview/window_selector.cc |
diff --git a/ash/wm/overview/window_selector.cc b/ash/wm/overview/window_selector.cc |
index 467aca6a8be669310006d0cafc85b779f1f87e3f..a8a755e72e498d6050fd5a856dfb206e4a454022 100644 |
--- a/ash/wm/overview/window_selector.cc |
+++ b/ash/wm/overview/window_selector.cc |
@@ -27,6 +27,8 @@ |
#include "ui/compositor/scoped_layer_animation_settings.h" |
#include "ui/events/event.h" |
#include "ui/gfx/screen.h" |
+#include "ui/views/border.h" |
+#include "ui/views/controls/textfield/textfield.h" |
#include "ui/wm/core/window_util.h" |
#include "ui/wm/public/activation_client.h" |
@@ -87,6 +89,32 @@ void UpdateShelfVisibility() { |
} |
} |
+views::Widget* CreateTextFilter(views::TextfieldController* controller, |
tdanderson
2014/06/25 15:48:23
Add some documentation on line 91 for this method.
Nina
2014/06/26 15:20:17
Done.
|
+ aura::Window* root_window) { |
+ views::Widget* widget = new views::Widget; |
+ views::Widget::InitParams params; |
+ params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
+ params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
+ params.parent = |
+ Shell::GetContainer(root_window, ash::kShellWindowId_OverlayContainer); |
+ params.accept_events = true; |
+ params.bounds = gfx::Rect(root_window->bounds().width() / 4, 0, |
+ root_window->bounds().width() / 2, 0); |
+ widget->Init(params); |
+ views::Textfield* textfield = new views::Textfield; |
+ textfield->set_controller(controller); |
+ textfield->SetBackgroundColor(SK_ColorTRANSPARENT); |
+ textfield->SetBorder(views::Border::NullBorder()); |
+ textfield->SetTextColor(SK_ColorWHITE); |
+ textfield->DisplayShadow(true); |
+ widget->SetContentsView(textfield); |
+ widget->Show(); |
+ textfield->RequestFocus(); |
+ |
+ return widget; |
+} |
+ |
} // namespace |
WindowSelector::WindowSelector(const WindowList& windows, |
@@ -98,7 +126,8 @@ WindowSelector::WindowSelector(const WindowList& windows, |
selected_grid_index_(0), |
overview_start_time_(base::Time::Now()), |
num_key_presses_(0), |
- num_items_(0) { |
+ num_items_(0), |
+ showing_selection_widget_(false) { |
DCHECK(delegate_); |
Shell* shell = Shell::GetInstance(); |
shell->OnOverviewModeStarting(); |
@@ -127,13 +156,11 @@ WindowSelector::WindowSelector(const WindowList& windows, |
DCHECK(!grid_list_.empty()); |
UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); |
- shell->activation_client()->AddObserver(this); |
+ text_filter_widget_.reset( |
+ CreateTextFilter(this, Shell::GetPrimaryRootWindow())); |
- // Remove focus from active window before entering overview. |
- aura::client::GetFocusClient( |
- Shell::GetPrimaryRootWindow())->FocusWindow(NULL); |
+ shell->activation_client()->AddObserver(this); |
- shell->PrependPreTargetHandler(this); |
shell->GetScreen()->AddObserver(this); |
shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); |
HideAndTrackNonOverviewWindows(); |
@@ -168,7 +195,6 @@ WindowSelector::~WindowSelector() { |
(*iter)->Show(); |
} |
- shell->RemovePreTargetHandler(this); |
shell->GetScreen()->RemoveObserver(this); |
size_t remaining_items = 0; |
@@ -207,11 +233,12 @@ void WindowSelector::OnGridEmpty(WindowGrid* grid) { |
CancelSelection(); |
} |
-void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { |
- if (event->type() != ui::ET_KEY_PRESSED) |
- return; |
+bool WindowSelector::HandleKeyEvent(views::Textfield* sender, |
+ const ui::KeyEvent& key_event) { |
+ if (key_event.type() != ui::ET_KEY_PRESSED) |
+ return false; |
- switch (event->key_code()) { |
+ switch (key_event.key_code()) { |
case ui::VKEY_ESCAPE: |
CancelSelection(); |
break; |
@@ -234,7 +261,7 @@ void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { |
case ui::VKEY_RETURN: |
// Ignore if no item is selected. |
if (!grid_list_[selected_grid_index_]->is_selecting()) |
- return; |
+ return true; |
tdanderson
2014/06/25 15:48:23
Should this be return false?
Nina
2014/06/26 15:20:17
I don't think we want the user to be able to write
|
UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", |
num_key_presses_); |
UMA_HISTOGRAM_CUSTOM_COUNTS( |
@@ -246,10 +273,10 @@ void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { |
SelectedWindow()->SelectionWindow())->Activate(); |
break; |
default: |
- // Not a key we are interested in. |
- return; |
+ // Not a key we are interested in, allow the textfield to handle it. |
+ return false; |
} |
- event->StopPropagation(); |
+ return true; |
} |
void WindowSelector::OnDisplayAdded(const gfx::Display& display) { |
@@ -290,8 +317,10 @@ void WindowSelector::OnWindowDestroying(aura::Window* window) { |
void WindowSelector::OnWindowActivated(aura::Window* gained_active, |
aura::Window* lost_active) { |
- if (ignore_activations_ || !gained_active) |
+ if (ignore_activations_ || !gained_active || |
tdanderson
2014/06/25 15:48:23
Use three lines.
Nina
2014/06/26 15:20:17
Done.
|
+ gained_active == text_filter_widget_->GetNativeWindow()) { |
return; |
+ } |
ScopedVector<WindowGrid>::iterator grid = |
std::find_if(grid_list_.begin(), grid_list_.end(), |
@@ -317,6 +346,27 @@ void WindowSelector::OnAttemptToReactivateWindow(aura::Window* request_active, |
OnWindowActivated(request_active, actual_active); |
} |
+void WindowSelector::ContentsChanged(views::Textfield* sender, |
+ const base::string16& new_contents) { |
+ if (!showing_selection_widget_ || new_contents.empty()) { |
+ ui::ScopedLayerAnimationSettings animation_settings( |
+ text_filter_widget_->GetNativeWindow()->layer()->GetAnimator()); |
+ animation_settings.SetPreemptionStrategy( |
+ ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
+ animation_settings.SetTweenType(showing_selection_widget_ ? |
+ gfx::Tween::FAST_OUT_LINEAR_IN : gfx::Tween::LINEAR_OUT_SLOW_IN); |
+ size_t root_window_width = Shell::GetPrimaryRootWindow()->bounds().width(); |
+ text_filter_widget_->SetBounds( |
+ gfx::Rect(root_window_width / 4, 0,root_window_width / 2, |
+ showing_selection_widget_ ? 0 : 50)); |
+ showing_selection_widget_ = !showing_selection_widget_; |
+ } |
+ for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin(); |
+ iter != grid_list_.end(); iter++) { |
tdanderson
2014/06/25 15:48:23
Align iter with ScopedVector.
Nina
2014/06/26 15:20:17
Done.
|
+ (*iter)->Filter(new_contents); |
+ } |
+} |
+ |
void WindowSelector::PositionWindows(bool animate) { |
for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin(); |
iter != grid_list_.end(); iter++) { |