Chromium Code Reviews| 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 "ui/aura/client/activation_client.h" | 8 #include "ui/aura/client/activation_client.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 internal::NativeWidgetDelegate* delegate) | 178 internal::NativeWidgetDelegate* delegate) |
| 179 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 179 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 180 close_widget_factory_(this), | 180 close_widget_factory_(this), |
| 181 can_activate_(true), | 181 can_activate_(true), |
| 182 desktop_root_window_host_(NULL), | 182 desktop_root_window_host_(NULL), |
| 183 window_(new aura::Window(this)), | 183 window_(new aura::Window(this)), |
| 184 content_window_container_(NULL), | 184 content_window_container_(NULL), |
| 185 native_widget_delegate_(delegate), | 185 native_widget_delegate_(delegate), |
| 186 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), | 186 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
| 187 restore_focus_on_activate_(false), | 187 restore_focus_on_activate_(false), |
| 188 cursor_(gfx::kNullCursor) { | 188 cursor_(gfx::kNullCursor), |
| 189 widget_type_(Widget::InitParams::TYPE_WINDOW) { | |
| 189 window_->SetProperty(kDesktopNativeWidgetAuraKey, this); | 190 window_->SetProperty(kDesktopNativeWidgetAuraKey, this); |
| 190 aura::client::SetFocusChangeObserver(window_, this); | 191 aura::client::SetFocusChangeObserver(window_, this); |
| 191 aura::client::SetActivationChangeObserver(window_, this); | 192 aura::client::SetActivationChangeObserver(window_, this); |
| 192 } | 193 } |
| 193 | 194 |
| 194 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { | 195 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { |
| 195 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 196 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 196 delete native_widget_delegate_; | 197 delete native_widget_delegate_; |
| 197 else | 198 else |
| 198 CloseNow(); | 199 CloseNow(); |
| 199 } | 200 } |
| 200 | 201 |
| 201 // static | 202 // static |
| 202 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow( | 203 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow( |
| 203 aura::Window* window) { | 204 aura::Window* window) { |
| 204 return window->GetProperty(kDesktopNativeWidgetAuraKey); | 205 return window->GetProperty(kDesktopNativeWidgetAuraKey); |
| 205 } | 206 } |
| 206 | 207 |
| 207 void DesktopNativeWidgetAura::OnHostClosed() { | 208 void DesktopNativeWidgetAura::OnHostClosed() { |
| 208 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by | 209 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by |
| 209 // DesktopRootWindowHost. | 210 // DesktopRootWindowHost. |
| 210 | 211 |
| 212 if (window_modality_controller_) | |
|
sky
2013/10/02 15:54:12
Document why this is explicit.
ananta
2013/10/02 17:46:55
Done.
| |
| 213 window_modality_controller_.reset(); | |
| 214 | |
| 211 // Make sure we don't still have capture. Otherwise CaptureController and | 215 // Make sure we don't still have capture. Otherwise CaptureController and |
| 212 // RootWindow are left referencing a deleted Window. | 216 // RootWindow are left referencing a deleted Window. |
| 213 { | 217 { |
| 214 aura::Window* capture_window = | 218 aura::Window* capture_window = |
| 215 capture_client_->capture_client()->GetCaptureWindow(); | 219 capture_client_->capture_client()->GetCaptureWindow(); |
| 216 if (capture_window && root_window_->Contains(capture_window)) | 220 if (capture_window && root_window_->Contains(capture_window)) |
| 217 capture_window->ReleaseCapture(); | 221 capture_window->ReleaseCapture(); |
| 218 } | 222 } |
| 219 | 223 |
| 220 // DesktopRootWindowHost owns the ActivationController which ShadowController | 224 // DesktopRootWindowHost owns the ActivationController which ShadowController |
| 221 // references. Make sure we destroy ShadowController early on. | 225 // references. Make sure we destroy ShadowController early on. |
| 222 shadow_controller_.reset(); | 226 shadow_controller_.reset(); |
| 223 tooltip_manager_.reset(); | 227 tooltip_manager_.reset(); |
| 224 scoped_tooltip_client_.reset(); | 228 scoped_tooltip_client_.reset(); |
| 225 if (window_modality_controller_) { | |
| 226 root_window_->RemovePreTargetHandler(window_modality_controller_.get()); | |
| 227 window_modality_controller_.reset(); | |
| 228 } | |
| 229 | 229 |
| 230 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); | 230 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); |
| 231 | 231 |
| 232 stacking_client_.reset(); // Uses root_window_ at destruction. | 232 stacking_client_.reset(); // Uses root_window_ at destruction. |
| 233 | 233 |
| 234 root_window_->RemoveRootWindowObserver(this); | 234 root_window_->RemoveRootWindowObserver(this); |
| 235 root_window_.reset(); // Uses input_method_event_filter_ at destruction. | 235 root_window_.reset(); // Uses input_method_event_filter_ at destruction. |
| 236 // RootWindow owns |desktop_root_window_host_|. | 236 // RootWindow owns |desktop_root_window_host_|. |
| 237 desktop_root_window_host_ = NULL; | 237 desktop_root_window_host_ = NULL; |
| 238 window_ = NULL; | 238 window_ = NULL; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 // If we're not active we need to deactivate the corresponding | 289 // If we're not active we need to deactivate the corresponding |
| 290 // aura::Window. This way if a child widget is active it gets correctly | 290 // aura::Window. This way if a child widget is active it gets correctly |
| 291 // deactivated (child widgets don't get native desktop activation changes, | 291 // deactivated (child widgets don't get native desktop activation changes, |
| 292 // only aura activation changes). | 292 // only aura activation changes). |
| 293 aura::Window* active_window = activation_client->GetActiveWindow(); | 293 aura::Window* active_window = activation_client->GetActiveWindow(); |
| 294 if (active_window) | 294 if (active_window) |
| 295 activation_client->DeactivateWindow(active_window); | 295 activation_client->DeactivateWindow(active_window); |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 void DesktopNativeWidgetAura::InstallWindowModalityController( | |
| 300 aura::RootWindow* root) { | |
| 301 // The WindowsModalityController event filter should be at the head of the | |
| 302 // pre target handlers list. This ensures that it handles input events first | |
| 303 // when modal windows are at the top of the Zorder. | |
| 304 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) | |
| 305 window_modality_controller_.reset( | |
| 306 new views::corewm::WindowModalityController(root)); | |
| 307 } | |
| 308 | |
| 299 //////////////////////////////////////////////////////////////////////////////// | 309 //////////////////////////////////////////////////////////////////////////////// |
| 300 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: | 310 // DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation: |
| 301 | 311 |
| 302 void DesktopNativeWidgetAura::InitNativeWidget( | 312 void DesktopNativeWidgetAura::InitNativeWidget( |
| 303 const Widget::InitParams& params) { | 313 const Widget::InitParams& params) { |
| 304 ownership_ = params.ownership; | 314 ownership_ = params.ownership; |
| 315 widget_type_ = params.type; | |
| 305 | 316 |
| 306 NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); | 317 NativeWidgetAura::RegisterNativeWidgetForWindow(this, window_); |
| 307 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate | 318 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate |
| 308 // these windows the size of the window gets augmented, effecting restore | 319 // these windows the size of the window gets augmented, effecting restore |
| 309 // bounds and maximized windows in bad ways. | 320 // bounds and maximized windows in bad ways. |
| 310 if (params.type == Widget::InitParams::TYPE_WINDOW && | 321 if (params.type == Widget::InitParams::TYPE_WINDOW && |
| 311 !params.remove_standard_frame) { | 322 !params.remove_standard_frame) { |
| 312 window_->SetProperty(aura::client::kAnimationsDisabledKey, true); | 323 window_->SetProperty(aura::client::kAnimationsDisabledKey, true); |
| 313 } | 324 } |
| 314 window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); | 325 window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 scoped_tooltip_client_.reset(new ScopedTooltipClient(root_window_.get())); | 358 scoped_tooltip_client_.reset(new ScopedTooltipClient(root_window_.get())); |
| 348 | 359 |
| 349 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { | 360 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { |
| 350 visibility_controller_.reset(new views::corewm::VisibilityController); | 361 visibility_controller_.reset(new views::corewm::VisibilityController); |
| 351 aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), | 362 aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), |
| 352 visibility_controller_.get()); | 363 visibility_controller_.get()); |
| 353 views::corewm::SetChildWindowVisibilityChangesAnimated( | 364 views::corewm::SetChildWindowVisibilityChangesAnimated( |
| 354 GetNativeView()->GetRootWindow()); | 365 GetNativeView()->GetRootWindow()); |
| 355 } | 366 } |
| 356 | 367 |
| 357 if (params.type == Widget::InitParams::TYPE_WINDOW) { | |
| 358 window_modality_controller_.reset( | |
| 359 new views::corewm::WindowModalityController); | |
| 360 root_window_->AddPreTargetHandler(window_modality_controller_.get()); | |
| 361 } | |
| 362 | |
| 363 window_->Show(); | 368 window_->Show(); |
| 364 desktop_root_window_host_->InitFocus(window_); | 369 desktop_root_window_host_->InitFocus(window_); |
| 365 | 370 |
| 366 aura::client::SetActivationDelegate(window_, this); | 371 aura::client::SetActivationDelegate(window_, this); |
| 367 | 372 |
| 368 shadow_controller_.reset( | 373 shadow_controller_.reset( |
| 369 new corewm::ShadowController( | 374 new corewm::ShadowController( |
| 370 aura::client::GetActivationClient(root_window_.get()))); | 375 aura::client::GetActivationClient(root_window_.get()))); |
| 371 | 376 |
| 372 window_reorderer_.reset(new WindowReorderer(window_, | 377 window_reorderer_.reset(new WindowReorderer(window_, |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1005 | 1010 |
| 1006 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { | 1011 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { |
| 1007 return this; | 1012 return this; |
| 1008 } | 1013 } |
| 1009 | 1014 |
| 1010 void DesktopNativeWidgetAura::UpdateWindowTransparency() { | 1015 void DesktopNativeWidgetAura::UpdateWindowTransparency() { |
| 1011 window_->SetTransparent(ShouldUseNativeFrame()); | 1016 window_->SetTransparent(ShouldUseNativeFrame()); |
| 1012 } | 1017 } |
| 1013 | 1018 |
| 1014 } // namespace views | 1019 } // namespace views |
| OLD | NEW |