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/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.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 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 | 403 |
404 void DesktopNativeWidgetAura::InitNativeWidget( | 404 void DesktopNativeWidgetAura::InitNativeWidget( |
405 const Widget::InitParams& params) { | 405 const Widget::InitParams& params) { |
406 ownership_ = params.ownership; | 406 ownership_ = params.ownership; |
407 widget_type_ = params.type; | 407 widget_type_ = params.type; |
408 | 408 |
409 NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_window_); | 409 NativeWidgetAura::RegisterNativeWidgetForWindow(this, content_window_); |
410 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate | 410 // Animations on TYPE_WINDOW are handled by the OS. Additionally if we animate |
411 // these windows the size of the window gets augmented, effecting restore | 411 // these windows the size of the window gets augmented, effecting restore |
412 // bounds and maximized windows in bad ways. | 412 // bounds and maximized windows in bad ways. |
413 if (params.type == Widget::InitParams::TYPE_WINDOW && | 413 if ((params.type == Widget::InitParams::TYPE_WINDOW || |
414 params.type == Widget::InitParams::TYPE_DRAG_BROWSER) && | |
414 !params.remove_standard_frame) { | 415 !params.remove_standard_frame) { |
415 content_window_->SetProperty(aura::client::kAnimationsDisabledKey, true); | 416 content_window_->SetProperty(aura::client::kAnimationsDisabledKey, true); |
416 } | 417 } |
417 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); | 418 content_window_->SetType(GetAuraWindowTypeForWidgetType(params.type)); |
418 content_window_->Init(params.layer_type); | 419 content_window_->Init(params.layer_type); |
419 wm::SetShadowType(content_window_, wm::SHADOW_TYPE_NONE); | 420 wm::SetShadowType(content_window_, wm::SHADOW_TYPE_NONE); |
420 | 421 |
421 content_window_container_ = new aura::Window(NULL); | 422 content_window_container_ = new aura::Window(NULL); |
422 content_window_container_->Init(ui::LAYER_NOT_DRAWN); | 423 content_window_container_->Init(ui::LAYER_NOT_DRAWN); |
423 content_window_container_->Show(); | 424 content_window_container_->Show(); |
424 content_window_container_->AddChild(content_window_); | 425 content_window_container_->AddChild(content_window_); |
425 | 426 |
426 desktop_window_tree_host_ = params.desktop_window_tree_host ? | 427 desktop_window_tree_host_ = params.desktop_window_tree_host ? |
427 params.desktop_window_tree_host : | 428 params.desktop_window_tree_host : |
428 DesktopWindowTreeHost::Create(native_widget_delegate_, this); | 429 DesktopWindowTreeHost::Create(native_widget_delegate_, this); |
429 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); | 430 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); |
430 desktop_window_tree_host_->Init(content_window_, params); | 431 desktop_window_tree_host_->Init(content_window_, params); |
431 | 432 |
432 host_->InitHost(); | 433 host_->InitHost(); |
433 host_->window()->AddChild(content_window_container_); | 434 host_->window()->AddChild(content_window_container_); |
434 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); | 435 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); |
435 | 436 |
436 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); | 437 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); |
437 | 438 |
438 // The WindowsModalityController event filter should be at the head of the | 439 // The WindowsModalityController event filter should be at the head of the |
439 // pre target handlers list. This ensures that it handles input events first | 440 // pre target handlers list. This ensures that it handles input events first |
440 // when modal windows are at the top of the Zorder. | 441 // when modal windows are at the top of the Zorder. |
441 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) | 442 if ((widget_type_ == Widget::InitParams::TYPE_WINDOW || |
443 widget_type_ == Widget::InitParams::TYPE_DRAG_BROWSER)) | |
Daniel Erat
2015/12/28 21:33:02
i don't think i understand this. why is a tab that
stapelberg
2016/01/18 17:22:23
I just did a search and replace for TYPE_WINDOW an
| |
442 window_modality_controller_.reset( | 444 window_modality_controller_.reset( |
443 new wm::WindowModalityController(host_->window())); | 445 new wm::WindowModalityController(host_->window())); |
444 | 446 |
445 // |root_window_event_filter_| must be created before | 447 // |root_window_event_filter_| must be created before |
446 // OnWindowTreeHostCreated() is invoked. | 448 // OnWindowTreeHostCreated() is invoked. |
447 | 449 |
448 // CEF sets focus to the window the user clicks down on. | 450 // CEF sets focus to the window the user clicks down on. |
449 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- | 451 // TODO(beng): see if we can't do this some other way. CEF seems a heavy- |
450 // handed way of accomplishing focus. | 452 // handed way of accomplishing focus. |
451 // No event filter for aura::Env. Create CompoundEventFilter per | 453 // No event filter for aura::Env. Create CompoundEventFilter per |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 | 517 |
516 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { | 518 if (params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW) { |
517 visibility_controller_.reset(new wm::VisibilityController); | 519 visibility_controller_.reset(new wm::VisibilityController); |
518 aura::client::SetVisibilityClient(host_->window(), | 520 aura::client::SetVisibilityClient(host_->window(), |
519 visibility_controller_.get()); | 521 visibility_controller_.get()); |
520 wm::SetChildWindowVisibilityChangesAnimated(host_->window()); | 522 wm::SetChildWindowVisibilityChangesAnimated(host_->window()); |
521 wm::SetChildWindowVisibilityChangesAnimated( | 523 wm::SetChildWindowVisibilityChangesAnimated( |
522 content_window_container_); | 524 content_window_container_); |
523 } | 525 } |
524 | 526 |
525 if (params.type == Widget::InitParams::TYPE_WINDOW) { | 527 if (params.type == Widget::InitParams::TYPE_WINDOW || |
528 params.type == Widget::InitParams::TYPE_DRAG_BROWSER) { | |
Daniel Erat
2015/12/28 21:33:02
same here. override-redirect windows typically don
stapelberg
2016/01/18 17:22:23
Done.
| |
526 focus_manager_event_handler_.reset(new FocusManagerEventHandler(this)); | 529 focus_manager_event_handler_.reset(new FocusManagerEventHandler(this)); |
527 host_->window()->AddPreTargetHandler(focus_manager_event_handler_.get()); | 530 host_->window()->AddPreTargetHandler(focus_manager_event_handler_.get()); |
528 } | 531 } |
529 | 532 |
530 event_client_.reset(new DesktopEventClient); | 533 event_client_.reset(new DesktopEventClient); |
531 aura::client::SetEventClient(host_->window(), event_client_.get()); | 534 aura::client::SetEventClient(host_->window(), event_client_.get()); |
532 | 535 |
533 aura::client::GetFocusClient(content_window_)->FocusWindow(content_window_); | 536 aura::client::GetFocusClient(content_window_)->FocusWindow(content_window_); |
534 | 537 |
535 aura::client::SetActivationDelegate(content_window_, this); | 538 aura::client::SetActivationDelegate(content_window_, this); |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1201 if (cursor_reference_count_ == 0) { | 1204 if (cursor_reference_count_ == 0) { |
1202 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1205 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1203 // for cleaning up |cursor_manager_|. | 1206 // for cleaning up |cursor_manager_|. |
1204 delete cursor_manager_; | 1207 delete cursor_manager_; |
1205 native_cursor_manager_ = NULL; | 1208 native_cursor_manager_ = NULL; |
1206 cursor_manager_ = NULL; | 1209 cursor_manager_ = NULL; |
1207 } | 1210 } |
1208 } | 1211 } |
1209 | 1212 |
1210 } // namespace views | 1213 } // namespace views |
OLD | NEW |