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" |
11 #include "ash/common/wm_window.h" | 11 #include "ash/common/wm_window.h" |
12 #include "ash/common/wm_window_property.h" | 12 #include "ash/common/wm_window_property.h" |
13 #include "ui/events/event.h" | 13 #include "ash/wm/window_util.h" |
| 14 #include "ui/events/event_constants.h" |
14 | 15 |
15 namespace ash { | 16 namespace ash { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 ShelfItemType GetShelfItemType(ShelfID id) { | 20 ShelfItemType GetShelfItemType(ShelfID id) { |
20 ShelfModel* model = WmShell::Get()->shelf_controller()->model(); | 21 ShelfModel* model = WmShell::Get()->shelf_controller()->model(); |
21 ShelfItems::const_iterator item = model->ItemByID(id); | 22 ShelfItems::const_iterator item = model->ItemByID(id); |
22 return item == model->items().end() ? TYPE_UNDEFINED : item->type; | 23 return item == model->items().end() ? TYPE_UNDEFINED : item->type; |
23 } | 24 } |
24 | 25 |
25 } // namespace | 26 } // namespace |
26 | 27 |
27 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id, | 28 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id, |
28 WmWindow* window) | 29 WmWindow* window) |
29 : id_(id), window_(window) { | 30 : id_(id), window_(window) { |
30 DCHECK_NE(kInvalidShelfID, id_); | 31 DCHECK_NE(kInvalidShelfID, id_); |
31 DCHECK(window_); | 32 DCHECK(window_); |
32 } | 33 } |
33 | 34 |
34 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} | 35 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} |
35 | 36 |
36 ShelfItemDelegate::PerformedAction ShelfWindowWatcherItemDelegate::ItemSelected( | 37 ShelfAction ShelfWindowWatcherItemDelegate::ItemSelected( |
37 const ui::Event& event) { | 38 ui::EventType event_type, |
| 39 int event_flags, |
| 40 int64_t display_id, |
| 41 ShelfLaunchSource source) { |
38 // Move panels attached on another display to the current display. | 42 // Move panels attached on another display to the current display. |
39 if (GetShelfItemType(id_) == TYPE_APP_PANEL && | 43 if (GetShelfItemType(id_) == TYPE_APP_PANEL && |
40 window_->GetBoolProperty(WmWindowProperty::PANEL_ATTACHED) && | 44 window_->GetBoolProperty(WmWindowProperty::PANEL_ATTACHED) && |
41 window_->MoveToEventRoot(event)) { | 45 wm::MoveWindowToDisplay(window_->aura_window(), display_id)) { |
42 window_->Activate(); | 46 window_->Activate(); |
43 return kExistingWindowActivated; | 47 return SHELF_ACTION_WINDOW_ACTIVATED; |
44 } | 48 } |
45 | 49 |
46 if (window_->IsActive()) { | 50 if (window_->IsActive()) { |
47 if (event.type() & ui::ET_KEY_RELEASED) { | 51 if (event_type == ui::ET_KEY_RELEASED) { |
48 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); | 52 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); |
49 return kNoAction; | 53 return SHELF_ACTION_NONE; |
50 } | 54 } |
51 window_->Minimize(); | 55 window_->Minimize(); |
52 return kExistingWindowMinimized; | 56 return SHELF_ACTION_WINDOW_MINIMIZED; |
53 } | 57 } |
54 window_->Activate(); | 58 window_->Activate(); |
55 return kExistingWindowActivated; | 59 return SHELF_ACTION_WINDOW_ACTIVATED; |
56 } | 60 } |
57 | 61 |
58 ShelfAppMenuItemList ShelfWindowWatcherItemDelegate::GetAppMenuItems( | 62 ShelfAppMenuItemList ShelfWindowWatcherItemDelegate::GetAppMenuItems( |
59 int event_flags) { | 63 int event_flags) { |
60 // Return an empty item list to avoid showing an application menu. | 64 // Return an empty item list to avoid showing an application menu. |
61 return ShelfAppMenuItemList(); | 65 return ShelfAppMenuItemList(); |
62 } | 66 } |
63 | 67 |
64 void ShelfWindowWatcherItemDelegate::Close() { | 68 void ShelfWindowWatcherItemDelegate::Close() { |
65 window_->CloseWidget(); | 69 window_->CloseWidget(); |
66 } | 70 } |
67 | 71 |
68 } // namespace ash | 72 } // namespace ash |
OLD | NEW |