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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 return icon_image; | 99 return icon_image; |
100 } | 100 } |
101 | 101 |
102 } // namespace | 102 } // namespace |
103 | 103 |
104 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) | 104 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) |
105 : model_(model), binding_(this) { | 105 : model_(model), binding_(this) { |
106 mojo::Connector* connector = | 106 mojo::Connector* connector = |
107 views::WindowManagerConnection::Get()->connector(); | 107 views::WindowManagerConnection::Get()->connector(); |
| 108 connector->ConnectToInterface("mojo:desktop_wm", &shelf_layout_); |
108 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); | 109 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); |
109 user_window_controller_->AddUserWindowObserver( | 110 user_window_controller_->AddUserWindowObserver( |
110 binding_.CreateInterfacePtrAndBind()); | 111 binding_.CreateInterfacePtrAndBind()); |
111 } | 112 } |
112 | 113 |
113 ShelfDelegateMus::~ShelfDelegateMus() {} | 114 ShelfDelegateMus::~ShelfDelegateMus() {} |
114 | 115 |
115 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { | 116 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { |
116 ash::ShelfWidget* widget = shelf->shelf_widget(); | 117 SetShelfPreferredSizes(shelf); |
117 ash::ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); | |
118 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); | |
119 gfx::Size size = layout_manager->GetIdealBounds().size(); | |
120 window->SetSharedProperty<gfx::Size>( | |
121 mus::mojom::WindowManager::kPreferredSize_Property, size); | |
122 | |
123 ash::StatusAreaWidget* status_widget = widget->status_area_widget(); | |
124 mus::Window* status_window = | |
125 aura::GetMusWindow(status_widget->GetNativeWindow()); | |
126 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); | |
127 status_window->SetSharedProperty<gfx::Size>( | |
128 mus::mojom::WindowManager::kPreferredSize_Property, status_size); | |
129 } | 118 } |
130 | 119 |
131 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { | 120 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { |
132 NOTIMPLEMENTED(); | 121 NOTIMPLEMENTED(); |
133 } | 122 } |
134 | 123 |
135 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { | 124 void ShelfDelegateMus::OnShelfAlignmentChanged(Shelf* shelf) { |
136 NOTIMPLEMENTED(); | 125 SetShelfPreferredSizes(shelf); |
| 126 shelf_layout_->SetAlignment( |
| 127 static_cast<mash::wm::mojom::ShelfAlignment>(shelf->GetAlignment())); |
137 } | 128 } |
138 | 129 |
139 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) { | 130 void ShelfDelegateMus::OnShelfAutoHideBehaviorChanged(Shelf* shelf) { |
140 NOTIMPLEMENTED(); | 131 shelf_layout_->SetAutoHideBehavior( |
| 132 static_cast<mash::wm::mojom::ShelfAutoHideBehavior>( |
| 133 shelf->auto_hide_behavior())); |
141 } | 134 } |
142 | 135 |
143 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { | 136 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { |
144 NOTIMPLEMENTED(); | 137 NOTIMPLEMENTED(); |
145 return 0; | 138 return 0; |
146 } | 139 } |
147 | 140 |
148 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { | 141 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { |
149 NOTIMPLEMENTED(); | 142 NOTIMPLEMENTED(); |
150 return false; | 143 return false; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 ShelfID shelf_id = window_id_to_shelf_id_[window_id]; | 237 ShelfID shelf_id = window_id_to_shelf_id_[window_id]; |
245 int index = model_->ItemIndexByID(shelf_id); | 238 int index = model_->ItemIndexByID(shelf_id); |
246 DCHECK_GE(index, 0); | 239 DCHECK_GE(index, 0); |
247 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); | 240 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); |
248 DCHECK(iter != model_->items().end()); | 241 DCHECK(iter != model_->items().end()); |
249 ShelfItem item = *iter; | 242 ShelfItem item = *iter; |
250 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 243 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
251 model_->Set(index, item); | 244 model_->Set(index, item); |
252 } | 245 } |
253 | 246 |
| 247 void ShelfDelegateMus::SetShelfPreferredSizes(Shelf* shelf) { |
| 248 ash::ShelfWidget* widget = shelf->shelf_widget(); |
| 249 ash::ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); |
| 250 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); |
| 251 gfx::Size size = layout_manager->GetIdealBounds().size(); |
| 252 window->SetSharedProperty<gfx::Size>( |
| 253 mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 254 |
| 255 ash::StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 256 mus::Window* status_window = |
| 257 aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 258 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 259 status_window->SetSharedProperty<gfx::Size>( |
| 260 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 261 } |
| 262 |
254 } // namespace sysui | 263 } // namespace sysui |
255 } // namespace ash | 264 } // namespace ash |
OLD | NEW |