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

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 2885313002: Shelf context menu should spawn at cursor position for mouse events. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_constants.h" 10 #include "ash/ash_constants.h"
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 } 1625 }
1626 } 1626 }
1627 // The menu clears |scoped_root_window_for_new_windows_| in OnMenuClosed. 1627 // The menu clears |scoped_root_window_for_new_windows_| in OnMenuClosed.
1628 if (!IsShowingMenu()) 1628 if (!IsShowingMenu())
1629 scoped_root_window_for_new_windows_.reset(); 1629 scoped_root_window_for_new_windows_.reset();
1630 } 1630 }
1631 1631
1632 void ShelfView::ShowContextMenuForView(views::View* source, 1632 void ShelfView::ShowContextMenuForView(views::View* source,
1633 const gfx::Point& point, 1633 const gfx::Point& point,
1634 ui::MenuSourceType source_type) { 1634 ui::MenuSourceType source_type) {
1635 // Align the context menu to the edge of the shelf. 1635 gfx::Point context_menu_point = point;
1636 aura::Window* shelf_window = shelf_widget_->GetNativeWindow(); 1636 // Align the context menu to the edge of the shelf for touch events.
1637 gfx::Rect shelf_bounds = 1637 if (source_type == ui::MenuSourceType::MENU_SOURCE_TOUCH) {
1638 is_overflow_mode() 1638 aura::Window* shelf_window = shelf_widget_->GetNativeWindow();
1639 ? owner_overflow_bubble_->bubble_view()->GetBubbleBounds() 1639 gfx::Rect shelf_bounds =
1640 : ScreenUtil::GetDisplayBoundsWithShelf(shelf_window); 1640 is_overflow_mode()
1641 ? owner_overflow_bubble_->bubble_view()->GetBubbleBounds()
1642 : ScreenUtil::GetDisplayBoundsWithShelf(shelf_window);
1641 1643
1642 gfx::Point context_menu_point; 1644 switch (wm_shelf_->GetAlignment()) {
1643 switch (wm_shelf_->GetAlignment()) { 1645 case SHELF_ALIGNMENT_BOTTOM:
1644 case SHELF_ALIGNMENT_BOTTOM: 1646 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
1645 case SHELF_ALIGNMENT_BOTTOM_LOCKED: 1647 context_menu_point.SetPoint(point.x(),
1646 context_menu_point.SetPoint(point.x(), 1648 shelf_bounds.bottom() - kShelfSize);
1647 shelf_bounds.bottom() - kShelfSize); 1649 break;
1648 break; 1650 case SHELF_ALIGNMENT_LEFT:
1649 case SHELF_ALIGNMENT_LEFT: 1651 context_menu_point.SetPoint(shelf_bounds.x() + kShelfSize, point.y());
1650 context_menu_point.SetPoint(shelf_bounds.x() + kShelfSize, point.y()); 1652 break;
1651 break; 1653 case SHELF_ALIGNMENT_RIGHT:
1652 case SHELF_ALIGNMENT_RIGHT: 1654 context_menu_point.SetPoint(shelf_bounds.right() - kShelfSize,
1653 context_menu_point.SetPoint(shelf_bounds.right() - kShelfSize, point.y()); 1655 point.y());
1654 break; 1656 break;
1657 }
1655 } 1658 }
1656 last_pressed_index_ = -1; 1659 last_pressed_index_ = -1;
1657 1660
1658 const ShelfItem* item = ShelfItemForView(source); 1661 const ShelfItem* item = ShelfItemForView(source);
1659 if (!item) { 1662 if (!item) {
1660 ShellPort::Get()->ShowContextMenu(context_menu_point, source_type); 1663 ShellPort::Get()->ShowContextMenu(context_menu_point, source_type);
1661 return; 1664 return;
1662 } 1665 }
1663 1666
1664 std::unique_ptr<ui::MenuModel> context_menu_model( 1667 std::unique_ptr<ui::MenuModel> context_menu_model(
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 if (pointer == TOUCH && 1825 if (pointer == TOUCH &&
1823 (base::TimeTicks::Now() - touch_press_time_) < 1826 (base::TimeTicks::Now() - touch_press_time_) <
1824 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) { 1827 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) {
1825 return false; 1828 return false;
1826 } 1829 }
1827 1830
1828 return true; 1831 return true;
1829 } 1832 }
1830 1833
1831 } // namespace ash 1834 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698