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

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

Issue 2613793002: Removes/promotes functions from WmWindowMus to WmWindowAura (Closed)
Patch Set: move WmWindowAuraTestApi to ash/test 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
« no previous file with comments | « ash/mus/bridge/wm_window_mus.h ('k') | ash/mus/bridge/wm_window_mus_test_api.h » ('j') | 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/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 17 matching lines...) Expand all
28 #include "ui/base/hit_test.h" 28 #include "ui/base/hit_test.h"
29 #include "ui/display/display.h" 29 #include "ui/display/display.h"
30 #include "ui/resources/grit/ui_resources.h" 30 #include "ui/resources/grit/ui_resources.h"
31 #include "ui/views/view.h" 31 #include "ui/views/view.h"
32 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
33 #include "ui/views/widget/widget_delegate.h" 33 #include "ui/views/widget/widget_delegate.h"
34 34
35 namespace ash { 35 namespace ash {
36 namespace mus { 36 namespace mus {
37 37
38 // static 38 WmWindowMus::WmWindowMus(aura::Window* window) : WmWindowAura(window) {}
39 bool WmWindowMus::default_use_empty_minimum_size_for_testing_ = false;
40
41 WmWindowMus::WmWindowMus(aura::Window* window)
42 : WmWindowAura(window),
43 use_empty_minimum_size_for_testing_(
44 default_use_empty_minimum_size_for_testing_) {}
45 39
46 WmWindowMus::~WmWindowMus() {} 40 WmWindowMus::~WmWindowMus() {}
47 41
48 // static 42 // static
49 const WmWindowMus* WmWindowMus::Get(const aura::Window* window) { 43 const WmWindowMus* WmWindowMus::Get(const aura::Window* window) {
50 if (!window) 44 if (!window)
51 return nullptr; 45 return nullptr;
52 46
53 if (HasInstance(window)) 47 if (HasInstance(window))
54 return static_cast<const WmWindowMus*>(WmWindowAura::Get(window)); 48 return static_cast<const WmWindowMus*>(WmWindowAura::Get(window));
55 49
56 // WmWindowMus is owned by the aura::Window. 50 // WmWindowMus is owned by the aura::Window.
57 // Unfortunately there isn't a good way to avoid the cast here. 51 // Unfortunately there isn't a good way to avoid the cast here.
58 return new WmWindowMus(const_cast<aura::Window*>(window)); 52 return new WmWindowMus(const_cast<aura::Window*>(window));
59 } 53 }
60 54
61 // static 55 // static
62 WmWindowMus* WmWindowMus::Get(views::Widget* widget) { 56 WmWindowMus* WmWindowMus::Get(views::Widget* widget) {
63 return WmWindowMus::Get(widget->GetNativeView()); 57 return WmWindowMus::Get(widget->GetNativeView());
64 } 58 }
65 59
66 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus() 60 const WmRootWindowControllerMus* WmWindowMus::GetRootWindowControllerMus()
67 const { 61 const {
68 return WmRootWindowControllerMus::Get(aura_window()->GetRootWindow()); 62 return WmRootWindowControllerMus::Get(aura_window()->GetRootWindow());
69 } 63 }
70 64
71 bool WmWindowMus::ShouldUseExtendedHitRegion() const {
72 const WmWindowMus* parent = Get(aura_window()->parent());
73 return parent && parent->children_use_extended_hit_region_;
74 }
75
76 bool WmWindowMus::IsContainer() const { 65 bool WmWindowMus::IsContainer() const {
77 return GetShellWindowId() != kShellWindowId_Invalid; 66 return GetShellWindowId() != kShellWindowId_Invalid;
78 } 67 }
79 68
80 const WmWindow* WmWindowMus::GetRootWindow() const {
81 return Get(aura_window()->GetRootWindow());
82 }
83
84 WmRootWindowController* WmWindowMus::GetRootWindowController() { 69 WmRootWindowController* WmWindowMus::GetRootWindowController() {
85 return GetRootWindowControllerMus(); 70 return GetRootWindowControllerMus();
86 } 71 }
87 72
88 WmShell* WmWindowMus::GetShell() const { 73 WmShell* WmWindowMus::GetShell() const {
89 return WmShellMus::Get(); 74 return WmShellMus::Get();
90 } 75 }
91 76
92 bool WmWindowMus::IsBubble() {
93 return aura_window()->GetProperty(aura::client::kWindowTypeKey) ==
94 ui::mojom::WindowType::BUBBLE;
95 }
96
97 bool WmWindowMus::HasNonClientArea() {
98 return widget_ ? true : false;
99 }
100
101 int WmWindowMus::GetNonClientComponent(const gfx::Point& location) {
102 return widget_ ? widget_->GetNonClientComponent(location) : HTNOWHERE;
103 }
104
105 gfx::Size WmWindowMus::GetMinimumSize() const {
106 return widget_ && !use_empty_minimum_size_for_testing_
107 ? widget_->GetMinimumSize()
108 : gfx::Size();
109 }
110
111 gfx::Size WmWindowMus::GetMaximumSize() const {
112 return widget_ ? widget_->GetMaximumSize() : gfx::Size();
113 }
114
115 gfx::Rect WmWindowMus::GetMinimizeAnimationTargetBoundsInScreen() const {
116 // TODO: need animation support: http://crbug.com/615087.
117 NOTIMPLEMENTED();
118 return GetBoundsInScreen();
119 }
120
121 bool WmWindowMus::IsSystemModal() const {
122 NOTIMPLEMENTED();
123 return false;
124 }
125
126 bool WmWindowMus::GetBoolProperty(WmWindowProperty key) {
127 switch (key) {
128 case WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY:
129 return snap_children_to_pixel_boundary_;
130
131 default:
132 break;
133 }
134
135 return WmWindowAura::GetBoolProperty(key);
136 }
137
138 int WmWindowMus::GetIntProperty(WmWindowProperty key) { 77 int WmWindowMus::GetIntProperty(WmWindowProperty key) {
139 if (key == WmWindowProperty::SHELF_ITEM_TYPE) { 78 if (key == WmWindowProperty::SHELF_ITEM_TYPE) {
140 if (aura_window()->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED) 79 if (aura_window()->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED)
141 return aura_window()->GetProperty(kShelfItemTypeKey); 80 return aura_window()->GetProperty(kShelfItemTypeKey);
142 81
143 // Mash provides a default shelf item type for non-ignored windows. 82 // Mash provides a default shelf item type for non-ignored windows.
144 return GetWindowState()->ignored_by_shelf() ? TYPE_UNDEFINED : TYPE_APP; 83 return GetWindowState()->ignored_by_shelf() ? TYPE_UNDEFINED : TYPE_APP;
145 } 84 }
146 85
147 return WmWindowAura::GetIntProperty(key); 86 return WmWindowAura::GetIntProperty(key);
148 } 87 }
149 88
150 WmWindow* WmWindowMus::GetToplevelWindow() {
151 return WmShellMus::GetToplevelAncestor(aura_window());
152 }
153
154 WmWindow* WmWindowMus::GetToplevelWindowForFocus() {
155 // TODO(sky): resolve if we really need two notions of top-level. In the mus
156 // world they are the same.
157 return WmShellMus::GetToplevelAncestor(aura_window());
158 }
159
160 // TODO(sky): investigate if needed. 89 // TODO(sky): investigate if needed.
161 bool WmWindowMus::MoveToEventRoot(const ui::Event& event) { 90 bool WmWindowMus::MoveToEventRoot(const ui::Event& event) {
162 views::View* target = static_cast<views::View*>(event.target()); 91 views::View* target = static_cast<views::View*>(event.target());
163 if (!target) 92 if (!target)
164 return false; 93 return false;
165 WmWindow* target_root = 94 WmWindow* target_root =
166 WmLookup::Get()->GetWindowForWidget(target->GetWidget())->GetRootWindow(); 95 WmLookup::Get()->GetWindowForWidget(target->GetWidget())->GetRootWindow();
167 if (!target_root || target_root == GetRootWindow()) 96 if (!target_root || target_root == GetRootWindow())
168 return false; 97 return false;
169 WmWindow* window_container = 98 WmWindow* window_container =
(...skipping 14 matching lines...) Expand all
184 } 113 }
185 wm::SetBoundsInScreen(this, bounds_in_screen, dst_display); 114 wm::SetBoundsInScreen(this, bounds_in_screen, dst_display);
186 } 115 }
187 116
188 // TODO(sky): remove this override. 117 // TODO(sky): remove this override.
189 void WmWindowMus::SetPinned(bool trusted) { 118 void WmWindowMus::SetPinned(bool trusted) {
190 // http://crbug.com/622486. 119 // http://crbug.com/622486.
191 NOTIMPLEMENTED(); 120 NOTIMPLEMENTED();
192 } 121 }
193 122
194 views::Widget* WmWindowMus::GetInternalWidget() {
195 // Don't return the window frame widget for an embedded client window.
196 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT)
197 return nullptr;
198
199 return widget_;
200 }
201
202 void WmWindowMus::CloseWidget() { 123 void WmWindowMus::CloseWidget() {
203 DCHECK(widget_); 124 views::Widget* widget = views::Widget::GetWidgetForNativeView(aura_window());
125 DCHECK(widget);
204 // Allow the client to service the close request for remote widgets. 126 // Allow the client to service the close request for remote widgets.
205 if (widget_creation_type_ == WidgetCreationType::FOR_CLIENT) { 127 if (aura_window()->GetProperty(kWidgetCreationTypeKey) ==
128 WidgetCreationType::FOR_CLIENT) {
206 WmShellMus::Get()->window_manager()->window_manager_client()->RequestClose( 129 WmShellMus::Get()->window_manager()->window_manager_client()->RequestClose(
207 aura_window()); 130 aura_window());
208 } else { 131 } else {
209 widget_->Close(); 132 widget->Close();
210 } 133 }
211 } 134 }
212 135
213 // TODO(sky): investigate if needed. 136 // TODO(sky): investigate if needed.
214 bool WmWindowMus::CanActivate() const { 137 bool WmWindowMus::CanActivate() const {
215 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not 138 // TODO(sky): this isn't quite right. Should key off CanFocus(), which is not
216 // replicated. 139 // replicated.
217 return WmWindowAura::CanActivate() && widget_ != nullptr; 140 // TODO(sky): fix const cast (most likely remove this override entirely).
141 return WmWindowAura::CanActivate() &&
142 views::Widget::GetWidgetForNativeView(
143 const_cast<aura::Window*>(aura_window())) != nullptr;
218 } 144 }
219 145
220 void WmWindowMus::ShowResizeShadow(int component) { 146 void WmWindowMus::ShowResizeShadow(int component) {
221 // TODO: http://crbug.com/640773. 147 // TODO: http://crbug.com/640773.
222 NOTIMPLEMENTED(); 148 NOTIMPLEMENTED();
223 } 149 }
224 150
225 void WmWindowMus::HideResizeShadow() { 151 void WmWindowMus::HideResizeShadow() {
226 // TODO: http://crbug.com/640773. 152 // TODO: http://crbug.com/640773.
227 NOTIMPLEMENTED(); 153 NOTIMPLEMENTED();
228 } 154 }
229 155
230 void WmWindowMus::InstallResizeHandleWindowTargeter( 156 void WmWindowMus::InstallResizeHandleWindowTargeter(
231 ImmersiveFullscreenController* immersive_fullscreen_controller) { 157 ImmersiveFullscreenController* immersive_fullscreen_controller) {
232 // TODO(sky): I believe once ImmersiveFullscreenController is ported this 158 // TODO(sky): I believe once ImmersiveFullscreenController is ported this
233 // won't be necessary in mash, but I need to verify that: 159 // won't be necessary in mash, but I need to verify that:
234 // http://crbug.com/548435. 160 // http://crbug.com/548435.
235 } 161 }
236 162
237 // TODO: nuke this once SetBoundsInScreen() is updated. 163 // TODO: nuke this once SetBoundsInScreen() is updated.
238 void WmWindowMus::SetBoundsInScreenBehaviorForChildren( 164 void WmWindowMus::SetBoundsInScreenBehaviorForChildren(
239 WmWindow::BoundsInScreenBehavior behavior) { 165 WmWindow::BoundsInScreenBehavior behavior) {
240 child_bounds_in_screen_behavior_ = behavior; 166 child_bounds_in_screen_behavior_ = behavior;
241 } 167 }
242 168
243 void WmWindowMus::SetSnapsChildrenToPhysicalPixelBoundary() {
244 if (snap_children_to_pixel_boundary_)
245 return;
246
247 snap_children_to_pixel_boundary_ = true;
248 for (auto& observer : observers()) {
249 observer.OnWindowPropertyChanged(
250 this, WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY);
251 }
252 }
253
254 void WmWindowMus::SnapToPixelBoundaryIfNecessary() {
255 WmWindowMus* parent = Get(aura_window()->parent());
256 if (parent && parent->snap_children_to_pixel_boundary_) {
257 // TODO: implement snap to pixel: http://crbug.com/615554.
258 NOTIMPLEMENTED();
259 }
260 }
261
262 void WmWindowMus::SetChildrenUseExtendedHitRegion() {
263 children_use_extended_hit_region_ = true;
264 }
265
266 void WmWindowMus::AddLimitedPreTargetHandler(ui::EventHandler* handler) { 169 void WmWindowMus::AddLimitedPreTargetHandler(ui::EventHandler* handler) {
267 DCHECK(WmShellMus::Get()->window_tree_client()->WasCreatedByThisClient( 170 DCHECK(WmShellMus::Get()->window_tree_client()->WasCreatedByThisClient(
268 aura::WindowMus::Get(aura_window()))); 171 aura::WindowMus::Get(aura_window())));
269 WmWindowAura::AddLimitedPreTargetHandler(handler); 172 WmWindowAura::AddLimitedPreTargetHandler(handler);
270 } 173 }
271 174
272 } // namespace mus 175 } // namespace mus
273 } // namespace ash 176 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/bridge/wm_window_mus.h ('k') | ash/mus/bridge/wm_window_mus_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698