| 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("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("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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 base::WeakPtr<DesktopDragDropClientAuraX11> alive( | 699 base::WeakPtr<DesktopDragDropClientAuraX11> alive( |
| 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 |
| 709 if (negotiated_operation_ == ui::DragDropTypes::DRAG_NONE) { |
| 710 UMA_HISTOGRAM_ENUMERATION("DragDrop.Cancel", source, |
| 711 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 712 } else { |
| 713 UMA_HISTOGRAM_ENUMERATION("DragDrop.Drop", source, |
| 714 ui::DragDropTypes::DRAG_EVENT_SOURCE_COUNT); |
| 715 } |
| 716 |
| 701 if (alive) { | 717 if (alive) { |
| 702 drag_widget_.reset(); | 718 drag_widget_.reset(); |
| 703 | 719 |
| 704 source_provider_ = NULL; | 720 source_provider_ = NULL; |
| 705 g_current_drag_drop_client = NULL; | 721 g_current_drag_drop_client = NULL; |
| 706 drag_operation_ = 0; | 722 drag_operation_ = 0; |
| 707 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndActionList")); | 723 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom("XdndActionList")); |
| 708 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom(kXdndDirectSave0)); | 724 XDeleteProperty(xdisplay_, xwindow_, atom_cache_.GetAtom(kXdndDirectSave0)); |
| 709 | 725 |
| 710 return negotiated_operation_; | 726 return negotiated_operation_; |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 for (int x = 0; x < in_bitmap->width(); ++x) { | 1208 for (int x = 0; x < in_bitmap->width(); ++x) { |
| 1193 if (SkColorGetA(in_row[x]) > kMinAlpha) | 1209 if (SkColorGetA(in_row[x]) > kMinAlpha) |
| 1194 return true; | 1210 return true; |
| 1195 } | 1211 } |
| 1196 } | 1212 } |
| 1197 | 1213 |
| 1198 return false; | 1214 return false; |
| 1199 } | 1215 } |
| 1200 | 1216 |
| 1201 } // namespace views | 1217 } // namespace views |
| OLD | NEW |