| 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 "ash/shelf/shelf.h" | 7 #include "ash/shelf/shelf.h" |
| 8 #include "ash/shelf/shelf_item_delegate.h" | 8 #include "ash/shelf/shelf_item_delegate.h" |
| 9 #include "ash/shelf/shelf_item_delegate_manager.h" | 9 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 uint32_t window_id_; | 74 uint32_t window_id_; |
| 75 base::string16 title_; | 75 base::string16 title_; |
| 76 UserWindowController* user_window_controller_; | 76 UserWindowController* user_window_controller_; |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegateMus); | 78 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegateMus); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) | 83 ShelfDelegateMus::ShelfDelegateMus(ShelfModel* model) |
| 84 : model_(model), binding_(this) { | 84 : model_(model), shelf_(nullptr), binding_(this) { |
| 85 mojo::Connector* connector = | 85 mojo::Connector* connector = |
| 86 views::WindowManagerConnection::Get()->connector(); | 86 views::WindowManagerConnection::Get()->connector(); |
| 87 connector->ConnectToInterface("mojo:desktop_wm", &shelf_layout_); |
| 87 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); | 88 connector->ConnectToInterface("mojo:desktop_wm", &user_window_controller_); |
| 88 user_window_controller_->AddUserWindowObserver( | 89 user_window_controller_->AddUserWindowObserver( |
| 89 binding_.CreateInterfacePtrAndBind()); | 90 binding_.CreateInterfacePtrAndBind()); |
| 90 } | 91 } |
| 91 | 92 |
| 92 ShelfDelegateMus::~ShelfDelegateMus() {} | 93 ShelfDelegateMus::~ShelfDelegateMus() {} |
| 93 | 94 |
| 94 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { | 95 void ShelfDelegateMus::OnShelfCreated(Shelf* shelf) { |
| 96 shelf_ = shelf; |
| 95 ash::ShelfWidget* widget = shelf->shelf_widget(); | 97 ash::ShelfWidget* widget = shelf->shelf_widget(); |
| 96 ash::ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); | 98 ash::ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); |
| 97 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); | 99 mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); |
| 98 gfx::Size size = layout_manager->GetIdealBounds().size(); | 100 gfx::Size size = layout_manager->GetIdealBounds().size(); |
| 99 window->SetSharedProperty<gfx::Size>( | 101 window->SetSharedProperty<gfx::Size>( |
| 100 mus::mojom::WindowManager::kPreferredSize_Property, size); | 102 mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 101 | 103 |
| 102 ash::StatusAreaWidget* status_widget = widget->status_area_widget(); | 104 ash::StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 103 mus::Window* status_window = | 105 mus::Window* status_window = |
| 104 aura::GetMusWindow(status_widget->GetNativeWindow()); | 106 aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 105 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); | 107 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 106 status_window->SetSharedProperty<gfx::Size>( | 108 status_window->SetSharedProperty<gfx::Size>( |
| 107 mus::mojom::WindowManager::kPreferredSize_Property, status_size); | 109 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 108 } | 110 } |
| 109 | 111 |
| 110 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { | 112 void ShelfDelegateMus::OnShelfDestroyed(Shelf* shelf) { |
| 111 NOTIMPLEMENTED(); | 113 DCHECK_EQ(shelf_, shelf); |
| 114 shelf_ = nullptr; |
| 115 } |
| 116 |
| 117 void ShelfDelegateMus::OnAlignmentChanged(ShelfAlignment alignment) { |
| 118 LOG(ERROR) << "MSW ShelfDelegateMus::OnShelfAlignmentChanged"; |
| 119 // TODO(msw): Need to update the preferred sizes... |
| 120 |
| 121 // ash::ShelfWidget* widget = shelf_->shelf_widget(); |
| 122 // ash::ShelfLayoutManager* layout_manager = widget->shelf_layout_manager(); |
| 123 // mus::Window* window = aura::GetMusWindow(widget->GetNativeWindow()); |
| 124 // gfx::Size size = layout_manager->GetIdealBounds().size(); |
| 125 // window->SetSharedProperty<gfx::Size>( |
| 126 // mus::mojom::WindowManager::kPreferredSize_Property, size); |
| 127 |
| 128 // ash::StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 129 // mus::Window* status_window = |
| 130 // aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 131 // gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 132 // status_window->SetSharedProperty<gfx::Size>( |
| 133 // mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 134 |
| 135 shelf_layout_->SetAlignment( |
| 136 static_cast<mash::wm::mojom::ShelfAlignment>(alignment)); |
| 137 } |
| 138 |
| 139 void ShelfDelegateMus::OnAutoHideBehaviorChanged( |
| 140 ShelfAutoHideBehavior auto_hide) { |
| 141 LOG(ERROR) << "MSW ShelfDelegateMus::OnAutoHideBehaviorChanged"; |
| 142 shelf_layout_->SetAutoHideBehavior( |
| 143 static_cast<mash::wm::mojom::ShelfAutoHideBehavior>(auto_hide)); |
| 112 } | 144 } |
| 113 | 145 |
| 114 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { | 146 ShelfID ShelfDelegateMus::GetShelfIDForAppID(const std::string& app_id) { |
| 115 NOTIMPLEMENTED(); | 147 NOTIMPLEMENTED(); |
| 116 return 0; | 148 return 0; |
| 117 } | 149 } |
| 118 | 150 |
| 119 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { | 151 bool ShelfDelegateMus::HasShelfIDToAppIDMapping(ShelfID id) const { |
| 120 NOTIMPLEMENTED(); | 152 NOTIMPLEMENTED(); |
| 121 return false; | 153 return false; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 DCHECK_GE(index, 0); | 235 DCHECK_GE(index, 0); |
| 204 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); | 236 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); |
| 205 DCHECK(iter != model_->items().end()); | 237 DCHECK(iter != model_->items().end()); |
| 206 ShelfItem item = *iter; | 238 ShelfItem item = *iter; |
| 207 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 239 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
| 208 model_->Set(index, item); | 240 model_->Set(index, item); |
| 209 } | 241 } |
| 210 | 242 |
| 211 } // namespace sysui | 243 } // namespace sysui |
| 212 } // namespace ash | 244 } // namespace ash |
| OLD | NEW |