| 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 "mash/wm/bridge/wm_window_mus.h" | 5 #include "mash/wm/bridge/wm_window_mus.h" |
| 6 | 6 |
| 7 #include "ash/wm/common/container_finder.h" | 7 #include "ash/wm/common/container_finder.h" |
| 8 #include "ash/wm/common/window_state.h" | 8 #include "ash/wm/common/window_state.h" |
| 9 #include "ash/wm/common/wm_layout_manager.h" | 9 #include "ash/wm/common/wm_layout_manager.h" |
| 10 #include "ash/wm/common/wm_window_observer.h" | 10 #include "ash/wm/common/wm_window_observer.h" |
| 11 #include "ash/wm/common/wm_window_property.h" | 11 #include "ash/wm/common/wm_window_property.h" |
| 12 #include "components/mus/public/cpp/property_type_converters.h" |
| 12 #include "components/mus/public/cpp/window.h" | 13 #include "components/mus/public/cpp/window.h" |
| 13 #include "components/mus/public/cpp/window_property.h" | 14 #include "components/mus/public/cpp/window_property.h" |
| 14 #include "components/mus/public/cpp/window_tree_client.h" | 15 #include "components/mus/public/cpp/window_tree_client.h" |
| 16 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 15 #include "mash/wm/bridge/mus_layout_manager_adapter.h" | 17 #include "mash/wm/bridge/mus_layout_manager_adapter.h" |
| 16 #include "mash/wm/bridge/wm_globals_mus.h" | 18 #include "mash/wm/bridge/wm_globals_mus.h" |
| 17 #include "mash/wm/bridge/wm_root_window_controller_mus.h" | 19 #include "mash/wm/bridge/wm_root_window_controller_mus.h" |
| 18 #include "mash/wm/property_util.h" | 20 #include "mash/wm/property_util.h" |
| 19 #include "ui/aura/mus/mus_util.h" | 21 #include "ui/aura/mus/mus_util.h" |
| 20 #include "ui/base/hit_test.h" | 22 #include "ui/base/hit_test.h" |
| 21 #include "ui/display/display.h" | 23 #include "ui/display/display.h" |
| 22 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 23 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
| 24 | 26 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 for (size_t i = 0; i < mus_windows.size(); ++i) | 141 for (size_t i = 0; i < mus_windows.size(); ++i) |
| 140 result[i] = Get(mus_windows[i]); | 142 result[i] = Get(mus_windows[i]); |
| 141 return result; | 143 return result; |
| 142 } | 144 } |
| 143 | 145 |
| 144 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() | 146 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() |
| 145 const { | 147 const { |
| 146 return WmRootWindowControllerMus::Get(window_->GetRoot()); | 148 return WmRootWindowControllerMus::Get(window_->GetRoot()); |
| 147 } | 149 } |
| 148 | 150 |
| 151 bool WmWindowMus::ShouldUseExtendedHitRegion() const { |
| 152 const WmWindowMus* parent = Get(window_->parent()); |
| 153 return parent && parent->children_use_extended_hit_region_; |
| 154 } |
| 155 |
| 149 const ash::wm::WmWindow* WmWindowMus::GetRootWindow() const { | 156 const ash::wm::WmWindow* WmWindowMus::GetRootWindow() const { |
| 150 return Get(window_->GetRoot()); | 157 return Get(window_->GetRoot()); |
| 151 } | 158 } |
| 152 | 159 |
| 153 ash::wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { | 160 ash::wm::WmRootWindowController* WmWindowMus::GetRootWindowController() { |
| 154 return GetRootWindowControllerMus(); | 161 return GetRootWindowControllerMus(); |
| 155 } | 162 } |
| 156 | 163 |
| 157 ash::wm::WmGlobals* WmWindowMus::GetGlobals() const { | 164 ash::wm::WmGlobals* WmWindowMus::GetGlobals() const { |
| 158 return WmGlobalsMus::Get(); | 165 return WmGlobalsMus::Get(); |
| 159 } | 166 } |
| 160 | 167 |
| 168 void WmWindowMus::SetName(const char* name) { |
| 169 if (name) { |
| 170 window_->SetSharedProperty<std::string>( |
| 171 mus::mojom::WindowManager::kName_Property, std::string(name)); |
| 172 } else { |
| 173 window_->ClearSharedProperty(mus::mojom::WindowManager::kName_Property); |
| 174 } |
| 175 } |
| 176 |
| 161 base::string16 WmWindowMus::GetTitle() const { | 177 base::string16 WmWindowMus::GetTitle() const { |
| 162 return GetWindowTitle(window_); | 178 return GetWindowTitle(window_); |
| 163 } | 179 } |
| 164 | 180 |
| 165 void WmWindowMus::SetShellWindowId(int id) { | 181 void WmWindowMus::SetShellWindowId(int id) { |
| 166 shell_window_id_ = id; | 182 shell_window_id_ = id; |
| 167 } | 183 } |
| 168 | 184 |
| 169 int WmWindowMus::GetShellWindowId() const { | 185 int WmWindowMus::GetShellWindowId() const { |
| 170 return shell_window_id_; | 186 return shell_window_id_; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return gfx::Transform(); | 288 return gfx::Transform(); |
| 273 } | 289 } |
| 274 | 290 |
| 275 bool WmWindowMus::IsSystemModal() const { | 291 bool WmWindowMus::IsSystemModal() const { |
| 276 NOTIMPLEMENTED(); | 292 NOTIMPLEMENTED(); |
| 277 return false; | 293 return false; |
| 278 } | 294 } |
| 279 | 295 |
| 280 bool WmWindowMus::GetBoolProperty(ash::wm::WmWindowProperty key) { | 296 bool WmWindowMus::GetBoolProperty(ash::wm::WmWindowProperty key) { |
| 281 switch (key) { | 297 switch (key) { |
| 282 case ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUDARY: | 298 case ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: |
| 283 NOTIMPLEMENTED(); | 299 return snap_children_to_pixel_boundary_; |
| 284 return true; | |
| 285 | 300 |
| 286 case ash::wm::WmWindowProperty::ALWAYS_ON_TOP: | 301 case ash::wm::WmWindowProperty::ALWAYS_ON_TOP: |
| 287 return IsAlwaysOnTop(); | 302 return IsAlwaysOnTop(); |
| 288 | 303 |
| 289 default: | 304 default: |
| 290 NOTREACHED(); | 305 NOTREACHED(); |
| 291 break; | 306 break; |
| 292 } | 307 } |
| 293 | 308 |
| 294 NOTREACHED(); | 309 NOTREACHED(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 // TODO: need animation support: http://crbug.com/615087. | 390 // TODO: need animation support: http://crbug.com/615087. |
| 376 NOTIMPLEMENTED(); | 391 NOTIMPLEMENTED(); |
| 377 } | 392 } |
| 378 | 393 |
| 379 void WmWindowMus::StopAnimatingProperty( | 394 void WmWindowMus::StopAnimatingProperty( |
| 380 ui::LayerAnimationElement::AnimatableProperty property) { | 395 ui::LayerAnimationElement::AnimatableProperty property) { |
| 381 // TODO: need animation support: http://crbug.com/615087. | 396 // TODO: need animation support: http://crbug.com/615087. |
| 382 NOTIMPLEMENTED(); | 397 NOTIMPLEMENTED(); |
| 383 } | 398 } |
| 384 | 399 |
| 400 void WmWindowMus::SetChildWindowVisibilityChangesAnimated() { |
| 401 // TODO: need animation support: http://crbug.com/615087. |
| 402 NOTIMPLEMENTED(); |
| 403 } |
| 404 |
| 405 void WmWindowMus::SetMasksToBounds(bool value) { |
| 406 // TODO: mus needs mask to bounds support: http://crbug.com/615550. |
| 407 NOTIMPLEMENTED(); |
| 408 } |
| 409 |
| 385 void WmWindowMus::SetBounds(const gfx::Rect& bounds) { | 410 void WmWindowMus::SetBounds(const gfx::Rect& bounds) { |
| 386 if (window_->parent()) { | 411 if (window_->parent()) { |
| 387 WmWindowMus* parent = WmWindowMus::Get(window_->parent()); | 412 WmWindowMus* parent = WmWindowMus::Get(window_->parent()); |
| 388 if (parent->layout_manager_adapter_) { | 413 if (parent->layout_manager_adapter_) { |
| 389 parent->layout_manager_adapter_->layout_manager()->SetChildBounds(this, | 414 parent->layout_manager_adapter_->layout_manager()->SetChildBounds(this, |
| 390 bounds); | 415 bounds); |
| 391 return; | 416 return; |
| 392 } | 417 } |
| 393 } | 418 } |
| 394 SetBoundsDirect(bounds); | 419 SetBoundsDirect(bounds); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 413 } | 438 } |
| 414 | 439 |
| 415 void WmWindowMus::SetBoundsDirectCrossFade(const gfx::Rect& bounds) { | 440 void WmWindowMus::SetBoundsDirectCrossFade(const gfx::Rect& bounds) { |
| 416 // TODO: need animation support: http://crbug.com/615087. | 441 // TODO: need animation support: http://crbug.com/615087. |
| 417 NOTIMPLEMENTED(); | 442 NOTIMPLEMENTED(); |
| 418 SetBoundsDirect(bounds); | 443 SetBoundsDirect(bounds); |
| 419 } | 444 } |
| 420 | 445 |
| 421 void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen, | 446 void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen, |
| 422 const display::Display& dst_display) { | 447 const display::Display& dst_display) { |
| 423 // TODO(sky): need to find WmRootWindowControllerMus for dst_display and | 448 // TODO: SetBoundsInScreen isn't fully implemented yet, |
| 424 // convert. | 449 // http://crbug.com/615552. |
| 425 NOTIMPLEMENTED(); | 450 NOTIMPLEMENTED(); |
| 426 SetBounds(ConvertRectFromScreen(bounds_in_screen)); | 451 SetBounds(ConvertRectFromScreen(bounds_in_screen)); |
| 427 } | 452 } |
| 428 | 453 |
| 429 gfx::Rect WmWindowMus::GetBoundsInScreen() const { | 454 gfx::Rect WmWindowMus::GetBoundsInScreen() const { |
| 430 return ConvertRectToScreen(gfx::Rect(window_->bounds().size())); | 455 return ConvertRectToScreen(gfx::Rect(window_->bounds().size())); |
| 431 } | 456 } |
| 432 | 457 |
| 433 const gfx::Rect& WmWindowMus::GetBounds() const { | 458 const gfx::Rect& WmWindowMus::GetBounds() const { |
| 434 return window_->bounds(); | 459 return window_->bounds(); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 636 } |
| 612 | 637 |
| 613 void WmWindowMus::ShowResizeShadow(int component) { | 638 void WmWindowMus::ShowResizeShadow(int component) { |
| 614 NOTIMPLEMENTED(); | 639 NOTIMPLEMENTED(); |
| 615 } | 640 } |
| 616 | 641 |
| 617 void WmWindowMus::HideResizeShadow() { | 642 void WmWindowMus::HideResizeShadow() { |
| 618 NOTIMPLEMENTED(); | 643 NOTIMPLEMENTED(); |
| 619 } | 644 } |
| 620 | 645 |
| 621 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { | 646 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( |
| 647 ash::wm::WmWindow::BoundsInScreenBehavior behavior) { |
| 648 // TODO: SetBoundsInScreen isn't fully implemented yet, |
| 649 // http://crbug.com/615552. |
| 622 NOTIMPLEMENTED(); | 650 NOTIMPLEMENTED(); |
| 623 } | 651 } |
| 624 | 652 |
| 653 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { |
| 654 if (snap_children_to_pixel_boundary_) |
| 655 return; |
| 656 |
| 657 snap_children_to_pixel_boundary_ = true; |
| 658 FOR_EACH_OBSERVER( |
| 659 ash::wm::WmWindowObserver, observers_, |
| 660 OnWindowPropertyChanged( |
| 661 this, ash::wm::WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); |
| 662 } |
| 663 |
| 664 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { |
| 665 WmWindowMus* parent = Get(window_->parent()); |
| 666 if (parent && parent->snap_children_to_pixel_boundary_) { |
| 667 // TODO: implement snap to pixel: http://crbug.com/615554. |
| 668 NOTIMPLEMENTED(); |
| 669 } |
| 670 } |
| 671 |
| 672 void WmWindowMus::SetChildrenUseExtendedHitRegion() { |
| 673 children_use_extended_hit_region_ = true; |
| 674 } |
| 675 |
| 676 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) { |
| 677 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented: |
| 678 // http://crbug.com/615552. |
| 679 NOTIMPLEMENTED(); |
| 680 } |
| 681 |
| 625 void WmWindowMus::AddObserver(ash::wm::WmWindowObserver* observer) { | 682 void WmWindowMus::AddObserver(ash::wm::WmWindowObserver* observer) { |
| 626 observers_.AddObserver(observer); | 683 observers_.AddObserver(observer); |
| 627 } | 684 } |
| 628 | 685 |
| 629 void WmWindowMus::RemoveObserver(ash::wm::WmWindowObserver* observer) { | 686 void WmWindowMus::RemoveObserver(ash::wm::WmWindowObserver* observer) { |
| 630 observers_.RemoveObserver(observer); | 687 observers_.RemoveObserver(observer); |
| 631 } | 688 } |
| 632 | 689 |
| 633 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { | 690 void WmWindowMus::OnTreeChanged(const TreeChangeParams& params) { |
| 634 ash::wm::WmWindowObserver::TreeChangeParams wm_params; | 691 ash::wm::WmWindowObserver::TreeChangeParams wm_params; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 OnWindowBoundsChanged(this, old_bounds, new_bounds)); | 730 OnWindowBoundsChanged(this, old_bounds, new_bounds)); |
| 674 } | 731 } |
| 675 | 732 |
| 676 void WmWindowMus::OnWindowDestroying(mus::Window* window) { | 733 void WmWindowMus::OnWindowDestroying(mus::Window* window) { |
| 677 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, | 734 FOR_EACH_OBSERVER(ash::wm::WmWindowObserver, observers_, |
| 678 OnWindowDestroying(this)); | 735 OnWindowDestroying(this)); |
| 679 } | 736 } |
| 680 | 737 |
| 681 } // namespace wm | 738 } // namespace wm |
| 682 } // namespace mash | 739 } // namespace mash |
| OLD | NEW |