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/shelf/shelf.h" | 5 #include "ash/shelf/shelf.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "ash/focus_cycler.h" | 10 #include "ash/focus_cycler.h" |
11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
12 #include "ash/screen_util.h" | 12 #include "ash/screen_util.h" |
13 #include "ash/shelf/shelf_delegate.h" | 13 #include "ash/shelf/shelf_delegate.h" |
14 #include "ash/shelf/shelf_item_delegate.h" | 14 #include "ash/shelf/shelf_item_delegate.h" |
15 #include "ash/shelf/shelf_item_delegate_manager.h" | 15 #include "ash/shelf/shelf_item_delegate_manager.h" |
16 #include "ash/shelf/shelf_layout_manager.h" | 16 #include "ash/shelf/shelf_layout_manager.h" |
17 #include "ash/shelf/shelf_model.h" | 17 #include "ash/shelf/shelf_model.h" |
18 #include "ash/shelf/shelf_navigator.h" | 18 #include "ash/shelf/shelf_navigator.h" |
19 #include "ash/shelf/shelf_util.h" | 19 #include "ash/shelf/shelf_util.h" |
20 #include "ash/shelf/shelf_view.h" | 20 #include "ash/shelf/shelf_view.h" |
21 #include "ash/shell.h" | 21 #include "ash/shell.h" |
22 #include "ash/shell_delegate.h" | 22 #include "ash/shell_delegate.h" |
23 #include "ash/shell_window_ids.h" | 23 #include "ash/shell_window_ids.h" |
| 24 #include "ash/wm/aura/wm_shelf_aura.h" |
24 #include "ash/wm/window_properties.h" | 25 #include "ash/wm/window_properties.h" |
25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
26 #include "ui/aura/window_event_dispatcher.h" | 27 #include "ui/aura/window_event_dispatcher.h" |
27 #include "ui/aura/window_observer.h" | 28 #include "ui/aura/window_observer.h" |
28 #include "ui/compositor/layer.h" | 29 #include "ui/compositor/layer.h" |
29 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
30 #include "ui/gfx/image/image.h" | 31 #include "ui/gfx/image/image.h" |
31 #include "ui/gfx/image/image_skia_operations.h" | 32 #include "ui/gfx/image/image_skia_operations.h" |
32 #include "ui/gfx/skbitmap_operations.h" | 33 #include "ui/gfx/skbitmap_operations.h" |
33 #include "ui/views/accessible_pane_view.h" | 34 #include "ui/views/accessible_pane_view.h" |
34 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
35 #include "ui/views/widget/widget_delegate.h" | 36 #include "ui/views/widget/widget_delegate.h" |
36 #include "ui/wm/public/activation_client.h" | 37 #include "ui/wm/public/activation_client.h" |
37 | 38 |
38 namespace ash { | 39 namespace ash { |
39 | 40 |
40 const char Shelf::kNativeViewName[] = "ShelfView"; | 41 const char Shelf::kNativeViewName[] = "ShelfView"; |
41 | 42 |
42 Shelf::Shelf(ShelfModel* shelf_model, | 43 Shelf::Shelf(ShelfModel* shelf_model, |
43 ShelfDelegate* shelf_delegate, | 44 ShelfDelegate* shelf_delegate, |
44 ShelfWidget* shelf_widget) | 45 ShelfWidget* shelf_widget) |
45 : delegate_(shelf_delegate), | 46 : delegate_(shelf_delegate), |
46 shelf_widget_(shelf_widget), | 47 shelf_widget_(shelf_widget), |
47 shelf_view_(new ShelfView(shelf_model, delegate_, this)), | 48 shelf_view_(new ShelfView(shelf_model, delegate_, this)), |
48 shelf_locking_manager_(this) { | 49 shelf_locking_manager_(this) { |
49 shelf_view_->Init(); | 50 shelf_view_->Init(); |
50 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); | 51 shelf_widget_->GetContentsView()->AddChildView(shelf_view_); |
51 shelf_widget_->GetNativeView()->SetName(kNativeViewName); | 52 shelf_widget_->GetNativeView()->SetName(kNativeViewName); |
| 53 // This has to be done after the ShelfWidget and ShelfLayoutManager have |
| 54 // been created. |
| 55 wm_shelf_.reset(new wm::WmShelfAura(this)); |
52 } | 56 } |
53 | 57 |
54 Shelf::~Shelf() { | 58 Shelf::~Shelf() { |
55 delegate_->OnShelfDestroyed(this); | 59 delegate_->OnShelfDestroyed(this); |
56 } | 60 } |
57 | 61 |
58 // static | 62 // static |
59 Shelf* Shelf::ForPrimaryDisplay() { | 63 Shelf* Shelf::ForPrimaryDisplay() { |
60 return Shelf::ForWindow(Shell::GetPrimaryRootWindow()); | 64 return Shelf::ForWindow(Shell::GetPrimaryRootWindow()); |
61 } | 65 } |
62 | 66 |
63 // static | 67 // static |
64 Shelf* Shelf::ForWindow(const aura::Window* window) { | 68 Shelf* Shelf::ForWindow(const aura::Window* window) { |
65 ShelfWidget* shelf_widget = RootWindowController::ForWindow(window)->shelf(); | 69 ShelfWidget* shelf_widget = RootWindowController::ForWindow(window)->shelf(); |
66 return shelf_widget ? shelf_widget->shelf() : nullptr; | 70 return shelf_widget ? shelf_widget->shelf() : nullptr; |
67 } | 71 } |
68 | 72 |
69 void Shelf::SetAlignment(ShelfAlignment alignment) { | 73 void Shelf::SetAlignment(wm::ShelfAlignment alignment) { |
70 if (alignment_ == alignment) | 74 if (alignment_ == alignment) |
71 return; | 75 return; |
72 | 76 |
73 if (shelf_locking_manager_.is_locked() && | 77 if (shelf_locking_manager_.is_locked() && |
74 alignment != SHELF_ALIGNMENT_BOTTOM_LOCKED) { | 78 alignment != wm::SHELF_ALIGNMENT_BOTTOM_LOCKED) { |
75 shelf_locking_manager_.set_stored_alignment(alignment); | 79 shelf_locking_manager_.set_stored_alignment(alignment); |
76 return; | 80 return; |
77 } | 81 } |
78 | 82 |
79 alignment_ = alignment; | 83 alignment_ = alignment; |
80 shelf_view_->OnShelfAlignmentChanged(); | 84 shelf_view_->OnShelfAlignmentChanged(); |
81 shelf_widget_->OnShelfAlignmentChanged(); | 85 shelf_widget_->OnShelfAlignmentChanged(); |
82 delegate_->OnShelfAlignmentChanged(this); | 86 delegate_->OnShelfAlignmentChanged(this); |
83 Shell::GetInstance()->OnShelfAlignmentChanged( | 87 Shell::GetInstance()->OnShelfAlignmentChanged( |
84 shelf_widget_->GetNativeWindow()->GetRootWindow()); | 88 shelf_widget_->GetNativeWindow()->GetRootWindow()); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 207 |
204 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { | 208 gfx::Rect Shelf::GetVisibleItemsBoundsInScreen() const { |
205 return shelf_view_->GetVisibleItemsBoundsInScreen(); | 209 return shelf_view_->GetVisibleItemsBoundsInScreen(); |
206 } | 210 } |
207 | 211 |
208 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { | 212 app_list::ApplicationDragAndDropHost* Shelf::GetDragAndDropHostForAppList() { |
209 return shelf_view_; | 213 return shelf_view_; |
210 } | 214 } |
211 | 215 |
212 } // namespace ash | 216 } // namespace ash |
OLD | NEW |