| 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_window.h" | 5 #include "ash/wm_window.h" |
| 6 | 6 |
| 7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
| 8 #include "ash/public/cpp/config.h" | 8 #include "ash/public/cpp/config.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/public/cpp/window_properties.h" | 10 #include "ash/public/cpp/window_properties.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 result[i] = WmWindow::GetAuraWindow(windows[i]); | 90 result[i] = WmWindow::GetAuraWindow(windows[i]); |
| 91 return result; | 91 return result; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // static | 94 // static |
| 95 const aura::Window* WmWindow::GetAuraWindow(const WmWindow* wm_window) { | 95 const aura::Window* WmWindow::GetAuraWindow(const WmWindow* wm_window) { |
| 96 return wm_window ? static_cast<const WmWindow*>(wm_window)->aura_window() | 96 return wm_window ? static_cast<const WmWindow*>(wm_window)->aura_window() |
| 97 : nullptr; | 97 : nullptr; |
| 98 } | 98 } |
| 99 | 99 |
| 100 bool WmWindow::ShouldUseExtendedHitRegion() const { | |
| 101 const WmWindow* parent = Get(window_->parent()); | |
| 102 return parent && | |
| 103 static_cast<const WmWindow*>(parent) | |
| 104 ->children_use_extended_hit_region_; | |
| 105 } | |
| 106 | |
| 107 void WmWindow::Destroy() { | 100 void WmWindow::Destroy() { |
| 108 delete window_; | 101 delete window_; |
| 109 // WARNING: this has been deleted. | 102 // WARNING: this has been deleted. |
| 110 } | 103 } |
| 111 | 104 |
| 112 const WmWindow* WmWindow::GetRootWindow() const { | 105 const WmWindow* WmWindow::GetRootWindow() const { |
| 113 return Get(window_->GetRootWindow()); | 106 return Get(window_->GetRootWindow()); |
| 114 } | 107 } |
| 115 | 108 |
| 116 RootWindowController* WmWindow::GetRootWindowController() { | 109 RootWindowController* WmWindow::GetRootWindowController() { |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 } | 501 } |
| 509 | 502 |
| 510 void WmWindow::SetSnapsChildrenToPhysicalPixelBoundary() { | 503 void WmWindow::SetSnapsChildrenToPhysicalPixelBoundary() { |
| 511 wm::SetSnapsChildrenToPhysicalPixelBoundary(window_); | 504 wm::SetSnapsChildrenToPhysicalPixelBoundary(window_); |
| 512 } | 505 } |
| 513 | 506 |
| 514 void WmWindow::SnapToPixelBoundaryIfNecessary() { | 507 void WmWindow::SnapToPixelBoundaryIfNecessary() { |
| 515 wm::SnapWindowToPixelBoundary(window_); | 508 wm::SnapWindowToPixelBoundary(window_); |
| 516 } | 509 } |
| 517 | 510 |
| 518 void WmWindow::SetChildrenUseExtendedHitRegion() { | |
| 519 children_use_extended_hit_region_ = true; | |
| 520 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, | |
| 521 -kResizeOutsideBoundsSize, | |
| 522 -kResizeOutsideBoundsSize); | |
| 523 gfx::Insets touch_extend = | |
| 524 mouse_extend.Scale(kResizeOutsideBoundsScaleForTouch); | |
| 525 // TODO: EasyResizeWindowTargeter makes it so children get events outside | |
| 526 // their bounds. This only works in mash when mash is providing the non-client | |
| 527 // frame. Mus needs to support an api for the WindowManager that enables | |
| 528 // events to be dispatched to windows outside the windows bounds that this | |
| 529 // function calls into. http://crbug.com/679056. | |
| 530 window_->SetEventTargeter(base::MakeUnique<::wm::EasyResizeWindowTargeter>( | |
| 531 window_, mouse_extend, touch_extend)); | |
| 532 } | |
| 533 | |
| 534 void WmWindow::AddTransientWindowObserver(WmTransientWindowObserver* observer) { | 511 void WmWindow::AddTransientWindowObserver(WmTransientWindowObserver* observer) { |
| 535 if (!added_transient_observer_) { | 512 if (!added_transient_observer_) { |
| 536 added_transient_observer_ = true; | 513 added_transient_observer_ = true; |
| 537 ::wm::TransientWindowManager::Get(window_)->AddObserver(this); | 514 ::wm::TransientWindowManager::Get(window_)->AddObserver(this); |
| 538 } | 515 } |
| 539 transient_observers_.AddObserver(observer); | 516 transient_observers_.AddObserver(observer); |
| 540 } | 517 } |
| 541 | 518 |
| 542 void WmWindow::RemoveTransientWindowObserver( | 519 void WmWindow::RemoveTransientWindowObserver( |
| 543 WmTransientWindowObserver* observer) { | 520 WmTransientWindowObserver* observer) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 559 observer.OnTransientChildAdded(this, Get(transient)); | 536 observer.OnTransientChildAdded(this, Get(transient)); |
| 560 } | 537 } |
| 561 | 538 |
| 562 void WmWindow::OnTransientChildRemoved(aura::Window* window, | 539 void WmWindow::OnTransientChildRemoved(aura::Window* window, |
| 563 aura::Window* transient) { | 540 aura::Window* transient) { |
| 564 for (auto& observer : transient_observers_) | 541 for (auto& observer : transient_observers_) |
| 565 observer.OnTransientChildRemoved(this, Get(transient)); | 542 observer.OnTransientChildRemoved(this, Get(transient)); |
| 566 } | 543 } |
| 567 | 544 |
| 568 } // namespace ash | 545 } // namespace ash |
| OLD | NEW |