Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1249)

Side by Side Diff: ash/wm/immersive_fullscreen_controller.cc

Issue 198413003: Enable immersive fullscreen on Windows Ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some linux compile errors, and check USE_ASH instead of OS define. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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. The height must be
109 // greater than 1px because the top pixel is used to trigger moving the cursor
110 // between displays if the user has a vertical display layout (primary display
111 // above/below secondary display).
112 #if defined(OS_WIN)
113 // Windows 8 reserves some pixels at the top of the screen for the hand icon
114 // that allows you to drag a metro app off the screen, so a few additional
115 // pixels of space must be reserved for the mouse reveal.
116 const int ImmersiveFullscreenController::kMouseRevealBoundsHeight = 9;
117 #else
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
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 795
783 // Callers with ANIMATE_NO expect this function to synchronously reveal the 796 // Callers with ANIMATE_NO expect this function to synchronously reveal the
784 // top-of-window views. 797 // top-of-window views.
785 if (reveal_state_ == REVEALED || 798 if (reveal_state_ == REVEALED ||
786 (reveal_state_ == SLIDING_OPEN && animate != ANIMATE_NO)) { 799 (reveal_state_ == SLIDING_OPEN && animate != ANIMATE_NO)) {
787 return; 800 return;
788 } 801 }
789 802
790 RevealState previous_reveal_state = reveal_state_; 803 RevealState previous_reveal_state = reveal_state_;
791 reveal_state_ = SLIDING_OPEN; 804 reveal_state_ = SLIDING_OPEN;
805
pkotwicz 2014/03/13 18:34:32 Nuke this change
zturner 2014/03/13 19:28:10 Done.
792 if (previous_reveal_state == CLOSED) { 806 if (previous_reveal_state == CLOSED) {
793 delegate_->OnImmersiveRevealStarted(); 807 delegate_->OnImmersiveRevealStarted();
794 808
795 // Do not do any more processing if OnImmersiveRevealStarted() changed 809 // Do not do any more processing if OnImmersiveRevealStarted() changed
796 // |reveal_state_|. 810 // |reveal_state_|.
797 if (reveal_state_ != SLIDING_OPEN) 811 if (reveal_state_ != SLIDING_OPEN)
798 return; 812 return;
799 } 813 }
800 // Slide in the reveal view. 814 // Slide in the reveal view.
801 if (animate == ANIMATE_NO) { 815 if (animate == ANIMATE_NO) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 857 }
844 858
845 void ImmersiveFullscreenController::OnSlideClosedAnimationCompleted() { 859 void ImmersiveFullscreenController::OnSlideClosedAnimationCompleted() {
846 DCHECK_EQ(SLIDING_CLOSED, reveal_state_); 860 DCHECK_EQ(SLIDING_CLOSED, reveal_state_);
847 reveal_state_ = CLOSED; 861 reveal_state_ = CLOSED;
848 delegate_->OnImmersiveRevealEnded(); 862 delegate_->OnImmersiveRevealEnded();
849 } 863 }
850 864
851 ImmersiveFullscreenController::SwipeType 865 ImmersiveFullscreenController::SwipeType
852 ImmersiveFullscreenController::GetSwipeType(ui::GestureEvent* event) const { 866 ImmersiveFullscreenController::GetSwipeType(ui::GestureEvent* event) const {
867 #if defined(OS_WIN)
868 if (event->type() == ui::ET_GESTURE_WIN8_EDGE_SWIPE)
869 return SWIPE_OPEN;
870 #endif
853 if (event->type() != ui::ET_GESTURE_SCROLL_UPDATE) 871 if (event->type() != ui::ET_GESTURE_SCROLL_UPDATE)
854 return SWIPE_NONE; 872 return SWIPE_NONE;
855 // Make sure that it is a clear vertical gesture. 873 // Make sure that it is a clear vertical gesture.
856 if (abs(event->details().scroll_y()) <= 874 if (abs(event->details().scroll_y()) <=
857 kSwipeVerticalThresholdMultiplier * abs(event->details().scroll_x())) 875 kSwipeVerticalThresholdMultiplier * abs(event->details().scroll_x()))
858 return SWIPE_NONE; 876 return SWIPE_NONE;
859 if (event->details().scroll_y() < 0) 877 if (event->details().scroll_y() < 0)
860 return SWIPE_CLOSE; 878 return SWIPE_CLOSE;
861 else if (event->details().scroll_y() > 0) 879 else if (event->details().scroll_y() > 0)
862 return SWIPE_OPEN; 880 return SWIPE_OPEN;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 AsBubbleDelegate(transient_child); 944 AsBubbleDelegate(transient_child);
927 if (bubble_delegate && 945 if (bubble_delegate &&
928 bubble_delegate->GetAnchorView() && 946 bubble_delegate->GetAnchorView() &&
929 top_container_->Contains(bubble_delegate->GetAnchorView())) { 947 top_container_->Contains(bubble_delegate->GetAnchorView())) {
930 bubble_manager_->StartObserving(transient_child); 948 bubble_manager_->StartObserving(transient_child);
931 } 949 }
932 } 950 }
933 } 951 }
934 952
935 } // namespace ash 953 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698