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_drag_drop_client_aurax11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h" |
6 | 6 |
7 #include <X11/Xatom.h> | 7 #include <X11/Xatom.h> |
8 | 8 |
9 #include "base/event_types.h" | 9 #include "base/event_types.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/histogram_macros.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 13 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
14 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
15 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
16 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
17 #include "ui/base/dragdrop/drop_target_event.h" | 18 #include "ui/base/dragdrop/drop_target_event.h" |
18 #include "ui/base/dragdrop/os_exchange_data.h" | 19 #include "ui/base/dragdrop/os_exchange_data.h" |
19 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 20 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
20 #include "ui/base/x/selection_utils.h" | 21 #include "ui/base/x/selection_utils.h" |
21 #include "ui/base/x/x11_foreign_window_manager.h" | 22 #include "ui/base/x/x11_foreign_window_manager.h" |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 target_window_location_, | 604 target_window_location_, |
604 target_window_root_location_, | 605 target_window_root_location_, |
605 target_current_context_->GetDragOperation()); | 606 target_current_context_->GetDragOperation()); |
606 if (target_current_context_->source_client()) { | 607 if (target_current_context_->source_client()) { |
607 event.set_flags(target_current_context_->source_client() | 608 event.set_flags(target_current_context_->source_client() |
608 ->current_modifier_state()); | 609 ->current_modifier_state()); |
609 } else { | 610 } else { |
610 event.set_flags(XGetModifiers()); | 611 event.set_flags(XGetModifiers()); |
611 } | 612 } |
612 | 613 |
| 614 if (!IsDragDropInProgress()) { |
| 615 UMA_HISTOGRAM_COUNTS("Event.DragDrop.ExternalOriginDrop", 1); |
| 616 } |
| 617 |
613 drag_operation = delegate->OnPerformDrop(event); | 618 drag_operation = delegate->OnPerformDrop(event); |
614 } | 619 } |
615 | 620 |
616 target_window_->RemoveObserver(this); | 621 target_window_->RemoveObserver(this); |
617 target_window_ = NULL; | 622 target_window_ = NULL; |
618 } | 623 } |
619 | 624 |
620 XEvent xev; | 625 XEvent xev; |
621 xev.xclient.type = ClientMessage; | 626 xev.xclient.type = ClientMessage; |
622 xev.xclient.message_type = atom_cache_.GetAtom("XdndFinished"); | 627 xev.xclient.message_type = atom_cache_.GetAtom("XdndFinished"); |
(...skipping 16 matching lines...) Expand all Loading... |
639 XDeleteProperty(xdisplay_, xwindow_, xselection.property); | 644 XDeleteProperty(xdisplay_, xwindow_, xselection.property); |
640 } | 645 } |
641 | 646 |
642 int DesktopDragDropClientAuraX11::StartDragAndDrop( | 647 int DesktopDragDropClientAuraX11::StartDragAndDrop( |
643 const ui::OSExchangeData& data, | 648 const ui::OSExchangeData& data, |
644 aura::Window* root_window, | 649 aura::Window* root_window, |
645 aura::Window* source_window, | 650 aura::Window* source_window, |
646 const gfx::Point& root_location, | 651 const gfx::Point& root_location, |
647 int operation, | 652 int operation, |
648 ui::DragDropTypes::DragEventSource source) { | 653 ui::DragDropTypes::DragEventSource source) { |
| 654 UMA_HISTOGRAM_ENUMERATION("Event.DragDrop.Start", source, |
| 655 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 656 |
649 source_current_window_ = None; | 657 source_current_window_ = None; |
650 DCHECK(!g_current_drag_drop_client); | 658 DCHECK(!g_current_drag_drop_client); |
651 g_current_drag_drop_client = this; | 659 g_current_drag_drop_client = this; |
652 waiting_on_status_ = false; | 660 waiting_on_status_ = false; |
653 next_position_message_.reset(); | 661 next_position_message_.reset(); |
654 status_received_since_enter_ = false; | 662 status_received_since_enter_ = false; |
655 source_state_ = SOURCE_STATE_OTHER; | 663 source_state_ = SOURCE_STATE_OTHER; |
656 drag_operation_ = operation; | 664 drag_operation_ = operation; |
657 negotiated_operation_ = ui::DragDropTypes::DRAG_NONE; | 665 negotiated_operation_ = ui::DragDropTypes::DRAG_NONE; |
658 | 666 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 weak_ptr_factory_.GetWeakPtr()); | 700 weak_ptr_factory_.GetWeakPtr()); |
693 | 701 |
694 // Windows has a specific method, DoDragDrop(), which performs the entire | 702 // Windows has a specific method, DoDragDrop(), which performs the entire |
695 // drag. We have to emulate this, so we spin off a nested runloop which will | 703 // drag. We have to emulate this, so we spin off a nested runloop which will |
696 // track all cursor movement and reroute events to a specific handler. | 704 // track all cursor movement and reroute events to a specific handler. |
697 move_loop_->RunMoveLoop( | 705 move_loop_->RunMoveLoop( |
698 source_window, | 706 source_window, |
699 cursor_manager_->GetInitializedCursor(ui::kCursorGrabbing)); | 707 cursor_manager_->GetInitializedCursor(ui::kCursorGrabbing)); |
700 | 708 |
701 if (alive) { | 709 if (alive) { |
| 710 if (negotiated_operation_ == ui::DragDropTypes::DRAG_NONE) { |
| 711 UMA_HISTOGRAM_ENUMERATION("Event.DragDrop.Cancel", source, |
| 712 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 713 } else { |
| 714 UMA_HISTOGRAM_ENUMERATION("Event.DragDrop.Drop", source, |
| 715 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 716 } |
702 drag_widget_.reset(); | 717 drag_widget_.reset(); |
703 | 718 |
704 source_provider_ = NULL; | 719 source_provider_ = NULL; |
705 g_current_drag_drop_client = NULL; | 720 g_current_drag_drop_client = NULL; |
706 drag_operation_ = 0; | 721 drag_operation_ = 0; |
707 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndActionList")); | 722 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndActionList")); |
708 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom(kXdndDirectSave0)); | 723 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom(kXdndDirectSave0)); |
709 | 724 |
710 return negotiated_operation_; | 725 return negotiated_operation_; |
711 } | 726 } |
| 727 UMA_HISTOGRAM_ENUMERATION("Event.DragDrop.Cancel", source, |
| 728 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
712 return ui::DragDropTypes::DRAG_NONE; | 729 return ui::DragDropTypes::DRAG_NONE; |
713 } | 730 } |
714 | 731 |
715 void DesktopDragDropClientAuraX11::DragUpdate(aura::Window* target, | 732 void DesktopDragDropClientAuraX11::DragUpdate(aura::Window* target, |
716 const ui::LocatedEvent& event) { | 733 const ui::LocatedEvent& event) { |
717 NOTIMPLEMENTED(); | 734 NOTIMPLEMENTED(); |
718 } | 735 } |
719 | 736 |
720 void DesktopDragDropClientAuraX11::Drop(aura::Window* target, | 737 void DesktopDragDropClientAuraX11::Drop(aura::Window* target, |
721 const ui::LocatedEvent& event) { | 738 const ui::LocatedEvent& event) { |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 for (int x = 0; x < in_bitmap->width(); ++x) { | 1209 for (int x = 0; x < in_bitmap->width(); ++x) { |
1193 if (SkColorGetA(in_row[x]) > kMinAlpha) | 1210 if (SkColorGetA(in_row[x]) > kMinAlpha) |
1194 return true; | 1211 return true; |
1195 } | 1212 } |
1196 } | 1213 } |
1197 | 1214 |
1198 return false; | 1215 return false; |
1199 } | 1216 } |
1200 | 1217 |
1201 } // namespace views | 1218 } // namespace views |
OLD | NEW |