Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 126513004: Rename RootWindowHost to WindowTreeHost (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "ui/aura/client/activation_client.h" 9 #include "ui/aura/client/activation_client.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 // static 242 // static
243 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow( 243 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow(
244 aura::Window* window) { 244 aura::Window* window) {
245 return window->GetProperty(kDesktopNativeWidgetAuraKey); 245 return window->GetProperty(kDesktopNativeWidgetAuraKey);
246 } 246 }
247 247
248 void DesktopNativeWidgetAura::OnHostClosed() { 248 void DesktopNativeWidgetAura::OnHostClosed() {
249 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by 249 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by
250 // DesktopRootWindowHost. 250 // DesktopWindowTreeHost.
251 251
252 // The WindowModalityController is at the front of the event pretarget 252 // The WindowModalityController is at the front of the event pretarget
253 // handler list. We destroy it first to preserve order symantics. 253 // handler list. We destroy it first to preserve order symantics.
254 if (window_modality_controller_) 254 if (window_modality_controller_)
255 window_modality_controller_.reset(); 255 window_modality_controller_.reset();
256 256
257 // Make sure we don't have capture. Otherwise CaptureController and RootWindow 257 // Make sure we don't have capture. Otherwise CaptureController and RootWindow
258 // are left referencing a deleted Window. 258 // are left referencing a deleted Window.
259 { 259 {
260 aura::Window* capture_window = capture_client_->GetCaptureWindow(); 260 aura::Window* capture_window = capture_client_->GetCaptureWindow();
261 if (capture_window && root_window_->window()->Contains(capture_window)) 261 if (capture_window && root_window_->window()->Contains(capture_window))
262 capture_window->ReleaseCapture(); 262 capture_window->ReleaseCapture();
263 } 263 }
264 264
265 // DesktopRootWindowHost owns the ActivationController which ShadowController 265 // DesktopWindowTreeHost owns the ActivationController which ShadowController
266 // references. Make sure we destroy ShadowController early on. 266 // references. Make sure we destroy ShadowController early on.
267 shadow_controller_.reset(); 267 shadow_controller_.reset();
268 tooltip_manager_.reset(); 268 tooltip_manager_.reset();
269 root_window_->window()->RemovePreTargetHandler(tooltip_controller_.get()); 269 root_window_->window()->RemovePreTargetHandler(tooltip_controller_.get());
270 aura::client::SetTooltipClient(root_window_->window(), NULL); 270 aura::client::SetTooltipClient(root_window_->window(), NULL);
271 tooltip_controller_.reset(); 271 tooltip_controller_.reset();
272 272
273 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); 273 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get());
274 274
275 window_tree_client_.reset(); // Uses root_window_ at destruction. 275 window_tree_client_.reset(); // Uses root_window_ at destruction.
276 276
277 capture_client_.reset(); // Uses root_window_ at destruction. 277 capture_client_.reset(); // Uses root_window_ at destruction.
278 278
279 root_window_->RemoveRootWindowObserver(this); 279 root_window_->RemoveRootWindowObserver(this);
280 root_window_.reset(); // Uses input_method_event_filter_ at destruction. 280 root_window_.reset(); // Uses input_method_event_filter_ at destruction.
281 // RootWindow owns |desktop_root_window_host_|. 281 // RootWindow owns |desktop_root_window_host_|.
282 desktop_root_window_host_ = NULL; 282 desktop_root_window_host_ = NULL;
283 content_window_ = NULL; 283 content_window_ = NULL;
284 284
285 native_widget_delegate_->OnNativeWidgetDestroyed(); 285 native_widget_delegate_->OnNativeWidgetDestroyed();
286 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 286 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
287 delete this; 287 delete this;
288 } 288 }
289 289
290 void DesktopNativeWidgetAura::OnDesktopRootWindowHostDestroyed( 290 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed(
291 aura::RootWindow* root) { 291 aura::RootWindow* root) {
292 // |root_window_| is still valid, but DesktopRootWindowHost is nearly 292 // |root_window_| is still valid, but DesktopWindowTreeHost is nearly
293 // destroyed. Do cleanup here of members DesktopRootWindowHost may also use. 293 // destroyed. Do cleanup here of members DesktopWindowTreeHost may also use.
294 aura::client::SetFocusClient(root->window(), NULL); 294 aura::client::SetFocusClient(root->window(), NULL);
295 aura::client::SetActivationClient(root->window(), NULL); 295 aura::client::SetActivationClient(root->window(), NULL);
296 focus_client_.reset(); 296 focus_client_.reset();
297 297
298 aura::client::SetDispatcherClient(root->window(), NULL); 298 aura::client::SetDispatcherClient(root->window(), NULL);
299 dispatcher_client_.reset(); 299 dispatcher_client_.reset();
300 300
301 aura::client::SetCursorClient(root->window(), NULL); 301 aura::client::SetCursorClient(root->window(), NULL);
302 native_cursor_manager_->RemoveRootWindow(root); 302 native_cursor_manager_->RemoveRootWindow(root);
303 303
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 content_window_->Init(params.layer_type); 362 content_window_->Init(params.layer_type);
363 corewm::SetShadowType(content_window_, corewm::SHADOW_TYPE_NONE); 363 corewm::SetShadowType(content_window_, corewm::SHADOW_TYPE_NONE);
364 364
365 content_window_container_ = new aura::Window(NULL); 365 content_window_container_ = new aura::Window(NULL);
366 content_window_container_->Init(ui::LAYER_NOT_DRAWN); 366 content_window_container_->Init(ui::LAYER_NOT_DRAWN);
367 content_window_container_->Show(); 367 content_window_container_->Show();
368 content_window_container_->AddChild(content_window_); 368 content_window_container_->AddChild(content_window_);
369 369
370 desktop_root_window_host_ = params.desktop_root_window_host ? 370 desktop_root_window_host_ = params.desktop_root_window_host ?
371 params.desktop_root_window_host : 371 params.desktop_root_window_host :
372 DesktopRootWindowHost::Create(native_widget_delegate_, this); 372 DesktopWindowTreeHost::Create(native_widget_delegate_, this);
373 aura::RootWindow::CreateParams rw_params(params.bounds); 373 aura::RootWindow::CreateParams rw_params(params.bounds);
374 desktop_root_window_host_->Init(content_window_, params, &rw_params); 374 desktop_root_window_host_->Init(content_window_, params, &rw_params);
375 375
376 root_window_.reset(new aura::RootWindow(rw_params)); 376 root_window_.reset(new aura::RootWindow(rw_params));
377 root_window_->Init(); 377 root_window_->Init();
378 root_window_->window()->AddChild(content_window_container_); 378 root_window_->window()->AddChild(content_window_container_);
379 379
380 // The WindowsModalityController event filter should be at the head of the 380 // The WindowsModalityController event filter should be at the head of the
381 // pre target handlers list. This ensures that it handles input events first 381 // pre target handlers list. This ensures that it handles input events first
382 // when modal windows are at the top of the Zorder. 382 // when modal windows are at the top of the Zorder.
383 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) 383 if (widget_type_ == Widget::InitParams::TYPE_WINDOW)
384 window_modality_controller_.reset( 384 window_modality_controller_.reset(
385 new views::corewm::WindowModalityController(root_window_->window())); 385 new views::corewm::WindowModalityController(root_window_->window()));
386 386
387 // |root_window_event_filter_| must be created before 387 // |root_window_event_filter_| must be created before
388 // OnRootWindowHostCreated() is invoked. 388 // OnWindowTreeHostCreated() is invoked.
389 389
390 // CEF sets focus to the window the user clicks down on. 390 // CEF sets focus to the window the user clicks down on.
391 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- 391 // TODO(beng): see if we can't do this some other way. CEF seems a heavy-
392 // handed way of accomplishing focus. 392 // handed way of accomplishing focus.
393 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. 393 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow.
394 root_window_event_filter_ = new corewm::CompoundEventFilter; 394 root_window_event_filter_ = new corewm::CompoundEventFilter;
395 // Pass ownership of the filter to the root_window. 395 // Pass ownership of the filter to the root_window.
396 root_window_->window()->SetEventFilter(root_window_event_filter_); 396 root_window_->window()->SetEventFilter(root_window_event_filter_);
397 397
398 // |root_window_| must be added to |native_cursor_manager_| before 398 // |root_window_| must be added to |native_cursor_manager_| before
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 431
432 InstallInputMethodEventFilter(); 432 InstallInputMethodEventFilter();
433 433
434 drag_drop_client_ = desktop_root_window_host_->CreateDragDropClient( 434 drag_drop_client_ = desktop_root_window_host_->CreateDragDropClient(
435 native_cursor_manager_); 435 native_cursor_manager_);
436 aura::client::SetDragDropClient(root_window_->window(), 436 aura::client::SetDragDropClient(root_window_->window(),
437 drag_drop_client_.get()); 437 drag_drop_client_.get());
438 438
439 focus_client_->FocusWindow(content_window_); 439 focus_client_->FocusWindow(content_window_);
440 440
441 OnRootWindowHostResized(root_window_.get()); 441 OnWindowTreeHostResized(root_window_.get());
442 442
443 root_window_->AddRootWindowObserver(this); 443 root_window_->AddRootWindowObserver(this);
444 444
445 window_tree_client_.reset( 445 window_tree_client_.reset(
446 new DesktopNativeWidgetAuraWindowTreeClient(root_window_->window())); 446 new DesktopNativeWidgetAuraWindowTreeClient(root_window_->window()));
447 drop_helper_.reset(new DropHelper( 447 drop_helper_.reset(new DropHelper(
448 static_cast<internal::RootView*>(GetWidget()->GetRootView()))); 448 static_cast<internal::RootView*>(GetWidget()->GetRootView())));
449 aura::client::SetDragDropDelegate(content_window_, this); 449 aura::client::SetDragDropDelegate(content_window_, this);
450 450
451 tooltip_manager_.reset(new TooltipManagerAura(GetWidget())); 451 tooltip_manager_.reset(new TooltipManagerAura(GetWidget()));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 return content_window_ ? 630 return content_window_ ?
631 desktop_root_window_host_->GetRestoredBounds() : gfx::Rect(); 631 desktop_root_window_host_->GetRestoredBounds() : gfx::Rect();
632 } 632 }
633 633
634 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { 634 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) {
635 if (!content_window_) 635 if (!content_window_)
636 return; 636 return;
637 // TODO(ananta) 637 // TODO(ananta)
638 // This code by default scales the bounds rectangle by 1. 638 // This code by default scales the bounds rectangle by 1.
639 // We could probably get rid of this and similar logic from 639 // We could probably get rid of this and similar logic from
640 // the DesktopNativeWidgetAura::OnRootWindowHostResized function. 640 // the DesktopNativeWidgetAura::OnWindowTreeHostResized function.
641 float scale = 1; 641 float scale = 1;
642 aura::Window* root = root_window_->window(); 642 aura::Window* root = root_window_->window();
643 if (root) { 643 if (root) {
644 scale = gfx::Screen::GetScreenFor(root)-> 644 scale = gfx::Screen::GetScreenFor(root)->
645 GetDisplayNearestWindow(root).device_scale_factor(); 645 GetDisplayNearestWindow(root).device_scale_factor();
646 } 646 }
647 gfx::Rect bounds_in_pixels( 647 gfx::Rect bounds_in_pixels(
648 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)), 648 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)),
649 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale))); 649 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale)));
650 desktop_root_window_host_->AsRootWindowHost()->SetBounds(bounds_in_pixels); 650 desktop_root_window_host_->AsWindowTreeHost()->SetBounds(bounds_in_pixels);
651 } 651 }
652 652
653 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { 653 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) {
654 if (content_window_) 654 if (content_window_)
655 desktop_root_window_host_->SetSize(size); 655 desktop_root_window_host_->SetSize(size);
656 } 656 }
657 657
658 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { 658 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) {
659 } 659 }
660 660
(...skipping 21 matching lines...) Expand all
682 } 682 }
683 683
684 void DesktopNativeWidgetAura::CloseNow() { 684 void DesktopNativeWidgetAura::CloseNow() {
685 if (content_window_) 685 if (content_window_)
686 desktop_root_window_host_->CloseNow(); 686 desktop_root_window_host_->CloseNow();
687 } 687 }
688 688
689 void DesktopNativeWidgetAura::Show() { 689 void DesktopNativeWidgetAura::Show() {
690 if (!content_window_) 690 if (!content_window_)
691 return; 691 return;
692 desktop_root_window_host_->AsRootWindowHost()->Show(); 692 desktop_root_window_host_->AsWindowTreeHost()->Show();
693 content_window_->Show(); 693 content_window_->Show();
694 } 694 }
695 695
696 void DesktopNativeWidgetAura::Hide() { 696 void DesktopNativeWidgetAura::Hide() {
697 if (!content_window_) 697 if (!content_window_)
698 return; 698 return;
699 desktop_root_window_host_->AsRootWindowHost()->Hide(); 699 desktop_root_window_host_->AsWindowTreeHost()->Hide();
700 content_window_->Hide(); 700 content_window_->Hide();
701 } 701 }
702 702
703 void DesktopNativeWidgetAura::ShowMaximizedWithBounds( 703 void DesktopNativeWidgetAura::ShowMaximizedWithBounds(
704 const gfx::Rect& restored_bounds) { 704 const gfx::Rect& restored_bounds) {
705 if (!content_window_) 705 if (!content_window_)
706 return; 706 return;
707 desktop_root_window_host_->ShowMaximizedWithBounds(restored_bounds); 707 desktop_root_window_host_->ShowMaximizedWithBounds(restored_bounds);
708 content_window_->Show(); 708 content_window_->Show();
709 } 709 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 desktop_root_window_host_->EndMoveLoop(); 846 desktop_root_window_host_->EndMoveLoop();
847 } 847 }
848 848
849 void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled( 849 void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled(
850 bool value) { 850 bool value) {
851 if (content_window_) 851 if (content_window_)
852 desktop_root_window_host_->SetVisibilityChangedAnimationsEnabled(value); 852 desktop_root_window_host_->SetVisibilityChangedAnimationsEnabled(value);
853 } 853 }
854 854
855 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const { 855 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const {
856 return DesktopRootWindowHost::GetNativeTheme(content_window_); 856 return DesktopWindowTreeHost::GetNativeTheme(content_window_);
857 } 857 }
858 858
859 void DesktopNativeWidgetAura::OnRootViewLayout() const { 859 void DesktopNativeWidgetAura::OnRootViewLayout() const {
860 if (content_window_) 860 if (content_window_)
861 desktop_root_window_host_->OnRootViewLayout(); 861 desktop_root_window_host_->OnRootViewLayout();
862 } 862 }
863 863
864 //////////////////////////////////////////////////////////////////////////////// 864 ////////////////////////////////////////////////////////////////////////////////
865 // DesktopNativeWidgetAura, aura::WindowDelegate implementation: 865 // DesktopNativeWidgetAura, aura::WindowDelegate implementation:
866 866
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1074 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { 1074 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) {
1075 DCHECK(drop_helper_.get() != NULL); 1075 DCHECK(drop_helper_.get() != NULL);
1076 Activate(); 1076 Activate();
1077 return drop_helper_->OnDrop(event.data(), event.location(), 1077 return drop_helper_->OnDrop(event.data(), event.location(),
1078 last_drop_operation_); 1078 last_drop_operation_);
1079 } 1079 }
1080 1080
1081 //////////////////////////////////////////////////////////////////////////////// 1081 ////////////////////////////////////////////////////////////////////////////////
1082 // DesktopNativeWidgetAura, aura::RootWindowObserver implementation: 1082 // DesktopNativeWidgetAura, aura::RootWindowObserver implementation:
1083 1083
1084 void DesktopNativeWidgetAura::OnRootWindowHostCloseRequested( 1084 void DesktopNativeWidgetAura::OnWindowTreeHostCloseRequested(
1085 const aura::RootWindow* root) { 1085 const aura::RootWindow* root) {
1086 Close(); 1086 Close();
1087 } 1087 }
1088 1088
1089 void DesktopNativeWidgetAura::OnRootWindowHostResized( 1089 void DesktopNativeWidgetAura::OnWindowTreeHostResized(
1090 const aura::RootWindow* root) { 1090 const aura::RootWindow* root) {
1091 // Don't update the bounds of the child layers when animating closed. If we 1091 // Don't update the bounds of the child layers when animating closed. If we
1092 // did it would force a paint, which we don't want. We don't want the paint 1092 // did it would force a paint, which we don't want. We don't want the paint
1093 // as we can't assume any of the children are valid. 1093 // as we can't assume any of the children are valid.
1094 if (desktop_root_window_host_->IsAnimatingClosed()) 1094 if (desktop_root_window_host_->IsAnimatingClosed())
1095 return; 1095 return;
1096 1096
1097 gfx::Rect new_bounds = gfx::Rect(root->window()->bounds().size()); 1097 gfx::Rect new_bounds = gfx::Rect(root->window()->bounds().size());
1098 content_window_->SetBounds(new_bounds); 1098 content_window_->SetBounds(new_bounds);
1099 // Can be NULL at start. 1099 // Can be NULL at start.
1100 if (content_window_container_) 1100 if (content_window_container_)
1101 content_window_container_->SetBounds(new_bounds); 1101 content_window_container_->SetBounds(new_bounds);
1102 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); 1102 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
1103 } 1103 }
1104 1104
1105 void DesktopNativeWidgetAura::OnRootWindowHostMoved( 1105 void DesktopNativeWidgetAura::OnWindowTreeHostMoved(
1106 const aura::RootWindow* root, 1106 const aura::RootWindow* root,
1107 const gfx::Point& new_origin) { 1107 const gfx::Point& new_origin) {
1108 TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnRootWindowHostMoved", 1108 TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnWindowTreeHostMoved",
1109 "new_origin", new_origin.ToString()); 1109 "new_origin", new_origin.ToString());
1110 1110
1111 native_widget_delegate_->OnNativeWidgetMove(); 1111 native_widget_delegate_->OnNativeWidgetMove();
1112 } 1112 }
1113 1113
1114 //////////////////////////////////////////////////////////////////////////////// 1114 ////////////////////////////////////////////////////////////////////////////////
1115 // DesktopNativeWidgetAura, NativeWidget implementation: 1115 // DesktopNativeWidgetAura, NativeWidget implementation:
1116 1116
1117 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { 1117 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() {
1118 return this; 1118 return this;
1119 } 1119 }
1120 1120
1121 void DesktopNativeWidgetAura::InstallInputMethodEventFilter() { 1121 void DesktopNativeWidgetAura::InstallInputMethodEventFilter() {
1122 DCHECK(!input_method_event_filter_.get()); 1122 DCHECK(!input_method_event_filter_.get());
1123 1123
1124 input_method_event_filter_.reset(new corewm::InputMethodEventFilter( 1124 input_method_event_filter_.reset(new corewm::InputMethodEventFilter(
1125 root_window_->host()->GetAcceleratedWidget())); 1125 root_window_->host()->GetAcceleratedWidget()));
1126 input_method_event_filter_->SetInputMethodPropertyInRootWindow( 1126 input_method_event_filter_->SetInputMethodPropertyInRootWindow(
1127 root_window_->window()); 1127 root_window_->window());
1128 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); 1128 root_window_event_filter_->AddHandler(input_method_event_filter_.get());
1129 } 1129 }
1130 1130
1131 void DesktopNativeWidgetAura::UpdateWindowTransparency() { 1131 void DesktopNativeWidgetAura::UpdateWindowTransparency() {
1132 content_window_->SetTransparent(ShouldUseNativeFrame()); 1132 content_window_->SetTransparent(ShouldUseNativeFrame());
1133 } 1133 }
1134 1134
1135 } // namespace views 1135 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | ui/views/widget/desktop_aura/desktop_root_window_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698