| OLD | NEW |
| 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 // PointerWatcher functionality. | 422 // PointerWatcher functionality. |
| 423 ShelfView* shelf_view = main_shelf_ ? main_shelf_ : this; | 423 ShelfView* shelf_view = main_shelf_ ? main_shelf_ : this; |
| 424 if (shelf_view->IsShowingOverflowBubble()) | 424 if (shelf_view->IsShowingOverflowBubble()) |
| 425 shelf_view->ToggleOverflowBubble(); | 425 shelf_view->ToggleOverflowBubble(); |
| 426 | 426 |
| 427 // Record the index for the last pressed shelf item. | 427 // Record the index for the last pressed shelf item. |
| 428 last_pressed_index_ = view_model_->GetIndexOfView(sender); | 428 last_pressed_index_ = view_model_->GetIndexOfView(sender); |
| 429 DCHECK_LT(-1, last_pressed_index_); | 429 DCHECK_LT(-1, last_pressed_index_); |
| 430 | 430 |
| 431 // Place new windows on the same display as the button. | 431 // Place new windows on the same display as the button. |
| 432 WmWindow* window = WmWindow::Get(sender->GetWidget()->GetNativeWindow()); | 432 aura::Window* window = sender->GetWidget()->GetNativeWindow(); |
| 433 scoped_root_window_for_new_windows_.reset( | 433 scoped_root_window_for_new_windows_.reset( |
| 434 new ScopedRootWindowForNewWindows(window->GetRootWindow())); | 434 new ScopedRootWindowForNewWindows(window->GetRootWindow())); |
| 435 | 435 |
| 436 // Slow down activation animations if shift key is pressed. | 436 // Slow down activation animations if shift key is pressed. |
| 437 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations; | 437 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations; |
| 438 if (event.IsShiftDown()) { | 438 if (event.IsShiftDown()) { |
| 439 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( | 439 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( |
| 440 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); | 440 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); |
| 441 } | 441 } |
| 442 | 442 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 455 | 455 |
| 456 case TYPE_APP_PANEL: | 456 case TYPE_APP_PANEL: |
| 457 case TYPE_DIALOG: | 457 case TYPE_DIALOG: |
| 458 break; | 458 break; |
| 459 | 459 |
| 460 case TYPE_UNDEFINED: | 460 case TYPE_UNDEFINED: |
| 461 NOTREACHED() << "ShelfItemType must be set."; | 461 NOTREACHED() << "ShelfItemType must be set."; |
| 462 break; | 462 break; |
| 463 } | 463 } |
| 464 | 464 |
| 465 const int64_t display_id = window->GetDisplayNearestWindow().id(); | 465 const int64_t display_id = |
| 466 display::Screen::GetScreen()->GetDisplayNearestWindow(window).id(); |
| 466 | 467 |
| 467 // Notify the item of its selection; handle the result in AfterItemSelected. | 468 // Notify the item of its selection; handle the result in AfterItemSelected. |
| 468 const ShelfItem& item = model_->items()[last_pressed_index_]; | 469 const ShelfItem& item = model_->items()[last_pressed_index_]; |
| 469 model_->GetShelfItemDelegate(item.id)->ItemSelected( | 470 model_->GetShelfItemDelegate(item.id)->ItemSelected( |
| 470 ui::Event::Clone(event), display_id, LAUNCH_FROM_UNKNOWN, | 471 ui::Event::Clone(event), display_id, LAUNCH_FROM_UNKNOWN, |
| 471 base::Bind(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(), | 472 base::Bind(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(), |
| 472 item, sender, base::Passed(ui::Event::Clone(event)), | 473 item, sender, base::Passed(ui::Event::Clone(event)), |
| 473 ink_drop)); | 474 ink_drop)); |
| 474 } | 475 } |
| 475 | 476 |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 | 1688 |
| 1688 closing_event_time_ = base::TimeTicks(); | 1689 closing_event_time_ = base::TimeTicks(); |
| 1689 int run_types = 0; | 1690 int run_types = 0; |
| 1690 if (context_menu) | 1691 if (context_menu) |
| 1691 run_types |= | 1692 run_types |= |
| 1692 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::FIXED_ANCHOR; | 1693 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::FIXED_ANCHOR; |
| 1693 launcher_menu_runner_.reset( | 1694 launcher_menu_runner_.reset( |
| 1694 new views::MenuRunner(menu_model_adapter_->CreateMenu(), run_types)); | 1695 new views::MenuRunner(menu_model_adapter_->CreateMenu(), run_types)); |
| 1695 | 1696 |
| 1696 // Place new windows on the same display as the button that spawned the menu. | 1697 // Place new windows on the same display as the button that spawned the menu. |
| 1697 WmWindow* window = WmWindow::Get(source->GetWidget()->GetNativeWindow()); | 1698 aura::Window* window = source->GetWidget()->GetNativeWindow(); |
| 1698 scoped_root_window_for_new_windows_.reset( | 1699 scoped_root_window_for_new_windows_.reset( |
| 1699 new ScopedRootWindowForNewWindows(window->GetRootWindow())); | 1700 new ScopedRootWindowForNewWindows(window->GetRootWindow())); |
| 1700 | 1701 |
| 1701 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; | 1702 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; |
| 1702 gfx::Rect anchor = gfx::Rect(click_point, gfx::Size()); | 1703 gfx::Rect anchor = gfx::Rect(click_point, gfx::Size()); |
| 1703 | 1704 |
| 1704 if (!context_menu) { | 1705 if (!context_menu) { |
| 1705 // Application lists use a bubble. | 1706 // Application lists use a bubble. |
| 1706 // It is possible to invoke the menu while it is sliding into view. To cover | 1707 // It is possible to invoke the menu while it is sliding into view. To cover |
| 1707 // that case, the screen coordinates are offsetted by the animation delta. | 1708 // that case, the screen coordinates are offsetted by the animation delta. |
| 1708 anchor = source->GetBoundsInScreen() + (window->GetTargetBounds().origin() - | 1709 anchor = source->GetBoundsInScreen() + |
| 1709 window->GetBounds().origin()); | 1710 (window->GetTargetBounds().origin() - window->bounds().origin()); |
| 1710 | 1711 |
| 1711 // Adjust the anchor location for shelf items with asymmetrical borders. | 1712 // Adjust the anchor location for shelf items with asymmetrical borders. |
| 1712 if (source->border()) | 1713 if (source->border()) |
| 1713 anchor.Inset(source->border()->GetInsets()); | 1714 anchor.Inset(source->border()->GetInsets()); |
| 1714 | 1715 |
| 1715 // Determine the menu alignment dependent on the shelf. | 1716 // Determine the menu alignment dependent on the shelf. |
| 1716 switch (wm_shelf_->GetAlignment()) { | 1717 switch (wm_shelf_->GetAlignment()) { |
| 1717 case SHELF_ALIGNMENT_BOTTOM: | 1718 case SHELF_ALIGNMENT_BOTTOM: |
| 1718 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 1719 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
| 1719 menu_alignment = views::MENU_ANCHOR_BUBBLE_ABOVE; | 1720 menu_alignment = views::MENU_ANCHOR_BUBBLE_ABOVE; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1825 if (pointer == TOUCH && | 1826 if (pointer == TOUCH && |
| 1826 (base::TimeTicks::Now() - touch_press_time_) < | 1827 (base::TimeTicks::Now() - touch_press_time_) < |
| 1827 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) { | 1828 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) { |
| 1828 return false; | 1829 return false; |
| 1829 } | 1830 } |
| 1830 | 1831 |
| 1831 return true; | 1832 return true; |
| 1832 } | 1833 } |
| 1833 | 1834 |
| 1834 } // namespace ash | 1835 } // namespace ash |
| OLD | NEW |