| 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_native_widget_helper_aura.h" | 5 #include "ui/views/widget/desktop_native_widget_helper_aura.h" |
| 6 | 6 |
| 7 #include "ui/views/widget/native_widget_aura.h" | |
| 8 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
| 9 #include "ui/aura/desktop/desktop_activation_client.h" | 8 #include "ui/aura/desktop/desktop_activation_client.h" |
| 10 #include "ui/aura/desktop/desktop_dispatcher_client.h" | 9 #include "ui/aura/desktop/desktop_dispatcher_client.h" |
| 11 #include "ui/aura/desktop/desktop_root_window_event_filter.h" | 10 #include "ui/aura/desktop/desktop_root_window_event_filter.h" |
| 12 #include "ui/aura/client/dispatcher_client.h" | 11 #include "ui/aura/client/dispatcher_client.h" |
| 12 #include "ui/views/widget/native_widget_aura.h" |
| 13 |
| 14 #if defined(OS_WIN) |
| 15 #include "ui/base/win/hwnd_subclass.h" |
| 16 #include "ui/views/widget/widget_message_filter.h" |
| 17 #endif |
| 13 | 18 |
| 14 namespace views { | 19 namespace views { |
| 15 | 20 |
| 16 DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura( | 21 DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura( |
| 17 NativeWidgetAura* widget) | 22 NativeWidgetAura* widget) |
| 18 : widget_(widget) { | 23 : widget_(widget) { |
| 19 } | 24 } |
| 20 | 25 |
| 21 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() {} | 26 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() {} |
| 22 | 27 |
| 23 void DesktopNativeWidgetHelperAura::PreInitialize( | 28 void DesktopNativeWidgetHelperAura::PreInitialize( |
| 24 const Widget::InitParams& params) { | 29 const Widget::InitParams& params) { |
| 25 gfx::Rect bounds = params.bounds; | 30 gfx::Rect bounds = params.bounds; |
| 26 if (bounds.IsEmpty()) { | 31 if (bounds.IsEmpty()) { |
| 27 // We must pass some non-zero value when we initialize a RootWindow. This | 32 // We must pass some non-zero value when we initialize a RootWindow. This |
| 28 // will probably be SetBounds()ed soon. | 33 // will probably be SetBounds()ed soon. |
| 29 bounds.set_size(gfx::Size(100, 100)); | 34 bounds.set_size(gfx::Size(100, 100)); |
| 30 } | 35 } |
| 31 root_window_.reset(new aura::RootWindow(bounds)); | 36 root_window_.reset(new aura::RootWindow(bounds)); |
| 37 root_window_->Init(); |
| 32 root_window_->SetEventFilter( | 38 root_window_->SetEventFilter( |
| 33 new aura::DesktopRootWindowEventFilter(root_window_.get())); | 39 new aura::DesktopRootWindowEventFilter(root_window_.get())); |
| 34 root_window_->AddRootWindowObserver(this); | 40 root_window_->AddRootWindowObserver(this); |
| 35 | 41 |
| 36 aura::client::SetActivationClient( | 42 aura::client::SetActivationClient( |
| 37 root_window_.get(), | 43 root_window_.get(), |
| 38 new aura::DesktopActivationClient(root_window_.get())); | 44 new aura::DesktopActivationClient(root_window_.get())); |
| 39 aura::client::SetDispatcherClient(root_window_.get(), | 45 aura::client::SetDispatcherClient(root_window_.get(), |
| 40 new aura::DesktopDispatcherClient); | 46 new aura::DesktopDispatcherClient); |
| 41 } | 47 } |
| 42 | 48 |
| 49 void DesktopNativeWidgetHelperAura::PostInitialize() { |
| 50 #if defined(OS_WIN) |
| 51 subclass_.reset(new ui::HWNDSubclass(root_window_->GetAcceleratedWidget())); |
| 52 subclass_->SetFilter(new WidgetMessageFilter(root_window_.get(), |
| 53 widget_->GetWidget())); |
| 54 #endif |
| 55 } |
| 56 |
| 43 void DesktopNativeWidgetHelperAura::ShowRootWindow() { | 57 void DesktopNativeWidgetHelperAura::ShowRootWindow() { |
| 44 if (root_window_.get()) | 58 if (root_window_.get()) |
| 45 root_window_->ShowRootWindow(); | 59 root_window_->ShowRootWindow(); |
| 46 } | 60 } |
| 47 | 61 |
| 48 aura::RootWindow* DesktopNativeWidgetHelperAura::GetRootWindow() { | 62 aura::RootWindow* DesktopNativeWidgetHelperAura::GetRootWindow() { |
| 49 return root_window_.get(); | 63 return root_window_.get(); |
| 50 } | 64 } |
| 51 | 65 |
| 52 gfx::Rect DesktopNativeWidgetHelperAura::ModifyAndSetBounds( | 66 gfx::Rect DesktopNativeWidgetHelperAura::ModifyAndSetBounds( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 79 widget_->SetBounds(gfx::Rect(root->GetHostSize())); | 93 widget_->SetBounds(gfx::Rect(root->GetHostSize())); |
| 80 } | 94 } |
| 81 | 95 |
| 82 void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( | 96 void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( |
| 83 const aura::RootWindow* root) { | 97 const aura::RootWindow* root) { |
| 84 DCHECK_EQ(root, root_window_.get()); | 98 DCHECK_EQ(root, root_window_.get()); |
| 85 widget_->GetWidget()->Close(); | 99 widget_->GetWidget()->Close(); |
| 86 } | 100 } |
| 87 | 101 |
| 88 } // namespace views | 102 } // namespace views |
| OLD | NEW |