| Index: ash/system/tray/system_tray.cc
|
| diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
|
| index 77cc0342a6314dd3407551084dad72d4ab6c3cc1..1c4ae5a976e22747b3a8f61917aa8ac4d3b52bb1 100644
|
| --- a/ash/system/tray/system_tray.cc
|
| +++ b/ash/system/tray/system_tray.cc
|
| @@ -625,14 +625,10 @@ void SystemTray::ActivateBubble() {
|
| }
|
|
|
| void SystemTray::OnGestureEvent(ui::GestureEvent* event) {
|
| - if (Shell::Get()
|
| - ->maximize_mode_controller()
|
| - ->IsMaximizeModeWindowManagerEnabled() &&
|
| - shelf_->IsHorizontalAlignment() && ProcessGestureEvent(*event)) {
|
| + if (ProcessGestureEvent(*event, false /* is_on_bubble */))
|
| event->SetHandled();
|
| - } else {
|
| + else
|
| TrayBackgroundView::OnGestureEvent(event);
|
| - }
|
| }
|
|
|
| gfx::Rect SystemTray::GetWorkAreaBoundsInScreen() const {
|
| @@ -653,7 +649,17 @@ bool SystemTray::PerformAction(const ui::Event& event) {
|
| return true;
|
| }
|
|
|
| -bool SystemTray::ProcessGestureEvent(const ui::GestureEvent& event) {
|
| +bool SystemTray::ProcessGestureEvent(const ui::GestureEvent& event,
|
| + bool is_on_bubble) {
|
| + if (!Shell::Get()
|
| + ->maximize_mode_controller()
|
| + ->IsMaximizeModeWindowManagerEnabled() ||
|
| + !shelf_->IsHorizontalAlignment()) {
|
| + return false;
|
| + }
|
| +
|
| + // Set |is_on_bubble_| before process the events.
|
| + is_on_bubble_ = is_on_bubble;
|
| if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN)
|
| return StartGestureDrag(event);
|
|
|
| @@ -678,29 +684,33 @@ bool SystemTray::ProcessGestureEvent(const ui::GestureEvent& event) {
|
| }
|
|
|
| bool SystemTray::StartGestureDrag(const ui::GestureEvent& gesture) {
|
| - // Close the system bubble if there is already a full one opened. And return
|
| - // false to let shelf handle the event.
|
| - if (HasSystemBubble() && full_system_tray_menu_) {
|
| - system_bubble_->bubble()->Close();
|
| - return false;
|
| - }
|
| + if (!is_on_bubble_) {
|
| + // Dragging happens on the system tray. Close the system bubble if there is
|
| + // already a full one opened. And return false to let shelf handle the
|
| + // event.
|
| + if (HasSystemBubble() && full_system_tray_menu_) {
|
| + system_bubble_->bubble()->Close();
|
| + return false;
|
| + }
|
|
|
| - // If the scroll sequence begins to scroll downward, return false so that the
|
| - // event will instead by handled by the shelf.
|
| - if (gesture.details().scroll_y_hint() > 0)
|
| - return false;
|
| + // If the scroll sequence begins to scroll downward, return false so that
|
| + // the event will instead by handled by the shelf.
|
| + if (gesture.details().scroll_y_hint() > 0)
|
| + return false;
|
| +
|
| + ShowDefaultView(BUBBLE_CREATE_NEW);
|
| + }
|
|
|
| is_in_drag_ = true;
|
| gesture_drag_amount_ = 0.f;
|
| - ShowDefaultView(BUBBLE_CREATE_NEW);
|
| system_tray_bubble_bounds_ =
|
| system_bubble_->bubble_view()->GetWidget()->GetWindowBoundsInScreen();
|
| - SetBubbleBounds(gesture.location());
|
| + UpdateBubbleBounds();
|
| return true;
|
| }
|
|
|
| void SystemTray::UpdateGestureDrag(const ui::GestureEvent& gesture) {
|
| - SetBubbleBounds(gesture.location());
|
| + UpdateBubbleBounds();
|
| gesture_drag_amount_ += gesture.details().scroll_y();
|
| }
|
|
|
| @@ -715,16 +725,13 @@ void SystemTray::CompleteGestureDrag(const ui::GestureEvent& gesture) {
|
| is_in_drag_ = false;
|
| }
|
|
|
| -void SystemTray::SetBubbleBounds(const gfx::Point& location) {
|
| - gfx::Point location_in_screen_coordinates(location);
|
| - View::ConvertPointToScreen(this, &location_in_screen_coordinates);
|
| -
|
| - // System tray bubble should not be dragged higher than its original height.
|
| - if (location_in_screen_coordinates.y() < system_tray_bubble_bounds_.y())
|
| - location_in_screen_coordinates.set_y(system_tray_bubble_bounds_.y());
|
| -
|
| +void SystemTray::UpdateBubbleBounds() {
|
| gfx::Rect bounds_on_location = system_tray_bubble_bounds_;
|
| - bounds_on_location.set_y(location_in_screen_coordinates.y());
|
| + // System tray bubble should not be dragged higher than its original height.
|
| + int bounds_y = (is_on_bubble_ ? system_tray_bubble_bounds_.y()
|
| + : shelf_->GetIdealBounds().y()) +
|
| + gesture_drag_amount_;
|
| + bounds_on_location.set_y(std::max(bounds_y, system_tray_bubble_bounds_.y()));
|
| system_bubble_->bubble_view()->GetWidget()->SetBounds(bounds_on_location);
|
| }
|
|
|
| @@ -739,7 +746,11 @@ bool SystemTray::ShouldShowSystemBubbleAfterScrollSequence(
|
|
|
| DCHECK(sequence_end.type() == ui::ET_GESTURE_SCROLL_END ||
|
| sequence_end.type() == ui::ET_SCROLL_FLING_START);
|
| - // Show the system menu if it is already at least one-third visible.
|
| +
|
| + // Keep the bubble's original state if the |gesture_drag_amount_| doesn't
|
| + // exceed one-third of the bubble's height.
|
| + if (is_on_bubble_)
|
| + return gesture_drag_amount_ < system_tray_bubble_bounds_.height() / 3.0;
|
| return -gesture_drag_amount_ >= system_tray_bubble_bounds_.height() / 3.0;
|
| }
|
|
|
|
|