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

Unified Diff: ash/shelf/shelf_view.cc

Issue 772963002: Make the second click on the app shelf icon close the window-list bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename the variable and add some comments. Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: ash/shelf/shelf_view.cc
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index c1774e56f0daed084efc866b40e8895b05562faa..2cf0ddf3edca17d7afb3981c975b994e30745e83 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -389,7 +389,9 @@ ShelfView::ShelfView(ShelfModel* model,
layout_manager_(manager),
overflow_mode_(false),
main_shelf_(NULL),
- dragged_off_from_overflow_to_shelf_(false) {
+ dragged_off_from_overflow_to_shelf_(false),
+ is_repost_event_(false),
+ last_index_at_repost_(-1) {
DCHECK(model_);
bounds_animator_.reset(new views::BoundsAnimator(this));
bounds_animator_->AddObserver(this);
@@ -1571,6 +1573,9 @@ void ShelfView::PointerPressedOnButton(views::View* view,
if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable())
return; // View is being deleted or not draggable, ignore request.
+ if (IsRepostEvent(event))
+ is_repost_event_ = true;
Mr4D (OOO till 08-26) 2014/12/05 20:57:13 As stated above: You might want to do is_repost_e
+
CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
drag_view_ = static_cast<ShelfButton*>(view);
drag_origin_ = gfx::Point(event.x(), event.y());
@@ -1663,10 +1668,18 @@ void ShelfView::ButtonPressed(views::Button* sender, const ui::Event& event) {
if (view_index == -1)
return;
- // If the previous menu was closed by the same event as this one, we ignore
- // the call.
- if (!IsUsableEvent(event))
+ // If the menu was just closed by the same event as this one, we ignore
+ // the call and don't open the menu again. See crbug.com/343005 for more
+ // detail.
+ if (is_repost_event_ && (view_index == last_index_at_repost_)) {
Mr4D (OOO till 08-26) 2014/12/05 20:57:13 line 1674 - 1683 could then be replaced with this:
+ is_repost_event_ = false;
return;
+ }
+
+ // Reset the |is_repost_event_ | to false and record the
+ // |last_index_at_repost_|.
+ is_repost_event_ = false;
+ last_index_at_repost_ = view_index;
// Don't activate the item twice on double-click. Otherwise the window starts
// animating open due to the first click, then immediately minimizes due to
@@ -1877,16 +1890,16 @@ void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
}
}
-bool ShelfView::IsUsableEvent(const ui::Event& event) {
+bool ShelfView::IsRepostEvent(const ui::Event& event) {
if (closing_event_time_ == base::TimeDelta())
- return true;
+ return false;
base::TimeDelta delta =
base::TimeDelta(event.time_stamp() - closing_event_time_);
closing_event_time_ = base::TimeDelta();
- // TODO(skuhne): This time seems excessive, but it appears that the reposting
- // takes that long. Need to come up with a better way of doing this.
- return (delta.InMilliseconds() < 0 || delta.InMilliseconds() > 130);
+ // If the current (press down) event is a repost event, the time stamp of
+ // these two events should be the same.
+ return (delta.InMilliseconds() == 0);
}
const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const {

Powered by Google App Engine
This is Rietveld 408576698