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/aura/wm_window_aura.h" | 5 #include "ash/aura/wm_window_aura.h" |
6 | 6 |
7 #include "ash/aura/aura_layout_manager_adapter.h" | 7 #include "ash/aura/aura_layout_manager_adapter.h" |
8 #include "ash/aura/wm_shell_aura.h" | 8 #include "ash/aura/wm_shell_aura.h" |
9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
10 #include "ash/common/shelf/shelf_item_types.h" | 10 #include "ash/common/shelf/shelf_item_types.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "ash/wm/window_properties.h" | 24 #include "ash/wm/window_properties.h" |
25 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
27 #include "base/memory/ptr_util.h" | 27 #include "base/memory/ptr_util.h" |
28 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 28 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
29 #include "ui/aura/client/aura_constants.h" | 29 #include "ui/aura/client/aura_constants.h" |
30 #include "ui/aura/client/focus_client.h" | 30 #include "ui/aura/client/focus_client.h" |
31 #include "ui/aura/client/window_parenting_client.h" | 31 #include "ui/aura/client/window_parenting_client.h" |
32 #include "ui/aura/env.h" | 32 #include "ui/aura/env.h" |
33 #include "ui/aura/layout_manager.h" | 33 #include "ui/aura/layout_manager.h" |
| 34 #include "ui/aura/mus/window_manager_delegate.h" |
| 35 #include "ui/aura/mus/window_mus.h" |
| 36 #include "ui/aura/mus/window_tree_client.h" |
34 #include "ui/aura/window.h" | 37 #include "ui/aura/window.h" |
35 #include "ui/aura/window_delegate.h" | 38 #include "ui/aura/window_delegate.h" |
36 #include "ui/aura/window_property.h" | 39 #include "ui/aura/window_property.h" |
37 #include "ui/base/hit_test.h" | 40 #include "ui/base/hit_test.h" |
38 #include "ui/compositor/layer_tree_owner.h" | 41 #include "ui/compositor/layer_tree_owner.h" |
39 #include "ui/compositor/scoped_layer_animation_settings.h" | 42 #include "ui/compositor/scoped_layer_animation_settings.h" |
40 #include "ui/display/screen.h" | 43 #include "ui/display/screen.h" |
41 #include "ui/gfx/geometry/insets.h" | 44 #include "ui/gfx/geometry/insets.h" |
42 #include "ui/views/widget/widget.h" | 45 #include "ui/views/widget/widget.h" |
43 #include "ui/views/widget/widget_delegate.h" | 46 #include "ui/views/widget/widget_delegate.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 bool WmWindowAura::default_use_empty_minimum_size_for_testing_ = false; | 93 bool WmWindowAura::default_use_empty_minimum_size_for_testing_ = false; |
91 | 94 |
92 WmWindowAura::~WmWindowAura() { | 95 WmWindowAura::~WmWindowAura() { |
93 if (added_transient_observer_) | 96 if (added_transient_observer_) |
94 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); | 97 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); |
95 | 98 |
96 window_->RemoveObserver(this); | 99 window_->RemoveObserver(this); |
97 } | 100 } |
98 | 101 |
99 // static | 102 // static |
100 const WmWindow* WmWindowAura::Get(const aura::Window* window) { | 103 const WmWindowAura* WmWindowAura::Get(const aura::Window* window) { |
101 if (!window) | 104 if (!window) |
102 return nullptr; | 105 return nullptr; |
103 | 106 |
104 const WmWindow* wm_window = window->GetProperty(kWmWindowKey); | 107 const WmWindowAura* wm_window = window->GetProperty(kWmWindowKey); |
105 if (wm_window) | 108 if (wm_window) |
106 return wm_window; | 109 return wm_window; |
107 DCHECK_EQ(aura::Env::Mode::LOCAL, aura::Env::GetInstance()->mode()); | |
108 // WmWindowAura is owned by the aura::Window. | 110 // WmWindowAura is owned by the aura::Window. |
109 // TODO(sky): fix constness. | 111 // TODO(sky): fix constness. |
110 return new WmWindowAura(const_cast<aura::Window*>(window)); | 112 return new WmWindowAura(const_cast<aura::Window*>(window)); |
111 } | 113 } |
112 | 114 |
113 // static | 115 // static |
114 std::vector<WmWindow*> WmWindowAura::FromAuraWindows( | 116 std::vector<WmWindow*> WmWindowAura::FromAuraWindows( |
115 const std::vector<aura::Window*>& aura_windows) { | 117 const std::vector<aura::Window*>& aura_windows) { |
116 std::vector<WmWindow*> result(aura_windows.size()); | 118 std::vector<WmWindow*> result(aura_windows.size()); |
117 for (size_t i = 0; i < aura_windows.size(); ++i) | 119 for (size_t i = 0; i < aura_windows.size(); ++i) |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 } | 716 } |
715 | 717 |
716 views::Widget* WmWindowAura::GetInternalWidget() { | 718 views::Widget* WmWindowAura::GetInternalWidget() { |
717 return window_->GetProperty(kWidgetCreationTypeKey) == | 719 return window_->GetProperty(kWidgetCreationTypeKey) == |
718 WidgetCreationType::INTERNAL | 720 WidgetCreationType::INTERNAL |
719 ? views::Widget::GetWidgetForNativeView(window_) | 721 ? views::Widget::GetWidgetForNativeView(window_) |
720 : nullptr; | 722 : nullptr; |
721 } | 723 } |
722 | 724 |
723 void WmWindowAura::CloseWidget() { | 725 void WmWindowAura::CloseWidget() { |
| 726 if (aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS && |
| 727 aura_window()->GetProperty(kWidgetCreationTypeKey) == |
| 728 WidgetCreationType::FOR_CLIENT) { |
| 729 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated |
| 730 // with the window. Mash only creates widgets for top level windows if mash |
| 731 // renders the non-client frame. |
| 732 DCHECK(Shell::window_manager_client()); |
| 733 Shell::window_manager_client()->RequestClose(aura_window()); |
| 734 return; |
| 735 } |
724 DCHECK(GetInternalWidget()); | 736 DCHECK(GetInternalWidget()); |
725 GetInternalWidget()->Close(); | 737 GetInternalWidget()->Close(); |
726 } | 738 } |
727 | 739 |
728 void WmWindowAura::SetFocused() { | 740 void WmWindowAura::SetFocused() { |
729 aura::client::GetFocusClient(window_)->FocusWindow(window_); | 741 aura::client::GetFocusClient(window_)->FocusWindow(window_); |
730 } | 742 } |
731 | 743 |
732 bool WmWindowAura::IsFocused() const { | 744 bool WmWindowAura::IsFocused() const { |
733 return window_->HasFocus(); | 745 return window_->HasFocus(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 WmTransientWindowObserver* observer) { | 872 WmTransientWindowObserver* observer) { |
861 transient_observers_.RemoveObserver(observer); | 873 transient_observers_.RemoveObserver(observer); |
862 if (added_transient_observer_ && | 874 if (added_transient_observer_ && |
863 !transient_observers_.might_have_observers()) { | 875 !transient_observers_.might_have_observers()) { |
864 added_transient_observer_ = false; | 876 added_transient_observer_ = false; |
865 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); | 877 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); |
866 } | 878 } |
867 } | 879 } |
868 | 880 |
869 void WmWindowAura::AddLimitedPreTargetHandler(ui::EventHandler* handler) { | 881 void WmWindowAura::AddLimitedPreTargetHandler(ui::EventHandler* handler) { |
870 // This behaves differently from WmWindowMus for child and embedded windows. | 882 // In mus AddPreTargetHandler() only works for windows created by this client. |
| 883 DCHECK(aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL || |
| 884 Shell::window_tree_client()->WasCreatedByThisClient( |
| 885 aura::WindowMus::Get(window_))); |
871 window_->AddPreTargetHandler(handler); | 886 window_->AddPreTargetHandler(handler); |
872 } | 887 } |
873 | 888 |
874 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { | 889 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { |
875 window_->RemovePreTargetHandler(handler); | 890 window_->RemovePreTargetHandler(handler); |
876 } | 891 } |
877 | 892 |
878 WmWindowAura::WmWindowAura(aura::Window* window) | 893 WmWindowAura::WmWindowAura(aura::Window* window) |
879 : window_(window), | 894 : window_(window), |
880 // Mirrors that of aura::Window. | 895 // Mirrors that of aura::Window. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 observer.OnTransientChildAdded(this, Get(transient)); | 1006 observer.OnTransientChildAdded(this, Get(transient)); |
992 } | 1007 } |
993 | 1008 |
994 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, | 1009 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, |
995 aura::Window* transient) { | 1010 aura::Window* transient) { |
996 for (auto& observer : transient_observers_) | 1011 for (auto& observer : transient_observers_) |
997 observer.OnTransientChildRemoved(this, Get(transient)); | 1012 observer.OnTransientChildRemoved(this, Get(transient)); |
998 } | 1013 } |
999 | 1014 |
1000 } // namespace ash | 1015 } // namespace ash |
OLD | NEW |