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

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: Compare the time stamp when the mouse is pressed down. 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..9368ba11c54a29b9c0213de4b6dadde00e1a0e14 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_usable_event_(true),
+ last_view_index_(-1) {
DCHECK(model_);
bounds_animator_.reset(new views::BoundsAnimator(this));
bounds_animator_->AddObserver(this);
@@ -1571,6 +1573,10 @@ 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 (!IsUsableEvent(event)) {
Mr4D (OOO till 08-26) 2014/12/05 15:21:47 No {}'s
Mr4D (OOO till 08-26) 2014/12/05 15:21:47 Aha! Nice find! Yes, this is much better then the
+ is_usable_event_ = false;
+ }
+
CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
drag_view_ = static_cast<ShelfButton*>(view);
drag_origin_ = gfx::Point(event.x(), event.y());
@@ -1663,10 +1669,16 @@ 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. See crbug.com/343005 for more detail.
+ if (!is_usable_event_ && (view_index == last_view_index_)) {
Mr4D (OOO till 08-26) 2014/12/05 15:21:47 The index does not need to be checked since we are
xdai1 2014/12/05 19:01:46 I think we still need to check the index because o
+ is_usable_event_ = true;
return;
+ }
+
+ // Reset the |is_usable_event_| to true and record the |view_index|.
+ is_usable_event_ = true;
+ last_view_index_ = 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
@@ -1884,9 +1896,9 @@ bool ShelfView::IsUsableEvent(const ui::Event& event) {
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 reposted event, the time stamp of
+ // these two events should be the same.
+ return (delta.InMilliseconds() != 0);
Mr4D (OOO till 08-26) 2014/12/05 15:21:47 Ahhhh! Much better!
}
const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const {

Powered by Google App Engine
This is Rietveld 408576698