Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2769)

Unified Diff: ash/shelf/shelf_view.cc

Issue 2876203003: Make shelf item can be dragged when context menu is opened.
Patch Set: Add widget observer for |owner_| in MenuHost. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_view.cc
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index 57bd5dc89af7ac9cf31b8da3cc8ba18cffb9d1c3..c27f310311eaef515f4fce3cf0f22521f624b85d 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -672,6 +672,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;
@@ -1733,6 +1735,7 @@ void ShelfView::AfterItemSelected(
void ShelfView::AfterGetContextMenuItems(
const ShelfID& shelf_id,
const gfx::Point& point,
+ views::View* source,
ui::MenuSourceType source_type,
std::vector<mojom::MenuItemPtr> menu_items) {
context_menu_id_ = shelf_id;
@@ -1740,7 +1743,7 @@ void ShelfView::AfterGetContextMenuItems(
ShowMenu(base::MakeUnique<ShelfContextMenuModel>(
std::move(menu_items), model_->GetShelfItemDelegate(shelf_id),
display_id),
- nullptr /* source */, point, true /* context_menu */, source_type,
+ source, point, true /* context_menu */, source_type,
nullptr /* ink_drop */);
}
@@ -1788,7 +1791,7 @@ void ShelfView::ShowContextMenuForView(views::View* source,
model_->GetShelfItemDelegate(item->id)->GetContextMenuItems(
display_id, base::Bind(&ShelfView::AfterGetContextMenuItems,
weak_factory_.GetWeakPtr(), item->id,
- context_menu_point, source_type));
+ context_menu_point, source, source_type));
}
void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model,
@@ -1807,6 +1810,15 @@ void ShelfView::ShowMenu(std::unique_ptr<ui::MenuModel> menu_model,
if (context_menu)
run_types |=
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::FIXED_ANCHOR;
+
+ // Selected shelf items with context menu opened can only be dragged if the
+ // shelf is not in auto-hide.
+ const ShelfItem* item = ShelfItemForView(source);
+ if (context_menu && item && item->type != TYPE_APP_LIST &&
+ shelf()->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_NEVER) {
+ run_types |= views::MenuRunner::SEND_GESTURE_EVENTS_TO_OWNER;
+ }
+
launcher_menu_runner_.reset(
new views::MenuRunner(menu_model_adapter_->CreateMenu(), run_types));
@@ -1860,10 +1872,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)
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698