Chromium Code Reviews| Index: ash/shelf/shelf_view.cc |
| diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc |
| index d2de17bb6a394191b941af37f8896dd32f8b07f3..4ce221b29ffb836818e22ea633efbf7172624f68 100644 |
| --- a/ash/shelf/shelf_view.cc |
| +++ b/ash/shelf/shelf_view.cc |
| @@ -11,6 +11,7 @@ |
| #include "ash/drag_drop/drag_image_view.h" |
| #include "ash/public/cpp/shelf_item_delegate.h" |
| #include "ash/scoped_root_window_for_new_windows.h" |
| +#include "ash/screen_util.h" |
| #include "ash/shelf/app_list_button.h" |
| #include "ash/shelf/overflow_bubble.h" |
| #include "ash/shelf/overflow_bubble_view.h" |
| @@ -1639,11 +1640,32 @@ void ShelfView::AfterItemSelected( |
| void ShelfView::ShowContextMenuForView(views::View* source, |
| const gfx::Point& point, |
| ui::MenuSourceType source_type) { |
| + // Align the context menu to the edge of the shelf. |
| + aura::Window* shelf_window = shelf_widget_->GetNativeWindow(); |
| + gfx::Rect shelf_bounds = |
| + is_overflow_mode() |
| + ? (owner_overflow_bubble_->bubble_view()->GetBubbleBounds()) |
|
msw
2017/05/10 22:18:22
nit: extra parens not needed here or on the next l
msw
2017/05/11 17:13:39
Just FYI, I would appreciate it if you respond to
|
| + : (ScreenUtil::GetDisplayBoundsWithShelf(shelf_window)); |
| + |
| + gfx::Point context_menu_point; |
| + switch (wm_shelf_->GetAlignment()) { |
| + case SHELF_ALIGNMENT_BOTTOM: |
| + case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| + context_menu_point.SetPoint(point.x(), |
| + shelf_bounds.bottom() - kShelfSize); |
| + break; |
| + case SHELF_ALIGNMENT_LEFT: |
| + context_menu_point.SetPoint(shelf_bounds.x() + kShelfSize, point.y()); |
| + break; |
| + case SHELF_ALIGNMENT_RIGHT: |
| + context_menu_point.SetPoint(shelf_bounds.right() - kShelfSize, point.y()); |
| + break; |
| + } |
| last_pressed_index_ = -1; |
| const ShelfItem* item = ShelfItemForView(source); |
| if (!item) { |
| - ShellPort::Get()->ShowContextMenu(point, source_type); |
| + ShellPort::Get()->ShowContextMenu(context_menu_point, source_type); |
| return; |
| } |
| @@ -1653,8 +1675,8 @@ void ShelfView::ShowContextMenuForView(views::View* source, |
| return; |
| context_menu_id_ = item ? item->id : ShelfID(); |
| - ShowMenu(std::move(context_menu_model), source, point, true, source_type, |
| - nullptr); |
| + ShowMenu(std::move(context_menu_model), source, context_menu_point, true, |
| + source_type, nullptr); |
| } |
| void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model, |
| @@ -1671,7 +1693,8 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model, |
| closing_event_time_ = base::TimeTicks(); |
| int run_types = 0; |
| if (context_menu) |
| - run_types |= views::MenuRunner::CONTEXT_MENU; |
| + run_types |= |
| + views::MenuRunner::CONTEXT_MENU | views::MenuRunner::SHELF_CONTEXT_MENU; |
| launcher_menu_runner_.reset( |
| new views::MenuRunner(menu_model_adapter_->CreateMenu(), run_types)); |
| @@ -1709,6 +1732,13 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model, |
| } |
| } |
| + // Distinguish the touch events that triggered on the bottom shelf or |
|
msw
2017/05/10 22:18:22
Should this be clobbering the |menu_alignment| val
minch1
2017/05/11 16:34:02
Oh, here will reassign the menu_alignment if |if(!
msw
2017/05/11 17:13:39
aside: it'd be nice if UX wanted both menus to loo
|
| + // left / right shelf. Since they should have different |MenuAnchorPosition|. |
| + if (wm_shelf_->IsHorizontalAlignment()) |
| + menu_alignment = views::MENU_ANCHOR_FIXED_BOTTOMCENTER; |
| + else |
| + menu_alignment = views::MENU_ANCHOR_SIDECENTER; |
| + |
| // 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); |
| @@ -1795,7 +1825,7 @@ bool ShelfView::CanPrepareForDrag(Pointer pointer, |
| return false; |
| } |
| - // Touch dragging only begins after a dealy from the press event. This |
| + // Touch dragging only begins after a delay from the press event. This |
| // prevents accidental dragging on swipe or scroll gestures. |
| if (pointer == TOUCH && |
| (base::TimeTicks::Now() - touch_press_time_) < |