| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/window_cycle_list.h" | 5 #include "ash/common/wm/window_cycle_list.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 // never change). | 383 // never change). |
| 384 mirror_container_->layer()->SetAnimator( | 384 mirror_container_->layer()->SetAnimator( |
| 385 ui::LayerAnimator::CreateImplicitAnimator()); | 385 ui::LayerAnimator::CreateImplicitAnimator()); |
| 386 // The selection highlight also animates all bounds changes and never | 386 // The selection highlight also animates all bounds changes and never |
| 387 // changes other animatable properties. | 387 // changes other animatable properties. |
| 388 highlight_view_->layer()->SetAnimator( | 388 highlight_view_->layer()->SetAnimator( |
| 389 ui::LayerAnimator::CreateImplicitAnimator()); | 389 ui::LayerAnimator::CreateImplicitAnimator()); |
| 390 } | 390 } |
| 391 } | 391 } |
| 392 | 392 |
| 393 void OnMouseCaptureLost() override { |
| 394 WmShell::Get()->window_cycle_controller()->StopCycling(); |
| 395 } |
| 396 |
| 393 View* GetContentsView() override { return this; } | 397 View* GetContentsView() override { return this; } |
| 394 | 398 |
| 395 View* GetInitiallyFocusedView() override { | 399 View* GetInitiallyFocusedView() override { |
| 396 return window_view_map_[target_window_]; | 400 return window_view_map_[target_window_]; |
| 397 } | 401 } |
| 398 | 402 |
| 399 WmWindow* target_window() { return target_window_; } | 403 WmWindow* target_window() { return target_window_; } |
| 400 | 404 |
| 401 private: | 405 private: |
| 402 WindowCycleController::Direction initial_direction_; | 406 WindowCycleController::Direction initial_direction_; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 // as the restore marker. | 461 // as the restore marker. |
| 458 stack_window_above_ = GetWindowBelow(stack_window_above_); | 462 stack_window_above_ = GetWindowBelow(stack_window_above_); |
| 459 } | 463 } |
| 460 } | 464 } |
| 461 | 465 |
| 462 WindowCycleList::WindowCycleList(const WindowList& windows) | 466 WindowCycleList::WindowCycleList(const WindowList& windows) |
| 463 : windows_(windows), | 467 : windows_(windows), |
| 464 current_index_(0), | 468 current_index_(0), |
| 465 initial_direction_(WindowCycleController::FORWARD), | 469 initial_direction_(WindowCycleController::FORWARD), |
| 466 cycle_view_(nullptr), | 470 cycle_view_(nullptr), |
| 471 cycle_ui_widget_(nullptr), |
| 467 screen_observer_(this) { | 472 screen_observer_(this) { |
| 468 if (!ShouldShowUi()) | 473 if (!ShouldShowUi()) |
| 469 WmShell::Get()->mru_window_tracker()->SetIgnoreActivations(true); | 474 WmShell::Get()->mru_window_tracker()->SetIgnoreActivations(true); |
| 470 | 475 |
| 471 for (WmWindow* window : windows_) | 476 for (WmWindow* window : windows_) |
| 472 window->AddObserver(this); | 477 window->AddObserver(this); |
| 473 | 478 |
| 474 if (ShouldShowUi()) { | 479 if (ShouldShowUi()) { |
| 475 if (g_disable_initial_delay) { | 480 if (g_disable_initial_delay) { |
| 476 InitWindowCycleView(); | 481 InitWindowCycleView(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 488 for (WmWindow* window : windows_) | 493 for (WmWindow* window : windows_) |
| 489 window->RemoveObserver(this); | 494 window->RemoveObserver(this); |
| 490 | 495 |
| 491 if (showing_window_) { | 496 if (showing_window_) { |
| 492 showing_window_->CancelRestore(); | 497 showing_window_->CancelRestore(); |
| 493 } else if (!windows_.empty()) { | 498 } else if (!windows_.empty()) { |
| 494 WmWindow* target_window = windows_[current_index_]; | 499 WmWindow* target_window = windows_[current_index_]; |
| 495 target_window->Show(); | 500 target_window->Show(); |
| 496 target_window->GetWindowState()->Activate(); | 501 target_window->GetWindowState()->Activate(); |
| 497 } | 502 } |
| 503 |
| 504 if (cycle_ui_widget_) |
| 505 cycle_ui_widget_->Close(); |
| 498 } | 506 } |
| 499 | 507 |
| 500 void WindowCycleList::Step(WindowCycleController::Direction direction) { | 508 void WindowCycleList::Step(WindowCycleController::Direction direction) { |
| 501 if (windows_.empty()) | 509 if (windows_.empty()) |
| 502 return; | 510 return; |
| 503 | 511 |
| 504 // When there is only one window, we should give feedback to the user. If the | 512 // When there is only one window, we should give feedback to the user. If the |
| 505 // window is minimized, we should also show it. | 513 // window is minimized, we should also show it. |
| 506 if (windows_.size() == 1) { | 514 if (windows_.size() == 1) { |
| 507 windows_[0]->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 515 windows_[0]->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 if (cycle_view_) | 599 if (cycle_view_) |
| 592 return; | 600 return; |
| 593 | 601 |
| 594 cycle_view_ = new WindowCycleView(windows_, initial_direction_); | 602 cycle_view_ = new WindowCycleView(windows_, initial_direction_); |
| 595 cycle_view_->SetTargetWindow(windows_[current_index_]); | 603 cycle_view_->SetTargetWindow(windows_[current_index_]); |
| 596 | 604 |
| 597 views::Widget* widget = new views::Widget; | 605 views::Widget* widget = new views::Widget; |
| 598 views::Widget::InitParams params; | 606 views::Widget::InitParams params; |
| 599 params.delegate = cycle_view_; | 607 params.delegate = cycle_view_; |
| 600 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | 608 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| 601 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 602 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 609 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 603 params.accept_events = true; | 610 params.accept_events = true; |
| 604 params.name = "WindowCycleList (Alt+Tab)"; | 611 params.name = "WindowCycleList (Alt+Tab)"; |
| 605 // TODO(estade): make sure nothing untoward happens when the lock screen | 612 // TODO(estade): make sure nothing untoward happens when the lock screen |
| 606 // or a system modal dialog is shown. | 613 // or a system modal dialog is shown. |
| 607 WmWindow* root_window = WmShell::Get()->GetRootWindowForNewWindows(); | 614 WmWindow* root_window = WmShell::Get()->GetRootWindowForNewWindows(); |
| 608 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | 615 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( |
| 609 widget, kShellWindowId_OverlayContainer, ¶ms); | 616 widget, kShellWindowId_OverlayContainer, ¶ms); |
| 610 widget->Init(params); | 617 widget->Init(params); |
| 611 | 618 |
| 612 screen_observer_.Add(display::Screen::GetScreen()); | 619 screen_observer_.Add(display::Screen::GetScreen()); |
| 613 gfx::Rect widget_rect = root_window->GetDisplayNearestWindow().bounds(); | 620 gfx::Rect widget_rect = root_window->GetDisplayNearestWindow().bounds(); |
| 614 int widget_height = cycle_view_->GetPreferredSize().height(); | 621 int widget_height = cycle_view_->GetPreferredSize().height(); |
| 615 widget_rect.set_y((widget_rect.height() - widget_height) / 2); | 622 widget_rect.set_y((widget_rect.height() - widget_height) / 2); |
| 616 widget_rect.set_height(widget_height); | 623 widget_rect.set_height(widget_height); |
| 617 widget->SetBounds(widget_rect); | 624 widget->SetBounds(widget_rect); |
| 618 widget->Show(); | 625 widget->Show(); |
| 619 cycle_ui_widget_.reset(widget); | 626 widget->SetCapture(cycle_view_); |
| 627 widget->set_auto_release_capture(false); |
| 628 cycle_ui_widget_ = widget; |
| 620 } | 629 } |
| 621 | 630 |
| 622 } // namespace ash | 631 } // namespace ash |
| OLD | NEW |