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

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

Issue 397223002: Enable copying long text to Chrome and pasting long text from Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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/ui_base.gyp ('k') | ui/base/x/selection_owner.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_OWNER_H_ 5 #ifndef UI_BASE_X_SELECTION_OWNER_H_
6 #define UI_BASE_X_SELECTION_OWNER_H_ 6 #define UI_BASE_X_SELECTION_OWNER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/ref_counted_memory.h"
13 #include "base/time/time.h"
14 #include "base/timer/timer.h"
12 #include "ui/base/ui_base_export.h" 15 #include "ui/base/ui_base_export.h"
13 #include "ui/base/x/selection_utils.h" 16 #include "ui/base/x/selection_utils.h"
14 #include "ui/gfx/x/x11_atom_cache.h" 17 #include "ui/gfx/x/x11_atom_cache.h"
15 #include "ui/gfx/x/x11_types.h" 18 #include "ui/gfx/x/x11_types.h"
16 19
17 namespace ui { 20 namespace ui {
18 21
19 // Owns a specific X11 selection on an X window. 22 // Owns a specific X11 selection on an X window.
20 // 23 //
21 // The selection owner object keeps track of which xwindow is the current 24 // The selection owner object keeps track of which xwindow is the current
(...skipping 16 matching lines...) Expand all
38 // |data| to other windows. 41 // |data| to other windows.
39 void TakeOwnershipOfSelection(const SelectionFormatMap& data); 42 void TakeOwnershipOfSelection(const SelectionFormatMap& data);
40 43
41 // Clears our internal format map and clears the selection owner, whether we 44 // Clears our internal format map and clears the selection owner, whether we
42 // own the selection or not. 45 // own the selection or not.
43 void ClearSelectionOwner(); 46 void ClearSelectionOwner();
44 47
45 // It is our owner's responsibility to plumb X11 events on |xwindow_| to us. 48 // It is our owner's responsibility to plumb X11 events on |xwindow_| to us.
46 void OnSelectionRequest(const XEvent& event); 49 void OnSelectionRequest(const XEvent& event);
47 void OnSelectionClear(const XEvent& event); 50 void OnSelectionClear(const XEvent& event);
48 // TODO(erg): Do we also need to follow PropertyNotify events? We currently 51
49 // don't, but there were open todos in the previous implementation. 52 // Returns true if SelectionOwner can process the XPropertyEvent event,
53 // |event|.
54 bool CanDispatchPropertyEvent(const XEvent& event);
55
56 void OnPropertyEvent(const XEvent& event);
50 57
51 private: 58 private:
59 // Holds state related to an incremental data transfer.
60 struct IncrementalTransfer {
61 IncrementalTransfer(XID window,
62 XAtom target,
63 XAtom property,
64 const scoped_refptr<base::RefCountedMemory>& data,
65 int offset,
66 base::TimeTicks timeout,
67 int foreign_window_manager_id);
68 ~IncrementalTransfer();
69
70 // Parameters from the XSelectionRequest. The data is transferred over
71 // |property| on |window|.
72 XID window;
73 XAtom target;
74 XAtom property;
75
76 // The data to be transferred.
77 scoped_refptr<base::RefCountedMemory> data;
78
79 // The offset from the beginning of |data| of the first byte to be
80 // transferred in the next chunk.
81 size_t offset;
82
83 // Time when the transfer should be aborted because the selection requestor
84 // is taking too long to notify us that we can send the next chunk.
85 base::TimeTicks timeout;
86
87 // Used to unselect PropertyChangeMask on |window| when we are done with
88 // the data transfer.
89 int foreign_window_manager_id;
90 };
91
52 // Attempts to convert the selection to |target|. If the conversion is 92 // Attempts to convert the selection to |target|. If the conversion is
53 // successful, true is returned and the result is stored in the |property| 93 // successful, true is returned and the result is stored in the |property|
54 // of |requestor|. 94 // of |requestor|.
55 bool ProcessTarget(XAtom target, XID requestor, XAtom property); 95 bool ProcessTarget(XAtom target, XID requestor, XAtom property);
56 96
97 // Sends the next chunk of data for given the incremental data transfer.
98 void ProcessIncrementalTransfer(IncrementalTransfer* transfer);
99
100 // Aborts any incremental data transfers which have timed out.
101 void AbortStaleIncrementalTransfers();
102
103 // Called when the transfer at |it| has completed to do cleanup.
104 void CompleteIncrementalTransfer(
105 std::vector<IncrementalTransfer>::iterator it);
106
107 // Returns the incremental data transfer, if any, which was waiting for
108 // |event|.
109 std::vector<IncrementalTransfer>::iterator FindIncrementalTransferForEvent(
110 const XEvent& event);
111
57 // Our X11 state. 112 // Our X11 state.
58 XDisplay* x_display_; 113 XDisplay* x_display_;
59 XID x_window_; 114 XID x_window_;
60 115
61 // The X11 selection that this instance communicates on. 116 // The X11 selection that this instance communicates on.
62 XAtom selection_name_; 117 XAtom selection_name_;
63 118
119 // The maximum size of data we can put in XChangeProperty().
120 size_t max_request_size_;
121
64 // The data we are currently serving. 122 // The data we are currently serving.
65 SelectionFormatMap format_map_; 123 SelectionFormatMap format_map_;
66 124
125 std::vector<IncrementalTransfer> incremental_transfers_;
126
127 // Used to abort stale incremental data transfers.
128 base::RepeatingTimer<SelectionOwner> incremental_transfer_abort_timer_;
129
67 X11AtomCache atom_cache_; 130 X11AtomCache atom_cache_;
68 131
69 DISALLOW_COPY_AND_ASSIGN(SelectionOwner); 132 DISALLOW_COPY_AND_ASSIGN(SelectionOwner);
70 }; 133 };
71 134
72 } // namespace ui 135 } // namespace ui
73 136
74 #endif // UI_BASE_X_SELECTION_OWNER_H_ 137 #endif // UI_BASE_X_SELECTION_OWNER_H_
OLDNEW
« no previous file with comments | « ui/base/ui_base.gyp ('k') | ui/base/x/selection_owner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698