Chromium Code Reviews| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 // During the blocking StartDragAndDrop() call, this converts the views-style | 148 // During the blocking StartDragAndDrop() call, this converts the views-style |
| 147 // |drag_operation_| bitfield into a vector of Atoms to offer to other | 149 // |drag_operation_| bitfield into a vector of Atoms to offer to other |
| 148 // processes. | 150 // processes. |
| 149 std::vector< ::Atom> GetOfferedDragOperations(); | 151 std::vector< ::Atom> GetOfferedDragOperations(); |
| 150 | 152 |
| 151 // This returns a representation of the data we're offering in this | 153 // This returns a representation of the data we're offering in this |
| 152 // drag. This is done to bypass an asynchronous roundtrip with the X11 | 154 // drag. This is done to bypass an asynchronous roundtrip with the X11 |
| 153 // server. | 155 // server. |
| 154 ui::SelectionFormatMap GetFormatMap() const; | 156 ui::SelectionFormatMap GetFormatMap() const; |
| 155 | 157 |
| 158 // Updates the cursor by re-grabbing the pointer while in the move loop. | |
| 159 void UpdateCursor(); | |
| 160 | |
| 156 // Handling XdndPosition can be paused while waiting for more data; this is | 161 // Handling XdndPosition can be paused while waiting for more data; this is |
| 157 // called either synchronously from OnXdndPosition, or asynchronously after | 162 // called either synchronously from OnXdndPosition, or asynchronously after |
| 158 // we've received data requested from the other window. | 163 // we've received data requested from the other window. |
| 159 void CompleteXdndPosition(::Window source_window, | 164 void CompleteXdndPosition(::Window source_window, |
| 160 const gfx::Point& screen_point); | 165 const gfx::Point& screen_point); |
| 161 | 166 |
| 162 void SendXdndEnter(::Window dest_window); | 167 void SendXdndEnter(::Window dest_window); |
| 163 void SendXdndLeave(::Window dest_window); | 168 void SendXdndLeave(::Window dest_window); |
| 164 void SendXdndPosition(::Window dest_window, | 169 void SendXdndPosition(::Window dest_window, |
| 165 const gfx::Point& screen_point, | 170 const gfx::Point& screen_point, |
| 166 unsigned long event_time); | 171 unsigned long event_time); |
| 167 void SendXdndDrop(::Window dest_window); | 172 void SendXdndDrop(::Window dest_window); |
| 168 | 173 |
| 169 // Sends |xev| to |xid|, optionally short circuiting the round trip to the X | 174 // Sends |xev| to |xid|, optionally short circuiting the round trip to the X |
| 170 // server. | 175 // server. |
| 171 void SendXClientEvent(::Window xid, XEvent* xev); | 176 void SendXClientEvent(::Window xid, XEvent* xev); |
| 172 | 177 |
| 178 // Sets an image to be used during the drag. | |
| 179 void SetDragImage(const gfx::ImageSkia& image, gfx::Vector2dF offset); | |
|
sadrul
2014/05/23 14:39:53
const gfx::Vector2dF&
varkha
2014/05/23 15:38:36
Done.
| |
| 180 | |
| 181 // Creates a window to show the drag image during the drag. | |
| 182 void CreateDragImageWindow(); | |
| 183 | |
| 173 // A nested message loop that notifies this object of events through the | 184 // A nested message loop that notifies this object of events through the |
| 174 // X11WholeScreenMoveLoopDelegate interface. | 185 // X11WholeScreenMoveLoopDelegate interface. |
| 175 X11WholeScreenMoveLoop move_loop_; | 186 X11WholeScreenMoveLoop move_loop_; |
| 176 | 187 |
| 177 aura::Window* root_window_; | 188 aura::Window* root_window_; |
| 178 | 189 |
| 179 Display* xdisplay_; | 190 Display* xdisplay_; |
| 180 ::Window xwindow_; | 191 ::Window xwindow_; |
| 181 | 192 |
| 182 ui::X11AtomCache atom_cache_; | 193 ui::X11AtomCache atom_cache_; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 | 249 |
| 239 // Ends the move loop if the target is too slow to respond after the mouse is | 250 // Ends the move loop if the target is too slow to respond after the mouse is |
| 240 // released. | 251 // released. |
| 241 base::OneShotTimer<DesktopDragDropClientAuraX11> end_move_loop_timer_; | 252 base::OneShotTimer<DesktopDragDropClientAuraX11> end_move_loop_timer_; |
| 242 | 253 |
| 243 // We use these cursors while dragging. | 254 // We use these cursors while dragging. |
| 244 gfx::NativeCursor grab_cursor_; | 255 gfx::NativeCursor grab_cursor_; |
| 245 gfx::NativeCursor copy_grab_cursor_; | 256 gfx::NativeCursor copy_grab_cursor_; |
| 246 gfx::NativeCursor move_grab_cursor_; | 257 gfx::NativeCursor move_grab_cursor_; |
| 247 | 258 |
| 259 // A Widget is created during the drag. | |
| 260 scoped_ptr<Widget> drag_widget_; | |
| 261 gfx::ImageSkia drag_image_; | |
| 262 gfx::Vector2dF drag_offset_; | |
| 263 | |
| 264 // Drag widget is positioned off screen when drag image is not set or is | |
| 265 // completely transparent. | |
| 266 gfx::Rect null_drag_widget_bounds_; | |
| 267 | |
| 248 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; | 268 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; |
| 249 | 269 |
| 250 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); | 270 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); |
| 251 }; | 271 }; |
| 252 | 272 |
| 253 } // namespace views | 273 } // namespace views |
| 254 | 274 |
| 255 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ | 275 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ |
| OLD | NEW |