| 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/bridge/wm_window_mus.h" | 5 #include "ash/mus/bridge/wm_window_mus.h" |
| 6 | 6 |
| 7 #include "ash/common/shelf/shelf_item_types.h" |
| 7 #include "ash/common/wm/container_finder.h" | 8 #include "ash/common/wm/container_finder.h" |
| 8 #include "ash/common/wm/window_positioning_utils.h" | 9 #include "ash/common/wm/window_positioning_utils.h" |
| 9 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 10 #include "ash/common/wm_layout_manager.h" | 11 #include "ash/common/wm_layout_manager.h" |
| 11 #include "ash/common/wm_transient_window_observer.h" | 12 #include "ash/common/wm_transient_window_observer.h" |
| 12 #include "ash/common/wm_window_observer.h" | 13 #include "ash/common/wm_window_observer.h" |
| 13 #include "ash/common/wm_window_property.h" | 14 #include "ash/common/wm_window_property.h" |
| 14 #include "ash/mus/bridge/mus_layout_manager_adapter.h" | 15 #include "ash/mus/bridge/mus_layout_manager_adapter.h" |
| 15 #include "ash/mus/bridge/wm_root_window_controller_mus.h" | 16 #include "ash/mus/bridge/wm_root_window_controller_mus.h" |
| 16 #include "ash/mus/bridge/wm_shell_mus.h" | 17 #include "ash/mus/bridge/wm_shell_mus.h" |
| 17 #include "ash/mus/property_util.h" | 18 #include "ash/mus/property_util.h" |
| 18 #include "services/ui/public/cpp/property_type_converters.h" | 19 #include "services/ui/public/cpp/property_type_converters.h" |
| 19 #include "services/ui/public/cpp/window.h" | 20 #include "services/ui/public/cpp/window.h" |
| 20 #include "services/ui/public/cpp/window_property.h" | 21 #include "services/ui/public/cpp/window_property.h" |
| 21 #include "services/ui/public/cpp/window_tree_client.h" | 22 #include "services/ui/public/cpp/window_tree_client.h" |
| 22 #include "services/ui/public/interfaces/window_manager.mojom.h" | 23 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 23 #include "ui/aura/mus/mus_util.h" | 24 #include "ui/aura/mus/mus_util.h" |
| 24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 25 #include "ui/base/hit_test.h" | 26 #include "ui/base/hit_test.h" |
| 26 #include "ui/display/display.h" | 27 #include "ui/display/display.h" |
| 28 #include "ui/resources/grit/ui_resources.h" |
| 27 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
| 28 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
| 29 #include "ui/views/widget/widget_delegate.h" | 31 #include "ui/views/widget/widget_delegate.h" |
| 30 | 32 |
| 31 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmWindowMus*); | 33 MUS_DECLARE_WINDOW_PROPERTY_TYPE(ash::mus::WmWindowMus*); |
| 32 | 34 |
| 33 namespace { | 35 namespace { |
| 34 | 36 |
| 35 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::mus::WmWindowMus, | 37 MUS_DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::mus::WmWindowMus, |
| 36 kWmWindowKey, | 38 kWmWindowKey, |
| 37 nullptr); | 39 nullptr); |
| 38 | 40 |
| 39 } // namespace | 41 } // namespace |
| 40 | 42 |
| 41 namespace ash { | 43 namespace ash { |
| 42 namespace mus { | 44 namespace mus { |
| 43 | 45 |
| 44 namespace { | 46 namespace { |
| 45 | 47 |
| 46 // This classes is used so that the WindowState constructor can be made | 48 // This class is used so that the WindowState constructor can be made protected. |
| 47 // protected. GetWindowState() is the only place that should be creating | 49 // GetWindowState() is the only place that should be creating WindowState. |
| 48 // WindowState. | |
| 49 class WindowStateMus : public wm::WindowState { | 50 class WindowStateMus : public wm::WindowState { |
| 50 public: | 51 public: |
| 51 explicit WindowStateMus(WmWindow* window) : wm::WindowState(window) {} | 52 explicit WindowStateMus(WmWindow* window) : wm::WindowState(window) {} |
| 52 ~WindowStateMus() override {} | 53 ~WindowStateMus() override {} |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); | 56 DISALLOW_COPY_AND_ASSIGN(WindowStateMus); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 ui::WindowShowState UIWindowShowStateFromMojom(ui::mojom::ShowState state) { | 59 ui::WindowShowState UIWindowShowStateFromMojom(ui::mojom::ShowState state) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 189 } |
| 189 } | 190 } |
| 190 | 191 |
| 191 std::string WmWindowMus::GetName() const { | 192 std::string WmWindowMus::GetName() const { |
| 192 return window_->HasSharedProperty(ui::mojom::WindowManager::kName_Property) | 193 return window_->HasSharedProperty(ui::mojom::WindowManager::kName_Property) |
| 193 ? window_->GetSharedProperty<std::string>( | 194 ? window_->GetSharedProperty<std::string>( |
| 194 ui::mojom::WindowManager::kName_Property) | 195 ui::mojom::WindowManager::kName_Property) |
| 195 : std::string(); | 196 : std::string(); |
| 196 } | 197 } |
| 197 | 198 |
| 199 void WmWindowMus::SetTitle(const base::string16& title) { |
| 200 SetWindowTitle(window_, title); |
| 201 } |
| 202 |
| 198 base::string16 WmWindowMus::GetTitle() const { | 203 base::string16 WmWindowMus::GetTitle() const { |
| 199 return GetWindowTitle(window_); | 204 return GetWindowTitle(window_); |
| 200 } | 205 } |
| 201 | 206 |
| 202 void WmWindowMus::SetShellWindowId(int id) { | 207 void WmWindowMus::SetShellWindowId(int id) { |
| 203 shell_window_id_ = id; | 208 shell_window_id_ = id; |
| 204 } | 209 } |
| 205 | 210 |
| 206 int WmWindowMus::GetShellWindowId() const { | 211 int WmWindowMus::GetShellWindowId() const { |
| 207 return shell_window_id_; | 212 return shell_window_id_; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 if (key == WmWindowProperty::TOP_VIEW_COLOR) { | 371 if (key == WmWindowProperty::TOP_VIEW_COLOR) { |
| 367 // TODO: need support for TOP_VIEW_COLOR: http://crbug.com/615100. | 372 // TODO: need support for TOP_VIEW_COLOR: http://crbug.com/615100. |
| 368 NOTIMPLEMENTED(); | 373 NOTIMPLEMENTED(); |
| 369 return; | 374 return; |
| 370 } | 375 } |
| 371 | 376 |
| 372 NOTREACHED(); | 377 NOTREACHED(); |
| 373 } | 378 } |
| 374 | 379 |
| 375 int WmWindowMus::GetIntProperty(WmWindowProperty key) { | 380 int WmWindowMus::GetIntProperty(WmWindowProperty key) { |
| 381 if (key == WmWindowProperty::MODAL_TYPE) { |
| 382 // TODO: WindowTree::SetModalWindow() needs to route through WindowManager |
| 383 // so wm can position. http://crbug.com/645996. |
| 384 NOTIMPLEMENTED(); |
| 385 return static_cast<int>(ui::MODAL_TYPE_NONE); |
| 386 } |
| 387 |
| 388 if (key == WmWindowProperty::SHELF_ICON_RESOURCE_ID) { |
| 389 if (window_->HasSharedProperty( |
| 390 ui::mojom::WindowManager::kShelfIconResourceId_Property)) { |
| 391 return window_->GetSharedProperty<int>( |
| 392 ui::mojom::WindowManager::kShelfIconResourceId_Property); |
| 393 } |
| 394 // Mash provides a default shelf icon image. |
| 395 // TODO(msw): Support icon resource ids and bitmaps: |
| 396 // mojo::Array<uint8_t> app_icon = GetWindowAppIcon(window_); |
| 397 return IDR_DEFAULT_FAVICON; |
| 398 } |
| 399 |
| 376 if (key == WmWindowProperty::SHELF_ID) { | 400 if (key == WmWindowProperty::SHELF_ID) { |
| 377 NOTIMPLEMENTED(); | 401 NOTIMPLEMENTED(); |
| 378 return 0; | 402 return kInvalidShelfID; |
| 403 } |
| 404 |
| 405 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { |
| 406 if (window_->HasSharedProperty( |
| 407 ui::mojom::WindowManager::kShelfItemType_Property)) { |
| 408 return window_->GetSharedProperty<int>( |
| 409 ui::mojom::WindowManager::kShelfItemType_Property); |
| 410 } |
| 411 // Mash provides a default shelf item type for non-ignored windows. |
| 412 return GetWindowIgnoredByShelf(window_) ? TYPE_UNDEFINED |
| 413 : TYPE_PLATFORM_APP; |
| 379 } | 414 } |
| 380 | 415 |
| 381 if (key == WmWindowProperty::TOP_VIEW_INSET) { | 416 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| 382 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. | 417 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. |
| 383 NOTIMPLEMENTED(); | 418 NOTIMPLEMENTED(); |
| 384 return 0; | 419 return 0; |
| 385 } | 420 } |
| 386 | 421 |
| 387 if (key == WmWindowProperty::MODAL_TYPE) { | |
| 388 // TODO: WindowTree::SetModalWindow() needs to route through WindowManager | |
| 389 // so wm can position. http://crbug.com/645996. | |
| 390 NOTIMPLEMENTED(); | |
| 391 return static_cast<int>(ui::MODAL_TYPE_NONE); | |
| 392 } | |
| 393 | |
| 394 NOTREACHED(); | 422 NOTREACHED(); |
| 395 return 0; | 423 return 0; |
| 396 } | 424 } |
| 397 | 425 |
| 398 void WmWindowMus::SetIntProperty(WmWindowProperty key, int value) { | 426 void WmWindowMus::SetIntProperty(WmWindowProperty key, int value) { |
| 427 if (key == WmWindowProperty::SHELF_ICON_RESOURCE_ID) { |
| 428 window_->SetSharedProperty<int>( |
| 429 ui::mojom::WindowManager::kShelfIconResourceId_Property, value); |
| 430 return; |
| 431 } |
| 432 |
| 399 if (key == WmWindowProperty::SHELF_ID) { | 433 if (key == WmWindowProperty::SHELF_ID) { |
| 400 NOTIMPLEMENTED(); | 434 NOTIMPLEMENTED(); |
| 401 return; | 435 return; |
| 402 } | 436 } |
| 403 | 437 |
| 438 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { |
| 439 window_->SetSharedProperty<int>( |
| 440 ui::mojom::WindowManager::kShelfItemType_Property, value); |
| 441 return; |
| 442 } |
| 443 |
| 404 if (key == WmWindowProperty::TOP_VIEW_INSET) { | 444 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| 405 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. | 445 // TODO: need support for TOP_VIEW_INSET: http://crbug.com/615100. |
| 406 NOTIMPLEMENTED(); | 446 NOTIMPLEMENTED(); |
| 407 return; | 447 return; |
| 408 } | 448 } |
| 409 | 449 |
| 410 NOTREACHED(); | 450 NOTREACHED(); |
| 411 } | 451 } |
| 412 | 452 |
| 413 ShelfItemDetails* WmWindowMus::GetShelfItemDetails() { | |
| 414 NOTIMPLEMENTED(); // TODO: Add support; see crbug.com/634150 | |
| 415 return nullptr; | |
| 416 } | |
| 417 | |
| 418 void WmWindowMus::SetShelfItemDetails(const ShelfItemDetails& details) { | |
| 419 NOTIMPLEMENTED(); // TODO: Add support; see crbug.com/634150 | |
| 420 } | |
| 421 | |
| 422 void WmWindowMus::ClearShelfItemDetails() { | |
| 423 NOTIMPLEMENTED(); // TODO: Add support; see crbug.com/634150 | |
| 424 } | |
| 425 | |
| 426 const wm::WindowState* WmWindowMus::GetWindowState() const { | 453 const wm::WindowState* WmWindowMus::GetWindowState() const { |
| 427 return window_state_.get(); | 454 return window_state_.get(); |
| 428 } | 455 } |
| 429 | 456 |
| 430 WmWindow* WmWindowMus::GetToplevelWindow() { | 457 WmWindow* WmWindowMus::GetToplevelWindow() { |
| 431 return WmShellMus::GetToplevelAncestor(window_); | 458 return WmShellMus::GetToplevelAncestor(window_); |
| 432 } | 459 } |
| 433 | 460 |
| 434 WmWindow* WmWindowMus::GetToplevelWindowForFocus() { | 461 WmWindow* WmWindowMus::GetToplevelWindowForFocus() { |
| 435 // TODO(sky): resolve if we really need two notions of top-level. In the mus | 462 // TODO(sky): resolve if we really need two notions of top-level. In the mus |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 } | 967 } |
| 941 | 968 |
| 942 void WmWindowMus::OnTransientChildRemoved(ui::Window* window, | 969 void WmWindowMus::OnTransientChildRemoved(ui::Window* window, |
| 943 ui::Window* transient) { | 970 ui::Window* transient) { |
| 944 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, | 971 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, |
| 945 OnTransientChildRemoved(this, Get(transient))); | 972 OnTransientChildRemoved(this, Get(transient))); |
| 946 } | 973 } |
| 947 | 974 |
| 948 } // namespace mus | 975 } // namespace mus |
| 949 } // namespace ash | 976 } // namespace ash |
| OLD | NEW |