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 <vector> | 9 #include <vector> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h" | 22 #include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h" |
23 #include "ui/wm/public/drag_drop_client.h" | 23 #include "ui/wm/public/drag_drop_client.h" |
24 | 24 |
25 namespace aura { | 25 namespace aura { |
26 namespace client { | 26 namespace client { |
27 class DragDropDelegate; | 27 class DragDropDelegate; |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 namespace gfx { | 31 namespace gfx { |
| 32 class ImageSkia; |
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 class X11MoveLoop; | 47 class X11MoveLoop; |
46 | 48 |
47 // Implements drag and drop on X11 for aura. On one side, this class takes raw | 49 // Implements drag and drop on X11 for aura. On one side, this class takes raw |
48 // X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it | 50 // X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it |
49 // handles the views drag events. | 51 // handles the views drag events. |
50 class VIEWS_EXPORT DesktopDragDropClientAuraX11 | 52 class VIEWS_EXPORT DesktopDragDropClientAuraX11 |
51 : public aura::client::DragDropClient, | 53 : public aura::client::DragDropClient, |
52 public aura::WindowObserver, | 54 public aura::WindowObserver, |
53 public X11MoveLoopDelegate { | 55 public X11MoveLoopDelegate { |
54 public: | 56 public: |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void CompleteXdndPosition(::Window source_window, | 179 void CompleteXdndPosition(::Window source_window, |
178 const gfx::Point& screen_point); | 180 const gfx::Point& screen_point); |
179 | 181 |
180 void SendXdndEnter(::Window dest_window); | 182 void SendXdndEnter(::Window dest_window); |
181 void SendXdndLeave(::Window dest_window); | 183 void SendXdndLeave(::Window dest_window); |
182 void SendXdndPosition(::Window dest_window, | 184 void SendXdndPosition(::Window dest_window, |
183 const gfx::Point& screen_point, | 185 const gfx::Point& screen_point, |
184 unsigned long event_time); | 186 unsigned long event_time); |
185 void SendXdndDrop(::Window dest_window); | 187 void SendXdndDrop(::Window dest_window); |
186 | 188 |
| 189 // Creates a widget for the user to drag around. |
| 190 void CreateDragWidget(const gfx::ImageSkia& image); |
| 191 |
| 192 // Returns true if |image| has any visible regions (defined as having a pixel |
| 193 // with alpha > 32). |
| 194 bool IsValidDragImage(const gfx::ImageSkia& image); |
| 195 |
187 // A nested message loop that notifies this object of events through the | 196 // A nested message loop that notifies this object of events through the |
188 // X11MoveLoopDelegate interface. | 197 // X11MoveLoopDelegate interface. |
189 scoped_ptr<X11MoveLoop> move_loop_; | 198 scoped_ptr<X11MoveLoop> move_loop_; |
190 | 199 |
191 aura::Window* root_window_; | 200 aura::Window* root_window_; |
192 | 201 |
193 Display* xdisplay_; | 202 Display* xdisplay_; |
194 ::Window xwindow_; | 203 ::Window xwindow_; |
195 | 204 |
196 ui::X11AtomCache atom_cache_; | 205 ui::X11AtomCache atom_cache_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // XdndActionsList. This is the requested action from the other window. This | 256 // XdndActionsList. This is the requested action from the other window. This |
248 // is DRAG_NONE if we haven't sent out an XdndPosition message yet, haven't | 257 // is DRAG_NONE if we haven't sent out an XdndPosition message yet, haven't |
249 // yet received an XdndStatus or if the other window has told us that there's | 258 // yet received an XdndStatus or if the other window has told us that there's |
250 // no action that we can agree on. | 259 // no action that we can agree on. |
251 ui::DragDropTypes::DragOperation negotiated_operation_; | 260 ui::DragDropTypes::DragOperation negotiated_operation_; |
252 | 261 |
253 // Ends the move loop if the target is too slow to respond after the mouse is | 262 // Ends the move loop if the target is too slow to respond after the mouse is |
254 // released. | 263 // released. |
255 base::OneShotTimer<DesktopDragDropClientAuraX11> end_move_loop_timer_; | 264 base::OneShotTimer<DesktopDragDropClientAuraX11> end_move_loop_timer_; |
256 | 265 |
| 266 // Widget that the user drags around. May be NULL. |
| 267 scoped_ptr<Widget> drag_widget_; |
| 268 |
| 269 // The offset of |drag_widget_| relative to the mouse position. |
| 270 gfx::Vector2d drag_widget_offset_; |
| 271 |
257 // We use these cursors while dragging. | 272 // We use these cursors while dragging. |
258 gfx::NativeCursor grab_cursor_; | 273 gfx::NativeCursor grab_cursor_; |
259 gfx::NativeCursor copy_grab_cursor_; | 274 gfx::NativeCursor copy_grab_cursor_; |
260 gfx::NativeCursor move_grab_cursor_; | 275 gfx::NativeCursor move_grab_cursor_; |
261 | 276 |
262 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; | 277 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; |
263 | 278 |
264 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); | 279 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); |
265 }; | 280 }; |
266 | 281 |
267 } // namespace views | 282 } // namespace views |
268 | 283 |
269 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ | 284 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ |
OLD | NEW |