Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 11444013: Get drag and drop working for win aura. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/corewm/compound_event_filter.h" 18 #include "ui/views/corewm/compound_event_filter.h"
19 #include "ui/views/corewm/input_method_event_filter.h" 19 #include "ui/views/corewm/input_method_event_filter.h"
20 #include "ui/views/drag_utils.h"
20 #include "ui/views/ime/input_method.h" 21 #include "ui/views/ime/input_method.h"
21 #include "ui/views/ime/input_method_bridge.h" 22 #include "ui/views/ime/input_method_bridge.h"
22 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" 23 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h"
24 #include "ui/views/widget/drop_helper.h"
23 #include "ui/views/widget/native_widget_aura_window_observer.h" 25 #include "ui/views/widget/native_widget_aura_window_observer.h"
26 #include "ui/views/widget/root_view.h"
24 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
25 #include "ui/views/widget/widget_aura_utils.h" 28 #include "ui/views/widget/widget_aura_utils.h"
26 29
27 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT, 30 DECLARE_EXPORTED_WINDOW_PROPERTY_TYPE(VIEWS_EXPORT,
28 views::DesktopNativeWidgetAura*); 31 views::DesktopNativeWidgetAura*);
29 32
30 namespace views { 33 namespace views {
31 34
32 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*, 35 DEFINE_WINDOW_PROPERTY_KEY(DesktopNativeWidgetAura*,
33 kDesktopNativeWidgetAuraKey, NULL); 36 kDesktopNativeWidgetAuraKey, NULL);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 window_->Show(); 129 window_->Show();
127 130
128 desktop_root_window_host_ = params.desktop_root_window_host ? 131 desktop_root_window_host_ = params.desktop_root_window_host ?
129 params.desktop_root_window_host : 132 params.desktop_root_window_host :
130 DesktopRootWindowHost::Create(native_widget_delegate_, 133 DesktopRootWindowHost::Create(native_widget_delegate_,
131 this, params.bounds); 134 this, params.bounds);
132 root_window_.reset( 135 root_window_.reset(
133 desktop_root_window_host_->Init(window_, params)); 136 desktop_root_window_host_->Init(window_, params));
134 stacking_client_.reset( 137 stacking_client_.reset(
135 new DesktopNativeWidgetAuraStackingClient(root_window_.get())); 138 new DesktopNativeWidgetAuraStackingClient(root_window_.get()));
139 drop_helper_.reset(new DropHelper(
140 static_cast<internal::RootView*>(GetWidget()->GetRootView())));
141 aura::client::SetDragDropDelegate(window_, this);
136 142
137 aura::client::SetActivationDelegate(window_, this); 143 aura::client::SetActivationDelegate(window_, this);
138 } 144 }
139 145
140 NonClientFrameView* DesktopNativeWidgetAura::CreateNonClientFrameView() { 146 NonClientFrameView* DesktopNativeWidgetAura::CreateNonClientFrameView() {
141 return desktop_root_window_host_->CreateNonClientFrameView(); 147 return desktop_root_window_host_->CreateNonClientFrameView();
142 } 148 }
143 149
144 bool DesktopNativeWidgetAura::ShouldUseNativeFrame() const { 150 bool DesktopNativeWidgetAura::ShouldUseNativeFrame() const {
145 return desktop_root_window_host_->ShouldUseNativeFrame(); 151 return desktop_root_window_host_->ShouldUseNativeFrame();
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 393 }
388 394
389 void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) { 395 void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) {
390 desktop_root_window_host_->FlashFrame(flash_frame); 396 desktop_root_window_host_->FlashFrame(flash_frame);
391 } 397 }
392 398
393 bool DesktopNativeWidgetAura::IsAccessibleWidget() const { 399 bool DesktopNativeWidgetAura::IsAccessibleWidget() const {
394 return false; 400 return false;
395 } 401 }
396 402
397 void DesktopNativeWidgetAura::RunShellDrag(View* view, 403 void DesktopNativeWidgetAura::RunShellDrag(
404 View* view,
398 const ui::OSExchangeData& data, 405 const ui::OSExchangeData& data,
399 const gfx::Point& location, 406 const gfx::Point& location,
400 int operation, 407 int operation,
401 ui::DragDropTypes::DragEventSource source) { 408 ui::DragDropTypes::DragEventSource source) {
409 views::RunShellDrag(window_, data, location, operation, source);
402 } 410 }
403 411
404 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { 412 void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) {
405 if (window_) 413 if (window_)
406 window_->SchedulePaintInRect(rect); 414 window_->SchedulePaintInRect(rect);
407 } 415 }
408 416
409 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) { 417 void DesktopNativeWidgetAura::SetCursor(gfx::NativeCursor cursor) {
410 desktop_root_window_host_->AsRootWindowHost()->SetCursor(cursor); 418 desktop_root_window_host_->AsRootWindowHost()->SetCursor(cursor);
411 } 419 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 } 523 }
516 524
517 void DesktopNativeWidgetAura::OnWindowDestroying() { 525 void DesktopNativeWidgetAura::OnWindowDestroying() {
518 native_widget_delegate_->OnNativeWidgetDestroying(); 526 native_widget_delegate_->OnNativeWidgetDestroying();
519 } 527 }
520 528
521 void DesktopNativeWidgetAura::OnWindowDestroyed() { 529 void DesktopNativeWidgetAura::OnWindowDestroyed() {
522 window_ = NULL; 530 window_ = NULL;
523 native_widget_delegate_->OnNativeWidgetDestroyed(); 531 native_widget_delegate_->OnNativeWidgetDestroyed();
524 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 532 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
525 delete this; 533 delete this;
526 } 534 }
527 535
528 void DesktopNativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { 536 void DesktopNativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) {
529 } 537 }
530 538
531 bool DesktopNativeWidgetAura::HasHitTestMask() const { 539 bool DesktopNativeWidgetAura::HasHitTestMask() const {
532 return native_widget_delegate_->HasHitTestMask(); 540 return native_widget_delegate_->HasHitTestMask();
533 } 541 }
534 542
535 void DesktopNativeWidgetAura::GetHitTestMask(gfx::Path* mask) const { 543 void DesktopNativeWidgetAura::GetHitTestMask(gfx::Path* mask) const {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate: 634 // DesktopNativeWidgetAura, views::internal::InputMethodDelegate:
627 635
628 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) { 636 void DesktopNativeWidgetAura::DispatchKeyEventPostIME(const ui::KeyEvent& key) {
629 FocusManager* focus_manager = 637 FocusManager* focus_manager =
630 native_widget_delegate_->AsWidget()->GetFocusManager(); 638 native_widget_delegate_->AsWidget()->GetFocusManager();
631 if (native_widget_delegate_->OnKeyEvent(key) || !focus_manager) 639 if (native_widget_delegate_->OnKeyEvent(key) || !focus_manager)
632 return; 640 return;
633 focus_manager->OnKeyEvent(key); 641 focus_manager->OnKeyEvent(key);
634 } 642 }
635 643
644 ////////////////////////////////////////////////////////////////////////////////
645 // DesktopNativeWidgetAura, aura::WindowDragDropDelegate implementation:
646
647 void DesktopNativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) {
648 DCHECK(drop_helper_.get() != NULL);
649 last_drop_operation_ = drop_helper_->OnDragOver(event.data(),
650 event.location(), event.source_operations());
651 }
652
653 int DesktopNativeWidgetAura::OnDragUpdated(const ui::DropTargetEvent& event) {
654 DCHECK(drop_helper_.get() != NULL);
655 last_drop_operation_ = drop_helper_->OnDragOver(event.data(),
656 event.location(), event.source_operations());
657 return last_drop_operation_;
658 }
659
660 void DesktopNativeWidgetAura::OnDragExited() {
661 DCHECK(drop_helper_.get() != NULL);
662 drop_helper_->OnDragExit();
663 }
664
665 int DesktopNativeWidgetAura::OnPerformDrop(const ui::DropTargetEvent& event) {
666 DCHECK(drop_helper_.get() != NULL);
667 return drop_helper_->OnDrop(event.data(), event.location(),
668 last_drop_operation_);
669 }
670
636 } // namespace views 671 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | ui/views/widget/desktop_aura/desktop_root_window_host_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698