Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: ash/wm/overview/window_selector.cc

Issue 324493004: Fix pressing enter key crashes overview mode without a selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Rob's comments, test failing. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/wm/overview/window_selector.h" 5 #include "ash/wm/overview/window_selector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/accessibility_delegate.h" 9 #include "ash/accessibility_delegate.h"
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // TODO(nsatragno): Use the previous index for more than two displays. 193 // TODO(nsatragno): Use the previous index for more than two displays.
194 selected_grid_index_ = 0; 194 selected_grid_index_ = 0;
195 if (grid_list_.empty()) 195 if (grid_list_.empty())
196 CancelSelection(); 196 CancelSelection();
197 } 197 }
198 198
199 void WindowSelector::OnKeyEvent(ui::KeyEvent* event) { 199 void WindowSelector::OnKeyEvent(ui::KeyEvent* event) {
200 if (event->type() != ui::ET_KEY_PRESSED) 200 if (event->type() != ui::ET_KEY_PRESSED)
201 return; 201 return;
202 202
203 bool handled = true;
204 switch (event->key_code()) { 203 switch (event->key_code()) {
205 case ui::VKEY_ESCAPE: 204 case ui::VKEY_ESCAPE:
206 CancelSelection(); 205 CancelSelection();
207 break; 206 break;
208 case ui::VKEY_UP: 207 case ui::VKEY_UP:
209 Move(WindowSelector::UP); 208 Move(WindowSelector::UP);
210 break; 209 break;
211 case ui::VKEY_DOWN: 210 case ui::VKEY_DOWN:
212 Move(WindowSelector::DOWN); 211 Move(WindowSelector::DOWN);
213 break; 212 break;
214 case ui::VKEY_RIGHT: 213 case ui::VKEY_RIGHT:
215 Move(WindowSelector::RIGHT); 214 Move(WindowSelector::RIGHT);
216 break; 215 break;
217 case ui::VKEY_LEFT: 216 case ui::VKEY_LEFT:
218 Move(WindowSelector::LEFT); 217 Move(WindowSelector::LEFT);
219 break; 218 break;
220 case ui::VKEY_RETURN: 219 case ui::VKEY_RETURN:
221 wm::GetWindowState( 220 // Ignore if no item is selected.
222 grid_list_[selected_grid_index_]-> 221 if (!grid_list_[selected_grid_index_]->is_selecting())
223 SelectedWindow()->SelectionWindow())->Activate(); 222 return;
223 wm::GetWindowState(grid_list_[selected_grid_index_]->
224 SelectedWindow()->SelectionWindow())->Activate();
224 break; 225 break;
225 default: 226 default:
226 // Not a key we are interested in. 227 // Not a key we are interested in.
227 handled = false; 228 return;
228 break;
229 } 229 }
230 if (handled) 230 event->StopPropagation();
231 event->SetHandled();
232 } 231 }
233 232
234 void WindowSelector::OnDisplayAdded(const gfx::Display& display) { 233 void WindowSelector::OnDisplayAdded(const gfx::Display& display) {
235 } 234 }
236 235
237 void WindowSelector::OnDisplayRemoved(const gfx::Display& display) { 236 void WindowSelector::OnDisplayRemoved(const gfx::Display& display) {
238 // TODO(nsatragno): Keep window selection active on remaining displays. 237 // TODO(nsatragno): Keep window selection active on remaining displays.
239 CancelSelection(); 238 CancelSelection();
240 } 239 }
241 240
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // root window, identify it and call Move() on it to initialize the 364 // root window, identify it and call Move() on it to initialize the
366 // selection widget. 365 // selection widget.
367 // TODO(nsatragno): If there are more than two monitors, move between grids 366 // TODO(nsatragno): If there are more than two monitors, move between grids
368 // in the requested direction. 367 // in the requested direction.
369 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size(); 368 selected_grid_index_ = (selected_grid_index_ + 1) % grid_list_.size();
370 grid_list_[selected_grid_index_]->Move(direction); 369 grid_list_[selected_grid_index_]->Move(direction);
371 } 370 }
372 } 371 }
373 372
374 } // namespace ash 373 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698