| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 // Always returns the same target. | 174 // Always returns the same target. |
| 175 class StaticWindowTargeter : public aura::WindowTargeter { | 175 class StaticWindowTargeter : public aura::WindowTargeter { |
| 176 public: | 176 public: |
| 177 explicit StaticWindowTargeter(aura::Window* target) : target_(target) {} | 177 explicit StaticWindowTargeter(aura::Window* target) : target_(target) {} |
| 178 virtual ~StaticWindowTargeter() {} | 178 virtual ~StaticWindowTargeter() {} |
| 179 | 179 |
| 180 private: | 180 private: |
| 181 // aura::WindowTargeter: | 181 // aura::WindowTargeter: |
| 182 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, | 182 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, |
| 183 ui::Event* event) OVERRIDE { | 183 ui::Event* event) override { |
| 184 return target_; | 184 return target_; |
| 185 } | 185 } |
| 186 | 186 |
| 187 virtual ui::EventTarget* FindTargetForLocatedEvent( | 187 virtual ui::EventTarget* FindTargetForLocatedEvent( |
| 188 ui::EventTarget* root, | 188 ui::EventTarget* root, |
| 189 ui::LocatedEvent* event) OVERRIDE { | 189 ui::LocatedEvent* event) override { |
| 190 return target_; | 190 return target_; |
| 191 } | 191 } |
| 192 | 192 |
| 193 aura::Window* target_; | 193 aura::Window* target_; |
| 194 DISALLOW_COPY_AND_ASSIGN(StaticWindowTargeter); | 194 DISALLOW_COPY_AND_ASSIGN(StaticWindowTargeter); |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 class WindowOverviewModeImpl : public WindowOverviewMode, | 197 class WindowOverviewModeImpl : public WindowOverviewMode, |
| 198 public ui::EventHandler, | 198 public ui::EventHandler, |
| 199 public ui::CompositorAnimationObserver, | 199 public ui::CompositorAnimationObserver, |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 split_view_controller_->left_window(), | 608 split_view_controller_->left_window(), |
| 609 split_view_controller_->right_window(), | 609 split_view_controller_->right_window(), |
| 610 window); | 610 window); |
| 611 } else { | 611 } else { |
| 612 delegate_->OnSelectWindow(window); | 612 delegate_->OnSelectWindow(window); |
| 613 } | 613 } |
| 614 } | 614 } |
| 615 } | 615 } |
| 616 | 616 |
| 617 // ui::EventHandler: | 617 // ui::EventHandler: |
| 618 virtual void OnMouseEvent(ui::MouseEvent* mouse) OVERRIDE { | 618 virtual void OnMouseEvent(ui::MouseEvent* mouse) override { |
| 619 if (mouse->type() == ui::ET_MOUSE_PRESSED) { | 619 if (mouse->type() == ui::ET_MOUSE_PRESSED) { |
| 620 aura::Window* select = SelectWindowAt(mouse); | 620 aura::Window* select = SelectWindowAt(mouse); |
| 621 if (select) { | 621 if (select) { |
| 622 mouse->SetHandled(); | 622 mouse->SetHandled(); |
| 623 SelectWindow(select); | 623 SelectWindow(select); |
| 624 } | 624 } |
| 625 } else if (mouse->type() == ui::ET_MOUSEWHEEL) { | 625 } else if (mouse->type() == ui::ET_MOUSEWHEEL) { |
| 626 DoScroll(static_cast<ui::MouseWheelEvent*>(mouse)->y_offset()); | 626 DoScroll(static_cast<ui::MouseWheelEvent*>(mouse)->y_offset()); |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 | 629 |
| 630 virtual void OnScrollEvent(ui::ScrollEvent* scroll) OVERRIDE { | 630 virtual void OnScrollEvent(ui::ScrollEvent* scroll) override { |
| 631 if (scroll->type() == ui::ET_SCROLL) | 631 if (scroll->type() == ui::ET_SCROLL) |
| 632 DoScroll(scroll->y_offset()); | 632 DoScroll(scroll->y_offset()); |
| 633 } | 633 } |
| 634 | 634 |
| 635 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE { | 635 virtual void OnGestureEvent(ui::GestureEvent* gesture) override { |
| 636 if (gesture->type() == ui::ET_GESTURE_TAP) { | 636 if (gesture->type() == ui::ET_GESTURE_TAP) { |
| 637 aura::Window* select = SelectWindowAt(gesture); | 637 aura::Window* select = SelectWindowAt(gesture); |
| 638 if (select) { | 638 if (select) { |
| 639 gesture->SetHandled(); | 639 gesture->SetHandled(); |
| 640 SelectWindow(select); | 640 SelectWindow(select); |
| 641 } | 641 } |
| 642 } else if (gesture->type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 642 } else if (gesture->type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 643 if (std::abs(gesture->details().scroll_x_hint()) > | 643 if (std::abs(gesture->details().scroll_x_hint()) > |
| 644 std::abs(gesture->details().scroll_y_hint()) * 2) { | 644 std::abs(gesture->details().scroll_y_hint()) * 2) { |
| 645 dragged_start_location_ = gesture->location(); | 645 dragged_start_location_ = gesture->location(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 if (fling_) { | 687 if (fling_) { |
| 688 fling_.reset(); | 688 fling_.reset(); |
| 689 RemoveAnimationObserver(); | 689 RemoveAnimationObserver(); |
| 690 gesture->SetHandled(); | 690 gesture->SetHandled(); |
| 691 } | 691 } |
| 692 dragged_window_ = NULL; | 692 dragged_window_ = NULL; |
| 693 } | 693 } |
| 694 } | 694 } |
| 695 | 695 |
| 696 // ui::CompositorAnimationObserver: | 696 // ui::CompositorAnimationObserver: |
| 697 virtual void OnAnimationStep(base::TimeTicks timestamp) OVERRIDE { | 697 virtual void OnAnimationStep(base::TimeTicks timestamp) override { |
| 698 CHECK(fling_); | 698 CHECK(fling_); |
| 699 if (fling_->start_timestamp() > timestamp) | 699 if (fling_->start_timestamp() > timestamp) |
| 700 return; | 700 return; |
| 701 gfx::Vector2dF scroll = fling_->GetScrollAmountAtTime(timestamp); | 701 gfx::Vector2dF scroll = fling_->GetScrollAmountAtTime(timestamp); |
| 702 if (scroll.IsZero()) { | 702 if (scroll.IsZero()) { |
| 703 fling_.reset(); | 703 fling_.reset(); |
| 704 RemoveAnimationObserver(); | 704 RemoveAnimationObserver(); |
| 705 } else { | 705 } else { |
| 706 DoScroll(scroll.y()); | 706 DoScroll(scroll.y()); |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 | 709 |
| 710 // WindowListProviderObserver: | 710 // WindowListProviderObserver: |
| 711 virtual void OnWindowStackingChanged() OVERRIDE { | 711 virtual void OnWindowStackingChanged() override { |
| 712 // Recompute the states of all windows. There isn't enough information at | 712 // Recompute the states of all windows. There isn't enough information at |
| 713 // this point to do anything more clever. | 713 // this point to do anything more clever. |
| 714 ComputeTerminalStatesForAllWindows(); | 714 ComputeTerminalStatesForAllWindows(); |
| 715 SetInitialWindowStates(); | 715 SetInitialWindowStates(); |
| 716 } | 716 } |
| 717 | 717 |
| 718 virtual void OnWindowRemoved(aura::Window* removed_window, | 718 virtual void OnWindowRemoved(aura::Window* removed_window, |
| 719 int index) OVERRIDE { | 719 int index) override { |
| 720 const aura::Window::Windows& windows = | 720 const aura::Window::Windows& windows = |
| 721 window_list_provider_->GetWindowList(); | 721 window_list_provider_->GetWindowList(); |
| 722 if (windows.empty()) | 722 if (windows.empty()) |
| 723 return; | 723 return; |
| 724 CHECK_LE(index, static_cast<int>(windows.size())); | 724 CHECK_LE(index, static_cast<int>(windows.size())); |
| 725 if (index == 0) { | 725 if (index == 0) { |
| 726 // The back-most window has been removed. Move all the remaining windows | 726 // The back-most window has been removed. Move all the remaining windows |
| 727 // one step backwards. | 727 // one step backwards. |
| 728 for (int i = windows.size() - 1; i > 0; --i) { | 728 for (int i = windows.size() - 1; i > 0; --i) { |
| 729 UpdateTerminalStateForWindowAtIndex( | 729 UpdateTerminalStateForWindowAtIndex( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 aura::Window* container, | 776 aura::Window* container, |
| 777 WindowListProvider* window_list_provider, | 777 WindowListProvider* window_list_provider, |
| 778 SplitViewController* split_view_controller, | 778 SplitViewController* split_view_controller, |
| 779 WindowOverviewModeDelegate* delegate) { | 779 WindowOverviewModeDelegate* delegate) { |
| 780 return scoped_ptr<WindowOverviewMode>( | 780 return scoped_ptr<WindowOverviewMode>( |
| 781 new WindowOverviewModeImpl(container, window_list_provider, | 781 new WindowOverviewModeImpl(container, window_list_provider, |
| 782 split_view_controller, delegate)); | 782 split_view_controller, delegate)); |
| 783 } | 783 } |
| 784 | 784 |
| 785 } // namespace athena | 785 } // namespace athena |
| OLD | NEW |