Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: ash/mus/bridge/wm_window_mus.cc

Issue 2344783002: Wires up WmWindowMus::SetBoundsInScreen() (Closed)
Patch Set: tweaks Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« ash/common/wm_window.h ('K') | « ash/mus/bridge/wm_window_mus.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/wm/container_finder.h" 7 #include "ash/common/wm/container_finder.h"
8 #include "ash/common/wm/window_positioning_utils.h"
8 #include "ash/common/wm/window_state.h" 9 #include "ash/common/wm/window_state.h"
9 #include "ash/common/wm_layout_manager.h" 10 #include "ash/common/wm_layout_manager.h"
10 #include "ash/common/wm_transient_window_observer.h" 11 #include "ash/common/wm_transient_window_observer.h"
11 #include "ash/common/wm_window_observer.h" 12 #include "ash/common/wm_window_observer.h"
12 #include "ash/common/wm_window_property.h" 13 #include "ash/common/wm_window_property.h"
13 #include "ash/mus/bridge/mus_layout_manager_adapter.h" 14 #include "ash/mus/bridge/mus_layout_manager_adapter.h"
14 #include "ash/mus/bridge/wm_root_window_controller_mus.h" 15 #include "ash/mus/bridge/wm_root_window_controller_mus.h"
15 #include "ash/mus/bridge/wm_shell_mus.h" 16 #include "ash/mus/bridge/wm_shell_mus.h"
16 #include "ash/mus/property_util.h" 17 #include "ash/mus/property_util.h"
17 #include "services/ui/public/cpp/property_type_converters.h" 18 #include "services/ui/public/cpp/property_type_converters.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 window_->AddObserver(this); 108 window_->AddObserver(this);
108 window_->SetLocalProperty(kWmWindowKey, this); 109 window_->SetLocalProperty(kWmWindowKey, this);
109 window_state_.reset(new WindowStateMus(this)); 110 window_state_.reset(new WindowStateMus(this));
110 } 111 }
111 112
112 WmWindowMus::~WmWindowMus() { 113 WmWindowMus::~WmWindowMus() {
113 window_->RemoveObserver(this); 114 window_->RemoveObserver(this);
114 } 115 }
115 116
116 // static 117 // static
117 WmWindowMus* WmWindowMus::Get(ui::Window* window) { 118 const WmWindowMus* WmWindowMus::Get(const ui::Window* window) {
118 if (!window) 119 if (!window)
119 return nullptr; 120 return nullptr;
120 121
121 WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey); 122 const WmWindowMus* wm_window = window->GetLocalProperty(kWmWindowKey);
122 if (wm_window) 123 if (wm_window)
123 return wm_window; 124 return wm_window;
124 // WmWindowMus is owned by the ui::Window. 125 // WmWindowMus is owned by the ui::Window.
125 return new WmWindowMus(window); 126 // Unfortunately there isn't a good way to avoid the cast here.
127 return new WmWindowMus(const_cast<ui::Window*>(window));
126 } 128 }
127 129
128 // static 130 // static
129 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { 131 WmWindowMus* WmWindowMus::Get(views::Widget* widget) {
130 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView())); 132 return WmWindowMus::Get(aura::GetMusWindow(widget->GetNativeView()));
131 } 133 }
132 134
133 // static 135 // static
134 const ui::Window* WmWindowMus::GetMusWindow(const WmWindow* wm_window) { 136 const ui::Window* WmWindowMus::GetMusWindow(const WmWindow* wm_window) {
135 return static_cast<const WmWindowMus*>(wm_window)->mus_window(); 137 return static_cast<const WmWindowMus*>(wm_window)->mus_window();
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 437
436 void WmWindowMus::SetParentUsingContext(WmWindow* context, 438 void WmWindowMus::SetParentUsingContext(WmWindow* context,
437 const gfx::Rect& screen_bounds) { 439 const gfx::Rect& screen_bounds) {
438 wm::GetDefaultParent(context, this, screen_bounds)->AddChild(this); 440 wm::GetDefaultParent(context, this, screen_bounds)->AddChild(this);
439 } 441 }
440 442
441 void WmWindowMus::AddChild(WmWindow* window) { 443 void WmWindowMus::AddChild(WmWindow* window) {
442 window_->AddChild(GetMusWindow(window)); 444 window_->AddChild(GetMusWindow(window));
443 } 445 }
444 446
445 WmWindow* WmWindowMus::GetParent() { 447 const WmWindow* WmWindowMus::GetParent() const {
446 return Get(window_->parent()); 448 return Get(window_->parent());
447 } 449 }
448 450
449 const WmWindow* WmWindowMus::GetTransientParent() const { 451 const WmWindow* WmWindowMus::GetTransientParent() const {
450 return Get(window_->transient_parent()); 452 return Get(window_->transient_parent());
451 } 453 }
452 454
453 std::vector<WmWindow*> WmWindowMus::GetTransientChildren() { 455 std::vector<WmWindow*> WmWindowMus::GetTransientChildren() {
454 return FromMusWindows(window_->transient_children()); 456 return FromMusWindows(window_->transient_children());
455 } 457 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 544 }
543 545
544 void WmWindowMus::SetBoundsDirectCrossFade(const gfx::Rect& bounds) { 546 void WmWindowMus::SetBoundsDirectCrossFade(const gfx::Rect& bounds) {
545 // TODO: need animation support: http://crbug.com/615087. 547 // TODO: need animation support: http://crbug.com/615087.
546 NOTIMPLEMENTED(); 548 NOTIMPLEMENTED();
547 SetBoundsDirect(bounds); 549 SetBoundsDirect(bounds);
548 } 550 }
549 551
550 void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen, 552 void WmWindowMus::SetBoundsInScreen(const gfx::Rect& bounds_in_screen,
551 const display::Display& dst_display) { 553 const display::Display& dst_display) {
552 // TODO: SetBoundsInScreen isn't fully implemented yet, 554 DCHECK(GetParent()); // Aura code assumed a client, so this does too.
James Cook 2016/09/15 16:31:40 "a client"? A child?
sky 2016/09/15 17:35:03 parent actually. Updated.
553 // http://crbug.com/615552. 555 if (static_cast<const WmWindowMus*>(GetParent())
James Cook 2016/09/15 16:31:40 Any particular reason this casts to const? (My agi
sky 2016/09/15 17:35:03 Actually, yes. WmWindow has the inline implementat
554 NOTIMPLEMENTED(); 556 ->child_bounds_in_screen_behavior_ ==
555 SetBounds(ConvertRectFromScreen(bounds_in_screen)); 557 BoundsInScreenBehavior::USE_LOCAL_COORDINATES) {
558 SetBounds(bounds_in_screen);
559 return;
560 }
561 wm::SetBoundsInScreen(this, bounds_in_screen, dst_display);
556 } 562 }
557 563
558 gfx::Rect WmWindowMus::GetBoundsInScreen() const { 564 gfx::Rect WmWindowMus::GetBoundsInScreen() const {
559 return ConvertRectToScreen(gfx::Rect(window_->bounds().size())); 565 return ConvertRectToScreen(gfx::Rect(window_->bounds().size()));
560 } 566 }
561 567
562 const gfx::Rect& WmWindowMus::GetBounds() const { 568 const gfx::Rect& WmWindowMus::GetBounds() const {
563 return window_->bounds(); 569 return window_->bounds();
564 } 570 }
565 571
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 } 607 }
602 608
603 void WmWindowMus::SetRestoreOverrides( 609 void WmWindowMus::SetRestoreOverrides(
604 const gfx::Rect& bounds_override, 610 const gfx::Rect& bounds_override,
605 ui::WindowShowState window_state_override) { 611 ui::WindowShowState window_state_override) {
606 // TODO(sky): see http://crbug.com/623314. 612 // TODO(sky): see http://crbug.com/623314.
607 NOTIMPLEMENTED(); 613 NOTIMPLEMENTED();
608 } 614 }
609 615
610 void WmWindowMus::SetLockedToRoot(bool value) { 616 void WmWindowMus::SetLockedToRoot(bool value) {
611 // TODO(sky): there is no getter for this. Investigate where used. 617 locked_to_root_ = value;
612 NOTIMPLEMENTED(); 618 }
619
620 bool WmWindowMus::IsLockedToRoot() const {
621 return locked_to_root_;
613 } 622 }
614 623
615 void WmWindowMus::SetCapture() { 624 void WmWindowMus::SetCapture() {
616 window_->SetCapture(); 625 window_->SetCapture();
617 } 626 }
618 627
619 bool WmWindowMus::HasCapture() { 628 bool WmWindowMus::HasCapture() {
620 return window_->HasCapture(); 629 return window_->HasCapture();
621 } 630 }
622 631
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 703
695 void WmWindowMus::CloseWidget() { 704 void WmWindowMus::CloseWidget() {
696 DCHECK(widget_); 705 DCHECK(widget_);
697 // Allow the client to service the close request for remote widgets. 706 // Allow the client to service the close request for remote widgets.
698 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT) 707 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT)
699 window_->RequestClose(); 708 window_->RequestClose();
700 else 709 else
701 widget_->Close(); 710 widget_->Close();
702 } 711 }
703 712
713 void WmWindowMus::SetFocused() {
714 window_->SetFocus();
715 }
716
704 bool WmWindowMus::IsFocused() const { 717 bool WmWindowMus::IsFocused() const {
705 return window_->HasFocus(); 718 return window_->HasFocus();
706 } 719 }
707 720
708 bool WmWindowMus::IsActive() const { 721 bool WmWindowMus::IsActive() const {
709 ui::Window* focused = window_->window_tree()->GetFocusedWindow(); 722 ui::Window* focused = window_->window_tree()->GetFocusedWindow();
710 return focused && window_->Contains(focused); 723 return focused && window_->Contains(focused);
711 } 724 }
712 725
713 void WmWindowMus::Activate() { 726 void WmWindowMus::Activate() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 786
774 void WmWindowMus::InstallResizeHandleWindowTargeter( 787 void WmWindowMus::InstallResizeHandleWindowTargeter(
775 ImmersiveFullscreenController* immersive_fullscreen_controller) { 788 ImmersiveFullscreenController* immersive_fullscreen_controller) {
776 // TODO(sky): I believe once ImmersiveFullscreenController is ported this 789 // TODO(sky): I believe once ImmersiveFullscreenController is ported this
777 // won't be necessary in mash, but I need to verify that: 790 // won't be necessary in mash, but I need to verify that:
778 // http://crbug.com/548435. 791 // http://crbug.com/548435.
779 } 792 }
780 793
781 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( 794 void WmWindowMus::SetBoundsInScreenBehaviorForChildren(
782 WmWindow::BoundsInScreenBehavior behavior) { 795 WmWindow::BoundsInScreenBehavior behavior) {
783 // TODO: SetBoundsInScreen isn't fully implemented yet, 796 child_bounds_in_screen_behavior_ = behavior;
784 // http://crbug.com/615552.
785 NOTIMPLEMENTED();
786 } 797 }
787 798
788 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() { 799 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() {
789 if (snap_children_to_pixel_boundary_) 800 if (snap_children_to_pixel_boundary_)
790 return; 801 return;
791 802
792 snap_children_to_pixel_boundary_ = true; 803 snap_children_to_pixel_boundary_ = true;
793 FOR_EACH_OBSERVER( 804 FOR_EACH_OBSERVER(
794 WmWindowObserver, observers_, 805 WmWindowObserver, observers_,
795 OnWindowPropertyChanged( 806 OnWindowPropertyChanged(
796 this, WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY)); 807 this, WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY));
797 } 808 }
798 809
799 void WmWindowMus::SnapToPixelBoundaryIfNecessary() { 810 void WmWindowMus::SnapToPixelBoundaryIfNecessary() {
800 WmWindowMus* parent = Get(window_->parent()); 811 WmWindowMus* parent = Get(window_->parent());
801 if (parent && parent->snap_children_to_pixel_boundary_) { 812 if (parent && parent->snap_children_to_pixel_boundary_) {
802 // TODO: implement snap to pixel: http://crbug.com/615554. 813 // TODO: implement snap to pixel: http://crbug.com/615554.
803 NOTIMPLEMENTED(); 814 NOTIMPLEMENTED();
804 } 815 }
805 } 816 }
806 817
807 void WmWindowMus::SetChildrenUseExtendedHitRegion() { 818 void WmWindowMus::SetChildrenUseExtendedHitRegion() {
808 children_use_extended_hit_region_ = true; 819 children_use_extended_hit_region_ = true;
809 } 820 }
810 821
811 void WmWindowMus::SetDescendantsStayInSameRootWindow(bool value) {
812 // TODO: this logic feeds into SetBoundsInScreen(), which is not implemented:
813 // http://crbug.com/615552.
814 NOTIMPLEMENTED();
815 }
816
817 std::unique_ptr<views::View> WmWindowMus::CreateViewWithRecreatedLayers() { 822 std::unique_ptr<views::View> WmWindowMus::CreateViewWithRecreatedLayers() {
818 // TODO: need real implementation, http://crbug.com/629497. 823 // TODO: need real implementation, http://crbug.com/629497.
819 std::unique_ptr<views::View> view(new views::View); 824 std::unique_ptr<views::View> view(new views::View);
820 return view; 825 return view;
821 } 826 }
822 827
823 void WmWindowMus::AddObserver(WmWindowObserver* observer) { 828 void WmWindowMus::AddObserver(WmWindowObserver* observer) {
824 observers_.AddObserver(observer); 829 observers_.AddObserver(observer);
825 } 830 }
826 831
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 } 923 }
919 924
920 void WmWindowMus::OnTransientChildRemoved(ui::Window* window, 925 void WmWindowMus::OnTransientChildRemoved(ui::Window* window,
921 ui::Window* transient) { 926 ui::Window* transient) {
922 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_, 927 FOR_EACH_OBSERVER(WmTransientWindowObserver, transient_observers_,
923 OnTransientChildRemoved(this, Get(transient))); 928 OnTransientChildRemoved(this, Get(transient)));
924 } 929 }
925 930
926 } // namespace mus 931 } // namespace mus
927 } // namespace ash 932 } // namespace ash
OLDNEW
« ash/common/wm_window.h ('K') | « ash/mus/bridge/wm_window_mus.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698