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..35a407758b9675de8485ae89415cb7637095e966 100644 |
--- a/ash/system/tray/system_tray.cc |
+++ b/ash/system/tray/system_tray.cc |
@@ -200,6 +200,8 @@ class SystemTray::ActivationObserver : public ::wm::ActivationChangeObserver { |
SystemTray::SystemTray(Shelf* shelf) |
: TrayBackgroundView(shelf), shelf_(shelf) { |
+ target_view_ = this; |
+ |
SetInkDropMode(InkDropMode::ON); |
// Since user avatar is on the right hand side of System tray of a |
@@ -601,6 +603,12 @@ void SystemTray::HideBubble(const TrayBubbleView* bubble_view) { |
HideBubbleWithView(bubble_view); |
} |
+bool SystemTray::ProcessGestureEventOnBubbleView(ui::GestureEvent* event, |
+ View* target) { |
+ target_view_ = target; |
+ return ProcessGestureEvent(*event); |
+} |
+ |
void SystemTray::CloseBubble(const ui::KeyEvent& key_event) { |
CloseSystemBubble(); |
} |
@@ -625,14 +633,11 @@ void SystemTray::ActivateBubble() { |
} |
void SystemTray::OnGestureEvent(ui::GestureEvent* event) { |
- if (Shell::Get() |
- ->maximize_mode_controller() |
- ->IsMaximizeModeWindowManagerEnabled() && |
- shelf_->IsHorizontalAlignment() && ProcessGestureEvent(*event)) { |
+ target_view_ = this; |
+ if (ProcessGestureEvent(*event)) |
event->SetHandled(); |
- } else { |
+ else |
TrayBackgroundView::OnGestureEvent(event); |
- } |
} |
gfx::Rect SystemTray::GetWorkAreaBoundsInScreen() const { |
@@ -654,6 +659,13 @@ bool SystemTray::PerformAction(const ui::Event& event) { |
} |
bool SystemTray::ProcessGestureEvent(const ui::GestureEvent& event) { |
+ if (!Shell::Get() |
+ ->maximize_mode_controller() |
+ ->IsMaximizeModeWindowManagerEnabled() || |
+ !shelf_->IsHorizontalAlignment()) { |
+ return false; |
+ } |
+ |
if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) |
return StartGestureDrag(event); |
@@ -678,21 +690,25 @@ 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 (target_view_ == this) { |
+ // 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()); |
@@ -717,14 +733,14 @@ void SystemTray::CompleteGestureDrag(const ui::GestureEvent& gesture) { |
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()); |
+ View::ConvertPointToScreen(target_view_, &location_in_screen_coordinates); |
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 = (target_view_ == this ? shelf_->GetIdealBounds().y() |
+ : system_tray_bubble_bounds_.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,8 +755,13 @@ 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. |
- return -gesture_drag_amount_ >= system_tray_bubble_bounds_.height() / 3.0; |
+ |
+ // Keep the bubble's original status if the |gesture_drag_amount_| doesn't |
+ // exceed one-third of the bubble's height. |
+ if (target_view_ == this) |
+ return -gesture_drag_amount_ >= system_tray_bubble_bounds_.height() / 3.0; |
+ else |
+ return gesture_drag_amount_ < system_tray_bubble_bounds_.height() / 3.0; |
sammiequon
2017/06/29 21:28:19
nit:
if (target_view == this)
return ...;
retu
minch1
2017/06/30 17:02:29
Done.
|
} |
void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() { |