OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
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_ | |
7 | |
8 #include <X11/Xlib.h> | |
9 | |
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | |
11 #undef RootWindow | |
12 | |
13 #include "base/compiler_specific.h" | |
14 #include "base/memory/ref_counted.h" | |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "ui/aura/client/drag_drop_client.h" | |
17 #include "ui/aura/window_observer.h" | |
18 #include "ui/base/x/x11_atom_cache.h" | |
19 #include "ui/gfx/point.h" | |
20 #include "ui/views/views_export.h" | |
21 | |
22 namespace aura { | |
23 class RootWindow; | |
24 namespace client { | |
25 class DragDropDelegate; | |
26 } | |
27 } | |
28 | |
29 namespace gfx { | |
30 class Point; | |
31 } | |
32 | |
33 namespace ui { | |
34 class DragSource; | |
35 class DropTargetEvent; | |
36 class OSExchangeData; | |
37 class RootWindow; | |
38 } | |
39 | |
40 namespace views { | |
41 class DesktopRootWindowHostX11; | |
42 | |
43 // Implements drag and drop on X11 for aura. On one side, this class takes raw | |
44 // X11 events forwarded from DesktopRootWindowHostLinux, while on the other, it | |
45 // handles the views drag events. | |
46 class VIEWS_EXPORT DesktopDragDropClientAuraX11 | |
47 : public aura::client::DragDropClient, | |
48 public aura::WindowObserver { | |
49 public: | |
50 DesktopDragDropClientAuraX11( | |
51 views::DesktopRootWindowHostX11* root_window_host, | |
52 aura::RootWindow* root_window, | |
53 Display* xdisplay, | |
54 ::Window xwindow); | |
55 virtual ~DesktopDragDropClientAuraX11(); | |
56 | |
57 // These methods handle the various X11 client messages from the platform. | |
58 void OnXdndEnter(const XClientMessageEvent& event); | |
59 void OnXdndLeave(const XClientMessageEvent& event); | |
60 void OnXdndPosition(const XClientMessageEvent& event); | |
61 void OnXdndStatus(const XClientMessageEvent& event); | |
62 void OnXdndFinished(const XClientMessageEvent& event); | |
63 void OnXdndDrop(const XClientMessageEvent& event); | |
64 | |
65 // Overridden from aura::client::DragDropClient: | |
66 virtual int StartDragAndDrop( | |
67 const ui::OSExchangeData& data, | |
68 aura::RootWindow* root_window, | |
69 aura::Window* source_window, | |
70 const gfx::Point& root_location, | |
71 int operation, | |
72 ui::DragDropTypes::DragEventSource source) OVERRIDE; | |
73 virtual void DragUpdate(aura::Window* target, | |
74 const ui::LocatedEvent& event) OVERRIDE; | |
75 virtual void Drop(aura::Window* target, | |
76 const ui::LocatedEvent& event) OVERRIDE; | |
77 virtual void DragCancel() OVERRIDE; | |
78 virtual bool IsDragDropInProgress() OVERRIDE; | |
79 | |
80 // aura::WindowObserver implementation: | |
81 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | |
82 | |
83 private: | |
84 // When we receive an position x11 message, we need to translate that into | |
85 // the underlying aura::Window representation. In the case of | |
Daniel Erat
2013/04/13 02:15:00
nit: fix partial sentence at the end of this comme
| |
86 void DragTranslate(const gfx::Point& root_window_location, | |
87 scoped_ptr<ui::OSExchangeData>* data, | |
88 scoped_ptr<ui::DropTargetEvent>* event, | |
89 aura::client::DragDropDelegate** delegate); | |
90 | |
91 // Called when we need to notify the current aura::Window that we're no | |
92 // longer dragging over it. | |
93 void NotifyDragLeave(); | |
94 | |
95 // Converts our bitfield of actions into an Atom that represents what action | |
96 // we're most likely to take on drop. | |
97 unsigned long DragOperationToAtom(int drag_operation); | |
98 | |
99 // Sends |xev| to |xid|, optionally short circuiting the round trip to the X | |
100 // server. | |
101 void SendXClientEvent(unsigned long xid, XEvent* xev); | |
102 | |
103 views::DesktopRootWindowHostX11* root_window_host_; | |
104 aura::RootWindow* root_window_; | |
105 | |
106 Display* xdisplay_; | |
107 ::Window xwindow_; | |
108 | |
109 ui::X11AtomCache atom_cache_; | |
110 | |
111 // Target side information. | |
112 | |
113 class X11DragContext; | |
114 scoped_ptr<X11DragContext> current_context_; | |
115 | |
116 // The Aura window that is currently under the cursor. We need to manually | |
117 // keep track of this because Windows will only call our drag enter method | |
118 // once when the user enters the associated X Window. But inside that X | |
119 // Window there could be multiple aura windows, so we need to generate drag | |
120 // enter events for them. | |
121 aura::Window* target_window_; | |
122 | |
123 // Because Xdnd messages don't contain the position in messages other than | |
124 // the XdndPosition message, we must manually keep track of the last position | |
125 // change. | |
126 gfx::Point target_window_location_; | |
127 gfx::Point target_window_root_location_; | |
128 | |
129 bool drag_drop_in_progress_; | |
130 | |
131 int drag_operation_; | |
132 | |
133 // scoped_refptr<ui::DragSource> drag_source_; | |
Daniel Erat
2013/04/13 02:15:00
delete this
| |
134 | |
135 DISALLOW_COPY_AND_ASSIGN(DesktopDragDropClientAuraX11); | |
136 }; | |
137 | |
138 } // namespace views | |
139 | |
140 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_DRAG_DROP_CLIENT_AURAX11_H_ | |
OLD | NEW |