OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/wm/immersive_fullscreen_controller.h" | 5 #include "ash/wm/immersive_fullscreen_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // vertical. This is used to make sure that gesture is close to vertical instead | 55 // vertical. This is used to make sure that gesture is close to vertical instead |
56 // of just more vertical then horizontal. | 56 // of just more vertical then horizontal. |
57 const int kSwipeVerticalThresholdMultiplier = 3; | 57 const int kSwipeVerticalThresholdMultiplier = 3; |
58 | 58 |
59 // The height in pixels of the region above the top edge of the display which | 59 // The height in pixels of the region above the top edge of the display which |
60 // hosts the immersive fullscreen window in which mouse events are ignored | 60 // hosts the immersive fullscreen window in which mouse events are ignored |
61 // (cannot reveal or unreveal the top-of-window views). | 61 // (cannot reveal or unreveal the top-of-window views). |
62 // See ShouldIgnoreMouseEventAtLocation() for more details. | 62 // See ShouldIgnoreMouseEventAtLocation() for more details. |
63 const int kHeightOfDeadRegionAboveTopContainer = 10; | 63 const int kHeightOfDeadRegionAboveTopContainer = 10; |
64 | 64 |
65 // The height in pixels of the region below the top edge of the display in which | |
66 // the mouse can trigger revealing the top-of-window views. The height must be | |
67 // greater than 1px because the top pixel is used to trigger moving the cursor | |
68 // between displays if the user has a vertical display layout (primary display | |
69 // above/below secondary display). | |
70 const int kMouseRevealBoundsHeight = 3; | |
71 | |
72 // Returns the BubbleDelegateView corresponding to |maybe_bubble| if | 65 // Returns the BubbleDelegateView corresponding to |maybe_bubble| if |
73 // |maybe_bubble| is a bubble. | 66 // |maybe_bubble| is a bubble. |
74 views::BubbleDelegateView* AsBubbleDelegate(aura::Window* maybe_bubble) { | 67 views::BubbleDelegateView* AsBubbleDelegate(aura::Window* maybe_bubble) { |
75 if (!maybe_bubble) | 68 if (!maybe_bubble) |
76 return NULL; | 69 return NULL; |
77 views::Widget* widget = views::Widget::GetWidgetForNativeView(maybe_bubble); | 70 views::Widget* widget = views::Widget::GetWidgetForNativeView(maybe_bubble); |
78 if (!widget) | 71 if (!widget) |
79 return NULL; | 72 return NULL; |
80 return widget->widget_delegate()->AsBubbleDelegate(); | 73 return widget->widget_delegate()->AsBubbleDelegate(); |
81 } | 74 } |
(...skipping 22 matching lines...) Expand all Loading... |
104 return location_in_screen; | 97 return location_in_screen; |
105 } | 98 } |
106 | 99 |
107 // Returns the bounds of the display nearest to |window| in screen coordinates. | 100 // Returns the bounds of the display nearest to |window| in screen coordinates. |
108 gfx::Rect GetDisplayBoundsInScreen(aura::Window* window) { | 101 gfx::Rect GetDisplayBoundsInScreen(aura::Window* window) { |
109 return Shell::GetScreen()->GetDisplayNearestWindow(window).bounds(); | 102 return Shell::GetScreen()->GetDisplayNearestWindow(window).bounds(); |
110 } | 103 } |
111 | 104 |
112 } // namespace | 105 } // namespace |
113 | 106 |
| 107 // The height in pixels of the region below the top edge of the display in which |
| 108 // the mouse can trigger revealing the top-of-window views. |
| 109 #if defined(OS_WIN) |
| 110 // Windows 8 reserves some pixels at the top of the screen for the hand icon |
| 111 // that allows you to drag a metro app off the screen, so a few additional |
| 112 // pixels of space must be reserved for the mouse reveal. |
| 113 const int ImmersiveFullscreenController::kMouseRevealBoundsHeight = 9; |
| 114 #else |
| 115 // The height must be greater than 1px because the top pixel is used to trigger |
| 116 // moving the cursor between displays if the user has a vertical display layout |
| 117 // (primary display above/below secondary display). |
| 118 const int ImmersiveFullscreenController::kMouseRevealBoundsHeight = 3; |
| 119 #endif |
| 120 |
114 //////////////////////////////////////////////////////////////////////////////// | 121 //////////////////////////////////////////////////////////////////////////////// |
115 | 122 |
116 // Class which keeps the top-of-window views revealed as long as one of the | 123 // Class which keeps the top-of-window views revealed as long as one of the |
117 // bubbles it is observing is visible. The logic to keep the top-of-window | 124 // bubbles it is observing is visible. The logic to keep the top-of-window |
118 // views revealed based on the visibility of bubbles anchored to | 125 // views revealed based on the visibility of bubbles anchored to |
119 // children of |ImmersiveFullscreenController::top_container_| is separate from | 126 // children of |ImmersiveFullscreenController::top_container_| is separate from |
120 // the logic related to |ImmersiveFullscreenController::focus_revealed_lock_| | 127 // the logic related to |ImmersiveFullscreenController::focus_revealed_lock_| |
121 // so that bubbles which are not activatable and bubbles which do not close | 128 // so that bubbles which are not activatable and bubbles which do not close |
122 // upon deactivation also keep the top-of-window views revealed for the | 129 // upon deactivation also keep the top-of-window views revealed for the |
123 // duration of their visibility. | 130 // duration of their visibility. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 void ImmersiveFullscreenController::OnGestureEvent(ui::GestureEvent* event) { | 397 void ImmersiveFullscreenController::OnGestureEvent(ui::GestureEvent* event) { |
391 if (!enabled_) | 398 if (!enabled_) |
392 return; | 399 return; |
393 | 400 |
394 // Touch gestures should not initiate revealing the top-of-window views while | 401 // Touch gestures should not initiate revealing the top-of-window views while |
395 // |widget_| is inactive. | 402 // |widget_| is inactive. |
396 if (!widget_->IsActive()) | 403 if (!widget_->IsActive()) |
397 return; | 404 return; |
398 | 405 |
399 switch (event->type()) { | 406 switch (event->type()) { |
| 407 #if defined(OS_WIN) |
| 408 case ui::ET_GESTURE_WIN8_EDGE_SWIPE: |
| 409 UpdateRevealedLocksForSwipe(GetSwipeType(event)); |
| 410 event->SetHandled(); |
| 411 break; |
| 412 #endif |
400 case ui::ET_GESTURE_SCROLL_BEGIN: | 413 case ui::ET_GESTURE_SCROLL_BEGIN: |
401 if (ShouldHandleGestureEvent(GetEventLocationInScreen(*event))) { | 414 if (ShouldHandleGestureEvent(GetEventLocationInScreen(*event))) { |
402 gesture_begun_ = true; | 415 gesture_begun_ = true; |
403 // Do not consume the event. Otherwise, we end up consuming all | 416 // Do not consume the event. Otherwise, we end up consuming all |
404 // ui::ET_GESTURE_SCROLL_BEGIN events in the top-of-window views | 417 // ui::ET_GESTURE_SCROLL_BEGIN events in the top-of-window views |
405 // when the top-of-window views are revealed. | 418 // when the top-of-window views are revealed. |
406 } | 419 } |
407 break; | 420 break; |
408 case ui::ET_GESTURE_SCROLL_UPDATE: | 421 case ui::ET_GESTURE_SCROLL_UPDATE: |
409 if (gesture_begun_) { | 422 if (gesture_begun_) { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 } | 856 } |
844 | 857 |
845 void ImmersiveFullscreenController::OnSlideClosedAnimationCompleted() { | 858 void ImmersiveFullscreenController::OnSlideClosedAnimationCompleted() { |
846 DCHECK_EQ(SLIDING_CLOSED, reveal_state_); | 859 DCHECK_EQ(SLIDING_CLOSED, reveal_state_); |
847 reveal_state_ = CLOSED; | 860 reveal_state_ = CLOSED; |
848 delegate_->OnImmersiveRevealEnded(); | 861 delegate_->OnImmersiveRevealEnded(); |
849 } | 862 } |
850 | 863 |
851 ImmersiveFullscreenController::SwipeType | 864 ImmersiveFullscreenController::SwipeType |
852 ImmersiveFullscreenController::GetSwipeType(ui::GestureEvent* event) const { | 865 ImmersiveFullscreenController::GetSwipeType(ui::GestureEvent* event) const { |
| 866 #if defined(OS_WIN) |
| 867 if (event->type() == ui::ET_GESTURE_WIN8_EDGE_SWIPE) |
| 868 return SWIPE_OPEN; |
| 869 #endif |
853 if (event->type() != ui::ET_GESTURE_SCROLL_UPDATE) | 870 if (event->type() != ui::ET_GESTURE_SCROLL_UPDATE) |
854 return SWIPE_NONE; | 871 return SWIPE_NONE; |
855 // Make sure that it is a clear vertical gesture. | 872 // Make sure that it is a clear vertical gesture. |
856 if (abs(event->details().scroll_y()) <= | 873 if (abs(event->details().scroll_y()) <= |
857 kSwipeVerticalThresholdMultiplier * abs(event->details().scroll_x())) | 874 kSwipeVerticalThresholdMultiplier * abs(event->details().scroll_x())) |
858 return SWIPE_NONE; | 875 return SWIPE_NONE; |
859 if (event->details().scroll_y() < 0) | 876 if (event->details().scroll_y() < 0) |
860 return SWIPE_CLOSE; | 877 return SWIPE_CLOSE; |
861 else if (event->details().scroll_y() > 0) | 878 else if (event->details().scroll_y() > 0) |
862 return SWIPE_OPEN; | 879 return SWIPE_OPEN; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 AsBubbleDelegate(transient_child); | 943 AsBubbleDelegate(transient_child); |
927 if (bubble_delegate && | 944 if (bubble_delegate && |
928 bubble_delegate->GetAnchorView() && | 945 bubble_delegate->GetAnchorView() && |
929 top_container_->Contains(bubble_delegate->GetAnchorView())) { | 946 top_container_->Contains(bubble_delegate->GetAnchorView())) { |
930 bubble_manager_->StartObserving(transient_child); | 947 bubble_manager_->StartObserving(transient_child); |
931 } | 948 } |
932 } | 949 } |
933 } | 950 } |
934 | 951 |
935 } // namespace ash | 952 } // namespace ash |
OLD | NEW |