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 <stddef.h> | 8 #include <stddef.h> |
8 #include <stdint.h> | 9 #include <stdint.h> |
9 #include <X11/Xatom.h> | |
10 | 10 |
11 #include "base/event_types.h" | 11 #include "base/event_types.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
16 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
17 #include "ui/aura/client/capture_client.h" | 18 #include "ui/aura/client/capture_client.h" |
18 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
19 #include "ui/aura/window_tree_host.h" | 20 #include "ui/aura/window_tree_host.h" |
20 #include "ui/base/clipboard/clipboard.h" | 21 #include "ui/base/clipboard/clipboard.h" |
21 #include "ui/base/dragdrop/drop_target_event.h" | 22 #include "ui/base/dragdrop/drop_target_event.h" |
22 #include "ui/base/dragdrop/os_exchange_data.h" | 23 #include "ui/base/dragdrop/os_exchange_data.h" |
23 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" | 24 #include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h" |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 void DesktopDragDropClientAuraX11::OnMoveLoopEnded() { | 832 void DesktopDragDropClientAuraX11::OnMoveLoopEnded() { |
832 if (source_current_window_ != None) { | 833 if (source_current_window_ != None) { |
833 SendXdndLeave(source_current_window_); | 834 SendXdndLeave(source_current_window_); |
834 source_current_window_ = None; | 835 source_current_window_ = None; |
835 } | 836 } |
836 target_current_context_.reset(); | 837 target_current_context_.reset(); |
837 repeat_mouse_move_timer_.Stop(); | 838 repeat_mouse_move_timer_.Stop(); |
838 end_move_loop_timer_.Stop(); | 839 end_move_loop_timer_.Stop(); |
839 } | 840 } |
840 | 841 |
841 scoped_ptr<X11MoveLoop> DesktopDragDropClientAuraX11::CreateMoveLoop( | 842 std::unique_ptr<X11MoveLoop> DesktopDragDropClientAuraX11::CreateMoveLoop( |
842 X11MoveLoopDelegate* delegate) { | 843 X11MoveLoopDelegate* delegate) { |
843 return make_scoped_ptr(new X11WholeScreenMoveLoop(this)); | 844 return base::WrapUnique(new X11WholeScreenMoveLoop(this)); |
844 } | 845 } |
845 | 846 |
846 XID DesktopDragDropClientAuraX11::FindWindowFor( | 847 XID DesktopDragDropClientAuraX11::FindWindowFor( |
847 const gfx::Point& screen_point) { | 848 const gfx::Point& screen_point) { |
848 views::X11TopmostWindowFinder finder; | 849 views::X11TopmostWindowFinder finder; |
849 ::Window target = finder.FindWindowAt(screen_point); | 850 ::Window target = finder.FindWindowAt(screen_point); |
850 | 851 |
851 if (target == None) | 852 if (target == None) |
852 return None; | 853 return None; |
853 | 854 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 this, | 946 this, |
946 &DesktopDragDropClientAuraX11::EndMoveLoop); | 947 &DesktopDragDropClientAuraX11::EndMoveLoop); |
947 } | 948 } |
948 | 949 |
949 void DesktopDragDropClientAuraX11::EndMoveLoop() { | 950 void DesktopDragDropClientAuraX11::EndMoveLoop() { |
950 move_loop_->EndMoveLoop(); | 951 move_loop_->EndMoveLoop(); |
951 } | 952 } |
952 | 953 |
953 void DesktopDragDropClientAuraX11::DragTranslate( | 954 void DesktopDragDropClientAuraX11::DragTranslate( |
954 const gfx::Point& root_window_location, | 955 const gfx::Point& root_window_location, |
955 scoped_ptr<ui::OSExchangeData>* data, | 956 std::unique_ptr<ui::OSExchangeData>* data, |
956 scoped_ptr<ui::DropTargetEvent>* event, | 957 std::unique_ptr<ui::DropTargetEvent>* event, |
957 aura::client::DragDropDelegate** delegate) { | 958 aura::client::DragDropDelegate** delegate) { |
958 gfx::Point root_location = root_window_location; | 959 gfx::Point root_location = root_window_location; |
959 root_window_->GetHost()->ConvertPointFromNativeScreen(&root_location); | 960 root_window_->GetHost()->ConvertPointFromNativeScreen(&root_location); |
960 aura::Window* target_window = | 961 aura::Window* target_window = |
961 root_window_->GetEventHandlerForPoint(root_location); | 962 root_window_->GetEventHandlerForPoint(root_location); |
962 bool target_window_changed = false; | 963 bool target_window_changed = false; |
963 if (target_window != target_window_) { | 964 if (target_window != target_window_) { |
964 if (target_window_) | 965 if (target_window_) |
965 NotifyDragLeave(); | 966 NotifyDragLeave(); |
966 target_window_ = target_window; | 967 target_window_ = target_window; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 | 1059 |
1059 ui::SelectionFormatMap DesktopDragDropClientAuraX11::GetFormatMap() const { | 1060 ui::SelectionFormatMap DesktopDragDropClientAuraX11::GetFormatMap() const { |
1060 return source_provider_ ? source_provider_->GetFormatMap() : | 1061 return source_provider_ ? source_provider_->GetFormatMap() : |
1061 ui::SelectionFormatMap(); | 1062 ui::SelectionFormatMap(); |
1062 } | 1063 } |
1063 | 1064 |
1064 void DesktopDragDropClientAuraX11::CompleteXdndPosition( | 1065 void DesktopDragDropClientAuraX11::CompleteXdndPosition( |
1065 ::Window source_window, | 1066 ::Window source_window, |
1066 const gfx::Point& screen_point) { | 1067 const gfx::Point& screen_point) { |
1067 int drag_operation = ui::DragDropTypes::DRAG_NONE; | 1068 int drag_operation = ui::DragDropTypes::DRAG_NONE; |
1068 scoped_ptr<ui::OSExchangeData> data; | 1069 std::unique_ptr<ui::OSExchangeData> data; |
1069 scoped_ptr<ui::DropTargetEvent> drop_target_event; | 1070 std::unique_ptr<ui::DropTargetEvent> drop_target_event; |
1070 DragDropDelegate* delegate = NULL; | 1071 DragDropDelegate* delegate = NULL; |
1071 DragTranslate(screen_point, &data, &drop_target_event, &delegate); | 1072 DragTranslate(screen_point, &data, &drop_target_event, &delegate); |
1072 if (delegate) | 1073 if (delegate) |
1073 drag_operation = delegate->OnDragUpdated(*drop_target_event); | 1074 drag_operation = delegate->OnDragUpdated(*drop_target_event); |
1074 | 1075 |
1075 // Sends an XdndStatus message back to the source_window. l[2,3] | 1076 // Sends an XdndStatus message back to the source_window. l[2,3] |
1076 // theoretically represent an area in the window where the current action is | 1077 // theoretically represent an area in the window where the current action is |
1077 // the same as what we're returning, but I can't find any implementation that | 1078 // the same as what we're returning, but I can't find any implementation that |
1078 // actually making use of this. A client can return (0, 0) and/or set the | 1079 // actually making use of this. A client can return (0, 0) and/or set the |
1079 // first bit of l[1] to disable the feature, and it appears that gtk neither | 1080 // first bit of l[1] to disable the feature, and it appears that gtk neither |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 for (int x = 0; x < in_bitmap->width(); ++x) { | 1222 for (int x = 0; x < in_bitmap->width(); ++x) { |
1222 if (SkColorGetA(in_row[x]) > kMinAlpha) | 1223 if (SkColorGetA(in_row[x]) > kMinAlpha) |
1223 return true; | 1224 return true; |
1224 } | 1225 } |
1225 } | 1226 } |
1226 | 1227 |
1227 return false; | 1228 return false; |
1228 } | 1229 } |
1229 | 1230 |
1230 } // namespace views | 1231 } // namespace views |
OLD | NEW |