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