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/wm/aura/wm_window_aura.h" | 5 #include "ash/wm/aura/wm_window_aura.h" |
6 | 6 |
| 7 #include "ash/ash_constants.h" |
7 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
8 #include "ash/shelf/shelf_util.h" | 9 #include "ash/shelf/shelf_util.h" |
9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
10 #include "ash/wm/aura/aura_layout_manager_adapter.h" | 11 #include "ash/wm/aura/aura_layout_manager_adapter.h" |
11 #include "ash/wm/aura/wm_globals_aura.h" | 12 #include "ash/wm/aura/wm_globals_aura.h" |
12 #include "ash/wm/aura/wm_root_window_controller_aura.h" | 13 #include "ash/wm/aura/wm_root_window_controller_aura.h" |
13 #include "ash/wm/common/window_state.h" | 14 #include "ash/wm/common/window_state.h" |
14 #include "ash/wm/common/wm_layout_manager.h" | 15 #include "ash/wm/common/wm_layout_manager.h" |
15 #include "ash/wm/common/wm_window_observer.h" | 16 #include "ash/wm/common/wm_window_observer.h" |
16 #include "ash/wm/common/wm_window_property.h" | 17 #include "ash/wm/common/wm_window_property.h" |
17 #include "ash/wm/resize_shadow_controller.h" | 18 #include "ash/wm/resize_shadow_controller.h" |
18 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
19 #include "ash/wm/window_properties.h" | 20 #include "ash/wm/window_properties.h" |
20 #include "ash/wm/window_state_aura.h" | 21 #include "ash/wm/window_state_aura.h" |
21 #include "ash/wm/window_util.h" | 22 #include "ash/wm/window_util.h" |
| 23 #include "base/memory/ptr_util.h" |
22 #include "ui/aura/client/aura_constants.h" | 24 #include "ui/aura/client/aura_constants.h" |
23 #include "ui/aura/client/window_tree_client.h" | 25 #include "ui/aura/client/window_tree_client.h" |
24 #include "ui/aura/layout_manager.h" | 26 #include "ui/aura/layout_manager.h" |
25 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
26 #include "ui/aura/window_delegate.h" | 28 #include "ui/aura/window_delegate.h" |
27 #include "ui/aura/window_property.h" | 29 #include "ui/aura/window_property.h" |
28 #include "ui/base/hit_test.h" | 30 #include "ui/base/hit_test.h" |
29 #include "ui/compositor/layer_tree_owner.h" | 31 #include "ui/compositor/layer_tree_owner.h" |
30 #include "ui/compositor/scoped_layer_animation_settings.h" | 32 #include "ui/compositor/scoped_layer_animation_settings.h" |
31 #include "ui/display/screen.h" | 33 #include "ui/display/screen.h" |
| 34 #include "ui/gfx/geometry/insets.h" |
32 #include "ui/views/widget/widget.h" | 35 #include "ui/views/widget/widget.h" |
33 #include "ui/wm/core/coordinate_conversion.h" | 36 #include "ui/wm/core/coordinate_conversion.h" |
| 37 #include "ui/wm/core/easy_resize_window_targeter.h" |
| 38 #include "ui/wm/core/visibility_controller.h" |
34 #include "ui/wm/core/window_util.h" | 39 #include "ui/wm/core/window_util.h" |
35 | 40 |
36 DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WmWindowAura*); | 41 DECLARE_WINDOW_PROPERTY_TYPE(ash::wm::WmWindowAura*); |
37 | 42 |
38 namespace ash { | 43 namespace ash { |
39 namespace wm { | 44 namespace wm { |
40 | 45 |
41 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::wm::WmWindowAura, kWmWindowKey, nullptr); | 46 DEFINE_OWNED_WINDOW_PROPERTY_KEY(ash::wm::WmWindowAura, kWmWindowKey, nullptr); |
42 | 47 |
43 namespace { | 48 namespace { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 117 |
113 WmRootWindowController* WmWindowAura::GetRootWindowController() { | 118 WmRootWindowController* WmWindowAura::GetRootWindowController() { |
114 aura::Window* root = window_->GetRootWindow(); | 119 aura::Window* root = window_->GetRootWindow(); |
115 return root ? WmRootWindowControllerAura::Get(root) : nullptr; | 120 return root ? WmRootWindowControllerAura::Get(root) : nullptr; |
116 } | 121 } |
117 | 122 |
118 WmGlobals* WmWindowAura::GetGlobals() const { | 123 WmGlobals* WmWindowAura::GetGlobals() const { |
119 return WmGlobals::Get(); | 124 return WmGlobals::Get(); |
120 } | 125 } |
121 | 126 |
| 127 void WmWindowAura::SetName(const char* name) { |
| 128 window_->SetName(name); |
| 129 } |
| 130 |
122 base::string16 WmWindowAura::GetTitle() const { | 131 base::string16 WmWindowAura::GetTitle() const { |
123 return window_->title(); | 132 return window_->title(); |
124 } | 133 } |
125 | 134 |
126 void WmWindowAura::SetShellWindowId(int id) { | 135 void WmWindowAura::SetShellWindowId(int id) { |
127 window_->set_id(id); | 136 window_->set_id(id); |
128 } | 137 } |
129 | 138 |
130 int WmWindowAura::GetShellWindowId() const { | 139 int WmWindowAura::GetShellWindowId() const { |
131 return window_->id(); | 140 return window_->id(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 gfx::Transform WmWindowAura::GetTargetTransform() const { | 222 gfx::Transform WmWindowAura::GetTargetTransform() const { |
214 return window_->layer()->GetTargetTransform(); | 223 return window_->layer()->GetTargetTransform(); |
215 } | 224 } |
216 | 225 |
217 bool WmWindowAura::IsSystemModal() const { | 226 bool WmWindowAura::IsSystemModal() const { |
218 return window_->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; | 227 return window_->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_SYSTEM; |
219 } | 228 } |
220 | 229 |
221 bool WmWindowAura::GetBoolProperty(WmWindowProperty key) { | 230 bool WmWindowAura::GetBoolProperty(WmWindowProperty key) { |
222 switch (key) { | 231 switch (key) { |
223 case WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUDARY: | 232 case WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY: |
224 return window_->GetProperty(kSnapChildrenToPixelBoundary); | 233 return window_->GetProperty(kSnapChildrenToPixelBoundary); |
225 | 234 |
226 case WmWindowProperty::ALWAYS_ON_TOP: | 235 case WmWindowProperty::ALWAYS_ON_TOP: |
227 return window_->GetProperty(aura::client::kAlwaysOnTopKey); | 236 return window_->GetProperty(aura::client::kAlwaysOnTopKey); |
228 | 237 |
229 default: | 238 default: |
230 NOTREACHED(); | 239 NOTREACHED(); |
231 break; | 240 break; |
232 } | 241 } |
233 | 242 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 311 |
303 void WmWindowAura::Animate(::wm::WindowAnimationType type) { | 312 void WmWindowAura::Animate(::wm::WindowAnimationType type) { |
304 ::wm::AnimateWindow(window_, type); | 313 ::wm::AnimateWindow(window_, type); |
305 } | 314 } |
306 | 315 |
307 void WmWindowAura::StopAnimatingProperty( | 316 void WmWindowAura::StopAnimatingProperty( |
308 ui::LayerAnimationElement::AnimatableProperty property) { | 317 ui::LayerAnimationElement::AnimatableProperty property) { |
309 window_->layer()->GetAnimator()->StopAnimatingProperty(property); | 318 window_->layer()->GetAnimator()->StopAnimatingProperty(property); |
310 } | 319 } |
311 | 320 |
| 321 void WmWindowAura::SetChildWindowVisibilityChangesAnimated() { |
| 322 ::wm::SetChildWindowVisibilityChangesAnimated(window_); |
| 323 } |
| 324 |
| 325 void WmWindowAura::SetMasksToBounds(bool value) { |
| 326 window_->layer()->SetMasksToBounds(value); |
| 327 } |
| 328 |
312 void WmWindowAura::SetBounds(const gfx::Rect& bounds) { | 329 void WmWindowAura::SetBounds(const gfx::Rect& bounds) { |
313 window_->SetBounds(bounds); | 330 window_->SetBounds(bounds); |
314 } | 331 } |
315 | 332 |
316 void WmWindowAura::SetBoundsWithTransitionDelay(const gfx::Rect& bounds, | 333 void WmWindowAura::SetBoundsWithTransitionDelay(const gfx::Rect& bounds, |
317 base::TimeDelta delta) { | 334 base::TimeDelta delta) { |
318 if (::wm::WindowAnimationsDisabled(window_)) { | 335 if (::wm::WindowAnimationsDisabled(window_)) { |
319 window_->SetBounds(bounds); | 336 window_->SetBounds(bounds); |
320 return; | 337 return; |
321 } | 338 } |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 resize_shadow_controller->ShowShadow(window_, component); | 558 resize_shadow_controller->ShowShadow(window_, component); |
542 } | 559 } |
543 | 560 |
544 void WmWindowAura::HideResizeShadow() { | 561 void WmWindowAura::HideResizeShadow() { |
545 ResizeShadowController* resize_shadow_controller = | 562 ResizeShadowController* resize_shadow_controller = |
546 Shell::GetInstance()->resize_shadow_controller(); | 563 Shell::GetInstance()->resize_shadow_controller(); |
547 if (resize_shadow_controller) | 564 if (resize_shadow_controller) |
548 resize_shadow_controller->HideShadow(window_); | 565 resize_shadow_controller->HideShadow(window_); |
549 } | 566 } |
550 | 567 |
| 568 void WmWindowAura::SetBoundsInScreenBehaviorForChildren( |
| 569 BoundsInScreenBehavior behavior) { |
| 570 window_->SetProperty( |
| 571 kUsesScreenCoordinatesKey, |
| 572 behavior == BoundsInScreenBehavior::USE_SCREEN_COORDINATES); |
| 573 } |
| 574 |
| 575 void WmWindowAura::SetSnapsChildrenToPhysicalPixelBoundary() { |
| 576 wm::SetSnapsChildrenToPhysicalPixelBoundary(window_); |
| 577 } |
| 578 |
551 void WmWindowAura::SnapToPixelBoundaryIfNecessary() { | 579 void WmWindowAura::SnapToPixelBoundaryIfNecessary() { |
552 SnapWindowToPixelBoundary(window_); | 580 SnapWindowToPixelBoundary(window_); |
553 } | 581 } |
554 | 582 |
| 583 void WmWindowAura::SetChildrenUseExtendedHitRegion() { |
| 584 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, |
| 585 -kResizeOutsideBoundsSize, |
| 586 -kResizeOutsideBoundsSize); |
| 587 gfx::Insets touch_extend = |
| 588 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); |
| 589 window_->SetEventTargeter(base::WrapUnique( |
| 590 new ::wm::EasyResizeWindowTargeter(window_, mouse_extend, touch_extend))); |
| 591 } |
| 592 |
| 593 void WmWindowAura::SetDescendantsStayInSameRootWindow(bool value) { |
| 594 window_->SetProperty(kStayInSameRootWindowKey, true); |
| 595 } |
| 596 |
555 void WmWindowAura::AddObserver(WmWindowObserver* observer) { | 597 void WmWindowAura::AddObserver(WmWindowObserver* observer) { |
556 observers_.AddObserver(observer); | 598 observers_.AddObserver(observer); |
557 } | 599 } |
558 | 600 |
559 void WmWindowAura::RemoveObserver(WmWindowObserver* observer) { | 601 void WmWindowAura::RemoveObserver(WmWindowObserver* observer) { |
560 observers_.RemoveObserver(observer); | 602 observers_.RemoveObserver(observer); |
561 } | 603 } |
562 | 604 |
563 WmWindowAura::~WmWindowAura() { | 605 WmWindowAura::~WmWindowAura() { |
564 window_->RemoveObserver(this); | 606 window_->RemoveObserver(this); |
(...skipping 16 matching lines...) Expand all Loading... |
581 | 623 |
582 void WmWindowAura::OnWindowPropertyChanged(aura::Window* window, | 624 void WmWindowAura::OnWindowPropertyChanged(aura::Window* window, |
583 const void* key, | 625 const void* key, |
584 intptr_t old) { | 626 intptr_t old) { |
585 if (key == aura::client::kShowStateKey) { | 627 if (key == aura::client::kShowStateKey) { |
586 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged(); | 628 ash::wm::GetWindowState(window_)->OnWindowShowStateChanged(); |
587 return; | 629 return; |
588 } | 630 } |
589 WmWindowProperty wm_property; | 631 WmWindowProperty wm_property; |
590 if (key == kSnapChildrenToPixelBoundary) { | 632 if (key == kSnapChildrenToPixelBoundary) { |
591 wm_property = WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUDARY; | 633 wm_property = WmWindowProperty::SNAP_CHILDREN_TO_PIXEL_BOUNDARY; |
592 } else if (key == aura::client::kAlwaysOnTopKey) { | 634 } else if (key == aura::client::kAlwaysOnTopKey) { |
593 wm_property = WmWindowProperty::ALWAYS_ON_TOP; | 635 wm_property = WmWindowProperty::ALWAYS_ON_TOP; |
594 } else if (key == kShelfID) { | 636 } else if (key == kShelfID) { |
595 wm_property = WmWindowProperty::SHELF_ID; | 637 wm_property = WmWindowProperty::SHELF_ID; |
596 } else if (key == aura::client::kTopViewInset) { | 638 } else if (key == aura::client::kTopViewInset) { |
597 wm_property = WmWindowProperty::TOP_VIEW_INSET; | 639 wm_property = WmWindowProperty::TOP_VIEW_INSET; |
598 } else { | 640 } else { |
599 return; | 641 return; |
600 } | 642 } |
601 FOR_EACH_OBSERVER(WmWindowObserver, observers_, | 643 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
(...skipping 16 matching lines...) Expand all Loading... |
618 FOR_EACH_OBSERVER(WmWindowObserver, observers_, | 660 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
619 OnWindowVisibilityChanging(this, visible)); | 661 OnWindowVisibilityChanging(this, visible)); |
620 } | 662 } |
621 | 663 |
622 void WmWindowAura::OnWindowTitleChanged(aura::Window* window) { | 664 void WmWindowAura::OnWindowTitleChanged(aura::Window* window) { |
623 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowTitleChanged(this)); | 665 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowTitleChanged(this)); |
624 } | 666 } |
625 | 667 |
626 } // namespace wm | 668 } // namespace wm |
627 } // namespace ash | 669 } // namespace ash |
OLD | NEW |