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/stacking_client.h" | 8 #include "ui/aura/client/stacking_client.h" |
9 #include "ui/aura/focus_manager.h" | 9 #include "ui/aura/focus_manager.h" |
10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
11 #include "ui/aura/root_window_host.h" | 11 #include "ui/aura/root_window_host.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/aura/window_property.h" | 13 #include "ui/aura/window_property.h" |
14 #include "ui/base/hit_test.h" | 14 #include "ui/base/hit_test.h" |
15 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
17 #include "ui/native_theme/native_theme.h" | 17 #include "ui/native_theme/native_theme.h" |
| 18 #include "ui/views/drag_utils.h" |
18 #include "ui/views/ime/input_method.h" | 19 #include "ui/views/ime/input_method.h" |
19 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" | 20 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" |
| 21 #include "ui/views/widget/drop_helper.h" |
20 #include "ui/views/widget/native_widget_aura_window_observer.h" | 22 #include "ui/views/widget/native_widget_aura_window_observer.h" |
| 23 #include "ui/views/widget/root_view.h" |
21 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
22 #include "ui/views/widget/widget_aura_utils.h" | 25 #include "ui/views/widget/widget_aura_utils.h" |
23 | 26 |
24 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, | 27 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, |
25 views::DesktopNativeWidgetAura*); | 28 views::DesktopNativeWidgetAura*); |
26 | 29 |
27 namespace views { | 30 namespace views { |
28 | 31 |
29 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, | 32 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, |
30 kDesktopNativeWidgetAuraKey, NULL); | 33 kDesktopNativeWidgetAuraKey, NULL); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 window_->Show(); | 107 window_->Show(); |
105 | 108 |
106 desktop_root_window_host_ = params.desktop_root_window_host ? | 109 desktop_root_window_host_ = params.desktop_root_window_host ? |
107 params.desktop_root_window_host : | 110 params.desktop_root_window_host : |
108 DesktopRootWindowHost::Create(native_widget_delegate_, | 111 DesktopRootWindowHost::Create(native_widget_delegate_, |
109 this, params.bounds); | 112 this, params.bounds); |
110 root_window_.reset( | 113 root_window_.reset( |
111 desktop_root_window_host_->Init(window_, params)); | 114 desktop_root_window_host_->Init(window_, params)); |
112 stacking_client_.reset( | 115 stacking_client_.reset( |
113 new DesktopNativeWidgetAuraStackingClient(root_window_.get())); | 116 new DesktopNativeWidgetAuraStackingClient(root_window_.get())); |
| 117 drop_helper_.reset(new DropHelper( |
| 118 static_cast<internal::RootView*>(GetWidget()->GetRootView()))); |
| 119 aura::client::SetDragDropDelegate(window_, this); |
114 | 120 |
115 aura::client::SetActivationDelegate(window_, this); | 121 aura::client::SetActivationDelegate(window_, this); |
116 } | 122 } |
117 | 123 |
118 NonClientFrameView* DesktopNativeWidgetAura::CreateNonClientFrameView() { | 124 NonClientFrameView* DesktopNativeWidgetAura::CreateNonClientFrameView() { |
119 return desktop_root_window_host_->CreateNonClientFrameView(); | 125 return desktop_root_window_host_->CreateNonClientFrameView(); |
120 } | 126 } |
121 | 127 |
122 bool DesktopNativeWidgetAura::ShouldUseNativeFrame() const { | 128 bool DesktopNativeWidgetAura::ShouldUseNativeFrame() const { |
123 return desktop_root_window_host_->ShouldUseNativeFrame(); | 129 return desktop_root_window_host_->ShouldUseNativeFrame(); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 370 } |
365 | 371 |
366 void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) { | 372 void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) { |
367 desktop_root_window_host_->FlashFrame(flash_frame); | 373 desktop_root_window_host_->FlashFrame(flash_frame); |
368 } | 374 } |
369 | 375 |
370 bool DesktopNativeWidgetAura::IsAccessibleWidget() const { | 376 bool DesktopNativeWidgetAura::IsAccessibleWidget() const { |
371 return false; | 377 return false; |
372 } | 378 } |
373 | 379 |
374 void DesktopNativeWidgetAura::RunShellDrag(View* view, | 380 void DesktopNativeWidgetAura::RunShellDrag( |
| 381 View* view, |
375 const ui::OSExchangeData& data, | 382 const ui::OSExchangeData& data, |
376 const gfx::Point& location, | 383 const gfx::Point& location, |
377 int operation, | 384 int operation, |
378 ui::DragDropTypes::DragEventSource source) { | 385 ui::DragDropTypes::DragEventSource source) { |
| 386 views::RunShellDrag(window_, data, location, operation, source); |
379 } | 387 } |
380 | 388 |
381 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { | 389 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { |
382 if (window_) | 390 if (window_) |
383 window_->SchedulePaintInRect(rect); | 391 window_->SchedulePaintInRect(rect); |
384 } | 392 } |
385 | 393 |
386 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { | 394 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { |
387 desktop_root_window_host_->AsRootWindowHost()->SetCursor(cursor); | 395 desktop_root_window_host_->AsRootWindowHost()->SetCursor(cursor); |
388 } | 396 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 if (IsVisible() && GetWidget()->non_client_view()) | 598 if (IsVisible() && GetWidget()->non_client_view()) |
591 GetWidget()->non_client_view()->SchedulePaint(); | 599 GetWidget()->non_client_view()->SchedulePaint(); |
592 } | 600 } |
593 | 601 |
594 void DesktopNativeWidgetAura::OnLostActive() { | 602 void DesktopNativeWidgetAura::OnLostActive() { |
595 native_widget_delegate_->OnNativeWidgetActivationChanged(false); | 603 native_widget_delegate_->OnNativeWidgetActivationChanged(false); |
596 if (IsVisible() && GetWidget()->non_client_view()) | 604 if (IsVisible() && GetWidget()->non_client_view()) |
597 GetWidget()->non_client_view()->SchedulePaint(); | 605 GetWidget()->non_client_view()->SchedulePaint(); |
598 } | 606 } |
599 | 607 |
| 608 //////////////////////////////////////////////////////////////////////////////// |
| 609 // DesktopNativeWidgetAura, aura::WindowDragDropDelegate implementation: |
| 610 |
| 611 void DesktopNativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { |
| 612 DCHECK(drop_helper_.get() != NULL); |
| 613 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), |
| 614 event.location(), event.source_operations()); |
| 615 } |
| 616 |
| 617 int DesktopNativeWidgetAura::OnDragUpdated(const ui::DropTargetEvent& event) { |
| 618 DCHECK(drop_helper_.get() != NULL); |
| 619 last_drop_operation_ = drop_helper_->OnDragOver(event.data(), |
| 620 event.location(), event.source_operations()); |
| 621 return last_drop_operation_; |
| 622 } |
| 623 |
| 624 void DesktopNativeWidgetAura::OnDragExited() { |
| 625 DCHECK(drop_helper_.get() != NULL); |
| 626 drop_helper_->OnDragExit(); |
| 627 } |
| 628 |
| 629 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) { |
| 630 DCHECK(drop_helper_.get() != NULL); |
| 631 return drop_helper_->OnDrop(event.data(), event.location(), |
| 632 last_drop_operation_); |
| 633 } |
| 634 |
600 } // namespace views | 635 } // namespace views |
OLD | NEW |