| 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/common/wm_window.h" | 5 #include "ash/common/wm_window.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/wm/window_state.h" | 10 #include "ash/common/wm/window_state.h" |
| 11 #include "ash/common/wm_layout_manager.h" | 11 #include "ash/common/wm_layout_manager.h" |
| 12 #include "ash/common/wm_transient_window_observer.h" | 12 #include "ash/common/wm_transient_window_observer.h" |
| 13 #include "ash/public/cpp/shell_window_ids.h" | 13 #include "ash/public/cpp/shell_window_ids.h" |
| 14 #include "ash/public/cpp/window_properties.h" | 14 #include "ash/public/cpp/window_properties.h" |
| 15 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/wm/resize_handle_window_targeter.h" | 17 #include "ash/wm/resize_handle_window_targeter.h" |
| 18 #include "ash/wm/resize_shadow_controller.h" | 18 #include "ash/wm/resize_shadow_controller.h" |
| 19 #include "ash/wm/widget_finder.h" |
| 19 #include "ash/wm/window_animations.h" | 20 #include "ash/wm/window_animations.h" |
| 20 #include "ash/wm/window_mirror_view.h" | 21 #include "ash/wm/window_mirror_view.h" |
| 21 #include "ash/wm/window_properties.h" | 22 #include "ash/wm/window_properties.h" |
| 22 #include "ash/wm/window_state_aura.h" | 23 #include "ash/wm/window_state_aura.h" |
| 23 #include "ash/wm/window_util.h" | 24 #include "ash/wm/window_util.h" |
| 24 #include "base/memory/ptr_util.h" | 25 #include "base/memory/ptr_util.h" |
| 25 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | 26 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
| 26 #include "ui/aura/client/aura_constants.h" | 27 #include "ui/aura/client/aura_constants.h" |
| 27 #include "ui/aura/client/focus_client.h" | 28 #include "ui/aura/client/focus_client.h" |
| 28 #include "ui/aura/client/window_parenting_client.h" | 29 #include "ui/aura/client/window_parenting_client.h" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 } | 572 } |
| 572 | 573 |
| 573 void WmWindow::Hide() { | 574 void WmWindow::Hide() { |
| 574 window_->Hide(); | 575 window_->Hide(); |
| 575 } | 576 } |
| 576 | 577 |
| 577 void WmWindow::Show() { | 578 void WmWindow::Show() { |
| 578 window_->Show(); | 579 window_->Show(); |
| 579 } | 580 } |
| 580 | 581 |
| 581 views::Widget* WmWindow::GetInternalWidget() { | |
| 582 return window_->GetProperty(kWidgetCreationTypeKey) == | |
| 583 WidgetCreationType::INTERNAL | |
| 584 ? views::Widget::GetWidgetForNativeView(window_) | |
| 585 : nullptr; | |
| 586 } | |
| 587 | |
| 588 void WmWindow::CloseWidget() { | 582 void WmWindow::CloseWidget() { |
| 589 if (WmShell::Get()->IsRunningInMash() && | 583 if (WmShell::Get()->IsRunningInMash() && |
| 590 aura_window()->GetProperty(kWidgetCreationTypeKey) == | 584 aura_window()->GetProperty(kWidgetCreationTypeKey) == |
| 591 WidgetCreationType::FOR_CLIENT) { | 585 WidgetCreationType::FOR_CLIENT) { |
| 592 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated | 586 // NOTE: in the FOR_CLIENT case there is not necessarily a widget associated |
| 593 // with the window. Mash only creates widgets for top level windows if mash | 587 // with the window. Mash only creates widgets for top level windows if mash |
| 594 // renders the non-client frame. | 588 // renders the non-client frame. |
| 595 DCHECK(Shell::window_manager_client()); | 589 DCHECK(Shell::window_manager_client()); |
| 596 Shell::window_manager_client()->RequestClose(aura_window()); | 590 Shell::window_manager_client()->RequestClose(aura_window()); |
| 597 return; | 591 return; |
| 598 } | 592 } |
| 599 DCHECK(GetInternalWidget()); | 593 views::Widget* widget = GetInternalWidgetForWindow(window_); |
| 600 GetInternalWidget()->Close(); | 594 DCHECK(widget); |
| 595 widget->Close(); |
| 601 } | 596 } |
| 602 | 597 |
| 603 void WmWindow::SetFocused() { | 598 void WmWindow::SetFocused() { |
| 604 aura::client::GetFocusClient(window_)->FocusWindow(window_); | 599 aura::client::GetFocusClient(window_)->FocusWindow(window_); |
| 605 } | 600 } |
| 606 | 601 |
| 607 bool WmWindow::IsFocused() const { | 602 bool WmWindow::IsFocused() const { |
| 608 return window_->HasFocus(); | 603 return window_->HasFocus(); |
| 609 } | 604 } |
| 610 | 605 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 observer.OnTransientChildAdded(this, Get(transient)); | 767 observer.OnTransientChildAdded(this, Get(transient)); |
| 773 } | 768 } |
| 774 | 769 |
| 775 void WmWindow::OnTransientChildRemoved(aura::Window* window, | 770 void WmWindow::OnTransientChildRemoved(aura::Window* window, |
| 776 aura::Window* transient) { | 771 aura::Window* transient) { |
| 777 for (auto& observer : transient_observers_) | 772 for (auto& observer : transient_observers_) |
| 778 observer.OnTransientChildRemoved(this, Get(transient)); | 773 observer.OnTransientChildRemoved(this, Get(transient)); |
| 779 } | 774 } |
| 780 | 775 |
| 781 } // namespace ash | 776 } // namespace ash |
| OLD | NEW |