From d6ccf92831784c2a3e06f5001ceb3c73c557f77b Mon Sep 17 00:00:00 2001 From: Alex Newcomer Date: Fri, 15 Dec 2017 22:55:16 +0000 Subject: [PATCH] CrOS: Fix two-finger touch on shelf app icons The bug is that after two-finger tapping on an app icon in the shelf, the shelf sometimes becomes unresponsive. This was caused by logic that assumed we wanted to forward all gesture events when the context menu was created with a gesture event. This is fixed by adding a check to see if we are actually dragging an app icon before asking MenuRunner to send events to owner. TEST=manual Bug: 794681 Change-Id: Ib2b764126874f9fd58578a1610a70e2c7881ff78 Reviewed-on: https://chromium-review.googlesource.com/828293 Commit-Queue: Alex Newcomer Reviewed-by: Xiyuan Xia Cr-Commit-Position: refs/heads/master@{#524502} --- ash/shelf/shelf_view.cc | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index 898dbf09848e2a..9019a482a49548 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -202,6 +202,24 @@ int64_t GetDisplayIdForView(View* view) { return display::Screen::GetScreen()->GetDisplayNearestWindow(window).id(); } +// Whether |item_view| is a ShelfButton and its state is STATE_DRAGGING. +bool ShelfButtonIsInDrag(const ShelfItemType item_type, + const views::View* item_view) { + switch (item_type) { + case TYPE_PINNED_APP: + case TYPE_BROWSER_SHORTCUT: + case TYPE_APP: + return static_cast(item_view)->state() & + ShelfButton::STATE_DRAGGING; + case TYPE_DIALOG: + case TYPE_APP_PANEL: + case TYPE_BACK_BUTTON: + case TYPE_APP_LIST: + case TYPE_UNDEFINED: + return false; + } +} + } // namespace // AnimationDelegate used when deleting an item. This steadily decreased the @@ -1861,8 +1879,7 @@ void ShelfView::ShowMenu(std::unique_ptr menu_model, // Only selected shelf items with context menu opened can be dragged. const ShelfItem* item = ShelfItemForView(source); - if (context_menu && item && item->type != TYPE_APP_LIST && - item->type != TYPE_BACK_BUTTON && + if (context_menu && item && ShelfButtonIsInDrag(item->type, source) && source_type == ui::MenuSourceType::MENU_SOURCE_TOUCH) { run_types |= views::MenuRunner::SEND_GESTURE_EVENTS_TO_OWNER; }