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/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
8 #include "ui/aura/desktop/desktop_activation_client.h" | 8 #include "ui/aura/desktop/desktop_activation_client.h" |
9 #include "ui/aura/desktop/desktop_dispatcher_client.h" | 9 #include "ui/aura/desktop/desktop_dispatcher_client.h" |
10 #include "ui/aura/desktop/desktop_root_window_event_filter.h" | |
11 #include "ui/aura/client/dispatcher_client.h" | 10 #include "ui/aura/client/dispatcher_client.h" |
11 #include "ui/aura/shared/input_method_event_filter.h" | |
12 #include "ui/aura/shared/root_window_event_filter.h" | |
12 #include "ui/views/widget/native_widget_aura.h" | 13 #include "ui/views/widget/native_widget_aura.h" |
13 | 14 |
14 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
15 #include "ui/base/win/hwnd_subclass.h" | 16 #include "ui/base/win/hwnd_subclass.h" |
16 #include "ui/views/widget/widget_message_filter.h" | 17 #include "ui/views/widget/widget_message_filter.h" |
17 #endif | 18 #endif |
18 | 19 |
19 namespace views { | 20 namespace views { |
20 | 21 |
21 DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura( | 22 DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura( |
22 NativeWidgetAura* widget) | 23 NativeWidgetAura* widget) |
23 : widget_(widget), | 24 : widget_(widget), |
25 root_window_event_filter_(NULL), | |
24 is_embedded_window_(false) { | 26 is_embedded_window_(false) { |
25 } | 27 } |
26 | 28 |
27 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() {} | 29 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() { |
30 if (root_window_event_filter_) { | |
Ben Goodger (Google)
2012/05/15 17:35:13
nit no braces
| |
31 root_window_event_filter_->RemoveFilter(input_method_filter_.get()); | |
32 } | |
33 } | |
28 | 34 |
29 void DesktopNativeWidgetHelperAura::PreInitialize( | 35 void DesktopNativeWidgetHelperAura::PreInitialize( |
30 const Widget::InitParams& params) { | 36 const Widget::InitParams& params) { |
31 // We don't want the status bubble or the omnibox to get their own root | 37 // We don't want the status bubble or the omnibox to get their own root |
32 // window on the desktop; on Linux | 38 // window on the desktop; on Linux |
33 // | 39 // |
34 // TODO(erg): This doesn't map perfectly to what I want to do. TYPE_POPUP is | 40 // TODO(erg): This doesn't map perfectly to what I want to do. TYPE_POPUP is |
35 // used for lots of stuff, like dragged tabs, and I only want this to trigger | 41 // used for lots of stuff, like dragged tabs, and I only want this to trigger |
36 // for the status bubble and the omnibox. | 42 // for the status bubble and the omnibox. |
37 if (params.type == Widget::InitParams::TYPE_POPUP) { | 43 if (params.type == Widget::InitParams::TYPE_POPUP) { |
38 is_embedded_window_ = true; | 44 is_embedded_window_ = true; |
39 return; | 45 return; |
40 } else if (params.type == Widget::InitParams::TYPE_CONTROL) { | 46 } else if (params.type == Widget::InitParams::TYPE_CONTROL) { |
41 return; | 47 return; |
42 } | 48 } |
43 | 49 |
44 gfx::Rect bounds = params.bounds; | 50 gfx::Rect bounds = params.bounds; |
45 if (bounds.IsEmpty()) { | 51 if (bounds.IsEmpty()) { |
46 // We must pass some non-zero value when we initialize a RootWindow. This | 52 // We must pass some non-zero value when we initialize a RootWindow. This |
47 // will probably be SetBounds()ed soon. | 53 // will probably be SetBounds()ed soon. |
48 bounds.set_size(gfx::Size(100, 100)); | 54 bounds.set_size(gfx::Size(100, 100)); |
49 } | 55 } |
50 root_window_.reset(new aura::RootWindow(bounds)); | 56 root_window_.reset(new aura::RootWindow(bounds)); |
51 root_window_->Init(); | 57 root_window_->Init(); |
52 root_window_->SetEventFilter( | 58 |
53 new aura::DesktopRootWindowEventFilter(root_window_.get())); | 59 root_window_event_filter_ = |
60 new aura::shared::RootWindowEventFilter(root_window_.get()); | |
61 root_window_->SetEventFilter(root_window_event_filter_); | |
62 | |
63 input_method_filter_.reset( | |
64 new aura::shared::InputMethodEventFilter(root_window_.get())); | |
65 root_window_event_filter_->AddFilter(input_method_filter_.get()); | |
66 | |
54 root_window_->AddRootWindowObserver(this); | 67 root_window_->AddRootWindowObserver(this); |
55 | 68 |
56 aura::client::SetActivationClient( | 69 aura::client::SetActivationClient( |
57 root_window_.get(), | 70 root_window_.get(), |
58 new aura::DesktopActivationClient(root_window_.get())); | 71 new aura::DesktopActivationClient(root_window_.get())); |
59 aura::client::SetDispatcherClient(root_window_.get(), | 72 aura::client::SetDispatcherClient(root_window_.get(), |
60 new aura::DesktopDispatcherClient); | 73 new aura::DesktopDispatcherClient); |
61 } | 74 } |
62 | 75 |
63 void DesktopNativeWidgetHelperAura::PostInitialize() { | 76 void DesktopNativeWidgetHelperAura::PostInitialize() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 root->GetHostSize())); | 135 root->GetHostSize())); |
123 } | 136 } |
124 | 137 |
125 void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( | 138 void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( |
126 const aura::RootWindow* root) { | 139 const aura::RootWindow* root) { |
127 DCHECK_EQ(root, root_window_.get()); | 140 DCHECK_EQ(root, root_window_.get()); |
128 widget_->GetWidget()->Close(); | 141 widget_->GetWidget()->Close(); |
129 } | 142 } |
130 | 143 |
131 } // namespace views | 144 } // namespace views |
OLD | NEW |