| 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); |
| 201 shelf->shelf_layout_manager()->AddObserver(this); |
| 198 } | 202 } |
| 199 | 203 |
| 200 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { | 204 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { |
| 205 shelf->shelf_layout_manager()->RemoveObserver(this); |
| 201 NOTIMPLEMENTED(); | 206 NOTIMPLEMENTED(); |
| 202 } | 207 } |
| 203 | 208 |
| 204 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { | 209 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { |
| 205 SetShelfPreferredSizes(shelf); | 210 SetShelfPreferredSizes(shelf); |
| 206 mash::shelf::mojom::Alignment alignment = | 211 mash::shelf::mojom::Alignment alignment = |
| 207 static_cast<mash::shelf::mojom::Alignment>(shelf->alignment()); | 212 static_cast<mash::shelf::mojom::Alignment>(shelf->alignment()); |
| 208 shelf_layout_->SetAlignment(alignment); | 213 shelf_layout_->SetAlignment(alignment); |
| 209 | 214 |
| 210 observers_.ForAllPtrs( | 215 observers_.ForAllPtrs( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 252 |
| 248 bool ShelfDelegateMus::IsAppPinned(const std::string& app_id) { | 253 bool ShelfDelegateMus::IsAppPinned(const std::string& app_id) { |
| 249 NOTIMPLEMENTED(); | 254 NOTIMPLEMENTED(); |
| 250 return false; | 255 return false; |
| 251 } | 256 } |
| 252 | 257 |
| 253 void ShelfDelegateMus::UnpinAppWithID(const std::string& app_id) { | 258 void ShelfDelegateMus::UnpinAppWithID(const std::string& app_id) { |
| 254 NOTIMPLEMENTED(); | 259 NOTIMPLEMENTED(); |
| 255 } | 260 } |
| 256 | 261 |
| 262 /////////////////////////////////////////////////////////////////////////////// |
| 263 // ShelfLayoutManagerObserver: |
| 264 |
| 265 void ShelfDelegateMus::DidChangeVisibilityState( |
| 266 ShelfLayoutManager* layout_manager, |
| 267 ShelfVisibilityState new_state) { |
| 268 // Push the new preferred size to the window manager. For example, when the |
| 269 // shelf is auto-hidden it becomes a very short "light bar". |
| 270 SetShelfPreferredSizes(layout_manager->shelf_widget()->shelf()); |
| 271 } |
| 272 |
| 273 void ShelfDelegateMus::OnAutoHideStateChanged( |
| 274 ShelfLayoutManager* layout_manager, |
| 275 ShelfAutoHideState new_state) { |
| 276 SetShelfPreferredSizes(layout_manager->shelf_widget()->shelf()); |
| 277 } |
| 278 |
| 279 /////////////////////////////////////////////////////////////////////////////// |
| 280 // mash::shelf::mojom::ShelfController: |
| 281 |
| 257 void ShelfDelegateMus::AddObserver( | 282 void ShelfDelegateMus::AddObserver( |
| 258 mash::shelf::mojom::ShelfObserverAssociatedPtrInfo observer) { | 283 mash::shelf::mojom::ShelfObserverAssociatedPtrInfo observer) { |
| 259 mash::shelf::mojom::ShelfObserverAssociatedPtr observer_ptr; | 284 mash::shelf::mojom::ShelfObserverAssociatedPtr observer_ptr; |
| 260 observer_ptr.Bind(std::move(observer)); | 285 observer_ptr.Bind(std::move(observer)); |
| 261 // Notify the observer of the current state. | 286 // Notify the observer of the current state. |
| 262 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 287 Shelf* shelf = Shelf::ForPrimaryDisplay(); |
| 263 observer_ptr->OnAlignmentChanged( | 288 observer_ptr->OnAlignmentChanged( |
| 264 static_cast<mash::shelf::mojom::Alignment>(shelf->alignment())); | 289 static_cast<mash::shelf::mojom::Alignment>(shelf->alignment())); |
| 265 observer_ptr->OnAutoHideBehaviorChanged( | 290 observer_ptr->OnAutoHideBehaviorChanged( |
| 266 static_cast<mash::shelf::mojom::AutoHideBehavior>( | 291 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()); | 469 DCHECK(iter != model_->items().end()); |
| 445 ShelfItem item = *iter; | 470 ShelfItem item = *iter; |
| 446 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 471 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
| 447 model_->Set(index, item); | 472 model_->Set(index, item); |
| 448 } | 473 } |
| 449 | 474 |
| 450 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) { | 475 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) { |
| 451 ShelfWidget* widget = shelf->shelf_widget(); | 476 ShelfWidget* widget = shelf->shelf_widget(); |
| 452 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); | 477 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); |
| 453 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); | 478 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); |
| 454 gfx::Size size = layout_manager->GetIdealBounds().size(); | 479 gfx::Size size = layout_manager->GetPreferredSize(); |
| 455 window->SetSharedProperty<gfx::Size>( | 480 window->SetSharedProperty<gfx::Size>( |
| 456 mus::mojom::WindowManager::kPreferredSize_Property, size); | 481 mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 457 | 482 |
| 458 StatusAreaWidget* status_widget = widget->status_area_widget(); | 483 StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 459 mus::Window* status_window = | 484 mus::Window* status_window = |
| 460 aura::GetMusWindow(status_widget->GetNativeWindow()); | 485 aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 461 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); | 486 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 462 status_window->SetSharedProperty<gfx::Size>( | 487 status_window->SetSharedProperty<gfx::Size>( |
| 463 mus::mojom::WindowManager::kPreferredSize_Property, status_size); | 488 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 464 } | 489 } |
| 465 | 490 |
| 466 } // namespace sysui | 491 } // namespace sysui |
| 467 } // namespace ash | 492 } // namespace ash |
| OLD | NEW |