OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/mus/shelf_delegate_mus.h" | 5 #include "ash/mus/shelf_delegate_mus.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
10 #include "ash/shelf/shelf_item_delegate.h" | 10 #include "ash/shelf/shelf_item_delegate.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 SkBitmap bitmap = mojo::ConvertTo<SkBitmap>(serialized_bitmap.storage()); | 109 SkBitmap bitmap = mojo::ConvertTo<SkBitmap>(serialized_bitmap.storage()); |
110 return GetShelfIconFromBitmap(bitmap); | 110 return GetShelfIconFromBitmap(bitmap); |
111 } | 111 } |
112 | 112 |
113 } // namespace | 113 } // namespace |
114 | 114 |
115 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) | 115 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) |
116 : model_(model), binding_(this) { | 116 : model_(model), binding_(this) { |
117 ::shell::Connector* connector = | 117 ::shell::Connector* connector = |
118 views::WindowManagerConnection::Get()->connector(); | 118 views::WindowManagerConnection::Get()->connector(); |
| 119 connector->ConnectToInterface("mojo:desktop_wm", &shelf_layout_); |
119 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); | 120 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); |
120 user_window_controller_->AddUserWindowObserver( | 121 user_window_controller_->AddUserWindowObserver( |
121 binding_.CreateInterfacePtrAndBind()); | 122 binding_.CreateInterfacePtrAndBind()); |
122 } | 123 } |
123 | 124 |
124 ShelfDelegateMus::~ShelfDelegateMus() {} | 125 ShelfDelegateMus::~ShelfDelegateMus() {} |
125 | 126 |
126 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { | 127 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { |
127 ShelfWidget* widget = shelf->shelf_widget(); | 128 SetShelfPreferredSizes(shelf); |
128 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); | |
129 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); | |
130 gfx::Size size = layout_manager->GetIdealBounds().size(); | |
131 window->SetSharedProperty<gfx::Size>( | |
132 mus::mojom::WindowManager::kPreferredSize_Property, size); | |
133 | |
134 StatusAreaWidget* status_widget = widget->status_area_widget(); | |
135 mus::Window* status_window = | |
136 aura::GetMusWindow(status_widget->GetNativeWindow()); | |
137 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); | |
138 status_window->SetSharedProperty<gfx::Size>( | |
139 mus::mojom::WindowManager::kPreferredSize_Property, status_size); | |
140 } | 129 } |
141 | 130 |
142 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { | 131 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { |
143 NOTIMPLEMENTED(); | 132 NOTIMPLEMENTED(); |
144 } | 133 } |
145 | 134 |
146 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { | 135 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { |
147 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { | 136 SetShelfPreferredSizes(shelf); |
148 observer->OnAlignmentChanged( | 137 mash::shelf::mojom::Alignment alignment = |
149 static_cast<mash::shelf::mojom::Alignment>(shelf->GetAlignment())); | 138 static_cast<mash::shelf::mojom::Alignment>(shelf->GetAlignment()); |
150 }); | 139 shelf_layout_->SetAlignment(alignment); |
| 140 |
| 141 observers_.ForAllPtrs( |
| 142 [alignment](mash::shelf::mojom::ShelfObserver* observer) { |
| 143 observer->OnAlignmentChanged(alignment); |
| 144 }); |
151 } | 145 } |
152 | 146 |
153 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) { | 147 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) { |
154 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { | 148 mash::shelf::mojom::AutoHideBehavior behavior = |
155 observer->OnAutoHideBehaviorChanged( | 149 static_cast<mash::shelf::mojom::AutoHideBehavior>( |
156 static_cast<mash::shelf::mojom::AutoHideBehavior>( | 150 shelf->auto_hide_behavior()); |
157 shelf->auto_hide_behavior())); | 151 shelf_layout_->SetAutoHideBehavior(behavior); |
158 }); | 152 |
| 153 observers_.ForAllPtrs( |
| 154 [behavior](mash::shelf::mojom::ShelfObserver* observer) { |
| 155 observer->OnAutoHideBehaviorChanged(behavior); |
| 156 }); |
159 } | 157 } |
160 | 158 |
161 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { | 159 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { |
162 NOTIMPLEMENTED(); | 160 NOTIMPLEMENTED(); |
163 return 0; | 161 return 0; |
164 } | 162 } |
165 | 163 |
166 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { | 164 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { |
167 NOTIMPLEMENTED(); | 165 NOTIMPLEMENTED(); |
168 return false; | 166 return false; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ShelfID shelf_id = window_id_to_shelf_id_[window_id]; | 312 ShelfID shelf_id = window_id_to_shelf_id_[window_id]; |
315 int index = model_->ItemIndexByID(shelf_id); | 313 int index = model_->ItemIndexByID(shelf_id); |
316 DCHECK_GE(index, 0); | 314 DCHECK_GE(index, 0); |
317 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); | 315 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); |
318 DCHECK(iter != model_->items().end()); | 316 DCHECK(iter != model_->items().end()); |
319 ShelfItem item = *iter; | 317 ShelfItem item = *iter; |
320 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 318 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
321 model_->Set(index, item); | 319 model_->Set(index, item); |
322 } | 320 } |
323 | 321 |
| 322 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) { |
| 323 ShelfWidget* widget = shelf->shelf_widget(); |
| 324 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); |
| 325 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); |
| 326 gfx::Size size = layout_manager->GetIdealBounds().size(); |
| 327 window->SetSharedProperty<gfx::Size>( |
| 328 mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 329 |
| 330 StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 331 mus::Window* status_window = |
| 332 aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 333 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 334 status_window->SetSharedProperty<gfx::Size>( |
| 335 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 336 } |
| 337 |
324 } // namespace sysui | 338 } // namespace sysui |
325 } // namespace ash | 339 } // namespace ash |
OLD | NEW |