| 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 "ui/aura/client/activation_client.h" | 8 #include "ui/aura/client/activation_client.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" |
| 11 #include "ui/aura/client/focus_client.h" | 11 #include "ui/aura/client/focus_client.h" |
| 12 #include "ui/aura/client/stacking_client.h" | 12 #include "ui/aura/client/window_tree_client.h" |
| 13 #include "ui/aura/root_window.h" | 13 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/root_window_host.h" | 14 #include "ui/aura/root_window_host.h" |
| 15 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
| 17 #include "ui/aura/window_property.h" | 17 #include "ui/aura/window_property.h" |
| 18 #include "ui/base/hit_test.h" | 18 #include "ui/base/hit_test.h" |
| 19 #include "ui/compositor/layer.h" | 19 #include "ui/compositor/layer.h" |
| 20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/display.h" | 21 #include "ui/gfx/display.h" |
| 22 #include "ui/gfx/point_conversions.h" | 22 #include "ui/gfx/point_conversions.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 DesktopNativeWidgetTopLevelHandler() | 126 DesktopNativeWidgetTopLevelHandler() |
| 127 : top_level_widget_(NULL) {} | 127 : top_level_widget_(NULL) {} |
| 128 | 128 |
| 129 virtual ~DesktopNativeWidgetTopLevelHandler() {} | 129 virtual ~DesktopNativeWidgetTopLevelHandler() {} |
| 130 | 130 |
| 131 Widget* top_level_widget_; | 131 Widget* top_level_widget_; |
| 132 | 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetTopLevelHandler); | 133 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetTopLevelHandler); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 class DesktopNativeWidgetAuraStackingClient : | 136 class DesktopNativeWidgetAuraWindowTreeClient : |
| 137 public aura::client::StackingClient { | 137 public aura::client::WindowTreeClient { |
| 138 public: | 138 public: |
| 139 explicit DesktopNativeWidgetAuraStackingClient(aura::RootWindow* root_window) | 139 explicit DesktopNativeWidgetAuraWindowTreeClient( |
| 140 aura::RootWindow* root_window) |
| 140 : root_window_(root_window) { | 141 : root_window_(root_window) { |
| 141 aura::client::SetStackingClient(root_window_, this); | 142 aura::client::SetWindowTreeClient(root_window_, this); |
| 142 } | 143 } |
| 143 virtual ~DesktopNativeWidgetAuraStackingClient() { | 144 virtual ~DesktopNativeWidgetAuraWindowTreeClient() { |
| 144 aura::client::SetStackingClient(root_window_, NULL); | 145 aura::client::SetWindowTreeClient(root_window_, NULL); |
| 145 } | 146 } |
| 146 | 147 |
| 147 // Overridden from client::StackingClient: | 148 // Overridden from client::WindowTreeClient: |
| 148 virtual aura::Window* GetDefaultParent(aura::Window* context, | 149 virtual aura::Window* GetDefaultParent(aura::Window* context, |
| 149 aura::Window* window, | 150 aura::Window* window, |
| 150 const gfx::Rect& bounds) OVERRIDE { | 151 const gfx::Rect& bounds) OVERRIDE { |
| 151 bool full_screen = window->GetProperty(aura::client::kShowStateKey) == | 152 bool full_screen = window->GetProperty(aura::client::kShowStateKey) == |
| 152 ui::SHOW_STATE_FULLSCREEN; | 153 ui::SHOW_STATE_FULLSCREEN; |
| 153 bool is_menu = false; | 154 bool is_menu = false; |
| 154 // TODO(erg): We need to be able to spawn and deal with toplevel windows if | 155 // TODO(erg): We need to be able to spawn and deal with toplevel windows if |
| 155 // we want the popups to extend past our window | 156 // we want the popups to extend past our window |
| 156 // bounds. http://crbug.com/288988 | 157 // bounds. http://crbug.com/288988 |
| 157 #if !defined(OS_LINUX) | 158 #if !defined(OS_LINUX) |
| 158 is_menu = window->type() == aura::client::WINDOW_TYPE_MENU; | 159 is_menu = window->type() == aura::client::WINDOW_TYPE_MENU; |
| 159 #endif | 160 #endif |
| 160 if (full_screen || is_menu) { | 161 if (full_screen || is_menu) { |
| 161 return DesktopNativeWidgetTopLevelHandler::CreateParentWindow( | 162 return DesktopNativeWidgetTopLevelHandler::CreateParentWindow( |
| 162 window, bounds, full_screen); | 163 window, bounds, full_screen); |
| 163 } | 164 } |
| 164 return root_window_; | 165 return root_window_; |
| 165 } | 166 } |
| 166 | 167 |
| 167 private: | 168 private: |
| 168 aura::RootWindow* root_window_; | 169 aura::RootWindow* root_window_; |
| 169 | 170 |
| 170 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAuraStackingClient); | 171 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAuraWindowTreeClient); |
| 171 }; | 172 }; |
| 172 | 173 |
| 173 } // namespace | 174 } // namespace |
| 174 | 175 |
| 175 //////////////////////////////////////////////////////////////////////////////// | 176 //////////////////////////////////////////////////////////////////////////////// |
| 176 // DesktopNativeWidgetAura, public: | 177 // DesktopNativeWidgetAura, public: |
| 177 | 178 |
| 178 DesktopNativeWidgetAura::DesktopNativeWidgetAura( | 179 DesktopNativeWidgetAura::DesktopNativeWidgetAura( |
| 179 internal::NativeWidgetDelegate* delegate) | 180 internal::NativeWidgetDelegate* delegate) |
| 180 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 181 : ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // DesktopRootWindowHost owns the ActivationController which ShadowController | 227 // DesktopRootWindowHost owns the ActivationController which ShadowController |
| 227 // references. Make sure we destroy ShadowController early on. | 228 // references. Make sure we destroy ShadowController early on. |
| 228 shadow_controller_.reset(); | 229 shadow_controller_.reset(); |
| 229 tooltip_manager_.reset(); | 230 tooltip_manager_.reset(); |
| 230 root_window_->RemovePreTargetHandler(tooltip_controller_.get()); | 231 root_window_->RemovePreTargetHandler(tooltip_controller_.get()); |
| 231 aura::client::SetTooltipClient(root_window_.get(), NULL); | 232 aura::client::SetTooltipClient(root_window_.get(), NULL); |
| 232 tooltip_controller_.reset(); | 233 tooltip_controller_.reset(); |
| 233 | 234 |
| 234 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); | 235 root_window_event_filter_->RemoveHandler(input_method_event_filter_.get()); |
| 235 | 236 |
| 236 stacking_client_.reset(); // Uses root_window_ at destruction. | 237 window_tree_client_.reset(); // Uses root_window_ at destruction. |
| 237 | 238 |
| 238 capture_client_.reset(); // Uses root_window_ at destruction. | 239 capture_client_.reset(); // Uses root_window_ at destruction. |
| 239 | 240 |
| 240 root_window_->RemoveRootWindowObserver(this); | 241 root_window_->RemoveRootWindowObserver(this); |
| 241 root_window_.reset(); // Uses input_method_event_filter_ at destruction. | 242 root_window_.reset(); // Uses input_method_event_filter_ at destruction. |
| 242 // RootWindow owns |desktop_root_window_host_|. | 243 // RootWindow owns |desktop_root_window_host_|. |
| 243 desktop_root_window_host_ = NULL; | 244 desktop_root_window_host_ = NULL; |
| 244 window_ = NULL; | 245 window_ = NULL; |
| 245 | 246 |
| 246 native_widget_delegate_->OnNativeWidgetDestroyed(); | 247 native_widget_delegate_->OnNativeWidgetDestroyed(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 347 |
| 347 content_window_container_ = new aura::Window(NULL); | 348 content_window_container_ = new aura::Window(NULL); |
| 348 content_window_container_->Init(ui::LAYER_NOT_DRAWN); | 349 content_window_container_->Init(ui::LAYER_NOT_DRAWN); |
| 349 content_window_container_->Show(); | 350 content_window_container_->Show(); |
| 350 content_window_container_->AddChild(window_); | 351 content_window_container_->AddChild(window_); |
| 351 root_window_->AddChild(content_window_container_); | 352 root_window_->AddChild(content_window_container_); |
| 352 OnRootWindowHostResized(root_window_.get()); | 353 OnRootWindowHostResized(root_window_.get()); |
| 353 | 354 |
| 354 root_window_->AddRootWindowObserver(this); | 355 root_window_->AddRootWindowObserver(this); |
| 355 | 356 |
| 356 stacking_client_.reset( | 357 window_tree_client_.reset( |
| 357 new DesktopNativeWidgetAuraStackingClient(root_window_.get())); | 358 new DesktopNativeWidgetAuraWindowTreeClient(root_window_.get())); |
| 358 drop_helper_.reset(new DropHelper( | 359 drop_helper_.reset(new DropHelper( |
| 359 static_cast<internal::RootView*>(GetWidget()->GetRootView()))); | 360 static_cast<internal::RootView*>(GetWidget()->GetRootView()))); |
| 360 aura::client::SetDragDropDelegate(window_, this); | 361 aura::client::SetDragDropDelegate(window_, this); |
| 361 | 362 |
| 362 tooltip_manager_.reset(new views::TooltipManagerAura(window_, GetWidget())); | 363 tooltip_manager_.reset(new views::TooltipManagerAura(window_, GetWidget())); |
| 363 | 364 |
| 364 tooltip_controller_.reset( | 365 tooltip_controller_.reset( |
| 365 new corewm::TooltipController( | 366 new corewm::TooltipController( |
| 366 desktop_root_window_host_->CreateTooltip())); | 367 desktop_root_window_host_->CreateTooltip())); |
| 367 aura::client::SetTooltipClient(root_window_.get(), tooltip_controller_.get()); | 368 aura::client::SetTooltipClient(root_window_.get(), tooltip_controller_.get()); |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1024 | 1025 |
| 1025 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { | 1026 ui::EventHandler* DesktopNativeWidgetAura::GetEventHandler() { |
| 1026 return this; | 1027 return this; |
| 1027 } | 1028 } |
| 1028 | 1029 |
| 1029 void DesktopNativeWidgetAura::UpdateWindowTransparency() { | 1030 void DesktopNativeWidgetAura::UpdateWindowTransparency() { |
| 1030 window_->SetTransparent(ShouldUseNativeFrame()); | 1031 window_->SetTransparent(ShouldUseNativeFrame()); |
| 1031 } | 1032 } |
| 1032 | 1033 |
| 1033 } // namespace views | 1034 } // namespace views |
| OLD | NEW |