| 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 "ui/views/mus/desktop_window_tree_host_mus.h" | 5 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/capture_client.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 11 #include "ui/aura/client/cursor_client.h" |
| 11 #include "ui/aura/client/drag_drop_client.h" | 12 #include "ui/aura/client/drag_drop_client.h" |
| 12 #include "ui/aura/client/focus_client.h" | 13 #include "ui/aura/client/focus_client.h" |
| 13 #include "ui/aura/client/transient_window_client.h" | 14 #include "ui/aura/client/transient_window_client.h" |
| 14 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 15 #include "ui/aura/mus/window_port_mus.h" | 16 #include "ui/aura/mus/window_port_mus.h" |
| 16 #include "ui/aura/mus/window_tree_host_mus.h" | 17 #include "ui/aura/mus/window_tree_host_mus.h" |
| 17 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 18 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
| 19 #include "ui/display/screen.h" | 20 #include "ui/display/screen.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // Widget can notify everyone listening for that signal. | 297 // Widget can notify everyone listening for that signal. |
| 297 native_widget_delegate_->OnNativeWidgetActivationChanged(active); | 298 native_widget_delegate_->OnNativeWidgetActivationChanged(active); |
| 298 } | 299 } |
| 299 | 300 |
| 300 void DesktopWindowTreeHostMus::OnWidgetInitDone() { | 301 void DesktopWindowTreeHostMus::OnWidgetInitDone() { |
| 301 // Because of construction order it's possible the bounds have changed before | 302 // Because of construction order it's possible the bounds have changed before |
| 302 // the NonClientView was created, which means we may not have sent the | 303 // the NonClientView was created, which means we may not have sent the |
| 303 // client-area and hit-test-mask. | 304 // client-area and hit-test-mask. |
| 304 SendClientAreaToServer(); | 305 SendClientAreaToServer(); |
| 305 SendHitTestMaskToServer(); | 306 SendHitTestMaskToServer(); |
| 307 |
| 308 MusClient::Get()->OnCaptureClientSet( |
| 309 aura::client::GetCaptureClient(window())); |
| 306 } | 310 } |
| 307 | 311 |
| 308 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { | 312 std::unique_ptr<corewm::Tooltip> DesktopWindowTreeHostMus::CreateTooltip() { |
| 309 return base::MakeUnique<corewm::TooltipAura>(); | 313 return base::MakeUnique<corewm::TooltipAura>(); |
| 310 } | 314 } |
| 311 | 315 |
| 312 std::unique_ptr<aura::client::DragDropClient> | 316 std::unique_ptr<aura::client::DragDropClient> |
| 313 DesktopWindowTreeHostMus::CreateDragDropClient( | 317 DesktopWindowTreeHostMus::CreateDragDropClient( |
| 314 DesktopNativeCursorManager* cursor_manager) { | 318 DesktopNativeCursorManager* cursor_manager) { |
| 315 // aura-mus handles installing a DragDropClient. | 319 // aura-mus handles installing a DragDropClient. |
| 316 return nullptr; | 320 return nullptr; |
| 317 } | 321 } |
| 318 | 322 |
| 319 void DesktopWindowTreeHostMus::Close() { | 323 void DesktopWindowTreeHostMus::Close() { |
| 320 if (close_widget_factory_.HasWeakPtrs()) | 324 if (close_widget_factory_.HasWeakPtrs()) |
| 321 return; | 325 return; |
| 322 | 326 |
| 323 // Even though we don't close immediately, we need to hide immediately | 327 // Even though we don't close immediately, we need to hide immediately |
| 324 // (otherwise events may be processed, which is unexpected). | 328 // (otherwise events may be processed, which is unexpected). |
| 325 Hide(); | 329 Hide(); |
| 326 | 330 |
| 327 // Close doesn't delete this immediately, as 'this' may still be on the stack | 331 // Close doesn't delete this immediately, as 'this' may still be on the stack |
| 328 // resulting in possible crashes when the stack unwindes. | 332 // resulting in possible crashes when the stack unwindes. |
| 329 base::ThreadTaskRunnerHandle::Get()->PostTask( | 333 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 330 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow, | 334 FROM_HERE, base::Bind(&DesktopWindowTreeHostMus::CloseNow, |
| 331 close_widget_factory_.GetWeakPtr())); | 335 close_widget_factory_.GetWeakPtr())); |
| 332 } | 336 } |
| 333 | 337 |
| 334 void DesktopWindowTreeHostMus::CloseNow() { | 338 void DesktopWindowTreeHostMus::CloseNow() { |
| 339 MusClient::Get()->OnCaptureClientUnset( |
| 340 aura::client::GetCaptureClient(window())); |
| 341 |
| 335 native_widget_delegate_->OnNativeWidgetDestroying(); | 342 native_widget_delegate_->OnNativeWidgetDestroying(); |
| 336 | 343 |
| 337 // If we have children, close them. Use a copy for iteration because they'll | 344 // If we have children, close them. Use a copy for iteration because they'll |
| 338 // remove themselves from |children_|. | 345 // remove themselves from |children_|. |
| 339 std::set<DesktopWindowTreeHostMus*> children_copy = children_; | 346 std::set<DesktopWindowTreeHostMus*> children_copy = children_; |
| 340 for (DesktopWindowTreeHostMus* child : children_copy) | 347 for (DesktopWindowTreeHostMus* child : children_copy) |
| 341 child->CloseNow(); | 348 child->CloseNow(); |
| 342 DCHECK(children_.empty()); | 349 DCHECK(children_.empty()); |
| 343 | 350 |
| 344 if (parent_) { | 351 if (parent_) { |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 aura::client::FocusClient* focus_client, | 739 aura::client::FocusClient* focus_client, |
| 733 aura::Window* window) { | 740 aura::Window* window) { |
| 734 if (window == this->window()) { | 741 if (window == this->window()) { |
| 735 desktop_native_widget_aura_->HandleActivationChanged(true); | 742 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 736 } else if (is_active_) { | 743 } else if (is_active_) { |
| 737 desktop_native_widget_aura_->HandleActivationChanged(false); | 744 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 738 } | 745 } |
| 739 } | 746 } |
| 740 | 747 |
| 741 } // namespace views | 748 } // namespace views |
| OLD | NEW |