OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_window_watcher_item_delegate.h" | 5 #include "ash/common/shelf/shelf_window_watcher_item_delegate.h" |
6 | 6 |
7 #include "ash/common/shelf/shelf_controller.h" | 7 #include "ash/common/shelf/shelf_controller.h" |
8 #include "ash/common/shelf/shelf_model.h" | 8 #include "ash/common/shelf/shelf_model.h" |
9 #include "ash/common/wm/window_state.h" | 9 #include "ash/common/wm/window_state.h" |
10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id, | 29 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id, |
30 WmWindow* window) | 30 WmWindow* window) |
31 : id_(id), window_(window) { | 31 : id_(id), window_(window) { |
32 DCHECK_NE(kInvalidShelfID, id_); | 32 DCHECK_NE(kInvalidShelfID, id_); |
33 DCHECK(window_); | 33 DCHECK(window_); |
34 } | 34 } |
35 | 35 |
36 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} | 36 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} |
37 | 37 |
38 ShelfAction ShelfWindowWatcherItemDelegate::ItemSelected( | 38 void ShelfWindowWatcherItemDelegate::ItemSelected( |
39 ui::EventType event_type, | 39 std::unique_ptr<ui::Event> event, |
40 int event_flags, | |
41 int64_t display_id, | 40 int64_t display_id, |
42 ShelfLaunchSource source) { | 41 ShelfLaunchSource source, |
| 42 const ItemSelectedCallback& callback) { |
43 // Move panels attached on another display to the current display. | 43 // Move panels attached on another display to the current display. |
44 if (GetShelfItemType(id_) == TYPE_APP_PANEL && | 44 if (GetShelfItemType(id_) == TYPE_APP_PANEL && |
45 window_->aura_window()->GetProperty(kPanelAttachedKey) && | 45 window_->aura_window()->GetProperty(kPanelAttachedKey) && |
46 wm::MoveWindowToDisplay(window_->aura_window(), display_id)) { | 46 wm::MoveWindowToDisplay(window_->aura_window(), display_id)) { |
47 window_->Activate(); | 47 window_->Activate(); |
48 return SHELF_ACTION_WINDOW_ACTIVATED; | 48 callback.Run(SHELF_ACTION_WINDOW_ACTIVATED, |
| 49 std::vector<mojom::MenuItemPtr>()); |
| 50 return; |
49 } | 51 } |
50 | 52 |
51 if (window_->IsActive()) { | 53 if (window_->IsActive()) { |
52 if (event_type == ui::ET_KEY_RELEASED) { | 54 if (event && event->type() == ui::ET_KEY_RELEASED) { |
53 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 55 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
54 return SHELF_ACTION_NONE; | 56 callback.Run(SHELF_ACTION_NONE, std::vector<mojom::MenuItemPtr>()); |
| 57 return; |
55 } | 58 } |
56 window_->Minimize(); | 59 window_->Minimize(); |
57 return SHELF_ACTION_WINDOW_MINIMIZED; | 60 callback.Run(SHELF_ACTION_WINDOW_MINIMIZED, |
| 61 std::vector<mojom::MenuItemPtr>()); |
| 62 return; |
58 } | 63 } |
59 window_->Activate(); | 64 window_->Activate(); |
60 return SHELF_ACTION_WINDOW_ACTIVATED; | 65 callback.Run(SHELF_ACTION_WINDOW_ACTIVATED, |
61 } | 66 std::vector<mojom::MenuItemPtr>()); |
62 | |
63 ShelfAppMenuItemList ShelfWindowWatcherItemDelegate::GetAppMenuItems( | |
64 int event_flags) { | |
65 // Return an empty item list to avoid showing an application menu. | |
66 return ShelfAppMenuItemList(); | |
67 } | 67 } |
68 | 68 |
69 void ShelfWindowWatcherItemDelegate::ExecuteCommand(uint32_t command_id, | 69 void ShelfWindowWatcherItemDelegate::ExecuteCommand(uint32_t command_id, |
70 int event_flags) { | 70 int32_t event_flags) {} |
71 // This delegate does not support showing an application menu. | |
72 NOTIMPLEMENTED(); | |
73 } | |
74 | 71 |
75 void ShelfWindowWatcherItemDelegate::Close() { | 72 void ShelfWindowWatcherItemDelegate::Close() { |
76 window_->CloseWidget(); | 73 window_->CloseWidget(); |
77 } | 74 } |
78 | 75 |
79 } // namespace ash | 76 } // namespace ash |
OLD | NEW |