| 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 <complex> | 7 #include <complex> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "athena/wm/overview_toolbar.h" | 10 #include "athena/wm/overview_toolbar.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 WindowOverviewState* target_state = | 255 WindowOverviewState* target_state = |
| 256 target_window->GetProperty(kWindowOverviewState); | 256 target_window->GetProperty(kWindowOverviewState); |
| 257 setter.SetWindowProgress(target_state->progress); | 257 setter.SetWindowProgress(target_state->progress); |
| 258 } | 258 } |
| 259 | 259 |
| 260 // Always returns the same target. | 260 // Always returns the same target. |
| 261 class StaticWindowTargeter : public aura::WindowTargeter { | 261 class StaticWindowTargeter : public aura::WindowTargeter { |
| 262 public: | 262 public: |
| 263 explicit StaticWindowTargeter(aura::Window* target) : target_(target) {} | 263 explicit StaticWindowTargeter(aura::Window* target) : target_(target) {} |
| 264 virtual ~StaticWindowTargeter() {} | 264 ~StaticWindowTargeter() override {} |
| 265 | 265 |
| 266 private: | 266 private: |
| 267 // aura::WindowTargeter: | 267 // aura::WindowTargeter: |
| 268 virtual ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, | 268 ui::EventTarget* FindTargetForEvent(ui::EventTarget* root, |
| 269 ui::Event* event) override { | 269 ui::Event* event) override { |
| 270 return target_; | 270 return target_; |
| 271 } | 271 } |
| 272 | 272 |
| 273 virtual ui::EventTarget* FindTargetForLocatedEvent( | 273 ui::EventTarget* FindTargetForLocatedEvent(ui::EventTarget* root, |
| 274 ui::EventTarget* root, | 274 ui::LocatedEvent* event) override { |
| 275 ui::LocatedEvent* event) override { | |
| 276 return target_; | 275 return target_; |
| 277 } | 276 } |
| 278 | 277 |
| 279 aura::Window* target_; | 278 aura::Window* target_; |
| 280 DISALLOW_COPY_AND_ASSIGN(StaticWindowTargeter); | 279 DISALLOW_COPY_AND_ASSIGN(StaticWindowTargeter); |
| 281 }; | 280 }; |
| 282 | 281 |
| 283 class WindowOverviewModeImpl : public WindowOverviewMode, | 282 class WindowOverviewModeImpl : public WindowOverviewMode, |
| 284 public ui::EventHandler, | 283 public ui::EventHandler, |
| 285 public ui::CompositorAnimationObserver, | 284 public ui::CompositorAnimationObserver, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 302 container_->set_target_handler(this); | 301 container_->set_target_handler(this); |
| 303 | 302 |
| 304 // Prepare the desired transforms for all the windows, and set the initial | 303 // Prepare the desired transforms for all the windows, and set the initial |
| 305 // state on the windows. | 304 // state on the windows. |
| 306 ComputeTerminalStatesForAllWindows(); | 305 ComputeTerminalStatesForAllWindows(); |
| 307 SetInitialWindowStates(); | 306 SetInitialWindowStates(); |
| 308 | 307 |
| 309 window_list_provider_->AddObserver(this); | 308 window_list_provider_->AddObserver(this); |
| 310 } | 309 } |
| 311 | 310 |
| 312 virtual ~WindowOverviewModeImpl() { | 311 ~WindowOverviewModeImpl() override { |
| 313 window_list_provider_->RemoveObserver(this); | 312 window_list_provider_->RemoveObserver(this); |
| 314 container_->set_target_handler(container_->delegate()); | 313 container_->set_target_handler(container_->delegate()); |
| 315 RemoveAnimationObserver(); | 314 RemoveAnimationObserver(); |
| 316 const aura::Window::Windows& windows = | 315 const aura::Window::Windows& windows = |
| 317 window_list_provider_->GetWindowList(); | 316 window_list_provider_->GetWindowList(); |
| 318 if (windows.empty()) | 317 if (windows.empty()) |
| 319 return; | 318 return; |
| 320 for (aura::Window* window : windows) | 319 for (aura::Window* window : windows) |
| 321 RestoreWindowState(window, split_view_controller_); | 320 RestoreWindowState(window, split_view_controller_); |
| 322 } | 321 } |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 split_view_controller_->left_window(), | 688 split_view_controller_->left_window(), |
| 690 split_view_controller_->right_window(), | 689 split_view_controller_->right_window(), |
| 691 window); | 690 window); |
| 692 } else { | 691 } else { |
| 693 delegate_->OnSelectWindow(window); | 692 delegate_->OnSelectWindow(window); |
| 694 } | 693 } |
| 695 } | 694 } |
| 696 } | 695 } |
| 697 | 696 |
| 698 // ui::EventHandler: | 697 // ui::EventHandler: |
| 699 virtual void OnMouseEvent(ui::MouseEvent* mouse) override { | 698 void OnMouseEvent(ui::MouseEvent* mouse) override { |
| 700 if (mouse->type() == ui::ET_MOUSE_PRESSED) { | 699 if (mouse->type() == ui::ET_MOUSE_PRESSED) { |
| 701 aura::Window* select = SelectWindowAt(mouse); | 700 aura::Window* select = SelectWindowAt(mouse); |
| 702 if (select) { | 701 if (select) { |
| 703 mouse->SetHandled(); | 702 mouse->SetHandled(); |
| 704 SelectWindow(select); | 703 SelectWindow(select); |
| 705 } | 704 } |
| 706 } else if (mouse->type() == ui::ET_MOUSEWHEEL) { | 705 } else if (mouse->type() == ui::ET_MOUSEWHEEL) { |
| 707 DoScroll(static_cast<ui::MouseWheelEvent*>(mouse)->y_offset()); | 706 DoScroll(static_cast<ui::MouseWheelEvent*>(mouse)->y_offset()); |
| 708 } | 707 } |
| 709 } | 708 } |
| 710 | 709 |
| 711 virtual void OnScrollEvent(ui::ScrollEvent* scroll) override { | 710 void OnScrollEvent(ui::ScrollEvent* scroll) override { |
| 712 if (scroll->type() == ui::ET_SCROLL) | 711 if (scroll->type() == ui::ET_SCROLL) |
| 713 DoScroll(scroll->y_offset()); | 712 DoScroll(scroll->y_offset()); |
| 714 } | 713 } |
| 715 | 714 |
| 716 virtual void OnGestureEvent(ui::GestureEvent* gesture) override { | 715 void OnGestureEvent(ui::GestureEvent* gesture) override { |
| 717 if (gesture->type() == ui::ET_GESTURE_TAP) { | 716 if (gesture->type() == ui::ET_GESTURE_TAP) { |
| 718 aura::Window* select = SelectWindowAt(gesture); | 717 aura::Window* select = SelectWindowAt(gesture); |
| 719 if (select) { | 718 if (select) { |
| 720 gesture->SetHandled(); | 719 gesture->SetHandled(); |
| 721 SelectWindow(select); | 720 SelectWindow(select); |
| 722 } | 721 } |
| 723 } else if (gesture->type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 722 } else if (gesture->type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 724 if (std::abs(gesture->details().scroll_x_hint()) > | 723 if (std::abs(gesture->details().scroll_x_hint()) > |
| 725 std::abs(gesture->details().scroll_y_hint()) * 2) { | 724 std::abs(gesture->details().scroll_y_hint()) * 2) { |
| 726 dragged_start_location_ = gesture->location(); | 725 dragged_start_location_ = gesture->location(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 if (fling_) { | 767 if (fling_) { |
| 769 fling_.reset(); | 768 fling_.reset(); |
| 770 RemoveAnimationObserver(); | 769 RemoveAnimationObserver(); |
| 771 gesture->SetHandled(); | 770 gesture->SetHandled(); |
| 772 } | 771 } |
| 773 dragged_window_ = nullptr; | 772 dragged_window_ = nullptr; |
| 774 } | 773 } |
| 775 } | 774 } |
| 776 | 775 |
| 777 // ui::CompositorAnimationObserver: | 776 // ui::CompositorAnimationObserver: |
| 778 virtual void OnAnimationStep(base::TimeTicks timestamp) override { | 777 void OnAnimationStep(base::TimeTicks timestamp) override { |
| 779 CHECK(fling_); | 778 CHECK(fling_); |
| 780 gfx::Vector2dF delta; | 779 gfx::Vector2dF delta; |
| 781 bool fling_active = fling_->ComputeScrollDeltaAtTime(timestamp, &delta); | 780 bool fling_active = fling_->ComputeScrollDeltaAtTime(timestamp, &delta); |
| 782 | 781 |
| 783 if (!delta.IsZero()) | 782 if (!delta.IsZero()) |
| 784 DoScroll(delta.y()); | 783 DoScroll(delta.y()); |
| 785 | 784 |
| 786 if (!fling_active) { | 785 if (!fling_active) { |
| 787 fling_.reset(); | 786 fling_.reset(); |
| 788 RemoveAnimationObserver(); | 787 RemoveAnimationObserver(); |
| 789 } | 788 } |
| 790 } | 789 } |
| 791 | 790 |
| 792 // WindowListProviderObserver: | 791 // WindowListProviderObserver: |
| 793 virtual void OnWindowStackingChanged() override { | 792 void OnWindowStackingChanged() override { |
| 794 // Recompute the states of all windows. There isn't enough information at | 793 // Recompute the states of all windows. There isn't enough information at |
| 795 // this point to do anything more clever. | 794 // this point to do anything more clever. |
| 796 ComputeTerminalStatesForAllWindows(); | 795 ComputeTerminalStatesForAllWindows(); |
| 797 SetInitialWindowStates(); | 796 SetInitialWindowStates(); |
| 798 } | 797 } |
| 799 | 798 |
| 800 virtual void OnWindowRemoved(aura::Window* removed_window, | 799 void OnWindowRemoved(aura::Window* removed_window, int index) override { |
| 801 int index) override { | |
| 802 const aura::Window::Windows& windows = | 800 const aura::Window::Windows& windows = |
| 803 window_list_provider_->GetWindowList(); | 801 window_list_provider_->GetWindowList(); |
| 804 if (windows.empty()) | 802 if (windows.empty()) |
| 805 return; | 803 return; |
| 806 CHECK_LE(index, static_cast<int>(windows.size())); | 804 CHECK_LE(index, static_cast<int>(windows.size())); |
| 807 if (index == 0) { | 805 if (index == 0) { |
| 808 // The back-most window has been removed. Move all the remaining windows | 806 // The back-most window has been removed. Move all the remaining windows |
| 809 // one step backwards. | 807 // one step backwards. |
| 810 for (int i = windows.size() - 1; i > 0; --i) { | 808 for (int i = windows.size() - 1; i > 0; --i) { |
| 811 UpdateTerminalStateForWindowAtIndex( | 809 UpdateTerminalStateForWindowAtIndex( |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 aura::Window* container, | 856 aura::Window* container, |
| 859 WindowListProvider* window_list_provider, | 857 WindowListProvider* window_list_provider, |
| 860 SplitViewController* split_view_controller, | 858 SplitViewController* split_view_controller, |
| 861 WindowOverviewModeDelegate* delegate) { | 859 WindowOverviewModeDelegate* delegate) { |
| 862 return scoped_ptr<WindowOverviewMode>( | 860 return scoped_ptr<WindowOverviewMode>( |
| 863 new WindowOverviewModeImpl(container, window_list_provider, | 861 new WindowOverviewModeImpl(container, window_list_provider, |
| 864 split_view_controller, delegate)); | 862 split_view_controller, delegate)); |
| 865 } | 863 } |
| 866 | 864 |
| 867 } // namespace athena | 865 } // namespace athena |
| OLD | NEW |