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

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

Issue 76583003: Rename RootWindowHost* to WindowTreeHost* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 230 }
231 231
232 // static 232 // static
233 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow( 233 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow(
234 aura::Window* window) { 234 aura::Window* window) {
235 return window->GetProperty(kDesktopNativeWidgetAuraKey); 235 return window->GetProperty(kDesktopNativeWidgetAuraKey);
236 } 236 }
237 237
238 void DesktopNativeWidgetAura::OnHostClosed() { 238 void DesktopNativeWidgetAura::OnHostClosed() {
239 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by 239 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by
240 // DesktopRootWindowHost. 240 // DesktopWindowTreeHost.
241 241
242 // The WindowModalityController is at the front of the event pretarget 242 // The WindowModalityController is at the front of the event pretarget
243 // handler list. We destroy it first to preserve order symantics. 243 // handler list. We destroy it first to preserve order symantics.
244 if (window_modality_controller_) 244 if (window_modality_controller_)
245 window_modality_controller_.reset(); 245 window_modality_controller_.reset();
246 246
247 // Make sure we don't have capture. Otherwise CaptureController and RootWindow 247 // Make sure we don't have capture. Otherwise CaptureController and RootWindow
248 // are left referencing a deleted Window. 248 // are left referencing a deleted Window.
249 { 249 {
250 aura::Window* capture_window = capture_client_->GetCaptureWindow(); 250 aura::Window* capture_window = capture_client_->GetCaptureWindow();
251 if (capture_window && root_window_->window()->Contains(capture_window)) 251 if (capture_window && root_window_->window()->Contains(capture_window))
252 capture_window->ReleaseCapture(); 252 capture_window->ReleaseCapture();
253 } 253 }
254 254
255 // DesktopRootWindowHost owns the ActivationController which ShadowController 255 // DesktopWindowTreeHost owns the ActivationController which ShadowController
256 // references. Make sure we destroy ShadowController early on. 256 // references. Make sure we destroy ShadowController early on.
257 shadow_controller_.reset(); 257 shadow_controller_.reset();
258 tooltip_manager_.reset(); 258 tooltip_manager_.reset();
259 root_window_->window()->RemovePreTargetHandler(tooltip_controller_.get()); 259 root_window_->window()->RemovePreTargetHandler(tooltip_controller_.get());
260 aura::client::SetTooltipClient(root_window_->window(), NULL); 260 aura::client::SetTooltipClient(root_window_->window(), NULL);
261 tooltip_controller_.reset(); 261 tooltip_controller_.reset();
262 262
263 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); 263 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get());
264 264
265 window_tree_client_.reset(); // Uses root_window_ at destruction. 265 window_tree_client_.reset(); // Uses root_window_ at destruction.
266 266
267 capture_client_.reset(); // Uses root_window_ at destruction. 267 capture_client_.reset(); // Uses root_window_ at destruction.
268 268
269 root_window_->RemoveRootWindowObserver(this); 269 root_window_->RemoveRootWindowObserver(this);
270 root_window_.reset(); // Uses input_method_event_filter_ at destruction. 270 root_window_.reset(); // Uses input_method_event_filter_ at destruction.
271 // RootWindow owns |desktop_root_window_host_|. 271 // RootWindow owns |desktop_root_window_host_|.
272 desktop_root_window_host_ = NULL; 272 desktop_root_window_host_ = NULL;
273 content_window_ = NULL; 273 content_window_ = NULL;
274 274
275 native_widget_delegate_->OnNativeWidgetDestroyed(); 275 native_widget_delegate_->OnNativeWidgetDestroyed();
276 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 276 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
277 delete this; 277 delete this;
278 } 278 }
279 279
280 void DesktopNativeWidgetAura::OnDesktopRootWindowHostDestroyed( 280 void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed(
281 aura::RootWindow* root) { 281 aura::RootWindow* root) {
282 // |root_window_| is still valid, but DesktopRootWindowHost is nearly 282 // |root_window_| is still valid, but DesktopWindowTreeHost is nearly
283 // destroyed. Do cleanup here of members DesktopRootWindowHost may also use. 283 // destroyed. Do cleanup here of members DesktopWindowTreeHost may also use.
284 aura::client::SetFocusClient(root->window(), NULL); 284 aura::client::SetFocusClient(root->window(), NULL);
285 aura::client::SetActivationClient(root->window(), NULL); 285 aura::client::SetActivationClient(root->window(), NULL);
286 focus_client_.reset(); 286 focus_client_.reset();
287 287
288 aura::client::SetDispatcherClient(root->window(), NULL); 288 aura::client::SetDispatcherClient(root->window(), NULL);
289 dispatcher_client_.reset(); 289 dispatcher_client_.reset();
290 290
291 aura::client::SetCursorClient(root->window(), NULL); 291 aura::client::SetCursorClient(root->window(), NULL);
292 native_cursor_manager_->RemoveRootWindow(root); 292 native_cursor_manager_->RemoveRootWindow(root);
293 293
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 content_window_->Init(params.layer_type); 352 content_window_->Init(params.layer_type);
353 corewm::SetShadowType(content_window_, corewm::SHADOW_TYPE_NONE); 353 corewm::SetShadowType(content_window_, corewm::SHADOW_TYPE_NONE);
354 354
355 content_window_container_ = new aura::Window(NULL); 355 content_window_container_ = new aura::Window(NULL);
356 content_window_container_->Init(ui::LAYER_NOT_DRAWN); 356 content_window_container_->Init(ui::LAYER_NOT_DRAWN);
357 content_window_container_->Show(); 357 content_window_container_->Show();
358 content_window_container_->AddChild(content_window_); 358 content_window_container_->AddChild(content_window_);
359 359
360 desktop_root_window_host_ = params.desktop_root_window_host ? 360 desktop_root_window_host_ = params.desktop_root_window_host ?
361 params.desktop_root_window_host : 361 params.desktop_root_window_host :
362 DesktopRootWindowHost::Create(native_widget_delegate_, this); 362 DesktopWindowTreeHost::Create(native_widget_delegate_, this);
363 aura::RootWindow::CreateParams rw_params(params.bounds); 363 aura::RootWindow::CreateParams rw_params(params.bounds);
364 desktop_root_window_host_->Init(content_window_, params, &rw_params); 364 desktop_root_window_host_->Init(content_window_, params, &rw_params);
365 365
366 root_window_.reset(new aura::RootWindow(rw_params)); 366 root_window_.reset(new aura::RootWindow(rw_params));
367 root_window_->Init(); 367 root_window_->Init();
368 root_window_->window()->AddChild(content_window_container_); 368 root_window_->window()->AddChild(content_window_container_);
369 369
370 // The WindowsModalityController event filter should be at the head of the 370 // The WindowsModalityController event filter should be at the head of the
371 // pre target handlers list. This ensures that it handles input events first 371 // pre target handlers list. This ensures that it handles input events first
372 // when modal windows are at the top of the Zorder. 372 // when modal windows are at the top of the Zorder.
373 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) 373 if (widget_type_ == Widget::InitParams::TYPE_WINDOW)
374 window_modality_controller_.reset( 374 window_modality_controller_.reset(
375 new views::corewm::WindowModalityController(root_window_->window())); 375 new views::corewm::WindowModalityController(root_window_->window()));
376 376
377 // |root_window_event_filter_| must be created before 377 // |root_window_event_filter_| must be created before
378 // OnRootWindowHostCreated() is invoked. 378 // OnWindowTreeHostCreated() is invoked.
379 379
380 // CEF sets focus to the window the user clicks down on. 380 // CEF sets focus to the window the user clicks down on.
381 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- 381 // TODO(beng): see if we can't do this some other way. CEF seems a heavy-
382 // handed way of accomplishing focus. 382 // handed way of accomplishing focus.
383 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. 383 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow.
384 root_window_event_filter_ = new corewm::CompoundEventFilter; 384 root_window_event_filter_ = new corewm::CompoundEventFilter;
385 // Pass ownership of the filter to the root_window. 385 // Pass ownership of the filter to the root_window.
386 root_window_->window()->SetEventFilter(root_window_event_filter_); 386 root_window_->window()->SetEventFilter(root_window_event_filter_);
387 387
388 // |root_window_| must be added to |native_cursor_manager_| before 388 // |root_window_| must be added to |native_cursor_manager_| before
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 421
422 InstallInputMethodEventFilter(); 422 InstallInputMethodEventFilter();
423 423
424 drag_drop_client_ = desktop_root_window_host_->CreateDragDropClient( 424 drag_drop_client_ = desktop_root_window_host_->CreateDragDropClient(
425 native_cursor_manager_); 425 native_cursor_manager_);
426 aura::client::SetDragDropClient(root_window_->window(), 426 aura::client::SetDragDropClient(root_window_->window(),
427 drag_drop_client_.get()); 427 drag_drop_client_.get());
428 428
429 focus_client_->FocusWindow(content_window_); 429 focus_client_->FocusWindow(content_window_);
430 430
431 OnRootWindowHostResized(root_window_.get()); 431 OnWindowTreeHostResized(root_window_.get());
432 432
433 root_window_->AddRootWindowObserver(this); 433 root_window_->AddRootWindowObserver(this);
434 434
435 window_tree_client_.reset( 435 window_tree_client_.reset(
436 new DesktopNativeWidgetAuraWindowTreeClient(root_window_->window())); 436 new DesktopNativeWidgetAuraWindowTreeClient(root_window_->window()));
437 drop_helper_.reset(new DropHelper( 437 drop_helper_.reset(new DropHelper(
438 static_cast<internal::RootView*>(GetWidget()->GetRootView()))); 438 static_cast<internal::RootView*>(GetWidget()->GetRootView())));
439 aura::client::SetDragDropDelegate(content_window_, this); 439 aura::client::SetDragDropDelegate(content_window_, this);
440 440
441 tooltip_manager_.reset(new TooltipManagerAura(GetWidget())); 441 tooltip_manager_.reset(new TooltipManagerAura(GetWidget()));
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 return content_window_ ? 620 return content_window_ ?
621 desktop_root_window_host_->GetRestoredBounds() : gfx::Rect(); 621 desktop_root_window_host_->GetRestoredBounds() : gfx::Rect();
622 } 622 }
623 623
624 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) { 624 void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) {
625 if (!content_window_) 625 if (!content_window_)
626 return; 626 return;
627 // TODO(ananta) 627 // TODO(ananta)
628 // This code by default scales the bounds rectangle by 1. 628 // This code by default scales the bounds rectangle by 1.
629 // We could probably get rid of this and similar logic from 629 // We could probably get rid of this and similar logic from
630 // the DesktopNativeWidgetAura::OnRootWindowHostResized function. 630 // the DesktopNativeWidgetAura::OnWindowTreeHostResized function.
631 float scale = 1; 631 float scale = 1;
632 aura::Window* root = root_window_->window(); 632 aura::Window* root = root_window_->window();
633 if (root) { 633 if (root) {
634 scale = gfx::Screen::GetScreenFor(root)-> 634 scale = gfx::Screen::GetScreenFor(root)->
635 GetDisplayNearestWindow(root).device_scale_factor(); 635 GetDisplayNearestWindow(root).device_scale_factor();
636 } 636 }
637 gfx::Rect bounds_in_pixels( 637 gfx::Rect bounds_in_pixels(
638 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)), 638 gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)),
639 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale))); 639 gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale)));
640 desktop_root_window_host_->AsRootWindowHost()->SetBounds(bounds_in_pixels); 640 desktop_root_window_host_->AsWindowTreeHost()->SetBounds(bounds_in_pixels);
641 } 641 }
642 642
643 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) { 643 void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) {
644 if (content_window_) 644 if (content_window_)
645 desktop_root_window_host_->SetSize(size); 645 desktop_root_window_host_->SetSize(size);
646 } 646 }
647 647
648 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) { 648 void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) {
649 } 649 }
650 650
(...skipping 21 matching lines...) Expand all
672 } 672 }
673 673
674 void DesktopNativeWidgetAura::CloseNow() { 674 void DesktopNativeWidgetAura::CloseNow() {
675 if (content_window_) 675 if (content_window_)
676 desktop_root_window_host_->CloseNow(); 676 desktop_root_window_host_->CloseNow();
677 } 677 }
678 678
679 void DesktopNativeWidgetAura::Show() { 679 void DesktopNativeWidgetAura::Show() {
680 if (!content_window_) 680 if (!content_window_)
681 return; 681 return;
682 desktop_root_window_host_->AsRootWindowHost()->Show(); 682 desktop_root_window_host_->AsWindowTreeHost()->Show();
683 content_window_->Show(); 683 content_window_->Show();
684 } 684 }
685 685
686 void DesktopNativeWidgetAura::Hide() { 686 void DesktopNativeWidgetAura::Hide() {
687 if (!content_window_) 687 if (!content_window_)
688 return; 688 return;
689 desktop_root_window_host_->AsRootWindowHost()->Hide(); 689 desktop_root_window_host_->AsWindowTreeHost()->Hide();
690 content_window_->Hide(); 690 content_window_->Hide();
691 } 691 }
692 692
693 void DesktopNativeWidgetAura::ShowMaximizedWithBounds( 693 void DesktopNativeWidgetAura::ShowMaximizedWithBounds(
694 const gfx::Rect& restored_bounds) { 694 const gfx::Rect& restored_bounds) {
695 if (!content_window_) 695 if (!content_window_)
696 return; 696 return;
697 desktop_root_window_host_->ShowMaximizedWithBounds(restored_bounds); 697 desktop_root_window_host_->ShowMaximizedWithBounds(restored_bounds);
698 content_window_->Show(); 698 content_window_->Show();
699 } 699 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 desktop_root_window_host_->EndMoveLoop(); 836 desktop_root_window_host_->EndMoveLoop();
837 } 837 }
838 838
839 void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled( 839 void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled(
840 bool value) { 840 bool value) {
841 if (content_window_) 841 if (content_window_)
842 desktop_root_window_host_->SetVisibilityChangedAnimationsEnabled(value); 842 desktop_root_window_host_->SetVisibilityChangedAnimationsEnabled(value);
843 } 843 }
844 844
845 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const { 845 ui::NativeTheme* DesktopNativeWidgetAura::GetNativeTheme() const {
846 return DesktopRootWindowHost::GetNativeTheme(content_window_); 846 return DesktopWindowTreeHost::GetNativeTheme(content_window_);
847 } 847 }
848 848
849 void DesktopNativeWidgetAura::OnRootViewLayout() const { 849 void DesktopNativeWidgetAura::OnRootViewLayout() const {
850 if (content_window_) 850 if (content_window_)
851 desktop_root_window_host_->OnRootViewLayout(); 851 desktop_root_window_host_->OnRootViewLayout();
852 } 852 }
853 853
854 //////////////////////////////////////////////////////////////////////////////// 854 ////////////////////////////////////////////////////////////////////////////////
855 // DesktopNativeWidgetAura, aura::WindowDelegate implementation: 855 // DesktopNativeWidgetAura, aura::WindowDelegate implementation:
856 856
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { 1064 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) {
1065 DCHECK(drop_helper_.get() != NULL); 1065 DCHECK(drop_helper_.get() != NULL);
1066 Activate(); 1066 Activate();
1067 return drop_helper_->OnDrop(event.data(), event.location(), 1067 return drop_helper_->OnDrop(event.data(), event.location(),
1068 last_drop_operation_); 1068 last_drop_operation_);
1069 } 1069 }
1070 1070
1071 //////////////////////////////////////////////////////////////////////////////// 1071 ////////////////////////////////////////////////////////////////////////////////
1072 // DesktopNativeWidgetAura, aura::RootWindowObserver implementation: 1072 // DesktopNativeWidgetAura, aura::RootWindowObserver implementation:
1073 1073
1074 void DesktopNativeWidgetAura::OnRootWindowHostCloseRequested( 1074 void DesktopNativeWidgetAura::OnWindowTreeHostCloseRequested(
1075 const aura::RootWindow* root) { 1075 const aura::RootWindow* root) {
1076 Close(); 1076 Close();
1077 } 1077 }
1078 1078
1079 void DesktopNativeWidgetAura::OnRootWindowHostResized( 1079 void DesktopNativeWidgetAura::OnWindowTreeHostResized(
1080 const aura::RootWindow* root) { 1080 const aura::RootWindow* root) {
1081 // Don't update the bounds of the child layers when animating closed. If we 1081 // Don't update the bounds of the child layers when animating closed. If we
1082 // did it would force a paint, which we don't want. We don't want the paint 1082 // did it would force a paint, which we don't want. We don't want the paint
1083 // as we can't assume any of the children are valid. 1083 // as we can't assume any of the children are valid.
1084 if (desktop_root_window_host_->IsAnimatingClosed()) 1084 if (desktop_root_window_host_->IsAnimatingClosed())
1085 return; 1085 return;
1086 1086
1087 gfx::Rect new_bounds = gfx::Rect(root->window()->bounds().size()); 1087 gfx::Rect new_bounds = gfx::Rect(root->window()->bounds().size());
1088 content_window_->SetBounds(new_bounds); 1088 content_window_->SetBounds(new_bounds);
1089 // Can be NULL at start. 1089 // Can be NULL at start.
1090 if (content_window_container_) 1090 if (content_window_container_)
1091 content_window_container_->SetBounds(new_bounds); 1091 content_window_container_->SetBounds(new_bounds);
1092 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); 1092 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size());
1093 } 1093 }
1094 1094
1095 void DesktopNativeWidgetAura::OnRootWindowHostMoved( 1095 void DesktopNativeWidgetAura::OnWindowTreeHostMoved(
1096 const aura::RootWindow* root, 1096 const aura::RootWindow* root,
1097 const gfx::Point& new_origin) { 1097 const gfx::Point& new_origin) {
1098 TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnRootWindowHostMoved", 1098 TRACE_EVENT1("views", "DesktopNativeWidgetAura::OnWindowTreeHostMoved",
1099 "new_origin", new_origin.ToString()); 1099 "new_origin", new_origin.ToString());
1100 1100
1101 native_widget_delegate_->OnNativeWidgetMove(); 1101 native_widget_delegate_->OnNativeWidgetMove();
1102 } 1102 }
1103 1103
1104 //////////////////////////////////////////////////////////////////////////////// 1104 ////////////////////////////////////////////////////////////////////////////////
1105 // DesktopNativeWidgetAura, NativeWidget implementation: 1105 // DesktopNativeWidgetAura, NativeWidget implementation:
1106 1106
1107 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { 1107 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() {
1108 return this; 1108 return this;
1109 } 1109 }
1110 1110
1111 void DesktopNativeWidgetAura::InstallInputMethodEventFilter() { 1111 void DesktopNativeWidgetAura::InstallInputMethodEventFilter() {
1112 DCHECK(!input_method_event_filter_.get()); 1112 DCHECK(!input_method_event_filter_.get());
1113 1113
1114 input_method_event_filter_.reset(new corewm::InputMethodEventFilter( 1114 input_method_event_filter_.reset(new corewm::InputMethodEventFilter(
1115 root_window_->host()->GetAcceleratedWidget())); 1115 root_window_->host()->GetAcceleratedWidget()));
1116 input_method_event_filter_->SetInputMethodPropertyInRootWindow( 1116 input_method_event_filter_->SetInputMethodPropertyInRootWindow(
1117 root_window_->window()); 1117 root_window_->window());
1118 root_window_event_filter_->AddHandler(input_method_event_filter_.get()); 1118 root_window_event_filter_->AddHandler(input_method_event_filter_.get());
1119 } 1119 }
1120 1120
1121 void DesktopNativeWidgetAura::UpdateWindowTransparency() { 1121 void DesktopNativeWidgetAura::UpdateWindowTransparency() {
1122 content_window_->SetTransparent(ShouldUseNativeFrame()); 1122 content_window_->SetTransparent(ShouldUseNativeFrame());
1123 } 1123 }
1124 1124
1125 } // namespace views 1125 } // 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