| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 232 |
| 233 int DesktopNativeWidgetAura::cursor_reference_count_ = 0; | 233 int DesktopNativeWidgetAura::cursor_reference_count_ = 0; |
| 234 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ = | 234 DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ = |
| 235 NULL; | 235 NULL; |
| 236 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; | 236 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; |
| 237 | 237 |
| 238 DesktopNativeWidgetAura::DesktopNativeWidgetAura( | 238 DesktopNativeWidgetAura::DesktopNativeWidgetAura( |
| 239 internal::NativeWidgetDelegate* delegate) | 239 internal::NativeWidgetDelegate* delegate) |
| 240 : desktop_window_tree_host_(NULL), | 240 : desktop_window_tree_host_(NULL), |
| 241 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 241 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 242 content_window_container_(NULL), | |
| 243 content_window_(new aura::Window(this)), | 242 content_window_(new aura::Window(this)), |
| 244 native_widget_delegate_(delegate), | 243 native_widget_delegate_(delegate), |
| 245 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), | 244 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
| 246 restore_focus_on_activate_(false), | 245 restore_focus_on_activate_(false), |
| 247 cursor_(gfx::kNullCursor), | 246 cursor_(gfx::kNullCursor), |
| 248 widget_type_(Widget::InitParams::TYPE_WINDOW), | 247 widget_type_(Widget::InitParams::TYPE_WINDOW), |
| 249 close_widget_factory_(this) { | 248 close_widget_factory_(this) { |
| 250 aura::client::SetFocusChangeObserver(content_window_, this); | 249 aura::client::SetFocusChangeObserver(content_window_, this); |
| 251 aura::client::SetActivationChangeObserver(content_window_, this); | 250 aura::client::SetActivationChangeObserver(content_window_, this); |
| 252 } | 251 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 // these windows the size of the window gets augmented, effecting restore | 409 // these windows the size of the window gets augmented, effecting restore |
| 411 // bounds and maximized windows in bad ways. | 410 // bounds and maximized windows in bad ways. |
| 412 if (params.type == Widget::InitParams::TYPE_WINDOW && | 411 if (params.type == Widget::InitParams::TYPE_WINDOW && |
| 413 !params.remove_standard_frame) { | 412 !params.remove_standard_frame) { |
| 414 content_window_->SetProperty(aura::client::kAnimationsDisabledKey, true); | 413 content_window_->SetProperty(aura::client::kAnimationsDisabledKey, true); |
| 415 } | 414 } |
| 416 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); | 415 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
| 417 content_window_->Init(params.layer_type); | 416 content_window_->Init(params.layer_type); |
| 418 wm::SetShadowElevation(content_window_, wm::ShadowElevation::NONE); | 417 wm::SetShadowElevation(content_window_, wm::ShadowElevation::NONE); |
| 419 | 418 |
| 420 content_window_container_ = new aura::Window(NULL); | |
| 421 content_window_container_->Init(ui::LAYER_NOT_DRAWN); | |
| 422 content_window_container_->Show(); | |
| 423 content_window_container_->AddChild(content_window_); | |
| 424 | |
| 425 if (!desktop_window_tree_host_) { | 419 if (!desktop_window_tree_host_) { |
| 426 desktop_window_tree_host_ = | 420 desktop_window_tree_host_ = |
| 427 params.desktop_window_tree_host | 421 params.desktop_window_tree_host |
| 428 ? params.desktop_window_tree_host | 422 ? params.desktop_window_tree_host |
| 429 : DesktopWindowTreeHost::Create(native_widget_delegate_, this); | 423 : DesktopWindowTreeHost::Create(native_widget_delegate_, this); |
| 430 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); | 424 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); |
| 431 } | 425 } |
| 432 desktop_window_tree_host_->Init(content_window_, params); | 426 desktop_window_tree_host_->Init(content_window_, params); |
| 433 | 427 |
| 434 host_->window()->AddChild(content_window_container_); | 428 host_->window()->AddChild(content_window_); |
| 435 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); | 429 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); |
| 436 | 430 |
| 437 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); | 431 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); |
| 438 | 432 |
| 439 // The WindowsModalityController event filter should be at the head of the | 433 // The WindowsModalityController event filter should be at the head of the |
| 440 // pre target handlers list. This ensures that it handles input events first | 434 // pre target handlers list. This ensures that it handles input events first |
| 441 // when modal windows are at the top of the Zorder. | 435 // when modal windows are at the top of the Zorder. |
| 442 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) | 436 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) |
| 443 window_modality_controller_.reset( | 437 window_modality_controller_.reset( |
| 444 new wm::WindowModalityController(host_->window())); | 438 new wm::WindowModalityController(host_->window())); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 aura::client::SetTooltipClient(host_->window(), | 505 aura::client::SetTooltipClient(host_->window(), |
| 512 tooltip_controller_.get()); | 506 tooltip_controller_.get()); |
| 513 host_->window()->AddPreTargetHandler(tooltip_controller_.get()); | 507 host_->window()->AddPreTargetHandler(tooltip_controller_.get()); |
| 514 } | 508 } |
| 515 | 509 |
| 516 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { | 510 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { |
| 517 visibility_controller_.reset(new wm::VisibilityController); | 511 visibility_controller_.reset(new wm::VisibilityController); |
| 518 aura::client::SetVisibilityClient(host_->window(), | 512 aura::client::SetVisibilityClient(host_->window(), |
| 519 visibility_controller_.get()); | 513 visibility_controller_.get()); |
| 520 wm::SetChildWindowVisibilityChangesAnimated(host_->window()); | 514 wm::SetChildWindowVisibilityChangesAnimated(host_->window()); |
| 521 wm::SetChildWindowVisibilityChangesAnimated( | |
| 522 content_window_container_); | |
| 523 } | 515 } |
| 524 | 516 |
| 525 if (params.type == Widget::InitParams::TYPE_WINDOW) { | 517 if (params.type == Widget::InitParams::TYPE_WINDOW) { |
| 526 focus_manager_event_handler_ = base::MakeUnique<FocusManagerEventHandler>( | 518 focus_manager_event_handler_ = base::MakeUnique<FocusManagerEventHandler>( |
| 527 GetWidget(), host_->window()); | 519 GetWidget(), host_->window()); |
| 528 } | 520 } |
| 529 | 521 |
| 530 event_client_.reset(new DesktopEventClient); | 522 event_client_.reset(new DesktopEventClient); |
| 531 aura::client::SetEventClient(host_->window(), event_client_.get()); | 523 aura::client::SetEventClient(host_->window(), event_client_.get()); |
| 532 | 524 |
| (...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 | 1152 |
| 1161 void DesktopNativeWidgetAura::OnHostResized(const aura::WindowTreeHost* host) { | 1153 void DesktopNativeWidgetAura::OnHostResized(const aura::WindowTreeHost* host) { |
| 1162 // Don't update the bounds of the child layers when animating closed. If we | 1154 // Don't update the bounds of the child layers when animating closed. If we |
| 1163 // did it would force a paint, which we don't want. We don't want the paint | 1155 // did it would force a paint, which we don't want. We don't want the paint |
| 1164 // as we can't assume any of the children are valid. | 1156 // as we can't assume any of the children are valid. |
| 1165 if (desktop_window_tree_host_->IsAnimatingClosed()) | 1157 if (desktop_window_tree_host_->IsAnimatingClosed()) |
| 1166 return; | 1158 return; |
| 1167 | 1159 |
| 1168 gfx::Rect new_bounds = gfx::Rect(host->window()->bounds().size()); | 1160 gfx::Rect new_bounds = gfx::Rect(host->window()->bounds().size()); |
| 1169 content_window_->SetBounds(new_bounds); | 1161 content_window_->SetBounds(new_bounds); |
| 1170 // Can be NULL at start. | |
| 1171 if (content_window_container_) | |
| 1172 content_window_container_->SetBounds(new_bounds); | |
| 1173 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); | 1162 native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
| 1174 } | 1163 } |
| 1175 | 1164 |
| 1176 void DesktopNativeWidgetAura::OnHostWorkspaceChanged( | 1165 void DesktopNativeWidgetAura::OnHostWorkspaceChanged( |
| 1177 const aura::WindowTreeHost* host) { | 1166 const aura::WindowTreeHost* host) { |
| 1178 native_widget_delegate_->OnNativeWidgetWorkspaceChanged(); | 1167 native_widget_delegate_->OnNativeWidgetWorkspaceChanged(); |
| 1179 } | 1168 } |
| 1180 | 1169 |
| 1181 void DesktopNativeWidgetAura::OnHostMovedInPixels( | 1170 void DesktopNativeWidgetAura::OnHostMovedInPixels( |
| 1182 const aura::WindowTreeHost* host, | 1171 const aura::WindowTreeHost* host, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1207 if (cursor_reference_count_ == 0) { | 1196 if (cursor_reference_count_ == 0) { |
| 1208 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1197 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
| 1209 // for cleaning up |cursor_manager_|. | 1198 // for cleaning up |cursor_manager_|. |
| 1210 delete cursor_manager_; | 1199 delete cursor_manager_; |
| 1211 native_cursor_manager_ = NULL; | 1200 native_cursor_manager_ = NULL; |
| 1212 cursor_manager_ = NULL; | 1201 cursor_manager_ = NULL; |
| 1213 } | 1202 } |
| 1214 } | 1203 } |
| 1215 | 1204 |
| 1216 } // namespace views | 1205 } // namespace views |
| OLD | NEW |