| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/widget/desktop_aura/desktop_native_widget_aura.h" | 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 desktop_window_tree_host_ = NULL; | 319 desktop_window_tree_host_ = NULL; |
| 320 content_window_ = NULL; | 320 content_window_ = NULL; |
| 321 | 321 |
| 322 native_widget_delegate_->OnNativeWidgetDestroyed(); | 322 native_widget_delegate_->OnNativeWidgetDestroyed(); |
| 323 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 323 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 324 delete this; | 324 delete this; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( | 327 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed( |
| 328 aura::WindowTreeHost* host) { | 328 aura::WindowTreeHost* host) { |
| 329 // We explicitly do NOT clear the cursor client property. Since the cursor | 329 if (use_desktop_native_cursor_manager_) { |
| 330 // manager is a singleton, it can outlive any window hierarchy, and it's | 330 // We explicitly do NOT clear the cursor client property. Since the cursor |
| 331 // important that objects attached to this destroying window hierarchy have | 331 // manager is a singleton, it can outlive any window hierarchy, and it's |
| 332 // an opportunity to deregister their observers from the cursor manager. | 332 // important that objects attached to this destroying window hierarchy have |
| 333 // They may want to do this when they are notified that they're being | 333 // an opportunity to deregister their observers from the cursor manager. |
| 334 // removed from the window hierarchy, which happens soon after this | 334 // They may want to do this when they are notified that they're being |
| 335 // function when DesktopWindowTreeHost* calls DestroyDispatcher(). | 335 // removed from the window hierarchy, which happens soon after this |
| 336 native_cursor_manager_->RemoveHost(host); | 336 // function when DesktopWindowTreeHost* calls DestroyDispatcher(). |
| 337 native_cursor_manager_->RemoveHost(host); |
| 338 } |
| 337 | 339 |
| 338 aura::client::SetScreenPositionClient(host->window(), NULL); | 340 aura::client::SetScreenPositionClient(host->window(), NULL); |
| 339 position_client_.reset(); | 341 position_client_.reset(); |
| 340 | 342 |
| 341 aura::client::SetDragDropClient(host->window(), NULL); | 343 aura::client::SetDragDropClient(host->window(), NULL); |
| 342 drag_drop_client_.reset(); | 344 drag_drop_client_.reset(); |
| 343 | 345 |
| 344 aura::client::SetEventClient(host->window(), NULL); | 346 aura::client::SetEventClient(host->window(), NULL); |
| 345 event_client_.reset(); | 347 event_client_.reset(); |
| 346 } | 348 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 // OnWindowTreeHostCreated() is invoked. | 442 // OnWindowTreeHostCreated() is invoked. |
| 441 | 443 |
| 442 // CEF sets focus to the window the user clicks down on. | 444 // CEF sets focus to the window the user clicks down on. |
| 443 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- | 445 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- |
| 444 // handed way of accomplishing focus. | 446 // handed way of accomplishing focus. |
| 445 // No event filter for aura::Env. Create CompoundEventFilter per | 447 // No event filter for aura::Env. Create CompoundEventFilter per |
| 446 // WindowEventDispatcher. | 448 // WindowEventDispatcher. |
| 447 root_window_event_filter_.reset(new wm::CompoundEventFilter); | 449 root_window_event_filter_.reset(new wm::CompoundEventFilter); |
| 448 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); | 450 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); |
| 449 | 451 |
| 450 // The host's dispatcher must be added to |native_cursor_manager_| before | 452 use_desktop_native_cursor_manager_ = |
| 451 // OnNativeWidgetCreated() is called. | 453 desktop_window_tree_host_->ShouldUseDesktopNativeCursorManager(); |
| 452 cursor_reference_count_++; | 454 if (use_desktop_native_cursor_manager_) { |
| 453 if (!native_cursor_manager_) | 455 // The host's dispatcher must be added to |native_cursor_manager_| before |
| 454 native_cursor_manager_ = new DesktopNativeCursorManager(); | 456 // OnNativeWidgetCreated() is called. |
| 455 if (!cursor_manager_) { | 457 cursor_reference_count_++; |
| 456 cursor_manager_ = new wm::CursorManager( | 458 if (!native_cursor_manager_) |
| 457 std::unique_ptr<wm::NativeCursorManager>(native_cursor_manager_)); | 459 native_cursor_manager_ = new DesktopNativeCursorManager(); |
| 460 if (!cursor_manager_) { |
| 461 cursor_manager_ = new wm::CursorManager( |
| 462 std::unique_ptr<wm::NativeCursorManager>(native_cursor_manager_)); |
| 463 } |
| 464 native_cursor_manager_->AddHost(host()); |
| 465 aura::client::SetCursorClient(host_->window(), cursor_manager_); |
| 458 } | 466 } |
| 459 native_cursor_manager_->AddHost(host()); | |
| 460 aura::client::SetCursorClient(host_->window(), cursor_manager_); | |
| 461 | 467 |
| 462 desktop_window_tree_host_->OnNativeWidgetCreated(params); | 468 desktop_window_tree_host_->OnNativeWidgetCreated(params); |
| 463 | 469 |
| 464 UpdateWindowTransparency(); | 470 UpdateWindowTransparency(); |
| 465 | 471 |
| 466 capture_client_.reset(new DesktopCaptureClient(host_->window())); | 472 capture_client_.reset(new DesktopCaptureClient(host_->window())); |
| 467 | 473 |
| 468 wm::FocusController* focus_controller = | 474 wm::FocusController* focus_controller = |
| 469 new wm::FocusController(new DesktopFocusRules(content_window_)); | 475 new wm::FocusController(new DesktopFocusRules(content_window_)); |
| 470 focus_client_.reset(focus_controller); | 476 focus_client_.reset(focus_controller); |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 if (cursor_reference_count_ == 0) { | 1207 if (cursor_reference_count_ == 0) { |
| 1202 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1208 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
| 1203 // for cleaning up |cursor_manager_|. | 1209 // for cleaning up |cursor_manager_|. |
| 1204 delete cursor_manager_; | 1210 delete cursor_manager_; |
| 1205 native_cursor_manager_ = NULL; | 1211 native_cursor_manager_ = NULL; |
| 1206 cursor_manager_ = NULL; | 1212 cursor_manager_ = NULL; |
| 1207 } | 1213 } |
| 1208 } | 1214 } |
| 1209 | 1215 |
| 1210 } // namespace views | 1216 } // namespace views |
| OLD | NEW |