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

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

Issue 1907863002: Converts DockedWindowLayoutManager to common ash/wm types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 4 years, 8 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/wm/aura/wm_window_aura.h ('k') | ash/wm/common/wm_activation_observer.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/wm/aura/wm_window_aura.h" 5 #include "ash/wm/aura/wm_window_aura.h"
6 6
7 #include "ash/screen_util.h" 7 #include "ash/screen_util.h"
8 #include "ash/wm/aura/aura_layout_manager_adapter.h"
8 #include "ash/wm/aura/wm_globals_aura.h" 9 #include "ash/wm/aura/wm_globals_aura.h"
9 #include "ash/wm/aura/wm_root_window_controller_aura.h" 10 #include "ash/wm/aura/wm_root_window_controller_aura.h"
11 #include "ash/wm/common/wm_layout_manager.h"
10 #include "ash/wm/common/wm_window_observer.h" 12 #include "ash/wm/common/wm_window_observer.h"
11 #include "ash/wm/common/wm_window_property.h" 13 #include "ash/wm/common/wm_window_property.h"
12 #include "ash/wm/window_animations.h" 14 #include "ash/wm/window_animations.h"
13 #include "ash/wm/window_properties.h" 15 #include "ash/wm/window_properties.h"
14 #include "ash/wm/window_state.h" 16 #include "ash/wm/window_state.h"
15 #include "ash/wm/window_state_aura.h" 17 #include "ash/wm/window_state_aura.h"
16 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
17 #include "ui/aura/client/aura_constants.h" 19 #include "ui/aura/client/aura_constants.h"
18 #include "ui/aura/client/window_tree_client.h" 20 #include "ui/aura/client/window_tree_client.h"
19 #include "ui/aura/layout_manager.h" 21 #include "ui/aura/layout_manager.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 }; 65 };
64 66
65 } // namespace 67 } // namespace
66 68
67 WmWindowAura::WmWindowAura(aura::Window* window) : window_(window) { 69 WmWindowAura::WmWindowAura(aura::Window* window) : window_(window) {
68 window_->AddObserver(this); 70 window_->AddObserver(this);
69 window_->SetProperty(kWmWindowKey, this); 71 window_->SetProperty(kWmWindowKey, this);
70 } 72 }
71 73
72 // static 74 // static
75 WmWindow* WmWindow::Get(views::Widget* widget) {
76 return WmWindowAura::Get(widget->GetNativeWindow());
77 }
78
79 // static
73 WmWindow* WmWindowAura::Get(aura::Window* window) { 80 WmWindow* WmWindowAura::Get(aura::Window* window) {
74 if (!window) 81 if (!window)
75 return nullptr; 82 return nullptr;
76 83
77 WmWindow* wm_window = window->GetProperty(kWmWindowKey); 84 WmWindow* wm_window = window->GetProperty(kWmWindowKey);
78 if (wm_window) 85 if (wm_window)
79 return wm_window; 86 return wm_window;
80 // WmWindowAura is owned by the aura::Window. 87 // WmWindowAura is owned by the aura::Window.
81 return new WmWindowAura(window); 88 return new WmWindowAura(window);
82 } 89 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 152 }
146 153
147 gfx::Rect WmWindowAura::ConvertRectToScreen(const gfx::Rect& rect) const { 154 gfx::Rect WmWindowAura::ConvertRectToScreen(const gfx::Rect& rect) const {
148 return ScreenUtil::ConvertRectToScreen(window_, rect); 155 return ScreenUtil::ConvertRectToScreen(window_, rect);
149 } 156 }
150 157
151 gfx::Rect WmWindowAura::ConvertRectFromScreen(const gfx::Rect& rect) const { 158 gfx::Rect WmWindowAura::ConvertRectFromScreen(const gfx::Rect& rect) const {
152 return ScreenUtil::ConvertRectFromScreen(window_, rect); 159 return ScreenUtil::ConvertRectFromScreen(window_, rect);
153 } 160 }
154 161
155 gfx::Size WmWindowAura::GetMinimumSize() { 162 gfx::Size WmWindowAura::GetMinimumSize() const {
156 return window_->delegate() ? window_->delegate()->GetMinimumSize() 163 return window_->delegate() ? window_->delegate()->GetMinimumSize()
157 : gfx::Size(); 164 : gfx::Size();
158 } 165 }
159 166
160 gfx::Size WmWindowAura::GetMaximumSize() { 167 gfx::Size WmWindowAura::GetMaximumSize() const {
161 return window_->delegate() ? window_->delegate()->GetMaximumSize() 168 return window_->delegate() ? window_->delegate()->GetMaximumSize()
162 : gfx::Size(); 169 : gfx::Size();
163 } 170 }
164 171
165 bool WmWindowAura::GetTargetVisibility() const { 172 bool WmWindowAura::GetTargetVisibility() const {
166 return window_->TargetVisibility(); 173 return window_->TargetVisibility();
167 } 174 }
168 175
169 bool WmWindowAura::IsVisible() const { 176 bool WmWindowAura::IsVisible() const {
170 return window_->IsVisible(); 177 return window_->IsVisible();
(...skipping 27 matching lines...) Expand all
198 } 205 }
199 206
200 void WmWindowAura::AddChild(WmWindow* window) { 207 void WmWindowAura::AddChild(WmWindow* window) {
201 window_->AddChild(GetAuraWindow(window)); 208 window_->AddChild(GetAuraWindow(window));
202 } 209 }
203 210
204 WmWindow* WmWindowAura::GetParent() { 211 WmWindow* WmWindowAura::GetParent() {
205 return Get(window_->parent()); 212 return Get(window_->parent());
206 } 213 }
207 214
208 WmWindow* WmWindowAura::GetTransientParent() { 215 const WmWindow* WmWindowAura::GetTransientParent() const {
209 return Get(::wm::GetTransientParent(window_)); 216 return Get(::wm::GetTransientParent(window_));
210 } 217 }
211 218
212 std::vector<WmWindow*> WmWindowAura::GetTransientChildren() { 219 std::vector<WmWindow*> WmWindowAura::GetTransientChildren() {
213 const std::vector<aura::Window*> aura_windows( 220 const std::vector<aura::Window*> aura_windows(
214 ::wm::GetTransientChildren(window_)); 221 ::wm::GetTransientChildren(window_));
215 std::vector<WmWindow*> wm_windows(aura_windows.size()); 222 std::vector<WmWindow*> wm_windows(aura_windows.size());
216 for (size_t i = 0; i < aura_windows.size(); ++i) 223 for (size_t i = 0; i < aura_windows.size(); ++i)
217 wm_windows[i] = Get(aura_windows[i]); 224 wm_windows[i] = Get(aura_windows[i]);
218 return wm_windows; 225 return wm_windows;
219 } 226 }
220 227
228 void WmWindowAura::SetLayoutManager(
229 std::unique_ptr<WmLayoutManager> layout_manager) {
230 // |window_| takes ownership of AuraLayoutManagerAdapter.
231 window_->SetLayoutManager(
232 new AuraLayoutManagerAdapter(std::move(layout_manager)));
233 }
234
235 WmLayoutManager* WmWindowAura::GetLayoutManager() {
236 return static_cast<AuraLayoutManagerAdapter*>(window_->layout_manager())
237 ->wm_layout_manager();
238 }
239
221 void WmWindowAura::SetVisibilityAnimationType(int type) { 240 void WmWindowAura::SetVisibilityAnimationType(int type) {
222 ::wm::SetWindowVisibilityAnimationType(window_, type); 241 ::wm::SetWindowVisibilityAnimationType(window_, type);
223 } 242 }
224 243
244 void WmWindowAura::SetVisibilityAnimationDuration(base::TimeDelta delta) {
245 ::wm::SetWindowVisibilityAnimationDuration(window_, delta);
246 }
247
225 void WmWindowAura::Animate(::wm::WindowAnimationType type) { 248 void WmWindowAura::Animate(::wm::WindowAnimationType type) {
226 ::wm::AnimateWindow(window_, type); 249 ::wm::AnimateWindow(window_, type);
227 } 250 }
228 251
229 void WmWindowAura::SetBounds(const gfx::Rect& bounds) { 252 void WmWindowAura::SetBounds(const gfx::Rect& bounds) {
230 window_->SetBounds(bounds); 253 window_->SetBounds(bounds);
231 } 254 }
232 255
233 void WmWindowAura::SetBoundsWithTransitionDelay(const gfx::Rect& bounds, 256 void WmWindowAura::SetBoundsWithTransitionDelay(const gfx::Rect& bounds,
234 base::TimeDelta delta) { 257 base::TimeDelta delta) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 } 390 }
368 391
369 bool WmWindowAura::CanActivate() const { 392 bool WmWindowAura::CanActivate() const {
370 return ::wm::CanActivateWindow(window_); 393 return ::wm::CanActivateWindow(window_);
371 } 394 }
372 395
373 void WmWindowAura::StackChildAtTop(WmWindow* child) { 396 void WmWindowAura::StackChildAtTop(WmWindow* child) {
374 window_->StackChildAtTop(GetAuraWindow(child)); 397 window_->StackChildAtTop(GetAuraWindow(child));
375 } 398 }
376 399
400 void WmWindowAura::StackChildAtBottom(WmWindow* child) {
401 window_->StackChildAtBottom(GetAuraWindow(child));
402 }
403
377 void WmWindowAura::StackChildAbove(WmWindow* child, WmWindow* target) { 404 void WmWindowAura::StackChildAbove(WmWindow* child, WmWindow* target) {
378 window_->StackChildAbove(GetAuraWindow(child), GetAuraWindow(target)); 405 window_->StackChildAbove(GetAuraWindow(child), GetAuraWindow(target));
379 } 406 }
380 407
381 void WmWindowAura::StackChildBelow(WmWindow* child, WmWindow* target) { 408 void WmWindowAura::StackChildBelow(WmWindow* child, WmWindow* target) {
382 window_->StackChildBelow(GetAuraWindow(child), GetAuraWindow(target)); 409 window_->StackChildBelow(GetAuraWindow(child), GetAuraWindow(target));
383 } 410 }
384 411
385 void WmWindowAura::SetAlwaysOnTop(bool value) { 412 void WmWindowAura::SetAlwaysOnTop(bool value) {
386 window_->SetProperty(aura::client::kAlwaysOnTopKey, value); 413 window_->SetProperty(aura::client::kAlwaysOnTopKey, value);
387 } 414 }
388 415
389 bool WmWindowAura::IsAlwaysOnTop() const { 416 bool WmWindowAura::IsAlwaysOnTop() const {
390 return window_->GetProperty(aura::client::kAlwaysOnTopKey); 417 return window_->GetProperty(aura::client::kAlwaysOnTopKey);
391 } 418 }
392 419
393 void WmWindowAura::Hide() { 420 void WmWindowAura::Hide() {
394 window_->Hide(); 421 window_->Hide();
395 } 422 }
396 423
397 void WmWindowAura::Show() { 424 void WmWindowAura::Show() {
398 window_->Show(); 425 window_->Show();
399 } 426 }
400 427
428 bool WmWindowAura::IsFocused() const {
429 return window_->HasFocus();
430 }
431
401 bool WmWindowAura::IsActive() const { 432 bool WmWindowAura::IsActive() const {
402 return IsActiveWindow(window_); 433 return IsActiveWindow(window_);
403 } 434 }
404 435
405 void WmWindowAura::Activate() { 436 void WmWindowAura::Activate() {
406 ActivateWindow(window_); 437 ActivateWindow(window_);
407 } 438 }
408 439
409 void WmWindowAura::Deactivate() { 440 void WmWindowAura::Deactivate() {
410 DeactivateWindow(window_); 441 DeactivateWindow(window_);
(...skipping 20 matching lines...) Expand all
431 std::vector<WmWindow*> result(aura_children.size()); 462 std::vector<WmWindow*> result(aura_children.size());
432 for (size_t i = 0; i < aura_children.size(); ++i) 463 for (size_t i = 0; i < aura_children.size(); ++i)
433 result[i] = Get(aura_children[i]); 464 result[i] = Get(aura_children[i]);
434 return result; 465 return result;
435 } 466 }
436 467
437 WmWindow* WmWindowAura::GetChildByShellWindowId(int id) { 468 WmWindow* WmWindowAura::GetChildByShellWindowId(int id) {
438 return Get(window_->GetChildById(id)); 469 return Get(window_->GetChildById(id));
439 } 470 }
440 471
472 void WmWindowAura::SnapToPixelBoundaryIfNecessary() {
473 SnapWindowToPixelBoundary(window_);
474 }
475
441 void WmWindowAura::AddObserver(WmWindowObserver* observer) { 476 void WmWindowAura::AddObserver(WmWindowObserver* observer) {
442 observers_.AddObserver(observer); 477 observers_.AddObserver(observer);
443 } 478 }
444 479
445 void WmWindowAura::RemoveObserver(WmWindowObserver* observer) { 480 void WmWindowAura::RemoveObserver(WmWindowObserver* observer) {
446 observers_.RemoveObserver(observer); 481 observers_.RemoveObserver(observer);
447 } 482 }
448 483
449 WmWindowAura::~WmWindowAura() { 484 WmWindowAura::~WmWindowAura() {
450 window_->RemoveObserver(this); 485 window_->RemoveObserver(this);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 const gfx::Rect& old_bounds, 523 const gfx::Rect& old_bounds,
489 const gfx::Rect& new_bounds) { 524 const gfx::Rect& new_bounds) {
490 FOR_EACH_OBSERVER(WmWindowObserver, observers_, 525 FOR_EACH_OBSERVER(WmWindowObserver, observers_,
491 OnWindowBoundsChanged(this, old_bounds, new_bounds)); 526 OnWindowBoundsChanged(this, old_bounds, new_bounds));
492 } 527 }
493 528
494 void WmWindowAura::OnWindowDestroying(aura::Window* window) { 529 void WmWindowAura::OnWindowDestroying(aura::Window* window) {
495 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowDestroying(this)); 530 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowDestroying(this));
496 } 531 }
497 532
533 void WmWindowAura::OnWindowVisibilityChanging(aura::Window* window,
534 bool visible) {
535 FOR_EACH_OBSERVER(WmWindowObserver, observers_,
536 OnWindowVisibilityChanging(this, visible));
537 }
538
498 } // namespace wm 539 } // namespace wm
499 } // namespace ash 540 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/aura/wm_window_aura.h ('k') | ash/wm/common/wm_activation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698