Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/base/x/selection_requestor.h

Issue 392153002: Remove X11/Xlib.h include from selection_requestor.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/clipboard/clipboard_aurax11.cc ('k') | ui/base/x/selection_requestor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_BASE_X_SELECTION_REQUESTOR_H_ 5 #ifndef UI_BASE_X_SELECTION_REQUESTOR_H_
6 #define UI_BASE_X_SELECTION_REQUESTOR_H_ 6 #define UI_BASE_X_SELECTION_REQUESTOR_H_
7 7
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 9
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
11 #undef RootWindow 11 #undef RootWindow
12 12
13 #include <list> 13 #include <list>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/event_types.h"
18 #include "base/memory/ref_counted_memory.h" 19 #include "base/memory/ref_counted_memory.h"
19 #include "ui/base/ui_base_export.h" 20 #include "ui/base/ui_base_export.h"
20 #include "ui/gfx/x/x11_atom_cache.h" 21 #include "ui/gfx/x/x11_atom_cache.h"
22 #include "ui/gfx/x/x11_types.h"
21 23
22 namespace ui { 24 namespace ui {
23 class PlatformEventDispatcher; 25 class PlatformEventDispatcher;
24 class SelectionData; 26 class SelectionData;
25 27
26 // Requests and later receives data from the X11 server through the selection 28 // Requests and later receives data from the X11 server through the selection
27 // system. 29 // system.
28 // 30 //
29 // X11 uses a system called "selections" to implement clipboards and drag and 31 // X11 uses a system called "selections" to implement clipboards and drag and
30 // drop. This class interprets messages from the statefull selection request 32 // drop. This class interprets messages from the statefull selection request
31 // API. SelectionRequestor should only deal with the X11 details; it does not 33 // API. SelectionRequestor should only deal with the X11 details; it does not
32 // implement per-component fast-paths. 34 // implement per-component fast-paths.
33 class UI_BASE_EXPORT SelectionRequestor { 35 class UI_BASE_EXPORT SelectionRequestor {
34 public: 36 public:
35 SelectionRequestor(Display* xdisplay, 37 SelectionRequestor(XDisplay* xdisplay,
36 ::Window xwindow, 38 XID xwindow,
37 ::Atom selection_name, 39 XAtom selection_name,
38 PlatformEventDispatcher* dispatcher); 40 PlatformEventDispatcher* dispatcher);
39 ~SelectionRequestor(); 41 ~SelectionRequestor();
40 42
41 // Does the work of requesting |target| from the selection we handle, 43 // Does the work of requesting |target| from the selection we handle,
42 // spinning up the nested message loop, and reading the resulting data 44 // spinning up the nested message loop, and reading the resulting data
43 // back. The result is stored in |out_data|. 45 // back. The result is stored in |out_data|.
44 // |out_data_items| is the length of |out_data| in |out_type| items. 46 // |out_data_items| is the length of |out_data| in |out_type| items.
45 bool PerformBlockingConvertSelection( 47 bool PerformBlockingConvertSelection(
46 ::Atom target, 48 XAtom target,
47 scoped_refptr<base::RefCountedMemory>* out_data, 49 scoped_refptr<base::RefCountedMemory>* out_data,
48 size_t* out_data_items, 50 size_t* out_data_items,
49 ::Atom* out_type); 51 XAtom* out_type);
50 52
51 // Requests |target| from the selection that we handle, passing |parameter| 53 // Requests |target| from the selection that we handle, passing |parameter|
52 // as a parameter to XConvertSelection(). 54 // as a parameter to XConvertSelection().
53 void PerformBlockingConvertSelectionWithParameter( 55 void PerformBlockingConvertSelectionWithParameter(
54 ::Atom target, 56 XAtom target,
55 const std::vector< ::Atom>& parameter); 57 const std::vector<XAtom>& parameter);
56 58
57 // Returns the first of |types| offered by the current selection holder, or 59 // Returns the first of |types| offered by the current selection holder, or
58 // returns NULL if none of those types are available. 60 // returns NULL if none of those types are available.
59 SelectionData RequestAndWaitForTypes(const std::vector< ::Atom>& types); 61 SelectionData RequestAndWaitForTypes(const std::vector<XAtom>& types);
60 62
61 // It is our owner's responsibility to plumb X11 SelectionNotify events on 63 // It is our owner's responsibility to plumb X11 SelectionNotify events on
62 // |xwindow_| to us. 64 // |xwindow_| to us.
63 void OnSelectionNotify(const XSelectionEvent& event); 65 void OnSelectionNotify(const XEvent& event);
64 66
65 private: 67 private:
66 // A request that has been issued and we are waiting for a response to. 68 // A request that has been issued and we are waiting for a response to.
67 struct PendingRequest { 69 struct PendingRequest {
68 explicit PendingRequest(Atom target); 70 explicit PendingRequest(XAtom target);
69 ~PendingRequest(); 71 ~PendingRequest();
70 72
71 // Data to the current XConvertSelection request. Used for error detection; 73 // Data to the current XConvertSelection request. Used for error detection;
72 // we verify it on the return message. 74 // we verify it on the return message.
73 ::Atom target; 75 XAtom target;
74 76
75 // Called to terminate the nested message loop. 77 // Called to terminate the nested message loop.
76 base::Closure quit_closure; 78 base::Closure quit_closure;
77 79
78 // The property in the returning SelectNotify message is used to signal 80 // The property in the returning SelectNotify message is used to signal
79 // success. If None, our request failed somehow. If equal to the property 81 // success. If None, our request failed somehow. If equal to the property
80 // atom that we sent in the XConvertSelection call, we can read that 82 // atom that we sent in the XConvertSelection call, we can read that
81 // property on |x_window_| for the requested data. 83 // property on |x_window_| for the requested data.
82 ::Atom returned_property; 84 XAtom returned_property;
83 85
84 // Set to true when return_property is populated. 86 // Set to true when return_property is populated.
85 bool returned; 87 bool returned;
86 }; 88 };
87 89
88 // Blocks till SelectionNotify is received for the target specified in 90 // Blocks till SelectionNotify is received for the target specified in
89 // |request|. 91 // |request|.
90 void BlockTillSelectionNotifyForRequest(PendingRequest* request); 92 void BlockTillSelectionNotifyForRequest(PendingRequest* request);
91 93
92 // Our X11 state. 94 // Our X11 state.
93 Display* x_display_; 95 XDisplay* x_display_;
94 ::Window x_window_; 96 XID x_window_;
95 97
96 // The X11 selection that this instance communicates on. 98 // The X11 selection that this instance communicates on.
97 ::Atom selection_name_; 99 XAtom selection_name_;
98 100
99 // Dispatcher which handles SelectionNotify and SelectionRequest for 101 // Dispatcher which handles SelectionNotify and SelectionRequest for
100 // |selection_name_|. PerformBlockingConvertSelection() calls the 102 // |selection_name_|. PerformBlockingConvertSelection() calls the
101 // dispatcher directly if PerformBlockingConvertSelection() is called after 103 // dispatcher directly if PerformBlockingConvertSelection() is called after
102 // the PlatformEventSource is destroyed. 104 // the PlatformEventSource is destroyed.
103 // Not owned. 105 // Not owned.
104 PlatformEventDispatcher* dispatcher_; 106 PlatformEventDispatcher* dispatcher_;
105 107
106 // A list of requests for which we are waiting for responses. 108 // A list of requests for which we are waiting for responses.
107 std::list<PendingRequest*> pending_requests_; 109 std::list<PendingRequest*> pending_requests_;
108 110
109 X11AtomCache atom_cache_; 111 X11AtomCache atom_cache_;
110 112
111 DISALLOW_COPY_AND_ASSIGN(SelectionRequestor); 113 DISALLOW_COPY_AND_ASSIGN(SelectionRequestor);
112 }; 114 };
113 115
114 } // namespace ui 116 } // namespace ui
115 117
116 #endif // UI_BASE_X_SELECTION_REQUESTOR_H_ 118 #endif // UI_BASE_X_SELECTION_REQUESTOR_H_
OLDNEW
« no previous file with comments | « ui/base/clipboard/clipboard_aurax11.cc ('k') | ui/base/x/selection_requestor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698