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 "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
12 #include "ui/aura/client/cursor_client.h" | 12 #include "ui/aura/client/cursor_client.h" |
13 #include "ui/aura/client/focus_client.h" | 13 #include "ui/aura/client/focus_client.h" |
14 #include "ui/aura/client/window_tree_client.h" | 14 #include "ui/aura/client/window_parenting_client.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/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
19 #include "ui/base/hit_test.h" | 19 #include "ui/base/hit_test.h" |
20 #include "ui/base/ime/input_method.h" | 20 #include "ui/base/ime/input_method.h" |
21 #include "ui/compositor/layer.h" | 21 #include "ui/compositor/layer.h" |
22 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
23 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
24 #include "ui/gfx/geometry/point_conversions.h" | 24 #include "ui/gfx/geometry/point_conversions.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 child_window_(NULL) {} | 161 child_window_(NULL) {} |
162 | 162 |
163 ~DesktopNativeWidgetTopLevelHandler() override {} | 163 ~DesktopNativeWidgetTopLevelHandler() override {} |
164 | 164 |
165 Widget* top_level_widget_; | 165 Widget* top_level_widget_; |
166 aura::Window* child_window_; | 166 aura::Window* child_window_; |
167 | 167 |
168 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetTopLevelHandler); | 168 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetTopLevelHandler); |
169 }; | 169 }; |
170 | 170 |
171 class DesktopNativeWidgetAuraWindowTreeClient : | 171 class DesktopNativeWidgetAuraWindowParentingClient |
172 public aura::client::WindowTreeClient { | 172 : public aura::client::WindowParentingClient { |
173 public: | 173 public: |
174 explicit DesktopNativeWidgetAuraWindowTreeClient( | 174 explicit DesktopNativeWidgetAuraWindowParentingClient( |
175 aura::Window* root_window) | 175 aura::Window* root_window) |
176 : root_window_(root_window) { | 176 : root_window_(root_window) { |
177 aura::client::SetWindowTreeClient(root_window_, this); | 177 aura::client::SetWindowParentingClient(root_window_, this); |
178 } | 178 } |
179 ~DesktopNativeWidgetAuraWindowTreeClient() override { | 179 ~DesktopNativeWidgetAuraWindowParentingClient() override { |
180 aura::client::SetWindowTreeClient(root_window_, NULL); | 180 aura::client::SetWindowParentingClient(root_window_, NULL); |
181 } | 181 } |
182 | 182 |
183 // Overridden from client::WindowTreeClient: | 183 // Overridden from client::WindowParentingClient: |
184 aura::Window* GetDefaultParent(aura::Window* context, | 184 aura::Window* GetDefaultParent(aura::Window* context, |
185 aura::Window* window, | 185 aura::Window* window, |
186 const gfx::Rect& bounds) override { | 186 const gfx::Rect& bounds) override { |
187 bool is_fullscreen = window->GetProperty(aura::client::kShowStateKey) == | 187 bool is_fullscreen = window->GetProperty(aura::client::kShowStateKey) == |
188 ui::SHOW_STATE_FULLSCREEN; | 188 ui::SHOW_STATE_FULLSCREEN; |
189 bool is_menu = window->type() == ui::wm::WINDOW_TYPE_MENU; | 189 bool is_menu = window->type() == ui::wm::WINDOW_TYPE_MENU; |
190 | 190 |
191 if (is_fullscreen || is_menu) { | 191 if (is_fullscreen || is_menu) { |
192 bool root_is_always_on_top = false; | 192 bool root_is_always_on_top = false; |
193 internal::NativeWidgetPrivate* native_widget = | 193 internal::NativeWidgetPrivate* native_widget = |
194 DesktopNativeWidgetAura::ForWindow(root_window_); | 194 DesktopNativeWidgetAura::ForWindow(root_window_); |
195 if (native_widget) | 195 if (native_widget) |
196 root_is_always_on_top = native_widget->IsAlwaysOnTop(); | 196 root_is_always_on_top = native_widget->IsAlwaysOnTop(); |
197 | 197 |
198 return DesktopNativeWidgetTopLevelHandler::CreateParentWindow( | 198 return DesktopNativeWidgetTopLevelHandler::CreateParentWindow( |
199 window, bounds, is_fullscreen, root_is_always_on_top); | 199 window, bounds, is_fullscreen, root_is_always_on_top); |
200 } | 200 } |
201 return root_window_; | 201 return root_window_; |
202 } | 202 } |
203 | 203 |
204 private: | 204 private: |
205 aura::Window* root_window_; | 205 aura::Window* root_window_; |
206 | 206 |
207 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAuraWindowTreeClient); | 207 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAuraWindowParentingClient); |
208 }; | 208 }; |
209 | 209 |
210 } // namespace | 210 } // namespace |
211 | 211 |
212 class RootWindowDestructionObserver : public aura::WindowObserver { | 212 class RootWindowDestructionObserver : public aura::WindowObserver { |
213 public: | 213 public: |
214 explicit RootWindowDestructionObserver(DesktopNativeWidgetAura* parent) | 214 explicit RootWindowDestructionObserver(DesktopNativeWidgetAura* parent) |
215 : parent_(parent) {} | 215 : parent_(parent) {} |
216 ~RootWindowDestructionObserver() override {} | 216 ~RootWindowDestructionObserver() override {} |
217 | 217 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // DesktopWindowTreeHost owns the ActivationController which ShadowController | 285 // DesktopWindowTreeHost owns the ActivationController which ShadowController |
286 // references. Make sure we destroy ShadowController early on. | 286 // references. Make sure we destroy ShadowController early on. |
287 shadow_controller_.reset(); | 287 shadow_controller_.reset(); |
288 tooltip_manager_.reset(); | 288 tooltip_manager_.reset(); |
289 if (tooltip_controller_.get()) { | 289 if (tooltip_controller_.get()) { |
290 host_->window()->RemovePreTargetHandler(tooltip_controller_.get()); | 290 host_->window()->RemovePreTargetHandler(tooltip_controller_.get()); |
291 aura::client::SetTooltipClient(host_->window(), NULL); | 291 aura::client::SetTooltipClient(host_->window(), NULL); |
292 tooltip_controller_.reset(); | 292 tooltip_controller_.reset(); |
293 } | 293 } |
294 | 294 |
295 window_tree_client_.reset(); // Uses host_->dispatcher() at destruction. | 295 window_parenting_client_.reset(); // Uses host_->dispatcher() at destruction. |
296 | 296 |
297 capture_client_.reset(); // Uses host_->dispatcher() at destruction. | 297 capture_client_.reset(); // Uses host_->dispatcher() at destruction. |
298 | 298 |
299 focus_manager_event_handler_.reset(); | 299 focus_manager_event_handler_.reset(); |
300 | 300 |
301 // FocusController uses |content_window_|. Destroy it now so that we don't | 301 // FocusController uses |content_window_|. Destroy it now so that we don't |
302 // have to worry about the possibility of FocusController attempting to use | 302 // have to worry about the possibility of FocusController attempting to use |
303 // |content_window_| after it's been destroyed but before all child windows | 303 // |content_window_| after it's been destroyed but before all child windows |
304 // have been destroyed. | 304 // have been destroyed. |
305 host_->window()->RemovePreTargetHandler(focus_client_.get()); | 305 host_->window()->RemovePreTargetHandler(focus_client_.get()); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 aura::client::SetDragDropClient(host_->window(), | 465 aura::client::SetDragDropClient(host_->window(), |
466 drag_drop_client_.get()); | 466 drag_drop_client_.get()); |
467 | 467 |
468 static_cast<aura::client::FocusClient*>(focus_client_.get())-> | 468 static_cast<aura::client::FocusClient*>(focus_client_.get())-> |
469 FocusWindow(content_window_); | 469 FocusWindow(content_window_); |
470 | 470 |
471 OnHostResized(host()); | 471 OnHostResized(host()); |
472 | 472 |
473 host_->AddObserver(this); | 473 host_->AddObserver(this); |
474 | 474 |
475 window_tree_client_.reset( | 475 window_parenting_client_.reset( |
476 new DesktopNativeWidgetAuraWindowTreeClient(host_->window())); | 476 new DesktopNativeWidgetAuraWindowParentingClient(host_->window())); |
477 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); | 477 drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); |
478 aura::client::SetDragDropDelegate(content_window_, this); | 478 aura::client::SetDragDropDelegate(content_window_, this); |
479 | 479 |
480 if (params.type != Widget::InitParams::TYPE_TOOLTIP) { | 480 if (params.type != Widget::InitParams::TYPE_TOOLTIP) { |
481 tooltip_manager_.reset(new TooltipManagerAura(GetWidget())); | 481 tooltip_manager_.reset(new TooltipManagerAura(GetWidget())); |
482 tooltip_controller_.reset( | 482 tooltip_controller_.reset( |
483 new corewm::TooltipController( | 483 new corewm::TooltipController( |
484 desktop_window_tree_host_->CreateTooltip())); | 484 desktop_window_tree_host_->CreateTooltip())); |
485 aura::client::SetTooltipClient(host_->window(), | 485 aura::client::SetTooltipClient(host_->window(), |
486 tooltip_controller_.get()); | 486 tooltip_controller_.get()); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1184 if (cursor_reference_count_ == 0) { | 1184 if (cursor_reference_count_ == 0) { |
1185 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1185 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1186 // for cleaning up |cursor_manager_|. | 1186 // for cleaning up |cursor_manager_|. |
1187 delete cursor_manager_; | 1187 delete cursor_manager_; |
1188 native_cursor_manager_ = NULL; | 1188 native_cursor_manager_ = NULL; |
1189 cursor_manager_ = NULL; | 1189 cursor_manager_ = NULL; |
1190 } | 1190 } |
1191 } | 1191 } |
1192 | 1192 |
1193 } // namespace views | 1193 } // namespace views |
OLD | NEW |