Commit fc531456 authored by Dan H's avatar Dan H Committed by Commit Bot

Revert "Better coordinate swipe to home gesture and drag handle nudge"

This reverts commit 57098dce.

Reason for revert: Causing test failures: https://bugs.chromium.org/p/chromium/issues/detail?id=1062658

Original change's description:
> Better coordinate swipe to home gesture and drag handle nudge
> 
> Manages the drag handle nudge during window drag from shelf to home or
> overview (which may end up in a gesture the nudge is describing).
> 
> If the contextual nudge is shown when the window drag starts, the nudge
> will not be hidden until the gesture completes (end it will get hidden
> when the gesture completes, even if the user does not end up going
> home).
> 
> If the contextual nudge is scheduled to be shown when the gesture
> starts, the show request will be canceled.
> 
> Adds logic that prevents drag handle nudge from showing up, unless it's
> a result of an explicit user action - tapping the drag handle.
> 
> BUG=1058617
> 
> Change-Id: I96fa2748308143ec42295dbfb472dc564da5bd03
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2107135
> Commit-Queue: Toni Baržić <tbarzic@chromium.org>
> Reviewed-by: Manu Cornet <manucornet@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#751200}

TBR=tbarzic@chromium.org,manucornet@chromium.org,yulunwu@chromium.org

Change-Id: I361894e79bf7bb027f690f5a6310874341d51ecf
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1058617
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2108525Reviewed-by: default avatarDan H <harringtond@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751360}
parent c09820e4
......@@ -12,7 +12,6 @@
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/ash_color_provider.h"
#include "ash/wm/overview/overview_controller.h"
#include "base/bind.h"
#include "base/debug/stack_trace.h"
#include "base/timer/timer.h"
......@@ -104,18 +103,11 @@ bool DragHandle::DoesIntersectRect(const views::View* target,
}
bool DragHandle::ShowDragHandleNudge() {
// Stop observing overview state if nudge show timer has fired.
if (!show_drag_handle_nudge_timer_.IsRunning())
overview_observer_.RemoveAll();
// Do not show drag handle nudge if it is already shown or drag handle is not
// visible.
if (ShowingNudge() || window_drag_from_shelf_in_progress_ || !GetVisible())
if (ShowingNudge() || !GetVisible())
return false;
showing_nudge_ = true;
StopDragHandleNudgeShowTimer();
PrefService* pref =
Shell::Get()->session_controller()->GetLastActiveUserPrefService();
base::TimeDelta nudge_duration = contextual_tooltip::GetNudgeTimeout(
......@@ -135,16 +127,8 @@ bool DragHandle::ShowDragHandleNudge() {
}
void DragHandle::ScheduleShowDragHandleNudge() {
if (showing_nudge_ || show_drag_handle_nudge_timer_.IsRunning() ||
window_drag_from_shelf_in_progress_ ||
Shell::Get()->overview_controller()->InOverviewSession()) {
if (showing_nudge_)
return;
}
// Observe overview controller to detect overview session start - this should
// cancel the scheduled nudge show.
overview_observer_.Add(Shell::Get()->overview_controller());
show_drag_handle_nudge_timer_.Start(
FROM_HERE, kShowNudgeDelay,
base::BindOnce(base::IgnoreResult(&DragHandle::ShowDragHandleNudge),
......@@ -157,8 +141,7 @@ void DragHandle::SetColorAndOpacity(SkColor color, float opacity) {
}
void DragHandle::HideDragHandleNudge(bool hidden_by_tap) {
StopDragHandleNudgeShowTimer();
show_drag_handle_nudge_timer_.Stop();
if (!ShowingNudge())
return;
hide_drag_handle_nudge_timer_.Stop();
......@@ -166,28 +149,6 @@ void DragHandle::HideDragHandleNudge(bool hidden_by_tap) {
showing_nudge_ = false;
}
void DragHandle::SetWindowDragFromShelfInProgress(bool gesture_in_progress) {
if (window_drag_from_shelf_in_progress_ == gesture_in_progress)
return;
window_drag_from_shelf_in_progress_ = gesture_in_progress;
// If the contextual nudge is not yet shown, make sure that any scheduled
// nudge show request is canceled.
if (!ShowingNudge()) {
StopDragHandleNudgeShowTimer();
return;
}
// If the drag handle nudge is shown when the gesture to home or overview
// starts, keep it around until the gesture completes.
if (window_drag_from_shelf_in_progress_) {
hide_drag_handle_nudge_timer_.Stop();
} else {
HideDragHandleNudge(/*hidden_by_tap=*/false);
}
}
void DragHandle::OnGestureEvent(ui::GestureEvent* event) {
if (!features::AreContextualNudgesEnabled())
return;
......@@ -219,10 +180,6 @@ gfx::Rect DragHandle::GetAnchorBoundsInScreen() const {
return anchor_bounds;
}
void DragHandle::OnOverviewModeStarting() {
StopDragHandleNudgeShowTimer();
}
void DragHandle::ShowDragHandleTooltip() {
DCHECK(!drag_handle_nudge_);
drag_handle_nudge_ = new ContextualNudge(
......@@ -294,7 +251,7 @@ void DragHandle::HideDragHandleNudgeHelper(bool hidden_by_tap) {
ui::ScopedLayerAnimationSettings opacity_animation_settings(
opacity_animator);
opacity_animation_settings.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
ui::LayerAnimator::ENQUEUE_NEW_ANIMATION);
opacity_animation_settings.SetTweenType(gfx::Tween::LINEAR);
opacity_animation_settings.SetTransitionDuration(
hidden_by_tap ? kDragHandleHideOnTapAnimationDuration
......@@ -347,9 +304,4 @@ void DragHandle::HandleTapOnNudge() {
HideDragHandleNudge(true /*hidden_by_tap*/);
}
void DragHandle::StopDragHandleNudgeShowTimer() {
show_drag_handle_nudge_timer_.Stop();
overview_observer_.RemoveAll();
}
} // namespace ash
......@@ -8,10 +8,7 @@
#include "ash/ash_export.h"
#include "ash/shelf/contextual_nudge.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/overview/overview_observer.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h"
#include "base/timer/timer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/views/view.h"
......@@ -20,8 +17,7 @@
namespace ash {
class ASH_EXPORT DragHandle : public views::View,
public views::ViewTargeterDelegate,
public OverviewObserver {
public views::ViewTargeterDelegate {
public:
explicit DragHandle(int drag_handle_corner_radius);
DragHandle(const DragHandle&) = delete;
......@@ -49,17 +45,10 @@ class ASH_EXPORT DragHandle : public views::View,
// tapping the nudge.
void HideDragHandleNudge(bool hidden_by_tap);
// Called when the window drag from shelf starts or ends. The drag handle
// contextual nudge will remain visible while the gesture is in progress.
void SetWindowDragFromShelfInProgress(bool gesture_in_progress);
// views::View:
void OnGestureEvent(ui::GestureEvent* event) override;
gfx::Rect GetAnchorBoundsInScreen() const override;
// OverviewObserver:
void OnOverviewModeStarting() override;
bool ShowingNudge() { return showing_nudge_; }
bool has_show_drag_handle_timer_for_testing() {
......@@ -74,10 +63,6 @@ class ASH_EXPORT DragHandle : public views::View,
return hide_drag_handle_nudge_timer_.IsRunning();
}
void fire_hide_drag_handle_timer_for_testing() {
hide_drag_handle_nudge_timer_.FireNow();
}
ContextualNudge* drag_handle_nudge_for_testing() {
return drag_handle_nudge_;
}
......@@ -105,9 +90,6 @@ class ASH_EXPORT DragHandle : public views::View,
// Handler for tap gesture on the contextual nudge widget. It hides the nudge.
void HandleTapOnNudge();
// Stops the timer to show the drag handle nudge.
void StopDragHandleNudgeShowTimer();
// Timer to hide drag handle nudge if it has a timed life.
base::OneShotTimer hide_drag_handle_nudge_timer_;
......@@ -116,16 +98,9 @@ class ASH_EXPORT DragHandle : public views::View,
bool showing_nudge_ = false;
// Whether window drag from shelf (i.e. gesture from in-app shelf to home or
// overview) is currently in progress. If the contextual nudge is shown when
// the gesture starts, it should remain shown until the gesture ends.
// Set by ShelfLayoutManager using SetWindowDragFromShelfInProgress().
bool window_drag_from_shelf_in_progress_ = false;
// A label used to educate users about swipe gestures on the drag handle.
ContextualNudge* drag_handle_nudge_ = nullptr;
ScopedObserver<OverviewController, OverviewObserver> overview_observer_{this};
base::WeakPtrFactory<DragHandle> weak_factory_{this};
};
......
This diff is collapsed.
......@@ -2596,8 +2596,6 @@ bool ShelfLayoutManager::MaybeStartDragWindowFromShelf(
return false;
}
shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(true);
aura::Window* window =
GetWindowForDragToHomeOrOverview(event_in_screen.location());
allow_fling_from_overview_to_home_ = !window;
......@@ -2627,8 +2625,6 @@ base::Optional<ShelfWindowDragResult> ShelfLayoutManager::MaybeEndWindowDrag(
if (!IsWindowDragInProgress())
return base::nullopt;
shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(false);
DCHECK_EQ(drag_status_, kDragInProgress);
base::Optional<float> velocity_y;
if (event_in_screen.type() == ui::ET_SCROLL_FLING_START) {
......@@ -2650,8 +2646,6 @@ bool ShelfLayoutManager::MaybeEndDragFromOverviewToHome(
return false;
}
shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(false);
if (event_in_screen.type() != ui::ET_SCROLL_FLING_START)
return false;
......@@ -2684,7 +2678,6 @@ void ShelfLayoutManager::MaybeCancelWindowDrag() {
return;
DCHECK_EQ(drag_status_, kDragInProgress);
shelf_widget_->GetDragHandle()->SetWindowDragFromShelfInProgress(false);
window_drag_controller_->CancelDrag();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment