Commit d6ccf928 authored by Alex Newcomer's avatar Alex Newcomer Committed by Commit Bot

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 <newcomer@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#524502}
parent fe7f9100
...@@ -202,6 +202,24 @@ int64_t GetDisplayIdForView(View* view) { ...@@ -202,6 +202,24 @@ int64_t GetDisplayIdForView(View* view) {
return display::Screen::GetScreen()->GetDisplayNearestWindow(window).id(); 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 } // namespace
// AnimationDelegate used when deleting an item. This steadily decreased the // AnimationDelegate used when deleting an item. This steadily decreased the
...@@ -1861,8 +1879,7 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model, ...@@ -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. // Only selected shelf items with context menu opened can be dragged.
const ShelfItem* item = ShelfItemForView(source); const ShelfItem* item = ShelfItemForView(source);
if (context_menu && item && item->type != TYPE_APP_LIST && if (context_menu && item && ShelfButtonIsInDrag(item->type, source) &&
item->type != TYPE_BACK_BUTTON &&
source_type == ui::MenuSourceType::MENU_SOURCE_TOUCH) { source_type == ui::MenuSourceType::MENU_SOURCE_TOUCH) {
run_types |= views::MenuRunner::SEND_GESTURE_EVENTS_TO_OWNER; run_types |= views::MenuRunner::SEND_GESTURE_EVENTS_TO_OWNER;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment