| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 ::shell::Connector* connector = | 186 ::shell::Connector* connector = |
| 187 views::WindowManagerConnection::Get()->connector(); | 187 views::WindowManagerConnection::Get()->connector(); |
| 188 connector->ConnectToInterface("mojo:desktop_wm", &shelf_layout_); | 188 connector->ConnectToInterface("mojo:desktop_wm", &shelf_layout_); |
| 189 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); | 189 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); |
| 190 user_window_controller_->AddUserWindowObserver( | 190 user_window_controller_->AddUserWindowObserver( |
| 191 binding_.CreateInterfacePtrAndBind()); | 191 binding_.CreateInterfacePtrAndBind()); |
| 192 } | 192 } |
| 193 | 193 |
| 194 ShelfDelegateMus::~ShelfDelegateMus() {} | 194 ShelfDelegateMus::~ShelfDelegateMus() {} |
| 195 | 195 |
| 196 /////////////////////////////////////////////////////////////////////////////// |
| 197 // ShelfDelegate: |
| 198 |
| 196 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { | 199 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { |
| 197 SetShelfPreferredSizes(shelf); | 200 SetShelfPreferredSizes(shelf); |
| 198 } | 201 } |
| 199 | 202 |
| 200 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { | 203 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { |
| 201 NOTIMPLEMENTED(); | 204 NOTIMPLEMENTED(); |
| 202 } | 205 } |
| 203 | 206 |
| 204 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { | 207 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { |
| 205 SetShelfPreferredSizes(shelf); | 208 SetShelfPreferredSizes(shelf); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 218 static_cast<mash::shelf::mojom::AutoHideBehavior>( | 221 static_cast<mash::shelf::mojom::AutoHideBehavior>( |
| 219 shelf->auto_hide_behavior()); | 222 shelf->auto_hide_behavior()); |
| 220 shelf_layout_->SetAutoHideBehavior(behavior); | 223 shelf_layout_->SetAutoHideBehavior(behavior); |
| 221 | 224 |
| 222 observers_.ForAllPtrs( | 225 observers_.ForAllPtrs( |
| 223 [behavior](mash::shelf::mojom::ShelfObserver* observer) { | 226 [behavior](mash::shelf::mojom::ShelfObserver* observer) { |
| 224 observer->OnAutoHideBehaviorChanged(behavior); | 227 observer->OnAutoHideBehaviorChanged(behavior); |
| 225 }); | 228 }); |
| 226 } | 229 } |
| 227 | 230 |
| 231 void ShelfDelegateMus::OnShelfAutoHideStateChanged(Shelf* shelf) { |
| 232 // Push the new preferred size to the window manager. For example, when the |
| 233 // shelf is auto-hidden it becomes a very short "light bar". |
| 234 SetShelfPreferredSizes(shelf); |
| 235 } |
| 236 |
| 237 void ShelfDelegateMus::OnShelfVisibilityStateChanged(Shelf* shelf) { |
| 238 SetShelfPreferredSizes(shelf); |
| 239 } |
| 240 |
| 228 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { | 241 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { |
| 229 if (app_id_to_shelf_id_.count(app_id)) | 242 if (app_id_to_shelf_id_.count(app_id)) |
| 230 return app_id_to_shelf_id_[app_id]; | 243 return app_id_to_shelf_id_[app_id]; |
| 231 return 0; | 244 return 0; |
| 232 } | 245 } |
| 233 | 246 |
| 234 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { | 247 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { |
| 235 return shelf_id_to_app_id_.count(id) != 0; | 248 return shelf_id_to_app_id_.count(id) != 0; |
| 236 } | 249 } |
| 237 | 250 |
| 238 const std::string& ShelfDelegateMus::GetAppIDForShelfID(ShelfID id) { | 251 const std::string& ShelfDelegateMus::GetAppIDForShelfID(ShelfID id) { |
| 239 if (shelf_id_to_app_id_.count(id)) | 252 if (shelf_id_to_app_id_.count(id)) |
| 240 return shelf_id_to_app_id_[id]; | 253 return shelf_id_to_app_id_[id]; |
| 241 return base::EmptyString(); | 254 return base::EmptyString(); |
| 242 } | 255 } |
| 243 | 256 |
| 244 void ShelfDelegateMus::PinAppWithID(const std::string& app_id) { | 257 void ShelfDelegateMus::PinAppWithID(const std::string& app_id) { |
| 245 NOTIMPLEMENTED(); | 258 NOTIMPLEMENTED(); |
| 246 } | 259 } |
| 247 | 260 |
| 248 bool ShelfDelegateMus::IsAppPinned(const std::string& app_id) { | 261 bool ShelfDelegateMus::IsAppPinned(const std::string& app_id) { |
| 249 NOTIMPLEMENTED(); | 262 NOTIMPLEMENTED(); |
| 250 return false; | 263 return false; |
| 251 } | 264 } |
| 252 | 265 |
| 253 void ShelfDelegateMus::UnpinAppWithID(const std::string& app_id) { | 266 void ShelfDelegateMus::UnpinAppWithID(const std::string& app_id) { |
| 254 NOTIMPLEMENTED(); | 267 NOTIMPLEMENTED(); |
| 255 } | 268 } |
| 256 | 269 |
| 270 /////////////////////////////////////////////////////////////////////////////// |
| 271 // mash::shelf::mojom::ShelfController: |
| 272 |
| 257 void ShelfDelegateMus::AddObserver( | 273 void ShelfDelegateMus::AddObserver( |
| 258 mash::shelf::mojom::ShelfObserverAssociatedPtrInfo observer) { | 274 mash::shelf::mojom::ShelfObserverAssociatedPtrInfo observer) { |
| 259 mash::shelf::mojom::ShelfObserverAssociatedPtr observer_ptr; | 275 mash::shelf::mojom::ShelfObserverAssociatedPtr observer_ptr; |
| 260 observer_ptr.Bind(std::move(observer)); | 276 observer_ptr.Bind(std::move(observer)); |
| 261 // Notify the observer of the current state. | 277 // Notify the observer of the current state. |
| 262 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 278 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 263 observer_ptr->OnAlignmentChanged( | 279 observer_ptr->OnAlignmentChanged( |
| 264 static_cast<mash::shelf::mojom::Alignment>(shelf->alignment())); | 280 static_cast<mash::shelf::mojom::Alignment>(shelf->alignment())); |
| 265 observer_ptr->OnAutoHideBehaviorChanged( | 281 observer_ptr->OnAutoHideBehaviorChanged( |
| 266 static_cast<mash::shelf::mojom::AutoHideBehavior>( | 282 static_cast<mash::shelf::mojom::AutoHideBehavior>( |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 DCHECK(iter != model_->items().end()); | 460 DCHECK(iter != model_->items().end()); |
| 445 ShelfItem item = *iter; | 461 ShelfItem item = *iter; |
| 446 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 462 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
| 447 model_->Set(index, item); | 463 model_->Set(index, item); |
| 448 } | 464 } |
| 449 | 465 |
| 450 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) { | 466 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) { |
| 451 ShelfWidget* widget = shelf->shelf_widget(); | 467 ShelfWidget* widget = shelf->shelf_widget(); |
| 452 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); | 468 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); |
| 453 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); | 469 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); |
| 454 gfx::Size size = layout_manager->GetIdealBounds().size(); | 470 gfx::Size size = layout_manager->GetPreferredSize(); |
| 455 window->SetSharedProperty<gfx::Size>( | 471 window->SetSharedProperty<gfx::Size>( |
| 456 mus::mojom::WindowManager::kPreferredSize_Property, size); | 472 mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 457 | 473 |
| 458 StatusAreaWidget* status_widget = widget->status_area_widget(); | 474 StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 459 mus::Window* status_window = | 475 mus::Window* status_window = |
| 460 aura::GetMusWindow(status_widget->GetNativeWindow()); | 476 aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 461 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); | 477 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 462 status_window->SetSharedProperty<gfx::Size>( | 478 status_window->SetSharedProperty<gfx::Size>( |
| 463 mus::mojom::WindowManager::kPreferredSize_Property, status_size); | 479 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 464 } | 480 } |
| 465 | 481 |
| 466 } // namespace sysui | 482 } // namespace sysui |
| 467 } // namespace ash | 483 } // namespace ash |
| OLD | NEW |