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/debug/trace_event.h" | 8 #include "base/debug/trace_event.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/window_tree_client.h" | 12 #include "ui/aura/client/window_tree_client.h" |
13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
15 #include "ui/aura/window_property.h" | |
16 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
17 #include "ui/base/hit_test.h" | 16 #include "ui/base/hit_test.h" |
18 #include "ui/base/ui_base_switches_util.h" | 17 #include "ui/base/ui_base_switches_util.h" |
19 #include "ui/compositor/layer.h" | 18 #include "ui/compositor/layer.h" |
20 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/display.h" | 20 #include "ui/gfx/display.h" |
22 #include "ui/gfx/point_conversions.h" | 21 #include "ui/gfx/point_conversions.h" |
23 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
24 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
25 #include "ui/gfx/size_conversions.h" | 24 #include "ui/gfx/size_conversions.h" |
26 #include "ui/native_theme/native_theme.h" | 25 #include "ui/native_theme/native_theme.h" |
27 #include "ui/views/corewm/tooltip.h" | 26 #include "ui/views/corewm/tooltip.h" |
28 #include "ui/views/corewm/tooltip_controller.h" | 27 #include "ui/views/corewm/tooltip_controller.h" |
29 #include "ui/views/drag_utils.h" | 28 #include "ui/views/drag_utils.h" |
30 #include "ui/views/ime/input_method_bridge.h" | 29 #include "ui/views/ime/input_method_bridge.h" |
31 #include "ui/views/ime/null_input_method.h" | 30 #include "ui/views/ime/null_input_method.h" |
32 #include "ui/views/view_constants_aura.h" | 31 #include "ui/views/view_constants_aura.h" |
33 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" | 32 #include "ui/views/widget/desktop_aura/desktop_capture_client.h" |
34 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" | 33 #include "ui/views/widget/desktop_aura/desktop_cursor_loader_updater.h" |
35 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" | 34 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" |
36 #include "ui/views/widget/desktop_aura/desktop_event_client.h" | 35 #include "ui/views/widget/desktop_aura/desktop_event_client.h" |
37 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" | 36 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" |
38 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" | 37 #include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h" |
38 #include "ui/views/widget/desktop_aura/desktop_native_widget_constants.h" | |
sadrul
2014/12/16 17:25:16
Is this file missing too?
oshima
2014/12/16 21:09:12
removed. my local build passed because the file wa
| |
39 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 39 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
40 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" | 40 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
41 #include "ui/views/widget/drop_helper.h" | 41 #include "ui/views/widget/drop_helper.h" |
42 #include "ui/views/widget/native_widget_aura.h" | 42 #include "ui/views/widget/native_widget_aura.h" |
43 #include "ui/views/widget/root_view.h" | 43 #include "ui/views/widget/root_view.h" |
44 #include "ui/views/widget/tooltip_manager_aura.h" | 44 #include "ui/views/widget/tooltip_manager_aura.h" |
45 #include "ui/views/widget/widget.h" | 45 #include "ui/views/widget/widget.h" |
46 #include "ui/views/widget/widget_aura_utils.h" | 46 #include "ui/views/widget/widget_aura_utils.h" |
47 #include "ui/views/widget/widget_delegate.h" | 47 #include "ui/views/widget/widget_delegate.h" |
48 #include "ui/views/widget/window_reorderer.h" | 48 #include "ui/views/widget/window_reorderer.h" |
49 #include "ui/views/window/native_frame_view.h" | 49 #include "ui/views/window/native_frame_view.h" |
50 #include "ui/wm/core/compound_event_filter.h" | 50 #include "ui/wm/core/compound_event_filter.h" |
51 #include "ui/wm/core/cursor_manager.h" | 51 #include "ui/wm/core/cursor_manager.h" |
52 #include "ui/wm/core/focus_controller.h" | 52 #include "ui/wm/core/focus_controller.h" |
53 #include "ui/wm/core/input_method_event_filter.h" | 53 #include "ui/wm/core/input_method_event_filter.h" |
54 #include "ui/wm/core/native_cursor_manager.h" | 54 #include "ui/wm/core/native_cursor_manager.h" |
55 #include "ui/wm/core/shadow_controller.h" | 55 #include "ui/wm/core/shadow_controller.h" |
56 #include "ui/wm/core/shadow_types.h" | 56 #include "ui/wm/core/shadow_types.h" |
57 #include "ui/wm/core/visibility_controller.h" | 57 #include "ui/wm/core/visibility_controller.h" |
58 #include "ui/wm/core/window_animations.h" | 58 #include "ui/wm/core/window_animations.h" |
59 #include "ui/wm/core/window_modality_controller.h" | 59 #include "ui/wm/core/window_modality_controller.h" |
60 #include "ui/wm/public/activation_client.h" | 60 #include "ui/wm/public/activation_client.h" |
61 #include "ui/wm/public/drag_drop_client.h" | 61 #include "ui/wm/public/drag_drop_client.h" |
62 | 62 |
63 #if defined(OS_WIN) | 63 #if defined(OS_WIN) |
64 #include "ui/base/win/shell.h" | 64 #include "ui/base/win/shell.h" |
65 #include "ui/gfx/win/dpi.h" | 65 #include "ui/gfx/win/dpi.h" |
66 #endif | 66 #endif |
67 | 67 |
68 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, | |
69 views::DesktopNativeWidgetAura*); | |
70 | |
71 namespace views { | 68 namespace views { |
72 | |
73 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, | |
74 kDesktopNativeWidgetAuraKey, NULL); | |
75 | |
76 namespace { | 69 namespace { |
77 | 70 |
78 // This class provides functionality to create a top level widget to host a | 71 // This class provides functionality to create a top level widget to host a |
79 // child window. | 72 // child window. |
80 class DesktopNativeWidgetTopLevelHandler : public aura::WindowObserver { | 73 class DesktopNativeWidgetTopLevelHandler : public aura::WindowObserver { |
81 public: | 74 public: |
82 // This function creates a widget with the bounds passed in which eventually | 75 // This function creates a widget with the bounds passed in which eventually |
83 // becomes the parent of the child window passed in. | 76 // becomes the parent of the child window passed in. |
84 static aura::Window* CreateParentWindow(aura::Window* child_window, | 77 static aura::Window* CreateParentWindow(aura::Window* child_window, |
85 const gfx::Rect& bounds, | 78 const gfx::Rect& bounds, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 aura::client::SetActivationChangeObserver(content_window_, this); | 259 aura::client::SetActivationChangeObserver(content_window_, this); |
267 } | 260 } |
268 | 261 |
269 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { | 262 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { |
270 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 263 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
271 delete native_widget_delegate_; | 264 delete native_widget_delegate_; |
272 else | 265 else |
273 CloseNow(); | 266 CloseNow(); |
274 } | 267 } |
275 | 268 |
276 // static | |
277 DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow( | |
278 aura::Window* window) { | |
279 return window->GetProperty(kDesktopNativeWidgetAuraKey); | |
280 } | |
281 | |
282 void DesktopNativeWidgetAura::OnHostClosed() { | 269 void DesktopNativeWidgetAura::OnHostClosed() { |
283 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by | 270 // Don't invoke Widget::OnNativeWidgetDestroying(), its done by |
284 // DesktopWindowTreeHost. | 271 // DesktopWindowTreeHost. |
285 | 272 |
286 // The WindowModalityController is at the front of the event pretarget | 273 // The WindowModalityController is at the front of the event pretarget |
287 // handler list. We destroy it first to preserve order symantics. | 274 // handler list. We destroy it first to preserve order symantics. |
288 if (window_modality_controller_) | 275 if (window_modality_controller_) |
289 window_modality_controller_.reset(); | 276 window_modality_controller_.reset(); |
290 | 277 |
291 // Make sure we don't have capture. Otherwise CaptureController and | 278 // Make sure we don't have capture. Otherwise CaptureController and |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
415 content_window_container_->AddChild(content_window_); | 402 content_window_container_->AddChild(content_window_); |
416 | 403 |
417 desktop_window_tree_host_ = params.desktop_window_tree_host ? | 404 desktop_window_tree_host_ = params.desktop_window_tree_host ? |
418 params.desktop_window_tree_host : | 405 params.desktop_window_tree_host : |
419 DesktopWindowTreeHost::Create(native_widget_delegate_, this); | 406 DesktopWindowTreeHost::Create(native_widget_delegate_, this); |
420 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); | 407 host_.reset(desktop_window_tree_host_->AsWindowTreeHost()); |
421 desktop_window_tree_host_->Init(content_window_, params); | 408 desktop_window_tree_host_->Init(content_window_, params); |
422 | 409 |
423 host_->InitHost(); | 410 host_->InitHost(); |
424 host_->window()->AddChild(content_window_container_); | 411 host_->window()->AddChild(content_window_container_); |
425 host_->window()->SetProperty(kDesktopNativeWidgetAuraKey, this); | 412 |
413 SetForWindow(host_->window(), this); | |
426 | 414 |
427 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); | 415 host_->window()->AddObserver(new RootWindowDestructionObserver(this)); |
428 | 416 |
429 // The WindowsModalityController event filter should be at the head of the | 417 // The WindowsModalityController event filter should be at the head of the |
430 // pre target handlers list. This ensures that it handles input events first | 418 // pre target handlers list. This ensures that it handles input events first |
431 // when modal windows are at the top of the Zorder. | 419 // when modal windows are at the top of the Zorder. |
432 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) | 420 if (widget_type_ == Widget::InitParams::TYPE_WINDOW) |
433 window_modality_controller_.reset( | 421 window_modality_controller_.reset( |
434 new wm::WindowModalityController(host_->window())); | 422 new wm::WindowModalityController(host_->window())); |
435 | 423 |
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1229 if (cursor_reference_count_ == 0) { | 1217 if (cursor_reference_count_ == 0) { |
1230 // We are the last DesktopNativeWidgetAura instance, and we are responsible | 1218 // We are the last DesktopNativeWidgetAura instance, and we are responsible |
1231 // for cleaning up |cursor_manager_|. | 1219 // for cleaning up |cursor_manager_|. |
1232 delete cursor_manager_; | 1220 delete cursor_manager_; |
1233 native_cursor_manager_ = NULL; | 1221 native_cursor_manager_ = NULL; |
1234 cursor_manager_ = NULL; | 1222 cursor_manager_ = NULL; |
1235 } | 1223 } |
1236 } | 1224 } |
1237 | 1225 |
1238 } // namespace views | 1226 } // namespace views |
OLD | NEW |