| 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/x/x11_atom_cache.h" | 19 #include "ui/gfx/x/x11_atom_cache.h" |
| 20 #include "ui/views/views_export.h" | 20 #include "ui/views/views_export.h" |
| 21 #include "ui/views/widget/desktop_aura/x11_move_loop_delegate.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_delegate.h" |
| 22 #include "ui/wm/public/drag_drop_client.h" | 23 #include "ui/wm/public/drag_drop_client.h" |
| 23 | 24 |
| 24 namespace aura { | 25 namespace aura { |
| 25 namespace client { | 26 namespace client { |
| 26 class DragDropDelegate; | 27 class DragDropDelegate; |
| 27 } | 28 } |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace gfx { | 31 namespace gfx { |
| 31 class Point; | 32 class Point; |
| 32 } | 33 } |
| 33 | 34 |
| 34 namespace ui { | 35 namespace ui { |
| 35 class DragSource; | 36 class DragSource; |
| 36 class DropTargetEvent; | 37 class DropTargetEvent; |
| 37 class OSExchangeData; | 38 class OSExchangeData; |
| 38 class OSExchangeDataProviderAuraX11; | 39 class OSExchangeDataProviderAuraX11; |
| 39 class SelectionFormatMap; | 40 class SelectionFormatMap; |
| 40 } | 41 } |
| 41 | 42 |
| 42 namespace views { | 43 namespace views { |
| 43 class DesktopNativeCursorManager; | 44 class DesktopNativeCursorManager; |
| 44 class X11MoveLoop; | |
| 45 | 45 |
| 46 // Implements drag and drop on X11 for aura. On one side, this class takes raw | 46 // 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 | 47 // X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it |
| 48 // handles the views drag events. | 48 // handles the views drag events. |
| 49 class VIEWS_EXPORT DesktopDragDropClientAuraX11 | 49 class VIEWS_EXPORT DesktopDragDropClientAuraX11 |
| 50 : public aura::client::DragDropClient, | 50 : public aura::client::DragDropClient, |
| 51 public aura::WindowObserver, | 51 public aura::WindowObserver, |
| 52 public X11MoveLoopDelegate { | 52 public X11WholeScreenMoveLoopDelegate { |
| 53 public: | 53 public: |
| 54 DesktopDragDropClientAuraX11( | 54 DesktopDragDropClientAuraX11( |
| 55 aura::Window* root_window, | 55 aura::Window* root_window, |
| 56 views::DesktopNativeCursorManager* cursor_manager, | 56 views::DesktopNativeCursorManager* cursor_manager, |
| 57 Display* xdisplay, | 57 Display* xdisplay, |
| 58 ::Window xwindow); | 58 ::Window xwindow); |
| 59 virtual ~DesktopDragDropClientAuraX11(); | 59 virtual ~DesktopDragDropClientAuraX11(); |
| 60 | 60 |
| 61 // We maintain a mapping of live DesktopDragDropClientAuraX11 objects to | 61 // We maintain a mapping of live DesktopDragDropClientAuraX11 objects to |
| 62 // their ::Windows. We do this so that we're able to short circuit sending | 62 // their ::Windows. We do this so that we're able to short circuit sending |
| 63 // X11 messages to windows in our process. | 63 // X11 messages to windows in our process. |
| 64 static DesktopDragDropClientAuraX11* GetForWindow(::Window window); | 64 static DesktopDragDropClientAuraX11* GetForWindow(::Window window); |
| 65 | 65 |
| 66 void Init(); | |
| 67 | |
| 68 // These methods handle the various X11 client messages from the platform. | 66 // These methods handle the various X11 client messages from the platform. |
| 69 void OnXdndEnter(const XClientMessageEvent& event); | 67 void OnXdndEnter(const XClientMessageEvent& event); |
| 70 void OnXdndLeave(const XClientMessageEvent& event); | 68 void OnXdndLeave(const XClientMessageEvent& event); |
| 71 void OnXdndPosition(const XClientMessageEvent& event); | 69 void OnXdndPosition(const XClientMessageEvent& event); |
| 72 void OnXdndStatus(const XClientMessageEvent& event); | 70 void OnXdndStatus(const XClientMessageEvent& event); |
| 73 void OnXdndFinished(const XClientMessageEvent& event); | 71 void OnXdndFinished(const XClientMessageEvent& event); |
| 74 void OnXdndDrop(const XClientMessageEvent& event); | 72 void OnXdndDrop(const XClientMessageEvent& event); |
| 75 | 73 |
| 76 // Called when XSelection data has been copied to our process. | 74 // Called when XSelection data has been copied to our process. |
| 77 void OnSelectionNotify(const XSelectionEvent& xselection); | 75 void OnSelectionNotify(const XSelectionEvent& xselection); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 95 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | 93 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 96 | 94 |
| 97 // Overridden from X11WholeScreenMoveLoopDelegate: | 95 // Overridden from X11WholeScreenMoveLoopDelegate: |
| 98 virtual void OnMouseMovement(XMotionEvent* event) OVERRIDE; | 96 virtual void OnMouseMovement(XMotionEvent* event) OVERRIDE; |
| 99 virtual void OnMouseReleased() OVERRIDE; | 97 virtual void OnMouseReleased() OVERRIDE; |
| 100 virtual void OnMoveLoopEnded() OVERRIDE; | 98 virtual void OnMoveLoopEnded() OVERRIDE; |
| 101 | 99 |
| 102 protected: | 100 protected: |
| 103 // The following methods are virtual for the sake of testing. | 101 // The following methods are virtual for the sake of testing. |
| 104 | 102 |
| 105 // Creates a move loop. | |
| 106 virtual scoped_ptr<X11MoveLoop> CreateMoveLoop( | |
| 107 X11MoveLoopDelegate* delegate); | |
| 108 | |
| 109 // Finds the topmost X11 window at |screen_point| and returns it if it is | 103 // Finds the topmost X11 window at |screen_point| and returns it if it is |
| 110 // Xdnd aware. Returns NULL otherwise. | 104 // Xdnd aware. Returns NULL otherwise. |
| 111 virtual ::Window FindWindowFor(const gfx::Point& screen_point); | 105 virtual ::Window FindWindowFor(const gfx::Point& screen_point); |
| 112 | 106 |
| 113 // Sends |xev| to |xid|, optionally short circuiting the round trip to the X | 107 // Sends |xev| to |xid|, optionally short circuiting the round trip to the X |
| 114 // server. | 108 // server. |
| 115 virtual void SendXClientEvent(::Window xid, XEvent* xev); | 109 virtual void SendXClientEvent(::Window xid, XEvent* xev); |
| 116 | 110 |
| 117 private: | 111 private: |
| 118 enum SourceState { | 112 enum SourceState { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 const gfx::Point& screen_point); | 171 const gfx::Point& screen_point); |
| 178 | 172 |
| 179 void SendXdndEnter(::Window dest_window); | 173 void SendXdndEnter(::Window dest_window); |
| 180 void SendXdndLeave(::Window dest_window); | 174 void SendXdndLeave(::Window dest_window); |
| 181 void SendXdndPosition(::Window dest_window, | 175 void SendXdndPosition(::Window dest_window, |
| 182 const gfx::Point& screen_point, | 176 const gfx::Point& screen_point, |
| 183 unsigned long event_time); | 177 unsigned long event_time); |
| 184 void SendXdndDrop(::Window dest_window); | 178 void SendXdndDrop(::Window dest_window); |
| 185 | 179 |
| 186 // A nested message loop that notifies this object of events through the | 180 // A nested message loop that notifies this object of events through the |
| 187 // X11MoveLoopDelegate interface. | 181 // X11WholeScreenMoveLoopDelegate interface. |
| 188 scoped_ptr<X11MoveLoop> move_loop_; | 182 X11WholeScreenMoveLoop move_loop_; |
| 189 | 183 |
| 190 aura::Window* root_window_; | 184 aura::Window* root_window_; |
| 191 | 185 |
| 192 Display* xdisplay_; | 186 Display* xdisplay_; |
| 193 ::Window xwindow_; | 187 ::Window xwindow_; |
| 194 | 188 |
| 195 ui::X11AtomCache atom_cache_; | 189 ui::X11AtomCache atom_cache_; |
| 196 | 190 |
| 197 // Target side information. | 191 // Target side information. |
| 198 class X11DragContext; | 192 class X11DragContext; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 gfx::NativeCursor move_grab_cursor_; | 253 gfx::NativeCursor move_grab_cursor_; |
| 260 | 254 |
| 261 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; | 255 base::WeakPtrFactory<DesktopDragDropClientAuraX11> weak_ptr_factory_; |
| 262 | 256 |
| 263 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); | 257 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); |
| 264 }; | 258 }; |
| 265 | 259 |
| 266 } // namespace views | 260 } // namespace views |
| 267 | 261 |
| 268 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ | 262 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ |
| OLD | NEW |