| 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/client/dispatcher_client.h" | 7 #include "ui/aura/client/dispatcher_client.h" |
| 8 #include "ui/aura/client/screen_position_client.h" | 8 #include "ui/aura/client/screen_position_client.h" |
| 9 #include "ui/aura/cursor_manager.h" | 9 #include "ui/aura/cursor_manager.h" |
| 10 #include "ui/aura/desktop/desktop_activation_client.h" | 10 #include "ui/aura/desktop/desktop_activation_client.h" |
| 11 #include "ui/aura/desktop/desktop_dispatcher_client.h" | 11 #include "ui/aura/desktop/desktop_dispatcher_client.h" |
| 12 #include "ui/aura/focus_manager.h" | 12 #include "ui/aura/focus_manager.h" |
| 13 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/shared/compound_event_filter.h" | 14 #include "ui/aura/shared/compound_event_filter.h" |
| 15 #include "ui/aura/shared/input_method_event_filter.h" | 15 #include "ui/aura/shared/input_method_event_filter.h" |
| 16 #include "ui/aura/shared/root_window_capture_client.h" | 16 #include "ui/aura/shared/root_window_capture_client.h" |
| 17 #include "ui/aura/window_property.h" |
| 17 #include "ui/views/widget/native_widget_aura.h" | 18 #include "ui/views/widget/native_widget_aura.h" |
| 18 | 19 |
| 19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 20 #include "ui/base/win/hwnd_subclass.h" | 21 #include "ui/base/win/hwnd_subclass.h" |
| 21 #include "ui/views/widget/widget_message_filter.h" | 22 #include "ui/views/widget/widget_message_filter.h" |
| 22 #elif defined(USE_X11) | 23 #elif defined(USE_X11) |
| 23 #include "ui/views/widget/x11_window_event_filter.h" | 24 #include "ui/views/widget/x11_window_event_filter.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 27 DECLARE_WINDOW_PROPERTY_TYPE(aura::Window*); |
| 28 |
| 26 namespace views { | 29 namespace views { |
| 27 | 30 |
| 31 DEFINE_WINDOW_PROPERTY_KEY( |
| 32 aura::Window*, kViewsWindowForRootWindow, NULL); |
| 33 |
| 28 namespace { | 34 namespace { |
| 29 | 35 |
| 30 // Client that always offsets the passed in point by the RootHost's origin. | 36 // Client that always offsets the passed in point by the RootHost's origin. |
| 31 class RootWindowScreenPositionClient | 37 class RootWindowScreenPositionClient |
| 32 : public aura::client::ScreenPositionClient { | 38 : public aura::client::ScreenPositionClient { |
| 33 public: | 39 public: |
| 34 explicit RootWindowScreenPositionClient(aura::RootWindow* root_window) | 40 explicit RootWindowScreenPositionClient(aura::RootWindow* root_window) |
| 35 : root_window_(root_window) {} | 41 : root_window_(root_window) {} |
| 36 virtual ~RootWindowScreenPositionClient() {} | 42 virtual ~RootWindowScreenPositionClient() {} |
| 37 | 43 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() { | 84 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() { |
| 79 if (root_window_event_filter_) { | 85 if (root_window_event_filter_) { |
| 80 #if defined(USE_X11) | 86 #if defined(USE_X11) |
| 81 root_window_event_filter_->RemoveFilter(x11_window_event_filter_.get()); | 87 root_window_event_filter_->RemoveFilter(x11_window_event_filter_.get()); |
| 82 #endif | 88 #endif |
| 83 | 89 |
| 84 root_window_event_filter_->RemoveFilter(input_method_filter_.get()); | 90 root_window_event_filter_->RemoveFilter(input_method_filter_.get()); |
| 85 } | 91 } |
| 86 } | 92 } |
| 87 | 93 |
| 94 // static |
| 95 aura::Window* DesktopNativeWidgetHelperAura::GetViewsWindowForRootWindow( |
| 96 aura::RootWindow* root) { |
| 97 return root ? root->GetProperty(kViewsWindowForRootWindow) : NULL; |
| 98 } |
| 99 |
| 88 void DesktopNativeWidgetHelperAura::PreInitialize( | 100 void DesktopNativeWidgetHelperAura::PreInitialize( |
| 89 aura::Window* window, | 101 aura::Window* window, |
| 90 const Widget::InitParams& params) { | 102 const Widget::InitParams& params) { |
| 91 #if !defined(OS_WIN) | 103 #if !defined(OS_WIN) |
| 92 // We don't want the status bubble or the omnibox to get their own root | 104 // We don't want the status bubble or the omnibox to get their own root |
| 93 // window on the desktop; on Linux | 105 // window on the desktop; on Linux |
| 94 // | 106 // |
| 95 // TODO(erg): This doesn't map perfectly to what I want to do. TYPE_POPUP is | 107 // TODO(erg): This doesn't map perfectly to what I want to do. TYPE_POPUP is |
| 96 // used for lots of stuff, like dragged tabs, and I only want this to trigger | 108 // used for lots of stuff, like dragged tabs, and I only want this to trigger |
| 97 // for the status bubble and the omnibox. | 109 // for the status bubble and the omnibox. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 108 gfx::Rect bounds = params.bounds; | 120 gfx::Rect bounds = params.bounds; |
| 109 if (bounds.IsEmpty()) { | 121 if (bounds.IsEmpty()) { |
| 110 // We must pass some non-zero value when we initialize a RootWindow. This | 122 // We must pass some non-zero value when we initialize a RootWindow. This |
| 111 // will probably be SetBounds()ed soon. | 123 // will probably be SetBounds()ed soon. |
| 112 bounds.set_size(gfx::Size(100, 100)); | 124 bounds.set_size(gfx::Size(100, 100)); |
| 113 } | 125 } |
| 114 // TODO(erg): Implement aura::CursorManager::Delegate to control | 126 // TODO(erg): Implement aura::CursorManager::Delegate to control |
| 115 // cursor's shape and visibility. | 127 // cursor's shape and visibility. |
| 116 | 128 |
| 117 root_window_.reset(new aura::RootWindow(bounds)); | 129 root_window_.reset(new aura::RootWindow(bounds)); |
| 130 root_window_->SetProperty(kViewsWindowForRootWindow, window); |
| 118 root_window_->Init(); | 131 root_window_->Init(); |
| 119 root_window_->set_focus_manager(new aura::FocusManager); | 132 root_window_->set_focus_manager(new aura::FocusManager); |
| 120 | 133 |
| 121 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. | 134 // No event filter for aura::Env. Create CompoundEvnetFilter per RootWindow. |
| 122 root_window_event_filter_ = new aura::shared::CompoundEventFilter; | 135 root_window_event_filter_ = new aura::shared::CompoundEventFilter; |
| 123 // Pass ownership of the filter to the root_window. | 136 // Pass ownership of the filter to the root_window. |
| 124 root_window_->SetEventFilter(root_window_event_filter_); | 137 root_window_->SetEventFilter(root_window_event_filter_); |
| 125 | 138 |
| 126 input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); | 139 input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); |
| 127 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window_.get()); | 140 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window_.get()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 root->GetHostSize())); | 213 root->GetHostSize())); |
| 201 } | 214 } |
| 202 | 215 |
| 203 void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( | 216 void DesktopNativeWidgetHelperAura::OnRootWindowHostClosed( |
| 204 const aura::RootWindow* root) { | 217 const aura::RootWindow* root) { |
| 205 DCHECK_EQ(root, root_window_.get()); | 218 DCHECK_EQ(root, root_window_.get()); |
| 206 widget_->GetWidget()->Close(); | 219 widget_->GetWidget()->Close(); |
| 207 } | 220 } |
| 208 | 221 |
| 209 } // namespace views | 222 } // namespace views |
| OLD | NEW |