Index: ash/shelf/shelf_view.cc |
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc |
index b8c65bc101c8aeac9c4d8efd7ee74bc451e6d508..c78d81f4619cb160428fefccae5dc31ba109f4d8 100644 |
--- a/ash/shelf/shelf_view.cc |
+++ b/ash/shelf/shelf_view.cc |
@@ -9,6 +9,7 @@ |
#include "ash/ash_constants.h" |
#include "ash/drag_drop/drag_image_view.h" |
+#include "ash/public/cpp/config.h" |
#include "ash/public/cpp/shelf_item_delegate.h" |
#include "ash/scoped_root_window_for_new_windows.h" |
#include "ash/screen_util.h" |
@@ -464,10 +465,21 @@ void ShelfView::ButtonPressed(views::Button* sender, |
// Notify the item of its selection; handle the result in AfterItemSelected. |
const ShelfItem& item = model_->items()[last_pressed_index_]; |
+ // Mash requires conversion of mouse and touch events to pointer events. |
+ std::unique_ptr<ui::Event> passed_event = ui::Event::Clone(event); |
+ if (Shell::GetAshConfig() == Config::MASH && |
+ ui::PointerEvent::CanConvertFrom(event)) { |
+ if (event.IsMouseEvent()) |
+ passed_event = base::MakeUnique<ui::PointerEvent>(*event.AsMouseEvent()); |
+ else if (event.IsTouchEvent()) |
+ passed_event = base::MakeUnique<ui::PointerEvent>(*event.AsTouchEvent()); |
+ else |
+ NOTREACHED() << "Need conversion of event to pointer event."; |
+ } |
model_->GetShelfItemDelegate(item.id)->ItemSelected( |
- ui::Event::Clone(event), display_id, LAUNCH_FROM_UNKNOWN, |
+ ui::Event::Clone(*passed_event), display_id, LAUNCH_FROM_UNKNOWN, |
James Cook
2017/05/30 22:47:47
Can you avoid cloning the event twice? Maybe move
msw
2017/05/31 16:55:21
Done. This miserable client code is a sign of poor
|
base::Bind(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(), |
- item, sender, base::Passed(ui::Event::Clone(event)), |
+ item, sender, base::Passed(ui::Event::Clone(*passed_event)), |
ink_drop)); |
} |
@@ -1596,6 +1608,9 @@ void ShelfView::ShelfItemMoved(int start_index, int target_index) { |
AnimateToIdealBounds(); |
} |
+void ShelfView::ShelfItemDelegateChanged(const ShelfID& id, |
+ ShelfItemDelegate* delegate) {} |
+ |
void ShelfView::AfterItemSelected( |
const ShelfItem& item, |
views::Button* sender, |