| 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 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <X11/Xlib.h> | 9 #include <X11/Xlib.h> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "ui/aura/window_observer.h" | 15 #include "ui/aura/window_observer.h" |
| 16 #include "ui/base/cursor/cursor.h" | 16 #include "ui/base/cursor/cursor.h" |
| 17 #include "ui/base/dragdrop/drag_drop_types.h" | 17 #include "ui/base/dragdrop/drag_drop_types.h" |
| 18 #include "ui/gfx/point.h" | 18 #include "ui/gfx/point.h" |
| 19 #include "ui/gfx/rect.h" |
| 19 #include "ui/gfx/x/x11_atom_cache.h" | 20 #include "ui/gfx/x/x11_atom_cache.h" |
| 20 #include "ui/views/views_export.h" | 21 #include "ui/views/views_export.h" |
| 21 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" | 22 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" |
| 22 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h" | 23 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h" |
| 23 #include "ui/wm/public/drag_drop_client.h" | 24 #include "ui/wm/public/drag_drop_client.h" |
| 24 | 25 |
| 25 namespace aura { | 26 namespace aura { |
| 26 namespace client { | 27 namespace client { |
| 27 class DragDropDelegate; | 28 class DragDropDelegate; |
| 28 } | 29 } |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace gfx { | 32 namespace gfx { |
| 32 class Point; | 33 class Point; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace ui { | 36 namespace ui { |
| 36 class DragSource; | 37 class DragSource; |
| 37 class DropTargetEvent; | 38 class DropTargetEvent; |
| 38 class OSExchangeData; | 39 class OSExchangeData; |
| 39 class OSExchangeDataProviderAuraX11; | 40 class OSExchangeDataProviderAuraX11; |
| 40 class SelectionFormatMap; | 41 class SelectionFormatMap; |
| 41 } | 42 } |
| 42 | 43 |
| 43 namespace views { | 44 namespace views { |
| 44 class DesktopNativeCursorManager; | 45 class DesktopNativeCursorManager; |
| 46 class Widget; |
| 45 | 47 |
| 46 // Implements drag and drop on X11 for aura. On one side, this class takes raw | 48 // Implements drag and drop on X11 for aura. On one side, this class takes raw |
| 47 // X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it | 49 // X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it |
| 48 // handles the views drag events. | 50 // handles the views drag events. |
| 49 class VIEWS_EXPORT DesktopDragDropClientAuraX11 | 51 class VIEWS_EXPORT DesktopDragDropClientAuraX11 |
| 50 : public aura::client::DragDropClient, | 52 : public aura::client::DragDropClient, |
| 51 public aura::WindowObserver, | 53 public aura::WindowObserver, |
| 52 public X11WholeScreenMoveLoopDelegate { | 54 public X11WholeScreenMoveLoopDelegate { |
| 53 public: | 55 public: |
| 54 DesktopDragDropClientAuraX11( | 56 DesktopDragDropClientAuraX11( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // During the blocking StartDragAndDrop() call, this converts the views-style | 159 // During the blocking StartDragAndDrop() call, this converts the views-style |
| 158 // |drag_operation_| bitfield into a vector of Atoms to offer to other | 160 // |drag_operation_| bitfield into a vector of Atoms to offer to other |
| 159 // processes. | 161 // processes. |
| 160 std::vector< ::Atom> GetOfferedDragOperations(); | 162 std::vector< ::Atom> GetOfferedDragOperations(); |
| 161 | 163 |
| 162 // This returns a representation of the data we're offering in this | 164 // This returns a representation of the data we're offering in this |
| 163 // drag. This is done to bypass an asynchronous roundtrip with the X11 | 165 // drag. This is done to bypass an asynchronous roundtrip with the X11 |
| 164 // server. | 166 // server. |
| 165 ui::SelectionFormatMap GetFormatMap() const; | 167 ui::SelectionFormatMap GetFormatMap() const; |
| 166 | 168 |
| 169 // Updates the cursor by re-grabbing the pointer while in the move loop. |
| 170 void UpdateCursor(); |
| 171 |
| 167 // Handling XdndPosition can be paused while waiting for more data; this is | 172 // Handling XdndPosition can be paused while waiting for more data; this is |
| 168 // called either synchronously from OnXdndPosition, or asynchronously after | 173 // called either synchronously from OnXdndPosition, or asynchronously after |
| 169 // we've received data requested from the other window. | 174 // we've received data requested from the other window. |
| 170 void CompleteXdndPosition(::Window source_window, | 175 void CompleteXdndPosition(::Window source_window, |
| 171 const gfx::Point& screen_point); | 176 const gfx::Point& screen_point); |
| 172 | 177 |
| 173 void SendXdndEnter(::Window dest_window); | 178 void SendXdndEnter(::Window dest_window); |
| 174 void SendXdndLeave(::Window dest_window); | 179 void SendXdndLeave(::Window dest_window); |
| 175 void SendXdndPosition(::Window dest_window, | 180 void SendXdndPosition(::Window dest_window, |
| 176 const gfx::Point& screen_point, | 181 const gfx::Point& screen_point, |
| 177 unsigned long event_time); | 182 unsigned long event_time); |
| 178 void SendXdndDrop(::Window dest_window); | 183 void SendXdndDrop(::Window dest_window); |
| 179 | 184 |
| 185 // Sets an image to be used during the drag. |
| 186 void SetDragImage(const gfx::ImageSkia& image, const gfx::Vector2dF& offset); |
| 187 |
| 188 // Creates a window to show the drag image during the drag. |
| 189 void CreateDragImageWindow(); |
| 190 |
| 180 // A nested message loop that notifies this object of events through the | 191 // A nested message loop that notifies this object of events through the |
| 181 // X11WholeScreenMoveLoopDelegate interface. | 192 // X11WholeScreenMoveLoopDelegate interface. |
| 182 X11WholeScreenMoveLoop move_loop_; | 193 X11WholeScreenMoveLoop move_loop_; |
| 183 | 194 |
| 184 aura::Window* root_window_; | 195 aura::Window* root_window_; |
| 185 | 196 |
| 186 Display* xdisplay_; | 197 Display* xdisplay_; |
| 187 ::Window xwindow_; | 198 ::Window xwindow_; |
| 188 | 199 |
| 189 ui::X11AtomCache atom_cache_; | 200 ui::X11AtomCache atom_cache_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 256 |
| 246 // Ends the move loop if the target is too slow to respond after the mouse is | 257 // Ends the move loop if the target is too slow to respond after the mouse is |
| 247 // released. | 258 // released. |
| 248 base::OneShotTimer<DesktopDragDropClientAuraX11> end_move_loop_timer_; | 259 base::OneShotTimer<DesktopDragDropClientAuraX11> end_move_loop_timer_; |
| 249 | 260 |
| 250 // We use these cursors while dragging. | 261 // We use these cursors while dragging. |
| 251 gfx::NativeCursor grab_cursor_; | 262 gfx::NativeCursor grab_cursor_; |
| 252 gfx::NativeCursor copy_grab_cursor_; | 263 gfx::NativeCursor copy_grab_cursor_; |
| 253 gfx::NativeCursor move_grab_cursor_; | 264 gfx::NativeCursor move_grab_cursor_; |
| 254 | 265 |
| 266 // A Widget is created during the drag. |
| 267 scoped_ptr<Widget> drag_widget_; |
| 268 gfx::ImageSkia drag_image_; |
| 269 gfx::Vector2dF drag_offset_; |
| 270 |
| 271 // Drag widget is positioned off screen when drag image is not set or is |
| 272 // completely transparent. |
| 273 gfx::Rect null_drag_widget_bounds_; |
| 274 |
| 255 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; | 275 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; |
| 256 | 276 |
| 257 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); | 277 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); |
| 258 }; | 278 }; |
| 259 | 279 |
| 260 } // namespace views | 280 } // namespace views |
| 261 | 281 |
| 262 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ | 282 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ |
| OLD | NEW |