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(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 root_window_.reset(); // Uses input_method_event_filter_ at destruction. | 236 root_window_.reset(); // Uses input_method_event_filter_ at destruction. |
| 236 // RootWindow owns |desktop_root_window_host_|. | 237 // RootWindow owns |desktop_root_window_host_|. |
| 237 desktop_root_window_host_ = NULL; | 238 desktop_root_window_host_ = NULL; |
| 238 window_ = NULL; | 239 window_ = NULL; |
| 239 | 240 |
| 240 native_widget_delegate_->OnNativeWidgetDestroyed(); | 241 native_widget_delegate_->OnNativeWidgetDestroyed(); |
| 241 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 242 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
| 242 delete this; | 243 delete this; |
| 243 } | 244 } |
| 244 | 245 |
| 245 void DesktopNativeWidgetAura::InstallInputMethodEventFilter( | 246 void DesktopNativeWidgetAura::InstallInputMethodEventFilter( |
|
sky
2013/10/01 17:32:12
Having a method called InstallInputMethodEventFilt
ananta
2013/10/01 22:37:33
Added a method InstallWindowModalityController to
| |
| 246 aura::RootWindow* root) { | 247 aura::RootWindow* root) { |
| 247 DCHECK(!input_method_event_filter_.get()); | 248 DCHECK(!input_method_event_filter_.get()); |
| 248 | 249 |
| 250 // The WindowsModalityController event filter should be at the head of the | |
| 251 // pre target handlers list. This ensures that it handles input events first | |
| 252 // when modal windows are at the top of the Zorder. | |
| 253 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) { | |
| 254 window_modality_controller_.reset( | |
| 255 new views::corewm::WindowModalityController); | |
| 256 root->AddPreTargetHandler(window_modality_controller_.get()); | |
| 257 } | |
| 258 | |
| 249 // CEF sets focus to the window the user clicks down on. | 259 // CEF sets focus to the window the user clicks down on. |
| 250 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- | 260 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- |
| 251 // handed way of accomplishing focus. | 261 // handed way of accomplishing focus. |
| 252 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. | 262 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. |
| 253 root_window_event_filter_ = new corewm::CompoundEventFilter; | 263 root_window_event_filter_ = new corewm::CompoundEventFilter; |
| 254 // Pass ownership of the filter to the root_window. | 264 // Pass ownership of the filter to the root_window. |
| 255 root->SetEventFilter(root_window_event_filter_); | 265 root->SetEventFilter(root_window_event_filter_); |
| 256 | 266 |
| 257 input_method_event_filter_.reset( | 267 input_method_event_filter_.reset( |
| 258 new corewm::InputMethodEventFilter(root->GetAcceleratedWidget())); | 268 new corewm::InputMethodEventFilter(root->GetAcceleratedWidget())); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 activation_client->DeactivateWindow(active_window); | 305 activation_client->DeactivateWindow(active_window); |
| 296 } | 306 } |
| 297 } | 307 } |
| 298 | 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 |