Chromium Code Reviews| Index: ash/shelf/shelf_view.cc |
| diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc |
| index 5ab343329e7077c3761a20c9b8b526df0e6378c2..afc867f919ddf000a5feb9bb8a93943a65552171 100644 |
| --- a/ash/shelf/shelf_view.cc |
| +++ b/ash/shelf/shelf_view.cc |
| @@ -43,6 +43,7 @@ |
| #include "ui/views/animation/bounds_animator.h" |
| #include "ui/views/border.h" |
| #include "ui/views/controls/button/image_button.h" |
| +#include "ui/views/controls/menu/menu_controller.h" |
| #include "ui/views/controls/menu/menu_model_adapter.h" |
| #include "ui/views/controls/menu/menu_runner.h" |
| #include "ui/views/focus/focus_search.h" |
| @@ -642,6 +643,8 @@ bool ShelfView::ShouldEventActivateButton(View* view, const ui::Event& event) { |
| void ShelfView::PointerPressedOnButton(views::View* view, |
| Pointer pointer, |
| const ui::LocatedEvent& event) { |
| + if (IsShowingMenu()) |
| + launcher_menu_runner_->Cancel(); |
| if (drag_view_) |
| return; |
| @@ -1656,7 +1659,8 @@ void ShelfView::ShowContextMenuForView(views::View* source, |
| last_pressed_index_ = -1; |
| const ShelfItem* item = ShelfItemForView(source); |
| - if (!item) { |
| + int index = view_model_->GetIndexOfView(source); |
| + if (index == 0 || !item) { |
|
xiyuan
2017/05/15 19:20:52
Why we need to include |index| == 0? Can you docum
minch1
2017/05/15 22:16:34
This is for the launcher icon (the first item in t
xiyuan
2017/05/15 22:41:10
It is more accurate to check |item| type than the
minch1
2017/05/16 22:13:38
Done.
|
| ShellPort::Get()->ShowContextMenu(context_menu_point, source_type); |
| return; |
| } |
| @@ -1731,6 +1735,9 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model, |
| menu_alignment = views::MENU_ANCHOR_FIXED_SIDECENTER; |
| } |
| + // No dragging if shelf is autohide. |
| + if (wm_shelf()->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_NEVER) |
| + views::MenuController::SetDoCancel(false); |
| // NOTE: if you convert to HAS_MNEMONICS be sure to update menu building code. |
| launcher_menu_runner_->RunMenuAt(source->GetWidget(), nullptr, anchor, |
| menu_alignment, source_type); |
| @@ -1739,10 +1746,6 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model, |
| void ShelfView::OnMenuClosed(views::InkDrop* ink_drop) { |
| context_menu_id_ = ShelfID(); |
| - // Hide the hide overflow bubble after showing a context menu for its items. |
| - if (owner_overflow_bubble_) |
| - owner_overflow_bubble_->Hide(); |
| - |
| closing_event_time_ = launcher_menu_runner_->closing_event_time(); |
| if (ink_drop) |