| 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/shelf/shelf_item_types.h" |
| 8 #include "ash/common/wm/container_finder.h" | 8 #include "ash/common/wm/container_finder.h" |
| 9 #include "ash/common/wm/window_positioning_utils.h" | 9 #include "ash/common/wm/window_positioning_utils.h" |
| 10 #include "ash/common/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 case ui::SHOW_STATE_FULLSCREEN: | 93 case ui::SHOW_STATE_FULLSCREEN: |
| 94 return ui::mojom::ShowState::FULLSCREEN; | 94 return ui::mojom::ShowState::FULLSCREEN; |
| 95 case ui::SHOW_STATE_DOCKED: | 95 case ui::SHOW_STATE_DOCKED: |
| 96 return ui::mojom::ShowState::DOCKED; | 96 return ui::mojom::ShowState::DOCKED; |
| 97 default: | 97 default: |
| 98 break; | 98 break; |
| 99 } | 99 } |
| 100 return ui::mojom::ShowState::DEFAULT; | 100 return ui::mojom::ShowState::DEFAULT; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Returns the WmWindowProperty enum value for the given ui::Window key name. |
| 104 WmWindowProperty WmWindowPropertyFromUI(const std::string& ui_window_key) { |
| 105 if (ui_window_key == ui::mojom::WindowManager::kAlwaysOnTop_Property) |
| 106 return WmWindowProperty::ALWAYS_ON_TOP; |
| 107 if (ui_window_key == ui::mojom::WindowManager::kShelfIconResourceId_Property) |
| 108 return WmWindowProperty::SHELF_ICON_RESOURCE_ID; |
| 109 if (ui_window_key == ui::mojom::WindowManager::kShelfItemType_Property) |
| 110 return WmWindowProperty::SHELF_ITEM_TYPE; |
| 111 return WmWindowProperty::INVALID_PROPERTY; |
| 112 } |
| 113 |
| 103 } // namespace | 114 } // namespace |
| 104 | 115 |
| 105 WmWindowMus::WmWindowMus(ui::Window* window) | 116 WmWindowMus::WmWindowMus(ui::Window* window) |
| 106 : window_(window), | 117 : window_(window), |
| 107 // Matches aura, see aura::Window for details. | 118 // Matches aura, see aura::Window for details. |
| 108 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { | 119 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 109 window_->AddObserver(this); | 120 window_->AddObserver(this); |
| 110 window_->SetLocalProperty(kWmWindowKey, this); | 121 window_->SetLocalProperty(kWmWindowKey, this); |
| 111 window_state_.reset(new WindowStateMus(this)); | 122 window_state_.reset(new WindowStateMus(this)); |
| 112 } | 123 } |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 return window_->GetSharedProperty<int>( | 413 return window_->GetSharedProperty<int>( |
| 403 ui::mojom::WindowManager::kShelfIconResourceId_Property); | 414 ui::mojom::WindowManager::kShelfIconResourceId_Property); |
| 404 } | 415 } |
| 405 // Mash provides a default shelf icon image. | 416 // Mash provides a default shelf icon image. |
| 406 // TODO(msw): Support icon resource ids and bitmaps: | 417 // TODO(msw): Support icon resource ids and bitmaps: |
| 407 // mojo::Array<uint8_t> app_icon = GetWindowAppIcon(window_); | 418 // mojo::Array<uint8_t> app_icon = GetWindowAppIcon(window_); |
| 408 return IDR_DEFAULT_FAVICON; | 419 return IDR_DEFAULT_FAVICON; |
| 409 } | 420 } |
| 410 | 421 |
| 411 if (key == WmWindowProperty::SHELF_ID) { | 422 if (key == WmWindowProperty::SHELF_ID) { |
| 412 NOTIMPLEMENTED(); | 423 if (window_->HasSharedProperty( |
| 424 ui::mojom::WindowManager::kShelfId_Property)) { |
| 425 return window_->GetSharedProperty<int>( |
| 426 ui::mojom::WindowManager::kShelfId_Property); |
| 427 } |
| 428 |
| 413 return kInvalidShelfID; | 429 return kInvalidShelfID; |
| 414 } | 430 } |
| 415 | 431 |
| 416 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | 432 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { |
| 417 if (window_->HasSharedProperty( | 433 if (window_->HasSharedProperty( |
| 418 ui::mojom::WindowManager::kShelfItemType_Property)) { | 434 ui::mojom::WindowManager::kShelfItemType_Property)) { |
| 419 return window_->GetSharedProperty<int>( | 435 return window_->GetSharedProperty<int>( |
| 420 ui::mojom::WindowManager::kShelfItemType_Property); | 436 ui::mojom::WindowManager::kShelfItemType_Property); |
| 421 } | 437 } |
| 422 // Mash provides a default shelf item type for non-ignored windows. | 438 // Mash provides a default shelf item type for non-ignored windows. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 435 } | 451 } |
| 436 | 452 |
| 437 void WmWindowMus::SetIntProperty(WmWindowProperty key, int value) { | 453 void WmWindowMus::SetIntProperty(WmWindowProperty key, int value) { |
| 438 if (key == WmWindowProperty::SHELF_ICON_RESOURCE_ID) { | 454 if (key == WmWindowProperty::SHELF_ICON_RESOURCE_ID) { |
| 439 window_->SetSharedProperty<int>( | 455 window_->SetSharedProperty<int>( |
| 440 ui::mojom::WindowManager::kShelfIconResourceId_Property, value); | 456 ui::mojom::WindowManager::kShelfIconResourceId_Property, value); |
| 441 return; | 457 return; |
| 442 } | 458 } |
| 443 | 459 |
| 444 if (key == WmWindowProperty::SHELF_ID) { | 460 if (key == WmWindowProperty::SHELF_ID) { |
| 445 NOTIMPLEMENTED(); | 461 window_->SetSharedProperty<int>(ui::mojom::WindowManager::kShelfId_Property, |
| 462 value); |
| 446 return; | 463 return; |
| 447 } | 464 } |
| 448 | 465 |
| 449 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { | 466 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { |
| 450 window_->SetSharedProperty<int>( | 467 window_->SetSharedProperty<int>( |
| 451 ui::mojom::WindowManager::kShelfItemType_Property, value); | 468 ui::mojom::WindowManager::kShelfItemType_Property, value); |
| 452 return; | 469 return; |
| 453 } | 470 } |
| 454 | 471 |
| 455 if (key == WmWindowProperty::TOP_VIEW_INSET) { | 472 if (key == WmWindowProperty::TOP_VIEW_INSET) { |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 | 944 |
| 928 void WmWindowMus::OnWindowSharedPropertyChanged( | 945 void WmWindowMus::OnWindowSharedPropertyChanged( |
| 929 ui::Window* window, | 946 ui::Window* window, |
| 930 const std::string& name, | 947 const std::string& name, |
| 931 const std::vector<uint8_t>* old_data, | 948 const std::vector<uint8_t>* old_data, |
| 932 const std::vector<uint8_t>* new_data) { | 949 const std::vector<uint8_t>* new_data) { |
| 933 if (name == ui::mojom::WindowManager::kShowState_Property) { | 950 if (name == ui::mojom::WindowManager::kShowState_Property) { |
| 934 GetWindowState()->OnWindowShowStateChanged(); | 951 GetWindowState()->OnWindowShowStateChanged(); |
| 935 return; | 952 return; |
| 936 } | 953 } |
| 937 if (name == ui::mojom::WindowManager::kAlwaysOnTop_Property) { | 954 if (name == ui::mojom::WindowManager::kWindowTitle_Property) { |
| 938 FOR_EACH_OBSERVER( | 955 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowTitleChanged(this)); |
| 939 WmWindowObserver, observers_, | |
| 940 OnWindowPropertyChanged(this, WmWindowProperty::ALWAYS_ON_TOP)); | |
| 941 return; | 956 return; |
| 942 } | 957 } |
| 943 | 958 |
| 959 // Notify WmWindowObserver of certain white-listed property changes. |
| 960 WmWindowProperty wm_property = WmWindowPropertyFromUI(name); |
| 961 if (wm_property != WmWindowProperty::INVALID_PROPERTY) { |
| 962 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 963 OnWindowPropertyChanged(this, wm_property)); |
| 964 return; |
| 965 } |
| 966 |
| 944 // Deal with snap to pixel. | 967 // Deal with snap to pixel. |
| 945 NOTIMPLEMENTED(); | 968 NOTIMPLEMENTED(); |
| 946 } | 969 } |
| 947 | 970 |
| 948 void WmWindowMus::OnWindowBoundsChanged(ui::Window* window, | 971 void WmWindowMus::OnWindowBoundsChanged(ui::Window* window, |
| 949 const gfx::Rect& old_bounds, | 972 const gfx::Rect& old_bounds, |
| 950 const gfx::Rect& new_bounds) { | 973 const gfx::Rect& new_bounds) { |
| 951 FOR_EACH_OBSERVER(WmWindowObserver, observers_, | 974 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 952 OnWindowBoundsChanged(this, old_bounds, new_bounds)); | 975 OnWindowBoundsChanged(this, old_bounds, new_bounds)); |
| 953 } | 976 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 978 } | 1001 } |
| 979 | 1002 |
| 980 void WmWindowMus::OnTransientChildRemoved(ui::Window* window, | 1003 void WmWindowMus::OnTransientChildRemoved(ui::Window* window, |
| 981 ui::Window* transient) { | 1004 ui::Window* transient) { |
| 982 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, | 1005 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, |
| 983 OnTransientChildRemoved(this, Get(transient))); | 1006 OnTransientChildRemoved(this, Get(transient))); |
| 984 } | 1007 } |
| 985 | 1008 |
| 986 } // namespace mus | 1009 } // namespace mus |
| 987 } // namespace ash | 1010 } // namespace ash |
| OLD | NEW |