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

Side by Side Diff: chrome/browser/gtk/xclipboard.h

Issue 100145: WIP: X clipboard stuff (Closed)
Patch Set: Created 11 years, 8 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
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/gtk/xclipboard.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 struct XClipboardImpl; // to hide Xlib headers
2
3 class XClipboard {
4 public:
5 // display: the X server display to use. This is a void* to avoid polluting th e namespace.
6 // delegate: an object which acts on events from the X server. All callbacks
7 // are made in the context of the thread which is running this object and
8 // will block processing if they block.
9 XClipboard(void* display, Delegate* delegate);
10
11 ~XClipboard();
12
13 // X understands an arbitary number of clipboard types. However, three are
14 // defined in the specs and two of those are actually used. the PRIMARY
15 // clipboard is used for the current selection. The CLIPBOARD clipboard is
16 // used when the user hits Ctrl-C or "Copy" from a menu etc.
17 enum Type {
18 CLIPBOARD_PRIMARY,
19 CLIPBOARD_SECONDARY,
20 CLIPBOARD_CLIPBOARD,
21 };
22
23 // Content types are passed around as strings.
24 typedef const std::string& ContentType;
25
26 class Delegate {
27 // This is called when we loose ownership of the given clipboard.
28 void ClipboardLost(Type);
29
30 // This is called when another client has requested the current clipboard
31 // contents. You can call ReplyWith* from within this callback.
32 void ClipboardContentsRequested(Type, uint64_t tag, ContentType);
33
34 // This is called when a clipboard request has completed (successfully or
35 // otherwise)
36 // tag: the value given to |RequestClipboard|
37 // success: true if |type| and |data| is valid
38 // type: the type of the data
39 // data: chunks of data. You must free these chunks.
40 void ClipboardRequestComplete(
41 uint64_t tag, bool success, ContentType type,
42 const std::vector<pair<uint8_t*, size_t> > &data);
43 };
44
45 // Assert that we own the given clipboard. If this returns true, then we own
46 // the given clipboard and ClipboardLost will be called when someone else
47 // takes it from us.
48 bool AssertOwnership(Type);
49
50 // Reply negatively to a request.
51 void ReplyWithFailure(uint64_t tag);
52
53 // Reply positivly to a clipboard request.
54 // tag: the value given in the |ClipboardContentsRequested| callback
55 // data: bytes to reply with.
56 // length: the length of |data|, in bytes
57 // This function may block arbitarity if the other client misbehaves. Also,
58 // this function may only enqueue the reply if ordering constrains proclude
59 // its immediate transmission.
60 void ReplyWithContents(uint64_t tag, const uint8_t* data, size_t length);
61
62 // Request the current contents of the given clipboard in the given format.
63 void RequestClipboard(uint64_t tag, Type, ContentType);
64
65 private:
66 Delegate* const delegate_;
67 XClipboardImpl* const pimpl_;
68 };
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/gtk/xclipboard.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698