| 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/wm/overview/window_selector.h" | 5 #include "ash/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 19 matching lines...) Expand all Loading... |
| 30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 31 #include "base/metrics/histogram.h" | 31 #include "base/metrics/histogram.h" |
| 32 #include "third_party/skia/include/core/SkPaint.h" | 32 #include "third_party/skia/include/core/SkPaint.h" |
| 33 #include "third_party/skia/include/core/SkPath.h" | 33 #include "third_party/skia/include/core/SkPath.h" |
| 34 #include "ui/aura/client/focus_client.h" | 34 #include "ui/aura/client/focus_client.h" |
| 35 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
| 36 #include "ui/aura/window_event_dispatcher.h" | 36 #include "ui/aura/window_event_dispatcher.h" |
| 37 #include "ui/aura/window_observer.h" | 37 #include "ui/aura/window_observer.h" |
| 38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/compositor/scoped_layer_animation_settings.h" | 39 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 40 #include "ui/display/screen.h" |
| 40 #include "ui/events/event.h" | 41 #include "ui/events/event.h" |
| 41 #include "ui/gfx/canvas.h" | 42 #include "ui/gfx/canvas.h" |
| 42 #include "ui/gfx/screen.h" | |
| 43 #include "ui/gfx/skia_util.h" | 43 #include "ui/gfx/skia_util.h" |
| 44 #include "ui/views/border.h" | 44 #include "ui/views/border.h" |
| 45 #include "ui/views/controls/textfield/textfield.h" | 45 #include "ui/views/controls/textfield/textfield.h" |
| 46 #include "ui/views/layout/box_layout.h" | 46 #include "ui/views/layout/box_layout.h" |
| 47 #include "ui/wm/core/window_util.h" | 47 #include "ui/wm/core/window_util.h" |
| 48 #include "ui/wm/public/activation_client.h" | 48 #include "ui/wm/public/activation_client.h" |
| 49 | 49 |
| 50 namespace ash { | 50 namespace ash { |
| 51 | 51 |
| 52 namespace { | 52 namespace { |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 CreateTextFilter(this, Shell::GetPrimaryRootWindow())); | 312 CreateTextFilter(this, Shell::GetPrimaryRootWindow())); |
| 313 } | 313 } |
| 314 | 314 |
| 315 DCHECK(!grid_list_.empty()); | 315 DCHECK(!grid_list_.empty()); |
| 316 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); | 316 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); |
| 317 | 317 |
| 318 Shell* shell = Shell::GetInstance(); | 318 Shell* shell = Shell::GetInstance(); |
| 319 | 319 |
| 320 shell->activation_client()->AddObserver(this); | 320 shell->activation_client()->AddObserver(this); |
| 321 | 321 |
| 322 gfx::Screen::GetScreen()->AddObserver(this); | 322 display::Screen::GetScreen()->AddObserver(this); |
| 323 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); | 323 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); |
| 324 // Send an a11y alert. | 324 // Send an a11y alert. |
| 325 shell->accessibility_delegate()->TriggerAccessibilityAlert( | 325 shell->accessibility_delegate()->TriggerAccessibilityAlert( |
| 326 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 326 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 327 | 327 |
| 328 UpdateShelfVisibility(); | 328 UpdateShelfVisibility(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 // NOTE: The work done in Shutdown() is not done in the destructor because it | 331 // NOTE: The work done in Shutdown() is not done in the destructor because it |
| 332 // may cause other, unrelated classes, (ie PanelLayoutManager) to make indirect | 332 // may cause other, unrelated classes, (ie PanelLayoutManager) to make indirect |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 grid_list_.clear(); | 375 grid_list_.clear(); |
| 376 UpdateShelfVisibility(); | 376 UpdateShelfVisibility(); |
| 377 } | 377 } |
| 378 | 378 |
| 379 void WindowSelector::RemoveAllObservers() { | 379 void WindowSelector::RemoveAllObservers() { |
| 380 Shell* shell = Shell::GetInstance(); | 380 Shell* shell = Shell::GetInstance(); |
| 381 for (aura::Window* window : observed_windows_) | 381 for (aura::Window* window : observed_windows_) |
| 382 window->RemoveObserver(this); | 382 window->RemoveObserver(this); |
| 383 | 383 |
| 384 shell->activation_client()->RemoveObserver(this); | 384 shell->activation_client()->RemoveObserver(this); |
| 385 gfx::Screen::GetScreen()->RemoveObserver(this); | 385 display::Screen::GetScreen()->RemoveObserver(this); |
| 386 if (restore_focus_window_) | 386 if (restore_focus_window_) |
| 387 restore_focus_window_->RemoveObserver(this); | 387 restore_focus_window_->RemoveObserver(this); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void WindowSelector::CancelSelection() { | 390 void WindowSelector::CancelSelection() { |
| 391 delegate_->OnSelectionEnded(); | 391 delegate_->OnSelectionEnded(); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void WindowSelector::OnGridEmpty(WindowGrid* grid) { | 394 void WindowSelector::OnGridEmpty(WindowGrid* grid) { |
| 395 ScopedVector<WindowGrid>::iterator iter = | 395 ScopedVector<WindowGrid>::iterator iter = |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 SelectWindow( | 462 SelectWindow( |
| 463 grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow()); | 463 grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow()); |
| 464 break; | 464 break; |
| 465 default: | 465 default: |
| 466 // Not a key we are interested in, allow the textfield to handle it. | 466 // Not a key we are interested in, allow the textfield to handle it. |
| 467 return false; | 467 return false; |
| 468 } | 468 } |
| 469 return true; | 469 return true; |
| 470 } | 470 } |
| 471 | 471 |
| 472 void WindowSelector::OnDisplayAdded(const gfx::Display& display) { | 472 void WindowSelector::OnDisplayAdded(const display::Display& display) {} |
| 473 } | |
| 474 | 473 |
| 475 void WindowSelector::OnDisplayRemoved(const gfx::Display& display) { | 474 void WindowSelector::OnDisplayRemoved(const display::Display& display) { |
| 476 // TODO(flackr): Keep window selection active on remaining displays. | 475 // TODO(flackr): Keep window selection active on remaining displays. |
| 477 CancelSelection(); | 476 CancelSelection(); |
| 478 } | 477 } |
| 479 | 478 |
| 480 void WindowSelector::OnDisplayMetricsChanged(const gfx::Display& display, | 479 void WindowSelector::OnDisplayMetricsChanged(const display::Display& display, |
| 481 uint32_t metrics) { | 480 uint32_t metrics) { |
| 482 PositionWindows(/* animate */ false); | 481 PositionWindows(/* animate */ false); |
| 483 RepositionTextFilterOnDisplayMetricsChange(); | 482 RepositionTextFilterOnDisplayMetricsChange(); |
| 484 } | 483 } |
| 485 | 484 |
| 486 void WindowSelector::OnWindowAdded(aura::Window* new_window) { | 485 void WindowSelector::OnWindowAdded(aura::Window* new_window) { |
| 487 if (!IsSelectable(new_window)) | 486 if (!IsSelectable(new_window)) |
| 488 return; | 487 return; |
| 489 | 488 |
| 490 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { | 489 for (size_t i = 0; i < kSwitchableWindowContainerIdsLength; ++i) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 for (size_t i = 0; | 634 for (size_t i = 0; |
| 636 i <= grid_list_.size() && | 635 i <= grid_list_.size() && |
| 637 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { | 636 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { |
| 638 selected_grid_index_ = | 637 selected_grid_index_ = |
| 639 (selected_grid_index_ + display_direction + grid_list_.size()) % | 638 (selected_grid_index_ + display_direction + grid_list_.size()) % |
| 640 grid_list_.size(); | 639 grid_list_.size(); |
| 641 } | 640 } |
| 642 } | 641 } |
| 643 | 642 |
| 644 } // namespace ash | 643 } // namespace ash |
| OLD | NEW |