| 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 mojo::Connector* connector = | 117 mojo::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) { |
| 136 SetShelfPreferredSizes(shelf); |
| 137 shelf_layout_->SetAlignment( |
| 138 static_cast<mash::wm::mojom::ShelfAlignment>(shelf->GetAlignment())); |
| 139 |
| 147 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { | 140 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { |
| 148 observer->OnAlignmentChanged( | 141 observer->OnAlignmentChanged( |
| 149 static_cast<mash::shelf::mojom::Alignment>(shelf->GetAlignment())); | 142 static_cast<mash::shelf::mojom::Alignment>(shelf->GetAlignment())); |
| 150 }); | 143 }); |
| 151 } | 144 } |
| 152 | 145 |
| 153 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) { | 146 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) { |
| 147 shelf_layout_->SetAutoHideBehavior( |
| 148 static_cast<mash::wm::mojom::ShelfAutoHideBehavior>( |
| 149 shelf->auto_hide_behavior())); |
| 150 |
| 154 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { | 151 observers_.ForAllPtrs([shelf](mash::shelf::mojom::ShelfObserver* observer) { |
| 155 observer->OnAutoHideBehaviorChanged( | 152 observer->OnAutoHideBehaviorChanged( |
| 156 static_cast<mash::shelf::mojom::AutoHideBehavior>( | 153 static_cast<mash::shelf::mojom::AutoHideBehavior>( |
| 157 shelf->auto_hide_behavior())); | 154 shelf->auto_hide_behavior())); |
| 158 }); | 155 }); |
| 159 } | 156 } |
| 160 | 157 |
| 161 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { | 158 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { |
| 162 NOTIMPLEMENTED(); | 159 NOTIMPLEMENTED(); |
| 163 return 0; | 160 return 0; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 ShelfID shelf_id = window_id_to_shelf_id_[window_id]; | 311 ShelfID shelf_id = window_id_to_shelf_id_[window_id]; |
| 315 int index = model_->ItemIndexByID(shelf_id); | 312 int index = model_->ItemIndexByID(shelf_id); |
| 316 DCHECK_GE(index, 0); | 313 DCHECK_GE(index, 0); |
| 317 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); | 314 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); |
| 318 DCHECK(iter != model_->items().end()); | 315 DCHECK(iter != model_->items().end()); |
| 319 ShelfItem item = *iter; | 316 ShelfItem item = *iter; |
| 320 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 317 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
| 321 model_->Set(index, item); | 318 model_->Set(index, item); |
| 322 } | 319 } |
| 323 | 320 |
| 321 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) { |
| 322 ShelfWidget* widget = shelf->shelf_widget(); |
| 323 ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); |
| 324 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); |
| 325 gfx::Size size = layout_manager->GetIdealBounds().size(); |
| 326 window->SetSharedProperty<gfx::Size>( |
| 327 mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 328 |
| 329 StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 330 mus::Window* status_window = |
| 331 aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 332 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 333 status_window->SetSharedProperty<gfx::Size>( |
| 334 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 335 } |
| 336 |
| 324 } // namespace sysui | 337 } // namespace sysui |
| 325 } // namespace ash | 338 } // namespace ash |
| OLD | NEW |