| 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/common/shelf/shelf_view.h" | 5 #include "ash/common/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); | 428 gfx::Point origin(GetMirroredXWithWidthInView(0, preferred_size.width()), 0); |
| 429 ConvertPointToScreen(this, &origin); | 429 ConvertPointToScreen(this, &origin); |
| 430 return gfx::Rect(origin, preferred_size); | 430 return gfx::Rect(origin, preferred_size); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void ShelfView::ButtonPressed(views::Button* sender, | 433 void ShelfView::ButtonPressed(views::Button* sender, |
| 434 const ui::Event& event, | 434 const ui::Event& event, |
| 435 views::InkDrop* ink_drop) { | 435 views::InkDrop* ink_drop) { |
| 436 if (sender == overflow_button_) { | 436 if (sender == overflow_button_) { |
| 437 ToggleOverflowBubble(); | 437 ToggleOverflowBubble(); |
| 438 shelf_button_pressed_metric_tracker_.ButtonPressed( | 438 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, |
| 439 event, sender, ShelfItemDelegate::kNoAction); | 439 SHELF_ACTION_NONE); |
| 440 return; | 440 return; |
| 441 } | 441 } |
| 442 | 442 |
| 443 // None of the checks in ShouldEventActivateButton() affects overflow button. | 443 // None of the checks in ShouldEventActivateButton() affects overflow button. |
| 444 // So, it is safe to be checked after handling overflow button. | 444 // So, it is safe to be checked after handling overflow button. |
| 445 if (!ShouldEventActivateButton(sender, event)) | 445 if (!ShouldEventActivateButton(sender, event)) |
| 446 return; | 446 return; |
| 447 | 447 |
| 448 // Record the index for the last pressed shelf item. | 448 // Record the index for the last pressed shelf item. |
| 449 last_pressed_index_ = view_model_->GetIndexOfView(sender); | 449 last_pressed_index_ = view_model_->GetIndexOfView(sender); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 476 | 476 |
| 477 case TYPE_APP_PANEL: | 477 case TYPE_APP_PANEL: |
| 478 case TYPE_DIALOG: | 478 case TYPE_DIALOG: |
| 479 break; | 479 break; |
| 480 | 480 |
| 481 case TYPE_UNDEFINED: | 481 case TYPE_UNDEFINED: |
| 482 NOTREACHED() << "ShelfItemType must be set."; | 482 NOTREACHED() << "ShelfItemType must be set."; |
| 483 break; | 483 break; |
| 484 } | 484 } |
| 485 | 485 |
| 486 ShelfItemDelegate::PerformedAction performed_action = | 486 const int64_t display_id = window->GetDisplayNearestWindow().id(); |
| 487 ShelfAction performed_action = |
| 487 model_->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) | 488 model_->GetShelfItemDelegate(model_->items()[last_pressed_index_].id) |
| 488 ->ItemSelected(event); | 489 ->ItemSelected(event.type(), event.flags(), display_id, |
| 490 LAUNCH_FROM_UNKNOWN); |
| 489 | 491 |
| 490 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, | 492 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, |
| 491 performed_action); | 493 performed_action); |
| 492 | 494 |
| 493 // For the app list menu no TRIGGERED ink drop effect is needed and it | 495 // For the app list menu no TRIGGERED ink drop effect is needed and it |
| 494 // handles its own ACTIVATED/DEACTIVATED states. | 496 // handles its own ACTIVATED/DEACTIVATED states. |
| 495 if (performed_action == ShelfItemDelegate::kNewWindowCreated || | 497 if (performed_action == SHELF_ACTION_NEW_WINDOW_CREATED || |
| 496 (performed_action != ShelfItemDelegate::kAppListMenuShown && | 498 (performed_action != SHELF_ACTION_APP_LIST_SHOWN && |
| 497 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, event, | 499 !ShowListMenuForView(model_->items()[last_pressed_index_], sender, event, |
| 498 ink_drop))) { | 500 ink_drop))) { |
| 499 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED); | 501 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED); |
| 500 } | 502 } |
| 501 // Allow the menu to clear |scoped_root_window_for_new_windows_| during | 503 // Allow the menu to clear |scoped_root_window_for_new_windows_| during |
| 502 // OnMenuClosed. | 504 // OnMenuClosed. |
| 503 if (!IsShowingMenu()) | 505 if (!IsShowingMenu()) |
| 504 scoped_root_window_for_new_windows_.reset(); | 506 scoped_root_window_for_new_windows_.reset(); |
| 505 } | 507 } |
| 506 | 508 |
| (...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1774 | 1776 |
| 1775 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { | 1777 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { |
| 1776 const gfx::Rect bounds = GetBoundsInScreen(); | 1778 const gfx::Rect bounds = GetBoundsInScreen(); |
| 1777 int distance = wm_shelf_->SelectValueForShelfAlignment( | 1779 int distance = wm_shelf_->SelectValueForShelfAlignment( |
| 1778 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), | 1780 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), |
| 1779 bounds.x() - coordinate.x()); | 1781 bounds.x() - coordinate.x()); |
| 1780 return distance > 0 ? distance : 0; | 1782 return distance > 0 ? distance : 0; |
| 1781 } | 1783 } |
| 1782 | 1784 |
| 1783 } // namespace ash | 1785 } // namespace ash |
| OLD | NEW |