Skip to content

Commit

Permalink
CrOS: Fix two-finger touch on shelf app icons
Browse files Browse the repository at this point in the history
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 <newcomer@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524502}
  • Loading branch information
Alex Newcomer authored and Commit Bot committed Dec 15, 2017
1 parent fe7f910 commit d6ccf92
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<const ShelfButton*>(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
Expand Down Expand Up @@ -1861,8 +1879,7 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> 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;
}
Expand Down

0 comments on commit d6ccf92

Please sign in to comment.