| 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 "athena/wm/window_overview_mode.h" | 5 #include "athena/wm/window_overview_mode.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 SplitViewController* split_view_controller) { | 86 SplitViewController* split_view_controller) { |
| 87 window->ClearProperty(kWindowOverviewState); | 87 window->ClearProperty(kWindowOverviewState); |
| 88 | 88 |
| 89 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 89 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 90 settings.SetPreemptionStrategy( | 90 settings.SetPreemptionStrategy( |
| 91 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 91 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 92 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250)); | 92 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250)); |
| 93 | 93 |
| 94 settings.AddObserver(new ui::ClosureAnimationObserver( | 94 settings.AddObserver(new ui::ClosureAnimationObserver( |
| 95 base::Bind(&HideWindowIfNotVisible, window, split_view_controller))); | 95 base::Bind(&HideWindowIfNotVisible, window, split_view_controller))); |
| 96 | |
| 97 window->SetTransform(gfx::Transform()); | 96 window->SetTransform(gfx::Transform()); |
| 98 | 97 |
| 99 // Reset the window opacity in case the user is dragging a window. | 98 // Reset the window opacity in case the user is dragging a window. |
| 100 window->layer()->SetOpacity(1.0f); | 99 window->layer()->SetOpacity(1.0f); |
| 101 | 100 |
| 102 wm::SetShadowType(window, wm::SHADOW_TYPE_NONE); | 101 wm::SetShadowType(window, wm::SHADOW_TYPE_NONE); |
| 103 } | 102 } |
| 104 | 103 |
| 105 gfx::RectF GetTransformedBounds(aura::Window* window) { | 104 gfx::RectF GetTransformedBounds(aura::Window* window) { |
| 106 gfx::Transform transform; | 105 gfx::Transform transform; |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 dragged_window_->layer()->SetOpacity(1.f); | 563 dragged_window_->layer()->SetOpacity(1.f); |
| 565 dragged_window_ = NULL; | 564 dragged_window_ = NULL; |
| 566 } | 565 } |
| 567 | 566 |
| 568 void EndDragWindow(const ui::GestureEvent& gesture) { | 567 void EndDragWindow(const ui::GestureEvent& gesture) { |
| 569 CHECK(dragged_window_); | 568 CHECK(dragged_window_); |
| 570 CHECK(overview_toolbar_); | 569 CHECK(overview_toolbar_); |
| 571 OverviewToolbar::ActionType action = overview_toolbar_->current_action(); | 570 OverviewToolbar::ActionType action = overview_toolbar_->current_action(); |
| 572 overview_toolbar_.reset(); | 571 overview_toolbar_.reset(); |
| 573 if (action == OverviewToolbar::ACTION_TYPE_SPLIT) { | 572 if (action == OverviewToolbar::ACTION_TYPE_SPLIT) { |
| 574 delegate_->OnSplitViewMode(NULL, dragged_window_); | 573 delegate_->OnSelectSplitViewWindow(NULL, |
| 574 dragged_window_, |
| 575 dragged_window_); |
| 575 return; | 576 return; |
| 576 } | 577 } |
| 577 | 578 |
| 578 // If the window is dropped on one of the left/right windows in split-mode, | 579 // If the window is dropped on one of the left/right windows in split-mode, |
| 579 // then switch that window. | 580 // then switch that window. |
| 580 aura::Window* split_drop = GetSplitWindowDropTarget(gesture); | 581 aura::Window* split_drop = GetSplitWindowDropTarget(gesture); |
| 581 if (split_drop) { | 582 if (split_drop) { |
| 582 aura::Window* left = split_view_controller_->left_window(); | 583 aura::Window* left = split_view_controller_->left_window(); |
| 583 aura::Window* right = split_view_controller_->right_window(); | 584 aura::Window* right = split_view_controller_->right_window(); |
| 584 if (left == split_drop) | 585 if (left == split_drop) |
| 585 left = dragged_window_; | 586 left = dragged_window_; |
| 586 else | 587 else |
| 587 right = dragged_window_; | 588 right = dragged_window_; |
| 588 delegate_->OnSplitViewMode(left, right); | 589 delegate_->OnSelectSplitViewWindow(left, right, dragged_window_); |
| 589 return; | 590 return; |
| 590 } | 591 } |
| 591 | 592 |
| 592 if (ShouldCloseDragWindow(gesture)) | 593 if (ShouldCloseDragWindow(gesture)) |
| 593 CloseDragWindow(gesture); | 594 CloseDragWindow(gesture); |
| 594 else | 595 else |
| 595 RestoreDragWindow(); | 596 RestoreDragWindow(); |
| 596 } | 597 } |
| 597 | 598 |
| 598 void SelectWindow(aura::Window* window) { | 599 void SelectWindow(aura::Window* window) { |
| 599 if (!split_view_controller_->IsSplitViewModeActive()) { | 600 if (!split_view_controller_->IsSplitViewModeActive()) { |
| 600 delegate_->OnSelectWindow(window); | 601 delegate_->OnSelectWindow(window); |
| 601 } else { | 602 } else { |
| 602 // If the selected window is one of the left/right windows, then keep the | 603 // If the selected window is one of the left/right windows, then keep the |
| 603 // current state. | 604 // current state. |
| 604 if (window == split_view_controller_->left_window() || | 605 if (window == split_view_controller_->left_window() || |
| 605 window == split_view_controller_->right_window()) { | 606 window == split_view_controller_->right_window()) { |
| 606 delegate_->OnSplitViewMode(split_view_controller_->left_window(), | 607 delegate_->OnSelectSplitViewWindow( |
| 607 split_view_controller_->right_window()); | 608 split_view_controller_->left_window(), |
| 609 split_view_controller_->right_window(), |
| 610 window); |
| 608 } else { | 611 } else { |
| 609 delegate_->OnSelectWindow(window); | 612 delegate_->OnSelectWindow(window); |
| 610 } | 613 } |
| 611 } | 614 } |
| 612 } | 615 } |
| 613 | 616 |
| 617 // WindowOverviewMode: |
| 618 virtual void SelectDefaultWindow() OVERRIDE { |
| 619 aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
| 620 if (windows.empty()) |
| 621 return; |
| 622 |
| 623 // TODO(pkotwicz): Do not select a window which is about to be deleted. |
| 624 SelectWindow(windows.back()); |
| 625 } |
| 626 |
| 614 // ui::EventHandler: | 627 // ui::EventHandler: |
| 615 virtual void OnMouseEvent(ui::MouseEvent* mouse) OVERRIDE { | 628 virtual void OnMouseEvent(ui::MouseEvent* mouse) OVERRIDE { |
| 616 if (mouse->type() == ui::ET_MOUSE_PRESSED) { | 629 if (mouse->type() == ui::ET_MOUSE_PRESSED) { |
| 617 aura::Window* select = SelectWindowAt(mouse); | 630 aura::Window* select = SelectWindowAt(mouse); |
| 618 if (select) { | 631 if (select) { |
| 619 mouse->SetHandled(); | 632 mouse->SetHandled(); |
| 620 SelectWindow(select); | 633 SelectWindow(select); |
| 621 } | 634 } |
| 622 } else if (mouse->type() == ui::ET_MOUSEWHEEL) { | 635 } else if (mouse->type() == ui::ET_MOUSEWHEEL) { |
| 623 DoScroll(static_cast<ui::MouseWheelEvent*>(mouse)->y_offset()); | 636 DoScroll(static_cast<ui::MouseWheelEvent*>(mouse)->y_offset()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 aura::Window* container, | 747 aura::Window* container, |
| 735 const WindowListProvider* window_list_provider, | 748 const WindowListProvider* window_list_provider, |
| 736 SplitViewController* split_view_controller, | 749 SplitViewController* split_view_controller, |
| 737 WindowOverviewModeDelegate* delegate) { | 750 WindowOverviewModeDelegate* delegate) { |
| 738 return scoped_ptr<WindowOverviewMode>( | 751 return scoped_ptr<WindowOverviewMode>( |
| 739 new WindowOverviewModeImpl(container, window_list_provider, | 752 new WindowOverviewModeImpl(container, window_list_provider, |
| 740 split_view_controller, delegate)); | 753 split_view_controller, delegate)); |
| 741 } | 754 } |
| 742 | 755 |
| 743 } // namespace athena | 756 } // namespace athena |
| OLD | NEW |