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

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

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

Powered by Google App Engine
This is Rietveld 408576698