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

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

Issue 2313033002: Refactor X11ForeignWindowManager (Reland) (Closed)
Patch Set: Rebase Created 4 years, 3 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 | « ui/base/x/BUILD.gn ('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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted_memory.h" 14 #include "base/memory/ref_counted_memory.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "ui/base/ui_base_export.h" 17 #include "ui/base/ui_base_export.h"
18 #include "ui/base/x/selection_utils.h" 18 #include "ui/base/x/selection_utils.h"
19 #include "ui/gfx/x/x11_atom_cache.h" 19 #include "ui/gfx/x/x11_atom_cache.h"
20 #include "ui/gfx/x/x11_types.h" 20 #include "ui/gfx/x/x11_types.h"
21 21
22 namespace ui { 22 namespace ui {
23 23
24 class XScopedEventSelector;
25
24 // Owns a specific X11 selection on an X window. 26 // Owns a specific X11 selection on an X window.
25 // 27 //
26 // The selection owner object keeps track of which xwindow is the current 28 // The selection owner object keeps track of which xwindow is the current
27 // owner, and when its |xwindow_|, offers different data types to other 29 // owner, and when its |xwindow_|, offers different data types to other
28 // processes. 30 // processes.
29 class UI_BASE_EXPORT SelectionOwner { 31 class UI_BASE_EXPORT SelectionOwner {
30 public: 32 public:
31 SelectionOwner(XDisplay* xdisplay, 33 SelectionOwner(XDisplay* xdisplay,
32 XID xwindow, 34 XID xwindow,
33 XAtom selection_name); 35 XAtom selection_name);
(...skipping 24 matching lines...) Expand all
58 void OnPropertyEvent(const XEvent& event); 60 void OnPropertyEvent(const XEvent& event);
59 61
60 private: 62 private:
61 // Holds state related to an incremental data transfer. 63 // Holds state related to an incremental data transfer.
62 struct IncrementalTransfer { 64 struct IncrementalTransfer {
63 IncrementalTransfer(XID window, 65 IncrementalTransfer(XID window,
64 XAtom target, 66 XAtom target,
65 XAtom property, 67 XAtom property,
66 const scoped_refptr<base::RefCountedMemory>& data, 68 const scoped_refptr<base::RefCountedMemory>& data,
67 int offset, 69 int offset,
68 base::TimeTicks timeout, 70 base::TimeTicks timeout);
69 int foreign_window_manager_id);
70 IncrementalTransfer(const IncrementalTransfer& other); 71 IncrementalTransfer(const IncrementalTransfer& other);
71 ~IncrementalTransfer(); 72 ~IncrementalTransfer();
72 73
73 // Parameters from the XSelectionRequest. The data is transferred over 74 // Parameters from the XSelectionRequest. The data is transferred over
74 // |property| on |window|. 75 // |property| on |window|.
75 XID window; 76 XID window;
76 XAtom target; 77 XAtom target;
77 XAtom property; 78 XAtom property;
78 79
79 // The data to be transferred. 80 // The data to be transferred.
80 scoped_refptr<base::RefCountedMemory> data; 81 scoped_refptr<base::RefCountedMemory> data;
81 82
82 // The offset from the beginning of |data| of the first byte to be 83 // The offset from the beginning of |data| of the first byte to be
83 // transferred in the next chunk. 84 // transferred in the next chunk.
84 size_t offset; 85 size_t offset;
85 86
86 // Time when the transfer should be aborted because the selection requestor 87 // Time when the transfer should be aborted because the selection requestor
87 // is taking too long to notify us that we can send the next chunk. 88 // is taking too long to notify us that we can send the next chunk.
88 base::TimeTicks timeout; 89 base::TimeTicks timeout;
89
90 // Used to unselect PropertyChangeMask on |window| when we are done with
91 // the data transfer.
92 int foreign_window_manager_id;
93 }; 90 };
94 91
95 // Attempts to convert the selection to |target|. If the conversion is 92 // Attempts to convert the selection to |target|. If the conversion is
96 // 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|
97 // of |requestor|. 94 // of |requestor|.
98 bool ProcessTarget(XAtom target, XID requestor, XAtom property); 95 bool ProcessTarget(XAtom target, XID requestor, XAtom property);
99 96
100 // Sends the next chunk of data for given the incremental data transfer. 97 // Sends the next chunk of data for given the incremental data transfer.
101 void ProcessIncrementalTransfer(IncrementalTransfer* transfer); 98 void ProcessIncrementalTransfer(IncrementalTransfer* transfer);
102 99
103 // Aborts any incremental data transfers which have timed out. 100 // Aborts any incremental data transfers which have timed out.
104 void AbortStaleIncrementalTransfers(); 101 void AbortStaleIncrementalTransfers();
105 102
106 // Called when the transfer at |it| has completed to do cleanup. 103 // Called when the transfer at |it| has completed to do cleanup.
107 void CompleteIncrementalTransfer( 104 void CompleteIncrementalTransfer(
108 std::vector<IncrementalTransfer>::iterator it); 105 std::vector<IncrementalTransfer>::iterator it);
109 106
110 // Returns the incremental data transfer, if any, which was waiting for 107 // Returns the incremental data transfer, if any, which was waiting for
111 // |event|. 108 // |event|.
112 std::vector<IncrementalTransfer>::iterator FindIncrementalTransferForEvent( 109 std::vector<IncrementalTransfer>::iterator FindIncrementalTransferForEvent(
113 const XEvent& event); 110 const XEvent& event);
114 111
115 // Our X11 state. 112 // Our X11 state.
116 XDisplay* x_display_; 113 XDisplay* x_display_;
117 XID x_window_; 114 XID x_window_;
118 115
116 // Events selected on the requesting window.
117 std::unique_ptr<XScopedEventSelector> requestor_events_;
118
119 // The X11 selection that this instance communicates on. 119 // The X11 selection that this instance communicates on.
120 XAtom selection_name_; 120 XAtom selection_name_;
121 121
122 // The time that this instance took ownership of its selection. 122 // The time that this instance took ownership of its selection.
123 Time acquired_selection_timestamp_; 123 Time acquired_selection_timestamp_;
124 124
125 // The maximum size of data we can put in XChangeProperty(). 125 // The maximum size of data we can put in XChangeProperty().
126 size_t max_request_size_; 126 size_t max_request_size_;
127 127
128 // The data we are currently serving. 128 // The data we are currently serving.
129 SelectionFormatMap format_map_; 129 SelectionFormatMap format_map_;
130 130
131 std::vector<IncrementalTransfer> incremental_transfers_; 131 std::vector<IncrementalTransfer> incremental_transfers_;
132 132
133 // Used to abort stale incremental data transfers. 133 // Used to abort stale incremental data transfers.
134 base::RepeatingTimer incremental_transfer_abort_timer_; 134 base::RepeatingTimer incremental_transfer_abort_timer_;
135 135
136 X11AtomCache atom_cache_; 136 X11AtomCache atom_cache_;
137 137
138 DISALLOW_COPY_AND_ASSIGN(SelectionOwner); 138 DISALLOW_COPY_AND_ASSIGN(SelectionOwner);
139 }; 139 };
140 140
141 } // namespace ui 141 } // namespace ui
142 142
143 #endif // UI_BASE_X_SELECTION_OWNER_H_ 143 #endif // UI_BASE_X_SELECTION_OWNER_H_
OLDNEW
« no previous file with comments | « ui/base/x/BUILD.gn ('k') | ui/base/x/selection_owner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698