Chromium Code Reviews| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 std::sort(root_windows.begin(), root_windows.end(), | 247 std::sort(root_windows.begin(), root_windows.end(), |
| 248 [](const WmWindow* a, const WmWindow* b) { | 248 [](const WmWindow* a, const WmWindow* b) { |
| 249 // Since we don't know if windows are vertically or horizontally | 249 // Since we don't know if windows are vertically or horizontally |
| 250 // oriented we use both x and y position. This may be confusing | 250 // oriented we use both x and y position. This may be confusing |
| 251 // if you have 3 or more monitors which are not strictly | 251 // if you have 3 or more monitors which are not strictly |
| 252 // horizontal or vertical but that case is not yet supported. | 252 // horizontal or vertical but that case is not yet supported. |
| 253 return (a->GetBoundsInScreen().x() + a->GetBoundsInScreen().y()) < | 253 return (a->GetBoundsInScreen().x() + a->GetBoundsInScreen().y()) < |
| 254 (b->GetBoundsInScreen().x() + b->GetBoundsInScreen().y()); | 254 (b->GetBoundsInScreen().x() + b->GetBoundsInScreen().y()); |
| 255 }); | 255 }); |
| 256 | 256 |
| 257 bool first_grid = true; | |
| 257 for (WmWindow* root : root_windows) { | 258 for (WmWindow* root : root_windows) { |
| 258 // Observed switchable containers for newly created windows on all root | 259 // Observed switchable containers for newly created windows on all root |
| 259 // windows. | 260 // windows. |
| 260 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) { | 261 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) { |
| 261 WmWindow* container = | 262 WmWindow* container = |
| 262 root->GetChildByShellWindowId(wm::kSwitchableWindowContainerIds[i]); | 263 root->GetChildByShellWindowId(wm::kSwitchableWindowContainerIds[i]); |
| 263 container->AddObserver(this); | 264 container->AddObserver(this); |
| 264 observed_windows_.insert(container); | 265 observed_windows_.insert(container); |
| 265 } | 266 } |
| 266 | 267 |
| 267 // Hide the callout widgets for panels. It is safe to call this for | 268 // Hide the callout widgets for panels. It is safe to call this for |
| 268 // root windows that don't contain any panel windows. | 269 // root windows that don't contain any panel windows. |
| 269 PanelLayoutManager::Get(root)->SetShowCalloutWidgets(false); | 270 PanelLayoutManager::Get(root)->SetShowCalloutWidgets(false); |
| 270 | 271 |
| 271 std::unique_ptr<WindowGrid> grid(new WindowGrid(root, windows, this)); | 272 std::unique_ptr<WindowGrid> grid(new WindowGrid(root, windows, this)); |
| 272 if (grid->empty()) | 273 if (grid->empty()) |
| 273 continue; | 274 continue; |
| 275 if (first_grid) { | |
|
tdanderson
2017/02/10 16:05:19
I'm not 100% convinced this is the right thing to
varkha
2017/02/10 17:34:30
Yes, I'll take this offline.
| |
| 276 grid->set_skip_first(true); | |
| 277 first_grid = false; | |
| 278 } | |
| 274 num_items_ += grid->size(); | 279 num_items_ += grid->size(); |
| 275 grid_list_.push_back(std::move(grid)); | 280 grid_list_.push_back(std::move(grid)); |
| 276 } | 281 } |
| 277 | 282 |
| 278 { | 283 { |
| 279 // The calls to WindowGrid::PrepareForOverview() and CreateTextFilter(...) | 284 // The calls to WindowGrid::PrepareForOverview() and CreateTextFilter(...) |
| 280 // requires some LayoutManagers (ie PanelLayoutManager) to perform layouts | 285 // requires some LayoutManagers (ie PanelLayoutManager) to perform layouts |
| 281 // so that windows are correctly visible and properly animated in overview | 286 // so that windows are correctly visible and properly animated in overview |
| 282 // mode. Otherwise these layouts should be suppressed during overview mode | 287 // mode. Otherwise these layouts should be suppressed during overview mode |
| 283 // so they don't conflict with overview mode animations. The | 288 // so they don't conflict with overview mode animations. The |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 397 selected_grid_index_--; | 402 selected_grid_index_--; |
| 398 // If the grid which became empty was the one with the selected window, we | 403 // If the grid which became empty was the one with the selected window, we |
| 399 // need to select a window on the newly selected grid. | 404 // need to select a window on the newly selected grid. |
| 400 if (selected_grid_index_ == index - 1) | 405 if (selected_grid_index_ == index - 1) |
| 401 Move(LEFT, true); | 406 Move(LEFT, true); |
| 402 } | 407 } |
| 403 if (grid_list_.empty()) | 408 if (grid_list_.empty()) |
| 404 CancelSelection(); | 409 CancelSelection(); |
| 405 } | 410 } |
| 406 | 411 |
| 412 void WindowSelector::IncrementSelection(int increment) { | |
| 413 const Direction direction = | |
| 414 increment > 0 ? WindowSelector::RIGHT : WindowSelector::LEFT; | |
| 415 for (int step = 0; step < abs(increment); ++step) | |
| 416 Move(direction, true); | |
| 417 } | |
| 418 | |
| 419 bool WindowSelector::AcceptSelection() { | |
| 420 if (!grid_list_[selected_grid_index_]->is_selecting()) | |
| 421 return false; | |
| 422 SelectWindow(grid_list_[selected_grid_index_]->SelectedWindow()); | |
| 423 return true; | |
| 424 } | |
| 425 | |
| 407 void WindowSelector::SelectWindow(WindowSelectorItem* item) { | 426 void WindowSelector::SelectWindow(WindowSelectorItem* item) { |
| 408 WmWindow* window = item->GetWindow(); | 427 WmWindow* window = item->GetWindow(); |
| 409 std::vector<WmWindow*> window_list = | 428 std::vector<WmWindow*> window_list = |
| 410 WmShell::Get()->mru_window_tracker()->BuildMruWindowList(); | 429 WmShell::Get()->mru_window_tracker()->BuildMruWindowList(); |
| 411 if (!window_list.empty()) { | 430 if (!window_list.empty()) { |
| 412 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the user is selecting | 431 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the user is selecting |
| 413 // a window other than the window that was active prior to entering overview | 432 // a window other than the window that was active prior to entering overview |
| 414 // mode (i.e., the window at the front of the MRU list). | 433 // mode (i.e., the window at the front of the MRU list). |
| 415 if (window_list[0] != window) { | 434 if (window_list[0] != window) { |
| 416 WmShell::Get()->RecordUserMetricsAction( | 435 WmShell::Get()->RecordUserMetricsAction( |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 for (size_t i = 0; i <= grid_list_.size() && | 682 for (size_t i = 0; i <= grid_list_.size() && |
| 664 grid_list_[selected_grid_index_]->Move(direction, animate); | 683 grid_list_[selected_grid_index_]->Move(direction, animate); |
| 665 i++) { | 684 i++) { |
| 666 selected_grid_index_ = | 685 selected_grid_index_ = |
| 667 (selected_grid_index_ + display_direction + grid_list_.size()) % | 686 (selected_grid_index_ + display_direction + grid_list_.size()) % |
| 668 grid_list_.size(); | 687 grid_list_.size(); |
| 669 } | 688 } |
| 670 } | 689 } |
| 671 | 690 |
| 672 } // namespace ash | 691 } // namespace ash |
| OLD | NEW |