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

Side by Side Diff: ash/aura/wm_window_aura.cc

Issue 2625873007: Promotes WmWindowMus functions to WmWindowAura and nukes WmWindowMus (Closed)
Patch Set: cleanup Created 3 years, 11 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
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/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
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
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
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 Shell::window_manager_client()->RequestClose(aura_window());
msw 2017/01/12 00:14:42 q: Should this DCHECK Shell::window_manager_client
sky 2017/01/12 14:43:44 Done.
733 return;
734 }
724 DCHECK(GetInternalWidget()); 735 DCHECK(GetInternalWidget());
725 GetInternalWidget()->Close(); 736 GetInternalWidget()->Close();
726 } 737 }
727 738
728 void WmWindowAura::SetFocused() { 739 void WmWindowAura::SetFocused() {
729 aura::client::GetFocusClient(window_)->FocusWindow(window_); 740 aura::client::GetFocusClient(window_)->FocusWindow(window_);
730 } 741 }
731 742
732 bool WmWindowAura::IsFocused() const { 743 bool WmWindowAura::IsFocused() const {
733 return window_->HasFocus(); 744 return window_->HasFocus();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 WmTransientWindowObserver* observer) { 871 WmTransientWindowObserver* observer) {
861 transient_observers_.RemoveObserver(observer); 872 transient_observers_.RemoveObserver(observer);
862 if (added_transient_observer_ && 873 if (added_transient_observer_ &&
863 !transient_observers_.might_have_observers()) { 874 !transient_observers_.might_have_observers()) {
864 added_transient_observer_ = false; 875 added_transient_observer_ = false;
865 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this); 876 ::wm::TransientWindowManager::Get(window_)->RemoveObserver(this);
866 } 877 }
867 } 878 }
868 879
869 void WmWindowAura::AddLimitedPreTargetHandler(ui::EventHandler* handler) { 880 void WmWindowAura::AddLimitedPreTargetHandler(ui::EventHandler* handler) {
870 // This behaves differently from WmWindowMus for child and embedded windows. 881 // In mus AddPreTargetHandler() only works for windows created by this client.
882 DCHECK(aura::Env::GetInstance()->mode() == aura::Env::Mode::LOCAL ||
883 Shell::window_tree_client()->WasCreatedByThisClient(
884 aura::WindowMus::Get(window_)));
871 window_->AddPreTargetHandler(handler); 885 window_->AddPreTargetHandler(handler);
872 } 886 }
873 887
874 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) { 888 void WmWindowAura::RemoveLimitedPreTargetHandler(ui::EventHandler* handler) {
875 window_->RemovePreTargetHandler(handler); 889 window_->RemovePreTargetHandler(handler);
876 } 890 }
877 891
878 WmWindowAura::WmWindowAura(aura::Window* window) 892 WmWindowAura::WmWindowAura(aura::Window* window)
879 : window_(window), 893 : window_(window),
880 // Mirrors that of aura::Window. 894 // Mirrors that of aura::Window.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 observer.OnTransientChildAdded(this, Get(transient)); 1005 observer.OnTransientChildAdded(this, Get(transient));
992 } 1006 }
993 1007
994 void WmWindowAura::OnTransientChildRemoved(aura::Window* window, 1008 void WmWindowAura::OnTransientChildRemoved(aura::Window* window,
995 aura::Window* transient) { 1009 aura::Window* transient) {
996 for (auto& observer : transient_observers_) 1010 for (auto& observer : transient_observers_)
997 observer.OnTransientChildRemoved(this, Get(transient)); 1011 observer.OnTransientChildRemoved(this, Get(transient));
998 } 1012 }
999 1013
1000 } // namespace ash 1014 } // namespace ash
OLDNEW
« no previous file with comments | « ash/aura/wm_window_aura.h ('k') | ash/mus/BUILD.gn » ('j') | ash/mus/bridge/wm_lookup_mus.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698