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

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

Issue 2700043002: [Desktop Linux]: Fix copy and pasting long selections (Closed)
Patch Set: Merge branch 'master' into selection_requestor Created 3 years, 10 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 | « no previous file | ui/base/x/selection_owner.cc » ('j') | ui/base/x/selection_owner.cc » ('J')
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 bool CanDispatchPropertyEvent(const XEvent& event); 58 bool CanDispatchPropertyEvent(const XEvent& event);
59 59
60 void OnPropertyEvent(const XEvent& event); 60 void OnPropertyEvent(const XEvent& event);
61 61
62 private: 62 private:
63 // Holds state related to an incremental data transfer. 63 // Holds state related to an incremental data transfer.
64 struct IncrementalTransfer { 64 struct IncrementalTransfer {
65 IncrementalTransfer(XID window, 65 IncrementalTransfer(XID window,
66 XAtom target, 66 XAtom target,
67 XAtom property, 67 XAtom property,
68 std::unique_ptr<XScopedEventSelector> event_selector,
68 const scoped_refptr<base::RefCountedMemory>& data, 69 const scoped_refptr<base::RefCountedMemory>& data,
69 int offset, 70 int offset,
70 base::TimeTicks timeout); 71 base::TimeTicks timeout);
71 IncrementalTransfer(const IncrementalTransfer& other);
72 ~IncrementalTransfer(); 72 ~IncrementalTransfer();
73 73
74 // Move-only class.
75 IncrementalTransfer(IncrementalTransfer&&);
76 IncrementalTransfer& operator=(IncrementalTransfer&&);
77
74 // Parameters from the XSelectionRequest. The data is transferred over 78 // Parameters from the XSelectionRequest. The data is transferred over
75 // |property| on |window|. 79 // |property| on |window|.
76 XID window; 80 XID window;
77 XAtom target; 81 XAtom target;
78 XAtom property; 82 XAtom property;
79 83
84 // Selects events on |window|.
85 std::unique_ptr<XScopedEventSelector> event_selector;
86
80 // The data to be transferred. 87 // The data to be transferred.
81 scoped_refptr<base::RefCountedMemory> data; 88 scoped_refptr<base::RefCountedMemory> data;
82 89
83 // The offset from the beginning of |data| of the first byte to be 90 // The offset from the beginning of |data| of the first byte to be
84 // transferred in the next chunk. 91 // transferred in the next chunk.
85 size_t offset; 92 size_t offset;
86 93
87 // Time when the transfer should be aborted because the selection requestor 94 // Time when the transfer should be aborted because the selection requestor
88 // is taking too long to notify us that we can send the next chunk. 95 // is taking too long to notify us that we can send the next chunk.
89 base::TimeTicks timeout; 96 base::TimeTicks timeout;
97
98 private:
99 DISALLOW_COPY_AND_ASSIGN(IncrementalTransfer);
90 }; 100 };
91 101
92 // Attempts to convert the selection to |target|. If the conversion is 102 // Attempts to convert the selection to |target|. If the conversion is
93 // successful, true is returned and the result is stored in the |property| 103 // successful, true is returned and the result is stored in the |property|
94 // of |requestor|. 104 // of |requestor|.
95 bool ProcessTarget(XAtom target, XID requestor, XAtom property); 105 bool ProcessTarget(XAtom target, XID requestor, XAtom property);
96 106
97 // Sends the next chunk of data for given the incremental data transfer. 107 // Sends the next chunk of data for given the incremental data transfer.
98 void ProcessIncrementalTransfer(IncrementalTransfer* transfer); 108 void ProcessIncrementalTransfer(IncrementalTransfer* transfer);
99 109
100 // Aborts any incremental data transfers which have timed out. 110 // Aborts any incremental data transfers which have timed out.
101 void AbortStaleIncrementalTransfers(); 111 void AbortStaleIncrementalTransfers();
102 112
103 // Called when the transfer at |it| has completed to do cleanup. 113 // Called when the transfer at |it| has completed to do cleanup.
104 void CompleteIncrementalTransfer( 114 void CompleteIncrementalTransfer(
105 std::vector<IncrementalTransfer>::iterator it); 115 std::vector<IncrementalTransfer>::iterator it);
106 116
107 // Returns the incremental data transfer, if any, which was waiting for 117 // Returns the incremental data transfer, if any, which was waiting for
108 // |event|. 118 // |event|.
109 std::vector<IncrementalTransfer>::iterator FindIncrementalTransferForEvent( 119 std::vector<IncrementalTransfer>::iterator FindIncrementalTransferForEvent(
110 const XEvent& event); 120 const XEvent& event);
111 121
112 // Our X11 state. 122 // Our X11 state.
113 XDisplay* x_display_; 123 XDisplay* x_display_;
114 XID x_window_; 124 XID x_window_;
115 125
116 // Events selected on the requesting window.
117 std::unique_ptr<XScopedEventSelector> requestor_events_;
118
119 // The X11 selection that this instance communicates on. 126 // The X11 selection that this instance communicates on.
120 XAtom selection_name_; 127 XAtom selection_name_;
121 128
122 // The time that this instance took ownership of its selection. 129 // The time that this instance took ownership of its selection.
123 Time acquired_selection_timestamp_; 130 Time acquired_selection_timestamp_;
124 131
125 // The maximum size of data we can put in XChangeProperty(). 132 // The maximum size of data we can put in XChangeProperty().
126 size_t max_request_size_; 133 size_t max_request_size_;
127 134
128 // The data we are currently serving. 135 // The data we are currently serving.
129 SelectionFormatMap format_map_; 136 SelectionFormatMap format_map_;
130 137
131 std::vector<IncrementalTransfer> incremental_transfers_; 138 std::vector<IncrementalTransfer> incremental_transfers_;
132 139
133 // Used to abort stale incremental data transfers. 140 // Used to abort stale incremental data transfers.
134 base::RepeatingTimer incremental_transfer_abort_timer_; 141 base::RepeatingTimer incremental_transfer_abort_timer_;
135 142
136 X11AtomCache atom_cache_; 143 X11AtomCache atom_cache_;
137 144
138 DISALLOW_COPY_AND_ASSIGN(SelectionOwner); 145 DISALLOW_COPY_AND_ASSIGN(SelectionOwner);
139 }; 146 };
140 147
141 } // namespace ui 148 } // namespace ui
142 149
143 #endif // UI_BASE_X_SELECTION_OWNER_H_ 150 #endif // UI_BASE_X_SELECTION_OWNER_H_
OLDNEW
« no previous file with comments | « no previous file | ui/base/x/selection_owner.cc » ('j') | ui/base/x/selection_owner.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698