| 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/split_view_controller.h" | 5 #include "athena/wm/split_view_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "athena/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
| 10 #include "athena/wm/public/window_list_provider.h" | 10 #include "athena/wm/public/window_list_provider.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 WINDOW_LEFT, | 51 WINDOW_LEFT, |
| 52 // Activate |right_window_|. | 52 // Activate |right_window_|. |
| 53 WINDOW_RIGHT | 53 WINDOW_RIGHT |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Always returns the same target. | 56 // Always returns the same target. |
| 57 class StaticViewTargeterDelegate : public views::ViewTargeterDelegate { | 57 class StaticViewTargeterDelegate : public views::ViewTargeterDelegate { |
| 58 public: | 58 public: |
| 59 explicit StaticViewTargeterDelegate(views::View* target) : target_(target) {} | 59 explicit StaticViewTargeterDelegate(views::View* target) : target_(target) {} |
| 60 | 60 |
| 61 virtual ~StaticViewTargeterDelegate() {} | 61 ~StaticViewTargeterDelegate() override {} |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 // views::ViewTargeterDelegate: | 64 // views::ViewTargeterDelegate: |
| 65 virtual views::View* TargetForRect(views::View* root, | 65 virtual views::View* TargetForRect(views::View* root, |
| 66 const gfx::Rect& rect) override { | 66 const gfx::Rect& rect) override { |
| 67 return target_; | 67 return target_; |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Not owned. | 70 // Not owned. |
| 71 views::View* target_; | 71 views::View* target_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(StaticViewTargeterDelegate); | 73 DISALLOW_COPY_AND_ASSIGN(StaticViewTargeterDelegate); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 // Expands the effective target area of the window of the widget containing the | 76 // Expands the effective target area of the window of the widget containing the |
| 77 // specified view. If the view is large enough to begin with, there should be | 77 // specified view. If the view is large enough to begin with, there should be |
| 78 // no change from the default targeting behavior. | 78 // no change from the default targeting behavior. |
| 79 class PriorityWindowTargeter : public aura::WindowTargeter, | 79 class PriorityWindowTargeter : public aura::WindowTargeter, |
| 80 public aura::WindowObserver { | 80 public aura::WindowObserver { |
| 81 public: | 81 public: |
| 82 explicit PriorityWindowTargeter(views::View* priority_view) | 82 explicit PriorityWindowTargeter(views::View* priority_view) |
| 83 : priority_view_(priority_view) { | 83 : priority_view_(priority_view) { |
| 84 CHECK(priority_view->GetWidget()); | 84 CHECK(priority_view->GetWidget()); |
| 85 window_ = priority_view->GetWidget()->GetNativeWindow(); | 85 window_ = priority_view->GetWidget()->GetNativeWindow(); |
| 86 CHECK(window_); | 86 CHECK(window_); |
| 87 window_->AddObserver(this); | 87 window_->AddObserver(this); |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual ~PriorityWindowTargeter() { | 90 ~PriorityWindowTargeter() override { |
| 91 window_->RemoveObserver(this); | 91 window_->RemoveObserver(this); |
| 92 } | 92 } |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 // aura::WindowTargeter: | 95 // aura::WindowTargeter: |
| 96 virtual ui::EventTarget* FindTargetForLocatedEvent( | 96 ui::EventTarget* FindTargetForLocatedEvent( |
| 97 ui::EventTarget* root, | 97 ui::EventTarget* root, |
| 98 ui::LocatedEvent* event) override { | 98 ui::LocatedEvent* event) override { |
| 99 if (!window_ || (event->type() != ui::ET_TOUCH_PRESSED)) | 99 if (!window_ || (event->type() != ui::ET_TOUCH_PRESSED)) |
| 100 return WindowTargeter::FindTargetForLocatedEvent(root, event); | 100 return WindowTargeter::FindTargetForLocatedEvent(root, event); |
| 101 CHECK_EQ(window_, priority_view_->GetWidget()->GetNativeWindow()); | 101 CHECK_EQ(window_, priority_view_->GetWidget()->GetNativeWindow()); |
| 102 | 102 |
| 103 // Bounds of the view in root window's coordinates. | 103 // Bounds of the view in root window's coordinates. |
| 104 gfx::Rect view_bounds = priority_view_->GetBoundsInScreen(); | 104 gfx::Rect view_bounds = priority_view_->GetBoundsInScreen(); |
| 105 // If there is a transform on the window's layer - apply it. | 105 // If there is a transform on the window's layer - apply it. |
| 106 gfx::Transform window_transform = window_->layer()->transform(); | 106 gfx::Transform window_transform = window_->layer()->transform(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 123 gfx::UnionRects(transformed_bounds, extension_rect); | 123 gfx::UnionRects(transformed_bounds, extension_rect); |
| 124 if (extended_bounds.Contains(event->root_location())) { | 124 if (extended_bounds.Contains(event->root_location())) { |
| 125 root->ConvertEventToTarget(window_, event); | 125 root->ConvertEventToTarget(window_, event); |
| 126 return window_; | 126 return window_; |
| 127 } | 127 } |
| 128 | 128 |
| 129 return WindowTargeter::FindTargetForLocatedEvent(root, event); | 129 return WindowTargeter::FindTargetForLocatedEvent(root, event); |
| 130 } | 130 } |
| 131 | 131 |
| 132 // aura::WindowObserver: | 132 // aura::WindowObserver: |
| 133 virtual void OnWindowDestroying(aura::Window* window) override { | 133 void OnWindowDestroying(aura::Window* window) override { |
| 134 DCHECK_EQ(window, window_); | 134 DCHECK_EQ(window, window_); |
| 135 window_->RemoveObserver(this); | 135 window_->RemoveObserver(this); |
| 136 window_ = NULL; | 136 window_ = NULL; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Minimum dimension of a target to be comfortably touchable. | 139 // Minimum dimension of a target to be comfortably touchable. |
| 140 // The effective touch target area of |priority_window_| gets expanded so | 140 // The effective touch target area of |priority_window_| gets expanded so |
| 141 // that it's width and height is ayt least |kMinTouchDimension|. | 141 // that it's width and height is ayt least |kMinTouchDimension|. |
| 142 int const kMinTouchDimension = 26; | 142 int const kMinTouchDimension = 26; |
| 143 | 143 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 ShowDivider(); | 634 ShowDivider(); |
| 635 } | 635 } |
| 636 | 636 |
| 637 void SplitViewController::OnSplitViewModeEnter() { | 637 void SplitViewController::OnSplitViewModeEnter() { |
| 638 } | 638 } |
| 639 | 639 |
| 640 void SplitViewController::OnSplitViewModeExit() { | 640 void SplitViewController::OnSplitViewModeExit() { |
| 641 } | 641 } |
| 642 | 642 |
| 643 } // namespace athena | 643 } // namespace athena |
| OLD | NEW |